LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
From: Jonathan Cameron <jic23@kernel.org>
To: "Lad, Prabhakar" <prabhakar.csengg@gmail.com>
Cc: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>,
	Geert Uytterhoeven <geert+renesas@glider.be>,
	Rob Herring <robh+dt@kernel.org>,
	Lars-Peter Clausen <lars@metafoo.de>,
	Magnus Damm <magnus.damm@gmail.com>,
	Philipp Zabel <p.zabel@pengutronix.de>,
	Alexandru Ardelean <aardelean@deviqon.com>,
	linux-iio <linux-iio@vger.kernel.org>,
	"open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE BINDINGS" 
	<devicetree@vger.kernel.org>,
	Linux-Renesas <linux-renesas-soc@vger.kernel.org>,
	LKML <linux-kernel@vger.kernel.org>,
	Biju Das <biju.das.jz@bp.renesas.com>
Subject: Re: [PATCH v3 2/3] iio: adc: Add driver for Renesas RZ/G2L A/D converter
Date: Sun, 1 Aug 2021 17:59:47 +0100	[thread overview]
Message-ID: <20210801175947.2b49878d@jic23-huawei> (raw)
In-Reply-To: <CA+V-a8vMdFrrcw3iqbSzd4oN_x6CijOwYo7eSFuf8LhfB6SFRg@mail.gmail.com>

On Sat, 31 Jul 2021 19:31:52 +0100
"Lad, Prabhakar" <prabhakar.csengg@gmail.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)) 

> 
> > > +                     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).


J

  reply	other threads:[~2021-08-01 16:57 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-07-26 18:28 [PATCH v3 0/3] Renesas RZ/G2L ADC driver support Lad Prabhakar
2021-07-26 18:28 ` [PATCH v3 1/3] dt-bindings: iio: adc: Add binding documentation for Renesas RZ/G2L A/D converter Lad Prabhakar
2021-07-26 21:42   ` Rob Herring
2021-07-27  8:06     ` Lad, Prabhakar
2021-07-27 20:30   ` Rob Herring
2021-07-26 18:28 ` [PATCH v3 2/3] iio: adc: Add driver " Lad Prabhakar
2021-07-27  7:13   ` Philipp Zabel
2021-07-27  8:02     ` Lad, Prabhakar
2021-07-27  8:13       ` Philipp Zabel
2021-07-27  8:54         ` Lad, Prabhakar
2021-07-31 17:11   ` Jonathan Cameron
2021-07-31 18:31     ` Lad, Prabhakar
2021-08-01 16:59       ` Jonathan Cameron [this message]
2021-08-01 19:51         ` Lad, Prabhakar
2021-07-26 18:28 ` [PATCH v3 3/3] arm64: dts: renesas: r9a07g044: Add ADC node Lad Prabhakar

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=20210801175947.2b49878d@jic23-huawei \
    --to=jic23@kernel.org \
    --cc=aardelean@deviqon.com \
    --cc=biju.das.jz@bp.renesas.com \
    --cc=devicetree@vger.kernel.org \
    --cc=geert+renesas@glider.be \
    --cc=lars@metafoo.de \
    --cc=linux-iio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-renesas-soc@vger.kernel.org \
    --cc=magnus.damm@gmail.com \
    --cc=p.zabel@pengutronix.de \
    --cc=prabhakar.csengg@gmail.com \
    --cc=prabhakar.mahadev-lad.rj@bp.renesas.com \
    --cc=robh+dt@kernel.org \
    --subject='Re: [PATCH v3 2/3] iio: adc: Add driver for Renesas RZ/G2L A/D converter' \
    /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

This is a public inbox, see mirroring instructions
on how to clone and mirror all data and code used for this inbox