Skip to content

Commit 757e2c5

Browse files
committed
drivers/uio/uio_dmem_genirq: Add the option of specifying the dynamic memory regions from device tree.
1 parent 45ec414 commit 757e2c5

File tree

1 file changed

+28
-2
lines changed

1 file changed

+28
-2
lines changed

drivers/uio/uio_dmem_genirq.c

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,29 @@ static int uio_dmem_genirq_probe(struct platform_device *pdev)
163163
}
164164
uioinfo->name = pdev->dev.of_node->name;
165165
uioinfo->version = "devicetree";
166+
/* alloc pdata */
167+
pdata = kzalloc(sizeof(pdata), GFP_KERNEL);
168+
if (!pdata) {
169+
ret = -ENOMEM;
170+
dev_err(&pdev->dev, "unable to kmalloc\n");
171+
goto bad2;
172+
}
173+
pdata->num_dynamic_regions = 0;
174+
of_property_read_u32(pdev->dev.of_node,
175+
"uio,number-of-dynamic-regions",
176+
&pdata->num_dynamic_regions);
177+
pdata->dynamic_region_sizes =
178+
kzalloc(sizeof(*pdata->dynamic_region_sizes) *
179+
pdata->num_dynamic_regions, GFP_KERNEL);
180+
if (!pdata->dynamic_region_sizes) {
181+
ret = -ENOMEM;
182+
dev_err(&pdev->dev, "unable to kmalloc\n");
183+
goto bad2;
184+
}
185+
of_property_read_u32_array(pdev->dev.of_node,
186+
"uio,dynamic-regions-sizes",
187+
pdata->dynamic_region_sizes,
188+
pdata->num_dynamic_regions);
166189
}
167190

168191
if (!uioinfo || !uioinfo->name || !uioinfo->version) {
@@ -327,10 +350,13 @@ static const struct dev_pm_ops uio_dmem_genirq_dev_pm_ops = {
327350
};
328351

329352
#ifdef CONFIG_OF
330-
static const struct of_device_id uio_of_genirq_match[] = {
331-
{ /* empty for now */ },
353+
static struct of_device_id uio_of_genirq_match[] = {
354+
{ .compatible = "dmem-uio", },
355+
{ /* end of list */ },
332356
};
333357
MODULE_DEVICE_TABLE(of, uio_of_genirq_match);
358+
module_param_string(of_id, uio_of_genirq_match[0].compatible, 128, 0);
359+
MODULE_PARM_DESC(of_id, "Openfirmware id of the device to be handled by uio");
334360
#endif
335361

336362
static struct platform_driver uio_dmem_genirq = {

0 commit comments

Comments
 (0)