serial: sh-sci: Replace struct sci_port_info by type/regtype encoding
Store the encoded port and register types directly in of_device_id.data, instead of using a pointer to a structure. This saves memory and simplifies the source code, especially when adding more compatible entries later. Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be> Reviewed-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com> Acked-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
parent
b8bbd6b292
commit
bd2238fb84
|
@ -2614,42 +2614,27 @@ static int sci_remove(struct platform_device *dev)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
struct sci_port_info {
|
|
||||||
unsigned int type;
|
#define SCI_OF_DATA(type, regtype) (void *)((type) << 16 | (regtype))
|
||||||
unsigned int regtype;
|
#define SCI_OF_TYPE(data) ((unsigned long)(data) >> 16)
|
||||||
};
|
#define SCI_OF_REGTYPE(data) ((unsigned long)(data) & 0xffff)
|
||||||
|
|
||||||
static const struct of_device_id of_sci_match[] = {
|
static const struct of_device_id of_sci_match[] = {
|
||||||
{
|
{
|
||||||
.compatible = "renesas,scif",
|
.compatible = "renesas,scif",
|
||||||
.data = &(const struct sci_port_info) {
|
.data = SCI_OF_DATA(PORT_SCIF, SCIx_SH4_SCIF_REGTYPE),
|
||||||
.type = PORT_SCIF,
|
|
||||||
.regtype = SCIx_SH4_SCIF_REGTYPE,
|
|
||||||
},
|
|
||||||
}, {
|
}, {
|
||||||
.compatible = "renesas,scifa",
|
.compatible = "renesas,scifa",
|
||||||
.data = &(const struct sci_port_info) {
|
.data = SCI_OF_DATA(PORT_SCIFA, SCIx_SCIFA_REGTYPE),
|
||||||
.type = PORT_SCIFA,
|
|
||||||
.regtype = SCIx_SCIFA_REGTYPE,
|
|
||||||
},
|
|
||||||
}, {
|
}, {
|
||||||
.compatible = "renesas,scifb",
|
.compatible = "renesas,scifb",
|
||||||
.data = &(const struct sci_port_info) {
|
.data = SCI_OF_DATA(PORT_SCIFB, SCIx_SCIFB_REGTYPE),
|
||||||
.type = PORT_SCIFB,
|
|
||||||
.regtype = SCIx_SCIFB_REGTYPE,
|
|
||||||
},
|
|
||||||
}, {
|
}, {
|
||||||
.compatible = "renesas,hscif",
|
.compatible = "renesas,hscif",
|
||||||
.data = &(const struct sci_port_info) {
|
.data = SCI_OF_DATA(PORT_HSCIF, SCIx_HSCIF_REGTYPE),
|
||||||
.type = PORT_HSCIF,
|
|
||||||
.regtype = SCIx_HSCIF_REGTYPE,
|
|
||||||
},
|
|
||||||
}, {
|
}, {
|
||||||
.compatible = "renesas,sci",
|
.compatible = "renesas,sci",
|
||||||
.data = &(const struct sci_port_info) {
|
.data = SCI_OF_DATA(PORT_SCI, SCIx_SCI_REGTYPE),
|
||||||
.type = PORT_SCI,
|
|
||||||
.regtype = SCIx_SCI_REGTYPE,
|
|
||||||
},
|
|
||||||
}, {
|
}, {
|
||||||
/* Terminator */
|
/* Terminator */
|
||||||
},
|
},
|
||||||
|
@ -2661,7 +2646,6 @@ sci_parse_dt(struct platform_device *pdev, unsigned int *dev_id)
|
||||||
{
|
{
|
||||||
struct device_node *np = pdev->dev.of_node;
|
struct device_node *np = pdev->dev.of_node;
|
||||||
const struct of_device_id *match;
|
const struct of_device_id *match;
|
||||||
const struct sci_port_info *info;
|
|
||||||
struct plat_sci_port *p;
|
struct plat_sci_port *p;
|
||||||
int id;
|
int id;
|
||||||
|
|
||||||
|
@ -2672,8 +2656,6 @@ sci_parse_dt(struct platform_device *pdev, unsigned int *dev_id)
|
||||||
if (!match)
|
if (!match)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
info = match->data;
|
|
||||||
|
|
||||||
p = devm_kzalloc(&pdev->dev, sizeof(struct plat_sci_port), GFP_KERNEL);
|
p = devm_kzalloc(&pdev->dev, sizeof(struct plat_sci_port), GFP_KERNEL);
|
||||||
if (!p)
|
if (!p)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@ -2688,8 +2670,8 @@ sci_parse_dt(struct platform_device *pdev, unsigned int *dev_id)
|
||||||
*dev_id = id;
|
*dev_id = id;
|
||||||
|
|
||||||
p->flags = UPF_IOREMAP | UPF_BOOT_AUTOCONF;
|
p->flags = UPF_IOREMAP | UPF_BOOT_AUTOCONF;
|
||||||
p->type = info->type;
|
p->type = SCI_OF_TYPE(match->data);
|
||||||
p->regtype = info->regtype;
|
p->regtype = SCI_OF_REGTYPE(match->data);
|
||||||
p->scscr = SCSCR_RE | SCSCR_TE;
|
p->scscr = SCSCR_RE | SCSCR_TE;
|
||||||
|
|
||||||
return p;
|
return p;
|
||||||
|
|
Loading…
Reference in New Issue