[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20130618142442.GA17361@amd.pavel.ucw.cz>
Date: Tue, 18 Jun 2013 16:24:43 +0200
From: Pavel Machek <pavel@...x.de>
To: Grant Likely <grant.likely@...retlab.ca>
Cc: Detlev Zundel <dzu@...x.de>, "Hans J. Koch" <hjk@...sjkoch.de>,
Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
Rob Herring <rob.herring@...xeda.com>,
Linux Kernel Mailing List <linux-kernel@...r.kernel.org>,
trivial <trivial@...nel.org>
Subject: Re: [PATCH] fix UIO with device tree but no assigned interrupt
Hi!
> > 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@...x.de>
> > Reported-by: Detlev Zundel <dzu@...x.de>
> > @@ -146,14 +138,15 @@ static int uio_pdrv_genirq_probe(struct platform_device *pdev)
> > priv->flags = 0; /* interrupt is enabled to begin with */
> > priv->pdev = pdev;
> >
> > - if (!uioinfo->irq) {
> > - ret = platform_get_irq(pdev, 0);
> > - if (ret < 0) {
> > - dev_err(&pdev->dev, "failed to get IRQ\n");
> > - goto bad0;
> > - }
> > - uioinfo->irq = ret;
> > + ret = platform_get_irq(pdev, 0);
> > + uioinfo->irq = ret;
> > + if (ret == -ENXIO && pdev->dev.of_node)
> > + uioinfo->irq = UIO_IRQ_NONE;
>
> This short-circuits the platform data use case where uioinfo->irq is
> already set. The if (!uioinfo->irq) test is still needed. The original
> code looks like it already handles it correctly for both the
> platform_data and DT use cases because in the DT case the uioinfo
> structure is zeroed by kzalloc().
Ok, fixed, thanks!
> As an aside, switching to devm_kzalloc() would simplify the unwind
> path.
Well, lets leave that for another day...
Pavel
--
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists