2019-08-11 11:15:00

by Daniel Mack

[permalink] [raw]
Subject: [PATCH] uio: uio_pdrv_genirq: Make UIO name controllable via DT node property

When probed via DT, the uio_pdrv_genirq driver currently uses the name
of the node and exposes that as name of the UIO device to userspace.

This doesn't work for systems where multiple nodes with the same name
(but different unit addresses) are present, or for systems where the
node names are auto-generated by a third-party tool.

This patch adds the possibility to read the UIO name from the optional
"linux,uio-name" property.

Signed-off-by: Daniel Mack <[email protected]>
---
drivers/uio/uio_pdrv_genirq.c | 14 +++++++++++---
1 file changed, 11 insertions(+), 3 deletions(-)

diff --git a/drivers/uio/uio_pdrv_genirq.c b/drivers/uio/uio_pdrv_genirq.c
index 6c759934bff3..24d60eb1bda5 100644
--- a/drivers/uio/uio_pdrv_genirq.c
+++ b/drivers/uio/uio_pdrv_genirq.c
@@ -105,12 +105,15 @@ static int uio_pdrv_genirq_irqcontrol(struct uio_info *dev_info, s32 irq_on)
static int uio_pdrv_genirq_probe(struct platform_device *pdev)
{
struct uio_info *uioinfo = dev_get_platdata(&pdev->dev);
+ struct device_node *node = pdev->dev.of_node;
struct uio_pdrv_genirq_platdata *priv;
struct uio_mem *uiomem;
int ret = -EINVAL;
int i;

- if (pdev->dev.of_node) {
+ if (node) {
+ const char *name;
+
/* alloc uioinfo for one device */
uioinfo = devm_kzalloc(&pdev->dev, sizeof(*uioinfo),
GFP_KERNEL);
@@ -118,8 +121,13 @@ static int uio_pdrv_genirq_probe(struct platform_device *pdev)
dev_err(&pdev->dev, "unable to kmalloc\n");
return -ENOMEM;
}
- uioinfo->name = devm_kasprintf(&pdev->dev, GFP_KERNEL, "%pOFn",
- pdev->dev.of_node);
+
+ if (!of_property_read_string(node, "linux,uio-name", &name))
+ uioinfo->name = devm_kstrdup(&pdev->dev, name, GFP_KERNEL);
+ else
+ uioinfo->name = devm_kasprintf(&pdev->dev, GFP_KERNEL,
+ "%pOFn", node);
+
uioinfo->version = "devicetree";
/* Multiple IRQs are not supported */
}
--
2.21.0


2019-08-15 21:29:03

by Daniel Mack

[permalink] [raw]
Subject: Re: [PATCH] uio: uio_pdrv_genirq: Make UIO name controllable via DT node property

On 15/8/2019 10:56 PM, Greg KH wrote:
> On Sun, Aug 11, 2019 at 01:02:13PM +0200, Daniel Mack wrote:
>> When probed via DT, the uio_pdrv_genirq driver currently uses the name
>> of the node and exposes that as name of the UIO device to userspace.
>>
>> This doesn't work for systems where multiple nodes with the same name
>> (but different unit addresses) are present, or for systems where the
>> node names are auto-generated by a third-party tool.
>>
>> This patch adds the possibility to read the UIO name from the optional
>> "linux,uio-name" property.
>
> Does that need to be documented anywhere?

This driver does not have a match table and is special in other ways
too, which is why I believe it isn't documented in
Documentation/devicetree/bindings.

I'll cook up a patch to describe how the probing works right now, and
also add a word on the newly introduced property.


Thanks,
Daniel

2019-08-15 23:34:00

by Greg Kroah-Hartman

[permalink] [raw]
Subject: Re: [PATCH] uio: uio_pdrv_genirq: Make UIO name controllable via DT node property

On Sun, Aug 11, 2019 at 01:02:13PM +0200, Daniel Mack wrote:
> When probed via DT, the uio_pdrv_genirq driver currently uses the name
> of the node and exposes that as name of the UIO device to userspace.
>
> This doesn't work for systems where multiple nodes with the same name
> (but different unit addresses) are present, or for systems where the
> node names are auto-generated by a third-party tool.
>
> This patch adds the possibility to read the UIO name from the optional
> "linux,uio-name" property.

Does that need to be documented anywhere?

thanks,

greg k-h