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