Skip to content
Snippets Groups Projects
Commit 043f85ce authored by Christophe JAILLET's avatar Christophe JAILLET Committed by Jassi Brar
Browse files

mailbox: zynq: Switch to flexible array to simplify code


Using flexible array is more straight forward. It
  - saves 1 pointer in the 'zynqmp_ipi_pdata' structure
  - saves an indirection when using this array
  - saves some LoC and avoids some always spurious pointer arithmetic

Signed-off-by: default avatarChristophe JAILLET <christophe.jaillet@wanadoo.fr>
Signed-off-by: default avatarJassi Brar <jaswinder.singh@linaro.org>
parent ceaa837f
No related branches found
No related tags found
No related merge requests found
...@@ -110,7 +110,7 @@ struct zynqmp_ipi_pdata { ...@@ -110,7 +110,7 @@ struct zynqmp_ipi_pdata {
unsigned int method; unsigned int method;
u32 local_id; u32 local_id;
int num_mboxes; int num_mboxes;
struct zynqmp_ipi_mbox *ipi_mboxes; struct zynqmp_ipi_mbox ipi_mboxes[];
}; };
static struct device_driver zynqmp_ipi_mbox_driver = { static struct device_driver zynqmp_ipi_mbox_driver = {
...@@ -635,7 +635,7 @@ static int zynqmp_ipi_probe(struct platform_device *pdev) ...@@ -635,7 +635,7 @@ static int zynqmp_ipi_probe(struct platform_device *pdev)
int num_mboxes, ret = -EINVAL; int num_mboxes, ret = -EINVAL;
num_mboxes = of_get_child_count(np); num_mboxes = of_get_child_count(np);
pdata = devm_kzalloc(dev, sizeof(*pdata) + (num_mboxes * sizeof(*mbox)), pdata = devm_kzalloc(dev, struct_size(pdata, ipi_mboxes, num_mboxes),
GFP_KERNEL); GFP_KERNEL);
if (!pdata) if (!pdata)
return -ENOMEM; return -ENOMEM;
...@@ -649,8 +649,6 @@ static int zynqmp_ipi_probe(struct platform_device *pdev) ...@@ -649,8 +649,6 @@ static int zynqmp_ipi_probe(struct platform_device *pdev)
} }
pdata->num_mboxes = num_mboxes; pdata->num_mboxes = num_mboxes;
pdata->ipi_mboxes = (struct zynqmp_ipi_mbox *)
((char *)pdata + sizeof(*pdata));
mbox = pdata->ipi_mboxes; mbox = pdata->ipi_mboxes;
for_each_available_child_of_node(np, nc) { for_each_available_child_of_node(np, nc) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment