linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] uio: fix irq init with dt support & irq not defined
@ 2019-11-05  7:28 Alexandru Ardelean
  2019-11-05  7:32 ` [PATCH v2] " Alexandru Ardelean
  0 siblings, 1 reply; 3+ messages in thread
From: Alexandru Ardelean @ 2019-11-05  7:28 UTC (permalink / raw)
  To: linux-kernel; +Cc: gregkh, dhobsong, Alexandru Ardelean, Dragos Bogdan

This change also does a bit of a unification for the IRQ init code.

But the actual problem is that UIO_IRQ_NONE == 0, so for the DT case where
UIO_IRQ_NONE gets assigned to `uioinfo->irq`, a 2nd initialization will get
triggered (for the IRQ) and this one will exit via `goto bad1`.

As far as things seem to go, the only case where UIO_IRQ_NONE seems valid,
is when using a device-tree. The driver has some legacy support for old
platform_data structures. It looks like, for platform_data a non-existent
IRQ is an invalid case (or was considered an invalid case).
Which is why -ENXIO is treated only when a DT is used.

Signed-off-by: Dragos Bogdan <dragos.bogdan@analog.com>
Signed-off-by: Alexandru Ardelean <alexandru.ardelean@analog.com>
---
 drivers/uio/uio_dmem_genirq.c | 12 ++++--------
 1 file changed, 4 insertions(+), 8 deletions(-)

diff --git a/drivers/uio/uio_dmem_genirq.c b/drivers/uio/uio_dmem_genirq.c
index ebcf1434e296..0a7d71d4a4f0 100644
--- a/drivers/uio/uio_dmem_genirq.c
+++ b/drivers/uio/uio_dmem_genirq.c
@@ -163,13 +163,6 @@ static int uio_dmem_genirq_probe(struct platform_device *pdev)
 		uioinfo->name = devm_kasprintf(&pdev->dev, GFP_KERNEL, "%pOFn",
 					       pdev->dev.of_node);
 		uioinfo->version = "devicetree";
-
-		/* Multiple IRQs are not supported */
-		irq = platform_get_irq(pdev, 0);
-		if (irq == -ENXIO)
-			uioinfo->irq = UIO_IRQ_NONE;
-		else
-			uioinfo->irq = irq;
 	}
 
 	if (!uioinfo || !uioinfo->name || !uioinfo->version) {
@@ -199,8 +192,11 @@ static int uio_dmem_genirq_probe(struct platform_device *pdev)
 	mutex_init(&priv->alloc_lock);
 
 	if (!uioinfo->irq) {
+		/* Multiple IRQs are not supported */
 		ret = platform_get_irq(pdev, 0);
-		if (ret < 0)
+		if (ret == -ENXIO && pdev->dev.of_node)
+			ret = UIO_IRQ_NONE;
+		else if (ret < 0)
 			goto bad1;
 		uioinfo->irq = ret;
 	}
-- 
2.20.1


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

* [PATCH v2] uio: fix irq init with dt support & irq not defined
  2019-11-05  7:28 [PATCH] uio: fix irq init with dt support & irq not defined Alexandru Ardelean
@ 2019-11-05  7:32 ` Alexandru Ardelean
  2019-11-06  6:41   ` Damian Hobson-Garcia
  0 siblings, 1 reply; 3+ messages in thread
From: Alexandru Ardelean @ 2019-11-05  7:32 UTC (permalink / raw)
  To: linux-kernel; +Cc: gregkh, dhobsong, Alexandru Ardelean, Dragos Bogdan

This change also does a bit of a unification for the IRQ init code.

But the actual problem is that UIO_IRQ_NONE == 0, so for the DT case where
UIO_IRQ_NONE gets assigned to `uioinfo->irq`, a 2nd initialization will get
triggered (for the IRQ) and this one will exit via `goto bad1`.

As far as things seem to go, the only case where UIO_IRQ_NONE seems valid,
is when using a device-tree. The driver has some legacy support for old
platform_data structures. It looks like, for platform_data a non-existent
IRQ is an invalid case (or was considered an invalid case).
Which is why -ENXIO is treated only when a DT is used.

Signed-off-by: Dragos Bogdan <dragos.bogdan@analog.com>
Signed-off-by: Alexandru Ardelean <alexandru.ardelean@analog.com>
---

Changelog v1 -> v2:
* removed `int irq` variable ; was omitted when porting the patch to a
  newer kernel base

 drivers/uio/uio_dmem_genirq.c | 14 ++++----------
 1 file changed, 4 insertions(+), 10 deletions(-)

diff --git a/drivers/uio/uio_dmem_genirq.c b/drivers/uio/uio_dmem_genirq.c
index ebcf1434e296..81c88f7bbbcb 100644
--- a/drivers/uio/uio_dmem_genirq.c
+++ b/drivers/uio/uio_dmem_genirq.c
@@ -151,8 +151,6 @@ static int uio_dmem_genirq_probe(struct platform_device *pdev)
 	int i;
 
 	if (pdev->dev.of_node) {
-		int irq;
-
 		/* alloc uioinfo for one device */
 		uioinfo = kzalloc(sizeof(*uioinfo), GFP_KERNEL);
 		if (!uioinfo) {
@@ -163,13 +161,6 @@ static int uio_dmem_genirq_probe(struct platform_device *pdev)
 		uioinfo->name = devm_kasprintf(&pdev->dev, GFP_KERNEL, "%pOFn",
 					       pdev->dev.of_node);
 		uioinfo->version = "devicetree";
-
-		/* Multiple IRQs are not supported */
-		irq = platform_get_irq(pdev, 0);
-		if (irq == -ENXIO)
-			uioinfo->irq = UIO_IRQ_NONE;
-		else
-			uioinfo->irq = irq;
 	}
 
 	if (!uioinfo || !uioinfo->name || !uioinfo->version) {
@@ -199,8 +190,11 @@ static int uio_dmem_genirq_probe(struct platform_device *pdev)
 	mutex_init(&priv->alloc_lock);
 
 	if (!uioinfo->irq) {
+		/* Multiple IRQs are not supported */
 		ret = platform_get_irq(pdev, 0);
-		if (ret < 0)
+		if (ret == -ENXIO && pdev->dev.of_node)
+			ret = UIO_IRQ_NONE;
+		else if (ret < 0)
 			goto bad1;
 		uioinfo->irq = ret;
 	}
-- 
2.20.1


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

* Re: [PATCH v2] uio: fix irq init with dt support & irq not defined
  2019-11-05  7:32 ` [PATCH v2] " Alexandru Ardelean
@ 2019-11-06  6:41   ` Damian Hobson-Garcia
  0 siblings, 0 replies; 3+ messages in thread
From: Damian Hobson-Garcia @ 2019-11-06  6:41 UTC (permalink / raw)
  To: Alexandru Ardelean, linux-kernel; +Cc: gregkh, Dragos Bogdan

On 2019-11-05 4:32 p.m., Alexandru Ardelean wrote:
> This change also does a bit of a unification for the IRQ init code.
> 
> But the actual problem is that UIO_IRQ_NONE == 0, so for the DT case where
> UIO_IRQ_NONE gets assigned to `uioinfo->irq`, a 2nd initialization will get
> triggered (for the IRQ) and this one will exit via `goto bad1`.
> 
> As far as things seem to go, the only case where UIO_IRQ_NONE seems valid,
> is when using a device-tree. The driver has some legacy support for old
> platform_data structures. It looks like, for platform_data a non-existent
> IRQ is an invalid case (or was considered an invalid case).
> Which is why -ENXIO is treated only when a DT is used.
> 
> Signed-off-by: Dragos Bogdan <dragos.bogdan@analog.com>
> Signed-off-by: Alexandru Ardelean <alexandru.ardelean@analog.com>
> ---
> 
> Changelog v1 -> v2:
> * removed `int irq` variable ; was omitted when porting the patch to a
>   newer kernel base
> 

This also brings the implementation in line with the what is done in
uio_pdrv_genirq.c

Acked-by: Damian Hobson-Garcia <dhobsong@igel.co.jp>

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

end of thread, other threads:[~2019-11-06  6:41 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-11-05  7:28 [PATCH] uio: fix irq init with dt support & irq not defined Alexandru Ardelean
2019-11-05  7:32 ` [PATCH v2] " Alexandru Ardelean
2019-11-06  6:41   ` Damian Hobson-Garcia

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).