From: Thierry Reding <thierry.reding-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
To: Sergei Shtylyov
<sergei.shtylyov-M4DtvfQ/ZS1MRgGoP+s0PdBPR1lH4CV8@public.gmane.org>
Cc: Laxman Dewangan
<ldewangan-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>,
Jon Hunter <jonathanh-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>,
Vinod Koul <vinod.koul-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>,
dmaengine-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
linux-tegra-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
Dan Williams
<dan.j.williams-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
Subject: Re: [PATCH] dmaengine: tegra210-adma: fix of_irq_get() error check
Date: Mon, 31 Jul 2017 11:30:57 +0200 [thread overview]
Message-ID: <20170731093057.GA26667@ulmo> (raw)
In-Reply-To: <20170730181051.733168837-M4DtvfQ/ZS1MRgGoP+s0PdBPR1lH4CV8@public.gmane.org>
[-- Attachment #1: Type: text/plain, Size: 1955 bytes --]
On Sun, Jul 30, 2017 at 09:10:44PM +0300, Sergei Shtylyov wrote:
> of_irq_get() may return 0 as well as negative error number on failure,
> while the driver only checks for the negative values. The driver would then
> call request_irq(0, ...) in tegra_adma_alloc_chan_resources() and never get
> valid channel interrupt.
>
> Check for 'tdc->irq <= 0' instead and return -ENXIO from the driver's probe
> iff of_irq_get() returned 0.
>
> Fixes: f46b195799b5 ("dmaengine: tegra-adma: Add support for Tegra210 ADMA")
> Signed-off-by: Sergei Shtylyov <sergei.shtylyov-M4DtvfQ/ZS1MRgGoP+s0PdBPR1lH4CV8@public.gmane.org>
>
> ---
> drivers/dma/tegra210-adma.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
Yeah, that interface isn't very optimal. The problem with it, and we've
had this kind before, is that every driver ends up having to implement a
fallback for == 0 with the result of everyone returning a different
error code.
Perhaps a good long-term solution would be to fix of_irq_get() to only
return positive for valid interrupts and negative error codes, so that
nobody has to deal with == 0 anymore.
That's obviously going to be a fairly big undertaking, so I'm fine with
fixing up the individual callsites first.
> Index: slave-dma/drivers/dma/tegra210-adma.c
> ===================================================================
> --- slave-dma.orig/drivers/dma/tegra210-adma.c
> +++ slave-dma/drivers/dma/tegra210-adma.c
> @@ -717,8 +717,8 @@ static int tegra_adma_probe(struct platf
> tdc->chan_addr = tdma->base_addr + ADMA_CH_REG_OFFSET(i);
>
> tdc->irq = of_irq_get(pdev->dev.of_node, i);
> - if (tdc->irq < 0) {
> - ret = tdc->irq;
> + if (tdc->irq <= 0) {
> + ret = tdc->irq ?: -ENXIO;
> goto irq_dispose;
> }
>
I think in this particular case it would be better to just call
platform_get_irq(), which already implements the equivalent.
Thierry
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
next prev parent reply other threads:[~2017-07-31 9:30 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-07-30 18:10 [PATCH] dmaengine: tegra210-adma: fix of_irq_get() error check Sergei Shtylyov
[not found] ` <20170730181051.733168837-M4DtvfQ/ZS1MRgGoP+s0PdBPR1lH4CV8@public.gmane.org>
2017-07-30 19:46 ` Sergei Shtylyov
2017-07-31 9:30 ` Thierry Reding [this message]
2017-07-31 9:57 ` Sergei Shtylyov
[not found] ` <0102e75c-d1be-e274-808b-f9d3f434924d-M4DtvfQ/ZS1MRgGoP+s0PdBPR1lH4CV8@public.gmane.org>
2017-07-31 12:59 ` Sergei Shtylyov
[not found] ` <49996233-5ccd-58e6-db00-b5d402ff6e74-M4DtvfQ/ZS1MRgGoP+s0PdBPR1lH4CV8@public.gmane.org>
2017-07-31 16:56 ` Thierry Reding
2017-07-31 17:07 ` Sergei Shtylyov
2017-07-31 20:11 ` Jon Hunter
2017-08-09 6:10 ` Vinod Koul
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20170731093057.GA26667@ulmo \
--to=thierry.reding-re5jqeeqqe8avxtiumwx3w@public.gmane.org \
--cc=dan.j.williams-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org \
--cc=dmaengine-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=jonathanh-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org \
--cc=ldewangan-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org \
--cc=linux-tegra-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=sergei.shtylyov-M4DtvfQ/ZS1MRgGoP+s0PdBPR1lH4CV8@public.gmane.org \
--cc=vinod.koul-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox