* [PATCH] iio: adc: nxp-sar-adc: use field_get() for EOC bit check
@ 2026-04-10 21:13 Piyush Patle
2026-04-10 21:26 ` David Lechner
0 siblings, 1 reply; 4+ messages in thread
From: Piyush Patle @ 2026-04-10 21:13 UTC (permalink / raw)
To: Jonathan Cameron, linux-iio
Cc: David Lechner, Nuno Sá, Andy Shevchenko, Daniel Lezcano,
Alexandru-Catalin Ionita, Felix Gu, linux-kernel
The driver uses FIELD_GET() for constant-mask fields but falls back
to a raw bit test for the per-channel EOC bit, as the mask depends
on the runtime channel index. A TODO notes that this should switch
to field_get() when available.
Use field_get() here now that runtime-mask support exists, and drop
the obsolete TODO. Since NXP_SAR_ADC_EOC_CH(c) is BIT(c), the
resulting !-test is semantically identical.
No functional change.
Signed-off-by: Piyush Patle <piyushpatle228@gmail.com>
---
drivers/iio/adc/nxp-sar-adc.c | 6 +-----
1 file changed, 1 insertion(+), 5 deletions(-)
diff --git a/drivers/iio/adc/nxp-sar-adc.c b/drivers/iio/adc/nxp-sar-adc.c
index 58103bf16aff..d6c2a0d50bb4 100644
--- a/drivers/iio/adc/nxp-sar-adc.c
+++ b/drivers/iio/adc/nxp-sar-adc.c
@@ -316,11 +316,7 @@ static int nxp_sar_adc_read_data(struct nxp_sar_adc *info, unsigned int chan)
ceocfr = readl(NXP_SAR_ADC_CEOCFR0(info->regs));
- /*
- * FIELD_GET() can not be used here because EOC_CH is not constant.
- * TODO: Switch to field_get() when it will be available.
- */
- if (!(NXP_SAR_ADC_EOC_CH(chan) & ceocfr))
+ if (!field_get(NXP_SAR_ADC_EOC_CH(chan), ceocfr))
return -EIO;
cdr = readl(NXP_SAR_ADC_CDR(info->regs, chan));
--
2.43.0
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] iio: adc: nxp-sar-adc: use field_get() for EOC bit check
2026-04-10 21:13 [PATCH] iio: adc: nxp-sar-adc: use field_get() for EOC bit check Piyush Patle
@ 2026-04-10 21:26 ` David Lechner
2026-04-10 21:46 ` Piyush Patle
2026-04-11 12:14 ` David Laight
0 siblings, 2 replies; 4+ messages in thread
From: David Lechner @ 2026-04-10 21:26 UTC (permalink / raw)
To: Piyush Patle, Jonathan Cameron, linux-iio
Cc: Nuno Sá, Andy Shevchenko, Daniel Lezcano,
Alexandru-Catalin Ionita, Felix Gu, linux-kernel
On 4/10/26 4:13 PM, Piyush Patle wrote:
> The driver uses FIELD_GET() for constant-mask fields but falls back
> to a raw bit test for the per-channel EOC bit, as the mask depends
> on the runtime channel index. A TODO notes that this should switch
> to field_get() when available.
Could drop this first paragraph, it is a bit redundant.
>
> Use field_get() here now that runtime-mask support exists, and drop
We like for commit messages to start with the verb like this, so
this would be ideal for the first paragraph of the commit message.
> the obsolete TODO. Since NXP_SAR_ADC_EOC_CH(c) is BIT(c), the
> resulting !-test is semantically identical.
>
> No functional change.
>
> Signed-off-by: Piyush Patle <piyushpatle228@gmail.com>
> ---
Reviewed-by: David Lechner <dlechner@baylibre.com>
And if you are interested in doing more like this, search the IIO
subsystem for __ffs. If it is used with << or >> then there is a
good chance it could be replaced with field_get() or field_prep().
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] iio: adc: nxp-sar-adc: use field_get() for EOC bit check
2026-04-10 21:26 ` David Lechner
@ 2026-04-10 21:46 ` Piyush Patle
2026-04-11 12:14 ` David Laight
1 sibling, 0 replies; 4+ messages in thread
From: Piyush Patle @ 2026-04-10 21:46 UTC (permalink / raw)
To: David Lechner
Cc: Jonathan Cameron, linux-iio, Nuno Sá, Andy Shevchenko,
Daniel Lezcano, Alexandru-Catalin Ionita, Felix Gu, linux-kernel
> On 4/10/26 4:13 PM, Piyush Patle wrote:
> > The driver uses FIELD_GET() for constant-mask fields but falls back
> > to a raw bit test for the per-channel EOC bit, as the mask depends
> > on the runtime channel index. A TODO notes that this should switch
> > to field_get() when available.
>
> Could drop this first paragraph, it is a bit redundant.
>
> >
> > Use field_get() here now that runtime-mask support exists, and drop
>
> We like for commit messages to start with the verb like this, so
> this would be ideal for the first paragraph of the commit message.
I have addressed all your comments.
>
> > the obsolete TODO. Since NXP_SAR_ADC_EOC_CH(c) is BIT(c), the
> > resulting !-test is semantically identical.
> >
> > No functional change.
> >
> > Signed-off-by: Piyush Patle <piyushpatle228@gmail.com>
> > ---
> Reviewed-by: David Lechner <dlechner@baylibre.com>
>
Thanks for the review. Sent v2!
>
> And if you are interested in doing more like this, search the IIO
> subsystem for __ffs. If it is used with << or >> then there is a
> good chance it could be replaced with field_get() or field_prep().
>
I'll also look for similar __ffs() patterns in IIO and convert them
to field_get()/field_prep() where appropriate.
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] iio: adc: nxp-sar-adc: use field_get() for EOC bit check
2026-04-10 21:26 ` David Lechner
2026-04-10 21:46 ` Piyush Patle
@ 2026-04-11 12:14 ` David Laight
1 sibling, 0 replies; 4+ messages in thread
From: David Laight @ 2026-04-11 12:14 UTC (permalink / raw)
To: David Lechner
Cc: Piyush Patle, Jonathan Cameron, linux-iio, Nuno Sá,
Andy Shevchenko, Daniel Lezcano, Alexandru-Catalin Ionita,
Felix Gu, linux-kernel
On Fri, 10 Apr 2026 16:26:05 -0500
David Lechner <dlechner@baylibre.com> wrote:
> On 4/10/26 4:13 PM, Piyush Patle wrote:
> > The driver uses FIELD_GET() for constant-mask fields but falls back
> > to a raw bit test for the per-channel EOC bit, as the mask depends
> > on the runtime channel index. A TODO notes that this should switch
> > to field_get() when available.
>
> Could drop this first paragraph, it is a bit redundant.
>
> >
> > Use field_get() here now that runtime-mask support exists, and drop
>
> We like for commit messages to start with the verb like this, so
> this would be ideal for the first paragraph of the commit message.
>
> > the obsolete TODO. Since NXP_SAR_ADC_EOC_CH(c) is BIT(c), the
> > resulting !-test is semantically identical.
> >
> > No functional change.
> >
> > Signed-off-by: Piyush Patle <piyushpatle228@gmail.com>
> > ---
> Reviewed-by: David Lechner <dlechner@baylibre.com>
>
>
> And if you are interested in doing more like this, search the IIO
> subsystem for __ffs. If it is used with << or >> then there is a
> good chance it could be replaced with field_get() or field_prep().
>
>
And likely make the code larger and slower :-)
At least run the bloat-o-meter.
David
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2026-04-11 12:14 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-04-10 21:13 [PATCH] iio: adc: nxp-sar-adc: use field_get() for EOC bit check Piyush Patle
2026-04-10 21:26 ` David Lechner
2026-04-10 21:46 ` Piyush Patle
2026-04-11 12:14 ` David Laight
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox