linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2 1/2] uio: uio_pdrv_genirq: Make UIO name controllable via DT node property
@ 2019-08-15 21:28 Daniel Mack
  2019-08-15 21:28 ` [PATCH v2 2/2] uio: Documentation: Add information on using uio_pdrv_genirq with DT Daniel Mack
  2019-08-27 16:07 ` [PATCH v2 1/2] uio: uio_pdrv_genirq: Make UIO name controllable via DT node property Daniel Mack
  0 siblings, 2 replies; 4+ messages in thread
From: Daniel Mack @ 2019-08-15 21:28 UTC (permalink / raw)
  To: gregkh; +Cc: devicetree, linux-kernel, Daniel Mack

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 <daniel@zonque.org>
---
 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


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH v2 2/2] uio: Documentation: Add information on using uio_pdrv_genirq with DT
  2019-08-15 21:28 [PATCH v2 1/2] uio: uio_pdrv_genirq: Make UIO name controllable via DT node property Daniel Mack
@ 2019-08-15 21:28 ` Daniel Mack
  2019-08-27 16:07 ` [PATCH v2 1/2] uio: uio_pdrv_genirq: Make UIO name controllable via DT node property Daniel Mack
  1 sibling, 0 replies; 4+ messages in thread
From: Daniel Mack @ 2019-08-15 21:28 UTC (permalink / raw)
  To: gregkh; +Cc: devicetree, linux-kernel, Daniel Mack

Add a paragraph to describe the use of the "of_id" module parameter,
along with the new DT property.

Signed-off-by: Daniel Mack <daniel@zonque.org>
---
 Documentation/driver-api/uio-howto.rst | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/Documentation/driver-api/uio-howto.rst b/Documentation/driver-api/uio-howto.rst
index 25f50eace28b..b9f28641ddf0 100644
--- a/Documentation/driver-api/uio-howto.rst
+++ b/Documentation/driver-api/uio-howto.rst
@@ -408,6 +408,13 @@ handler code. You also do not need to know anything about the chip's
 internal registers to create the kernel part of the driver. All you need
 to know is the irq number of the pin the chip is connected to.
 
+When used in a device-tree enabled system, the driver needs to be
+probed with the ``"of_id"`` module parameter set to the ``"compatible"``
+string of the node the driver is supposed to handle. By default, the
+node's name (without the unit address) is exposed as name for the
+UIO device in userspace. To set a custom name, a property named
+``"linux,uio-name"`` may be specified in the DT node.
+
 Using uio_dmem_genirq for platform devices
 ------------------------------------------
 
-- 
2.21.0


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH v2 1/2] uio: uio_pdrv_genirq: Make UIO name controllable via DT node property
  2019-08-15 21:28 [PATCH v2 1/2] uio: uio_pdrv_genirq: Make UIO name controllable via DT node property Daniel Mack
  2019-08-15 21:28 ` [PATCH v2 2/2] uio: Documentation: Add information on using uio_pdrv_genirq with DT Daniel Mack
@ 2019-08-27 16:07 ` Daniel Mack
  2019-08-27 17:04   ` Greg KH
  1 sibling, 1 reply; 4+ messages in thread
From: Daniel Mack @ 2019-08-27 16:07 UTC (permalink / raw)
  To: gregkh; +Cc: devicetree, linux-kernel

Hi Greg,

On 15/8/2019 11:28 PM, 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.

Any opinion on this one?


Thanks,
Daniel


> 
> Signed-off-by: Daniel Mack <daniel@zonque.org>
> ---
>  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 */
>  	}
> 


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH v2 1/2] uio: uio_pdrv_genirq: Make UIO name controllable via DT node property
  2019-08-27 16:07 ` [PATCH v2 1/2] uio: uio_pdrv_genirq: Make UIO name controllable via DT node property Daniel Mack
@ 2019-08-27 17:04   ` Greg KH
  0 siblings, 0 replies; 4+ messages in thread
From: Greg KH @ 2019-08-27 17:04 UTC (permalink / raw)
  To: Daniel Mack; +Cc: devicetree, linux-kernel

On Tue, Aug 27, 2019 at 06:07:04PM +0200, Daniel Mack wrote:
> Hi Greg,
> 
> On 15/8/2019 11:28 PM, 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.
> 
> Any opinion on this one?

Sorry, it's in my "to review" queue, was traveling all last week and
it's really big now :(

it's not lost...

greg k-h

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2019-08-27 17:04 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-08-15 21:28 [PATCH v2 1/2] uio: uio_pdrv_genirq: Make UIO name controllable via DT node property Daniel Mack
2019-08-15 21:28 ` [PATCH v2 2/2] uio: Documentation: Add information on using uio_pdrv_genirq with DT Daniel Mack
2019-08-27 16:07 ` [PATCH v2 1/2] uio: uio_pdrv_genirq: Make UIO name controllable via DT node property Daniel Mack
2019-08-27 17:04   ` Greg KH

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).