lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <CA+V-a8ukR39BsvUd055p8w-kafZ-SQDXydkJXag7c+7m3MEihg@mail.gmail.com>
Date:   Sun, 1 Aug 2021 20:51:18 +0100
From:   "Lad, Prabhakar" <prabhakar.csengg@...il.com>
To:     Jonathan Cameron <jic23@...nel.org>
Cc:     Lad Prabhakar <prabhakar.mahadev-lad.rj@...renesas.com>,
        Geert Uytterhoeven <geert+renesas@...der.be>,
        Rob Herring <robh+dt@...nel.org>,
        Lars-Peter Clausen <lars@...afoo.de>,
        Magnus Damm <magnus.damm@...il.com>,
        Philipp Zabel <p.zabel@...gutronix.de>,
        Alexandru Ardelean <aardelean@...iqon.com>,
        linux-iio <linux-iio@...r.kernel.org>,
        "open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE BINDINGS" 
        <devicetree@...r.kernel.org>,
        Linux-Renesas <linux-renesas-soc@...r.kernel.org>,
        LKML <linux-kernel@...r.kernel.org>,
        Biju Das <biju.das.jz@...renesas.com>
Subject: Re: [PATCH v3 2/3] iio: adc: Add driver for Renesas RZ/G2L A/D converter

Hi Jonathan,

On Sun, Aug 1, 2021 at 5:57 PM Jonathan Cameron <jic23@...nel.org> wrote:
>
> On Sat, 31 Jul 2021 19:31:52 +0100
> "Lad, Prabhakar" <prabhakar.csengg@...il.com> wrote:
>
> > Hi Jonathan,
> >
> > Thank you for the review.
> >
>
> ...
>
> > > > +#define DRIVER_NAME          "rzg2l-adc"
> > >
> > > As only used in one place, just put it inline there so we don't need
> > > to go find if we want to know the value - I'm lazy.
> > >
> > Its being used in two places
> > 1: indio_dev->name = DRIVER_NAME #In probe call
> > 2: .name = DRIVER_NAME # In platform_driver struct
> >
> > Let me know if you want me to replace them inline and drop the above macro.
>
> oops.  Searching apparently failed me ;)  Fine as is.
>
> ...
>
>
> > > > +static const struct iio_info rzg2l_adc_iio_info = {
> > > > +     .read_raw = rzg2l_adc_read_raw,
> > > > +     .read_label = rzg2l_adc_read_label,
> > > > +};
> > > > +
> > > > +static irqreturn_t rzg2l_adc_isr(int irq, void *dev_id)
> > > > +{
> > > > +     struct rzg2l_adc *adc = (struct rzg2l_adc *)dev_id;
> > >
> > > No need for explicit cast from void * to another pointer type.
> > > This is always valid without in C.
> > >
> > Agreed.
> >
> > > > +     unsigned long intst;
> > > > +     u32 reg;
> > > > +     int ch;
> > > > +
> > > > +     reg = rzg2l_adc_readl(adc, RZG2L_ADSTS);
> > > > +
> > > > +     /* A/D conversion channel select error interrupt */
> > > > +     if (reg & RZG2L_ADSTS_CSEST) {
> > > > +             rzg2l_adc_writel(adc, RZG2L_ADSTS, reg);
> > > > +             return IRQ_HANDLED;
> > > > +     }
> > > > +
> > > > +     intst = reg & RZG2L_ADSTS_INTST_MASK;
> > > > +     if (!intst)
> > > > +             return IRQ_NONE;
> > > > +
> > > > +     for_each_set_bit(ch, &intst, RZG2L_ADC_MAX_CHANNELS) {
> > > > +             if (intst & BIT(ch))
> > >
> > > I'm missing how this if can fail given we only end up in here when the bit is
> > > set.
> > >
> > ADC has 8 channels RZG2L_ADSTS register bits [0:7] will be set to 1
> > when the given channel ADC conversion has been completed. So the above
> > if condition checks if the bit is set to 1 and then reads the
> > corresponding value of that channel.
>
> Just looking at the two lines of code above
> for_each_set_bit(ch, &intst, RZG2L_ADC_MAX_CHANNELS)
> will only call the the next line if the bit is set.  E.g. It will only call
> it
> if (intst & BIT(ch))
>
> So you can only get into the body of the for loop if this bit is set and the
> condition is always true.  Hence drop
> if (intst & BIT(ch))
>
Agreed can be dropped.

> >
> > > > +                     adc->last_val[ch] = rzg2l_adc_readl(adc, RZG2L_ADCR(ch)) &
> > > > +                                         RZG2L_ADCR_AD_MASK;
> > > > +     }
> > > > +
> > > > +     /* clear the channel interrupt */
> > > > +     rzg2l_adc_writel(adc, RZG2L_ADSTS, reg);
> > > > +
> > > > +     complete(&adc->completion);
> > > > +
> > > > +     return IRQ_HANDLED;
> > > > +}
> > > > +
>
> ...
>
> > > > +
> > > > +     pm_runtime_enable(dev);
> > >
> > > I think you also want to set the state to suspended to ensure the resume is
> > > called on get.
> > >
> > pm_runtime_set_suspended() should only be called when runtime is
> > disabled or is it that I am missing something ?
>
> If you want the runtime pm code to assume your device is suspended initially
> then you set the state before you call pm_runtime_enable(dev).
>
OK will call pm_runtime_set_suspended() before enabling.

Cheers,
Prabhakar

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ