From 3ec1bd7693ee5bba69eaa1a2b74b14d37971769e Mon Sep 17 00:00:00 2001 From: Alexandru Ardelean Date: Tue, 5 Nov 2019 09:32:12 +0200 Subject: [PATCH] uio: fix irq init with dt support & irq not defined 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 Signed-off-by: Alexandru Ardelean Acked-by: Damian Hobson-Garcia Link: https://lore.kernel.org/r/20191105073212.16719-1-alexandru.ardelean@analog.com Signed-off-by: Greg Kroah-Hartman --- 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 ebcf143..81c88f7b 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.7.4