[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CA+V-a8uuZ+w=Y6=VmeiyGvM+5F_0JY5PwCsg3MCq9W0_fmPBew@mail.gmail.com>
Date: Mon, 20 Dec 2021 11:58:51 +0000
From: "Lad, Prabhakar" <prabhakar.csengg@...il.com>
To: Wolfram Sang <wsa+renesas@...g-engineering.com>,
Lad Prabhakar <prabhakar.mahadev-lad.rj@...renesas.com>,
Rob Herring <robh+dt@...nel.org>,
Nicolas Saenz Julienne <nsaenz@...nel.org>,
Florian Fainelli <f.fainelli@...il.com>,
Ray Jui <rjui@...adcom.com>,
Scott Branden <sbranden@...adcom.com>,
bcm-kernel-feedback-list@...adcom.com,
Chris Brandt <chris.brandt@...esas.com>,
Linux I2C <linux-i2c@...r.kernel.org>,
linux-rpi-kernel@...ts.infradead.org,
LAK <linux-arm-kernel@...ts.infradead.org>,
LKML <linux-kernel@...r.kernel.org>,
Linux-Renesas <linux-renesas-soc@...r.kernel.org>,
Prabhakar <prabhakar.csengg@...il.com>
Subject: Re: [PATCH 2/3] i2c: sh_mobile: Use platform_get_irq_optional() to
get the interrupt
Hi Wolfram,
Thank you for the review.
On Mon, Dec 20, 2021 at 10:16 AM Wolfram Sang
<wsa+renesas@...g-engineering.com> wrote:
>
> Hi Prabhakar,
>
> > + if (!np) {
>
> Very minor nit: Maybe 'if (np)' and switch the blocks? Positive logic is
> a tad easier to read.
>
OK will update it for v2.
> > + struct resource *res;
> > + resource_size_t n;
> > +
> > + while ((res = platform_get_resource(dev, IORESOURCE_IRQ, k))) {
> > + for (n = res->start; n <= res->end; n++) {
> > + ret = devm_request_irq(&dev->dev, n, sh_mobile_i2c_isr,
> > + 0, dev_name(&dev->dev), pd);
> > + if (ret) {
> > + dev_err(&dev->dev, "cannot request IRQ %pa\n", &n);
> > + return ret;
> > + }
> > + }
> > + k++;
> > + }
>
> Yeah, it is good to keep the legacy block as is.
>
> > + do {
> > + irq = platform_get_irq_optional(dev, k);
> > + if (irq <= 0 && irq != -ENXIO)
> > + return irq ? irq : -ENXIO;
> > + if (irq == -ENXIO)
> > + break;
> > + ret = devm_request_irq(&dev->dev, irq, sh_mobile_i2c_isr,
> > + 0, dev_name(&dev->dev), pd);
> > if (ret) {
> > - dev_err(&dev->dev, "cannot request IRQ %pa\n", &n);
> > + dev_err(&dev->dev, "cannot request IRQ %d\n", irq);
> > return ret;
> > }
> > - }
> > - k++;
> > + k++;
> > + } while (irq);
>
> In addition to the 'irq == 0' case from patch 1, I tried to shorten the
> block for the np-case. I only came up with this. The assigntment and
> comparison of the while-argument is not exactly pretty, but the block
> itself is easier to read. I'll let you decide.
>
> while (irq = platform_get_irq_optional(dev, k) != -ENXIO) {
> if (irq < 0)
> return irq;
>
> ret = devm_request_irq(&dev->dev, irq, sh_mobile_i2c_isr,
> 0, dev_name(&dev->dev), pd);
> if (ret) {
> dev_err(&dev->dev, "cannot request IRQ %d\n", irq);
> return ret;
> }
> k++;
> }
>
> Only brainstorming, not even build tested.
>
LGTM, I'll give that a shot.
Cheers,
Prabhakar
Powered by blists - more mailing lists