Linux-ARM-Kernel Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] iio: stm32-dfsdm: Treat flags as booleans
@ 2026-06-12 21:51 Rob Herring (Arm)
  2026-06-13 13:39 ` Andy Shevchenko
  0 siblings, 1 reply; 3+ messages in thread
From: Rob Herring (Arm) @ 2026-06-12 21:51 UTC (permalink / raw)
  To: Jonathan Cameron, David Lechner, Nuno Sá, Andy Shevchenko,
	Maxime Coquelin, Alexandre Torgue
  Cc: linux-iio, linux-stm32, linux-arm-kernel, linux-kernel

The "st,adc-alt-channel" and "st,filter0-sync" properties are
documented as boolean flags. The legacy parser read them as integer
cells, unlike the child-node parser which already checks only for
presence.

Use presence and boolean helpers so both parsers follow the binding and
the property type checker no longer reports the flags.

Assisted-by: Codex:gpt-5-5
Signed-off-by: Rob Herring (Arm) <robh@kernel.org>
---
 drivers/iio/adc/stm32-dfsdm-adc.c | 12 ++++--------
 1 file changed, 4 insertions(+), 8 deletions(-)

diff --git a/drivers/iio/adc/stm32-dfsdm-adc.c b/drivers/iio/adc/stm32-dfsdm-adc.c
index 9664b9bd75d4..00f05e167afc 100644
--- a/drivers/iio/adc/stm32-dfsdm-adc.c
+++ b/drivers/iio/adc/stm32-dfsdm-adc.c
@@ -660,11 +660,8 @@ static int stm32_dfsdm_channel_parse_of(struct stm32_dfsdm *dfsdm,
 	}
 	df_ch->src = val;
 
-	ret = of_property_read_u32_index(indio_dev->dev.of_node,
-					 "st,adc-alt-channel", chan_idx,
-					 &df_ch->alt_si);
-	if (ret < 0)
-		df_ch->alt_si = 0;
+	df_ch->alt_si = of_property_present(indio_dev->dev.of_node,
+					    "st,adc-alt-channel");
 
 	return 0;
 }
@@ -1815,9 +1812,8 @@ static int stm32_dfsdm_adc_probe(struct platform_device *pdev)
 
 	adc->dfsdm->fl_list[adc->fl_id].ford = val;
 
-	ret = of_property_read_u32(dev->of_node, "st,filter0-sync", &val);
-	if (!ret)
-		adc->dfsdm->fl_list[adc->fl_id].sync_mode = val;
+	adc->dfsdm->fl_list[adc->fl_id].sync_mode =
+		of_property_read_bool(dev->of_node, "st,filter0-sync");
 
 	adc->dev_data = dev_data;
 	ret = dev_data->init(dev, iio);
-- 
2.53.0



^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] iio: stm32-dfsdm: Treat flags as booleans
  2026-06-12 21:51 [PATCH] iio: stm32-dfsdm: Treat flags as booleans Rob Herring (Arm)
@ 2026-06-13 13:39 ` Andy Shevchenko
  2026-06-21 14:10   ` Jonathan Cameron
  0 siblings, 1 reply; 3+ messages in thread
From: Andy Shevchenko @ 2026-06-13 13:39 UTC (permalink / raw)
  To: Rob Herring (Arm)
  Cc: Jonathan Cameron, David Lechner, Nuno Sá, Andy Shevchenko,
	Maxime Coquelin, Alexandre Torgue, linux-iio, linux-stm32,
	linux-arm-kernel, linux-kernel

On Fri, Jun 12, 2026 at 04:51:50PM -0500, Rob Herring (Arm) wrote:
> The "st,adc-alt-channel" and "st,filter0-sync" properties are
> documented as boolean flags. The legacy parser read them as integer
> cells, unlike the child-node parser which already checks only for
> presence.
> 
> Use presence and boolean helpers so both parsers follow the binding and
> the property type checker no longer reports the flags.

For the patch
Reviewed-by: Andy Shevchenko <andriy.shevchenko@intel.com>

However one interesting remark below.

...

> -	ret = of_property_read_u32_index(indio_dev->dev.of_node,
> -					 "st,adc-alt-channel", chan_idx,
> -					 &df_ch->alt_si);

> +	df_ch->alt_si = of_property_present(indio_dev->dev.of_node,

I believe it still has another (serious?) issue. We usually don't use indio_dev
for device properties. It's not a device that is described in DT.
It seems the only driver in IIO that does that. Note, I haven't conducted any
deeper research, it might be (however I'm quite in doubt) that this is correct
use and one device registers a few indio_dev:s.

> +					    "st,adc-alt-channel");

-- 
With Best Regards,
Andy Shevchenko




^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] iio: stm32-dfsdm: Treat flags as booleans
  2026-06-13 13:39 ` Andy Shevchenko
@ 2026-06-21 14:10   ` Jonathan Cameron
  0 siblings, 0 replies; 3+ messages in thread
From: Jonathan Cameron @ 2026-06-21 14:10 UTC (permalink / raw)
  To: Andy Shevchenko
  Cc: Rob Herring (Arm), David Lechner, Nuno Sá, Andy Shevchenko,
	Maxime Coquelin, Alexandre Torgue, linux-iio, linux-stm32,
	linux-arm-kernel, linux-kernel

On Sat, 13 Jun 2026 16:39:16 +0300
Andy Shevchenko <andriy.shevchenko@intel.com> wrote:

> On Fri, Jun 12, 2026 at 04:51:50PM -0500, Rob Herring (Arm) wrote:
> > The "st,adc-alt-channel" and "st,filter0-sync" properties are
> > documented as boolean flags. The legacy parser read them as integer
> > cells, unlike the child-node parser which already checks only for
> > presence.
> > 
> > Use presence and boolean helpers so both parsers follow the binding and
> > the property type checker no longer reports the flags.  
> 
> For the patch
> Reviewed-by: Andy Shevchenko <andriy.shevchenko@intel.com>
> 
> However one interesting remark below.
> 
> ...
> 
> > -	ret = of_property_read_u32_index(indio_dev->dev.of_node,
> > -					 "st,adc-alt-channel", chan_idx,
> > -					 &df_ch->alt_si);  
> 
> > +	df_ch->alt_si = of_property_present(indio_dev->dev.of_node,  
> 
> I believe it still has another (serious?) issue. We usually don't use indio_dev
> for device properties. It's not a device that is described in DT.
> It seems the only driver in IIO that does that. Note, I haven't conducted any
> deeper research, it might be (however I'm quite in doubt) that this is correct
> use and one device registers a few indio_dev:s.

It is curious.  The registration sequence in this driver is complex, but I'm not
seeing anything that sets the fwnode for the struct iio_dev->dev before calling
the init() callbacks that end up in this code.  It is set later by iio_device_register()
(iirc that has something to do with consumers turning up later).

St folk could you take a look at this and see what we are missing
if it does currently work?

For now I'll apply this patch but might need to drop it if a fix clashes
with it.

Thanks,

Jonathan



> 
> > +					    "st,adc-alt-channel");  
> 



^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2026-06-21 14:10 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-06-12 21:51 [PATCH] iio: stm32-dfsdm: Treat flags as booleans Rob Herring (Arm)
2026-06-13 13:39 ` Andy Shevchenko
2026-06-21 14:10   ` Jonathan Cameron

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