* [uio 1/2] fix uio_pdrv_genirq with device tree but no interrupt
@ 2013-06-18 20:34 Pavel Machek
2013-06-18 22:44 ` Greg KH
0 siblings, 1 reply; 3+ messages in thread
From: Pavel Machek @ 2013-06-18 20:34 UTC (permalink / raw)
To: gregkh, linux-kernel
If device is initialized from device tree, but has no interrupt
assigned, uio will still try to request and interrupt old way,
fails, and fails registration.
This is wrong; don't try initializing irq using platform data if
device tree is available.
Simplified code based on suggestion by Grant Likely.
Fixed memory leak in "irq can not be registered" error path.
Signed-off-by: Pavel Machek <pavel@denx.de>
Reported-by: Detlev Zundel <dzu@denx.de>
diff --git a/drivers/uio/uio_pdrv_genirq.c b/drivers/uio/uio_pdrv_genirq.c
index c122bca..d594dd9 100644
--- a/drivers/uio/uio_pdrv_genirq.c
+++ b/drivers/uio/uio_pdrv_genirq.c
@@ -103,24 +103,16 @@ static int uio_pdrv_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) {
ret = -ENOMEM;
dev_err(&pdev->dev, "unable to kmalloc\n");
- goto bad2;
+ return ret;
}
uioinfo->name = pdev->dev.of_node->name;
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) {
@@ -148,12 +140,15 @@ static int uio_pdrv_genirq_probe(struct platform_device *pdev)
if (!uioinfo->irq) {
ret = platform_get_irq(pdev, 0);
- if (ret < 0) {
+ uioinfo->irq = ret;
+ if (ret == -ENXIO && pdev->dev.of_node)
+ uioinfo->irq = UIO_IRQ_NONE;
+ else if (ret < 0) {
dev_err(&pdev->dev, "failed to get IRQ\n");
- goto bad0;
+ goto bad1;
}
- uioinfo->irq = ret;
}
+
uiomem = &uioinfo->mem[0];
for (i = 0; i < pdev->num_resources; ++i) {
@@ -206,19 +201,19 @@ static int uio_pdrv_genirq_probe(struct platform_device *pdev)
ret = uio_register_device(&pdev->dev, priv->uioinfo);
if (ret) {
dev_err(&pdev->dev, "unable to register uio device\n");
- goto bad1;
+ goto bad2;
}
platform_set_drvdata(pdev, priv);
return 0;
+ bad2:
+ pm_runtime_disable(&pdev->dev);
bad1:
kfree(priv);
- pm_runtime_disable(&pdev->dev);
bad0:
/* kfree uioinfo for OF */
if (pdev->dev.of_node)
kfree(uioinfo);
- bad2:
return ret;
}
--
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [uio 1/2] fix uio_pdrv_genirq with device tree but no interrupt
2013-06-18 20:34 [uio 1/2] fix uio_pdrv_genirq with device tree but no interrupt Pavel Machek
@ 2013-06-18 22:44 ` Greg KH
2013-06-19 11:11 ` Pavel Machek
0 siblings, 1 reply; 3+ messages in thread
From: Greg KH @ 2013-06-18 22:44 UTC (permalink / raw)
To: Pavel Machek; +Cc: linux-kernel
What's with the odd [uio] in the Subject? What happened to the
universal [PATCH 1/2] format?
Ick, I'll fix this up this time, but come on, you know better...
greg k-h
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [uio 1/2] fix uio_pdrv_genirq with device tree but no interrupt
2013-06-18 22:44 ` Greg KH
@ 2013-06-19 11:11 ` Pavel Machek
0 siblings, 0 replies; 3+ messages in thread
From: Pavel Machek @ 2013-06-19 11:11 UTC (permalink / raw)
To: Greg KH; +Cc: linux-kernel
On Tue 2013-06-18 15:44:04, Greg KH wrote:
> What's with the odd [uio] in the Subject? What happened to the
> universal [PATCH 1/2] format?
>
> Ick, I'll fix this up this time, but come on, you know better...
Sorry about that. It seems every maintainer has slightly different
rules for that... I thought that stuff in [] is normally ignored, so I
did not give it too much thought.
Pavel
--
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2013-06-19 11:11 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-06-18 20:34 [uio 1/2] fix uio_pdrv_genirq with device tree but no interrupt Pavel Machek
2013-06-18 22:44 ` Greg KH
2013-06-19 11:11 ` Pavel Machek
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox