mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] iio: adc: at91_adc: use const char * for DT string property
@ 2026-07-22 19:39 Amin GATTOUT
  2026-07-22 19:47 ` David Lechner
  0 siblings, 1 reply; 3+ messages in thread
From: Amin GATTOUT @ 2026-07-22 19:39 UTC (permalink / raw)
  To: Jonathan Cameron, David Lechner, Nuno Sá,
	Andy Shevchenko, Nicolas Ferre, Alexandre Belloni,
	Claudiu Beznea
  Cc: linux-iio, linux-arm-kernel, linux-kernel, Amin GATTOUT

Declare the local variable as const char * and remove the unnecessary cast
when passing it to of_property_read_string().

Signed-off-by: Amin GATTOUT <amin.gattout@gmail.com>
---
 drivers/iio/adc/at91_adc.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/iio/adc/at91_adc.c b/drivers/iio/adc/at91_adc.c
index f610ad729bf3..0ac74ad92fca 100644
--- a/drivers/iio/adc/at91_adc.c
+++ b/drivers/iio/adc/at91_adc.c
@@ -988,7 +988,7 @@ static int at91_adc_probe(struct platform_device *pdev)
 	struct iio_dev *idev;
 	struct at91_adc_state *st;
 	u32 reg, prop;
-	char *s;
+	const char *s;
 
 	idev = devm_iio_device_alloc(&pdev->dev, sizeof(struct at91_adc_state));
 	if (!idev)
@@ -1023,7 +1023,7 @@ static int at91_adc_probe(struct platform_device *pdev)
 
 	st->res = st->caps->high_res_bits;
 	if (st->caps->low_res_bits &&
-	    !of_property_read_string(node, "atmel,adc-use-res", (const char **)&s)
+	    !of_property_read_string(node, "atmel,adc-use-res", &s)
 	    && !strcmp(s, "lowres"))
 		st->res = st->caps->low_res_bits;
 

---
base-commit: 248951ddc14de84de3910f9b13f51491a8cd91df
change-id: 20260722-master-23179d7c00c4

Best regards,
-- 
Amin GATTOUT <amin.gattout@gmail.com>


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

* Re: [PATCH] iio: adc: at91_adc: use const char * for DT string property
  2026-07-22 19:39 [PATCH] iio: adc: at91_adc: use const char * for DT string property Amin GATTOUT
@ 2026-07-22 19:47 ` David Lechner
  2026-07-25 23:22   ` Jonathan Cameron
  0 siblings, 1 reply; 3+ messages in thread
From: David Lechner @ 2026-07-22 19:47 UTC (permalink / raw)
  To: Amin GATTOUT, Jonathan Cameron, Nuno Sá,
	Andy Shevchenko, Nicolas Ferre, Alexandre Belloni,
	Claudiu Beznea
  Cc: linux-iio, linux-arm-kernel, linux-kernel

On 7/22/26 2:39 PM, Amin GATTOUT wrote:
> Declare the local variable as const char * and remove the unnecessary cast
> when passing it to of_property_read_string().
> 
> Signed-off-by: Amin GATTOUT <amin.gattout@gmail.com>
> ---
>  drivers/iio/adc/at91_adc.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/iio/adc/at91_adc.c b/drivers/iio/adc/at91_adc.c
> index f610ad729bf3..0ac74ad92fca 100644
> --- a/drivers/iio/adc/at91_adc.c
> +++ b/drivers/iio/adc/at91_adc.c
> @@ -988,7 +988,7 @@ static int at91_adc_probe(struct platform_device *pdev)
>  	struct iio_dev *idev;
>  	struct at91_adc_state *st;
>  	u32 reg, prop;
> -	char *s;
> +	const char *s;
>  
>  	idev = devm_iio_device_alloc(&pdev->dev, sizeof(struct at91_adc_state));
>  	if (!idev)
> @@ -1023,7 +1023,7 @@ static int at91_adc_probe(struct platform_device *pdev)
>  
>  	st->res = st->caps->high_res_bits;
>  	if (st->caps->low_res_bits &&
> -	    !of_property_read_string(node, "atmel,adc-use-res", (const char **)&s)
> +	    !of_property_read_string(node, "atmel,adc-use-res", &s)
>  	    && !strcmp(s, "lowres"))
>  		st->res = st->caps->low_res_bits;
>  
> 
> ---
> base-commit: 248951ddc14de84de3910f9b13f51491a8cd91df
> change-id: 20260722-master-23179d7c00c4
> 
> Best regards,

Makes sense.

Reviewed-by: David Lechner <dlechner@baylibre.com>

Although perhaps could be simplified instead by using
of_property_match_string().

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

* Re: [PATCH] iio: adc: at91_adc: use const char * for DT string property
  2026-07-22 19:47 ` David Lechner
@ 2026-07-25 23:22   ` Jonathan Cameron
  0 siblings, 0 replies; 3+ messages in thread
From: Jonathan Cameron @ 2026-07-25 23:22 UTC (permalink / raw)
  To: David Lechner
  Cc: Amin GATTOUT, Nuno Sá,
	Andy Shevchenko, Nicolas Ferre, Alexandre Belloni,
	Claudiu Beznea, linux-iio, linux-arm-kernel, linux-kernel

On Wed, 22 Jul 2026 14:47:08 -0500
David Lechner <dlechner@baylibre.com> wrote:

> On 7/22/26 2:39 PM, Amin GATTOUT wrote:
> > Declare the local variable as const char * and remove the unnecessary cast
> > when passing it to of_property_read_string().
> > 
> > Signed-off-by: Amin GATTOUT <amin.gattout@gmail.com>
> > ---
> >  drivers/iio/adc/at91_adc.c | 4 ++--
> >  1 file changed, 2 insertions(+), 2 deletions(-)
> > 
> > diff --git a/drivers/iio/adc/at91_adc.c b/drivers/iio/adc/at91_adc.c
> > index f610ad729bf3..0ac74ad92fca 100644
> > --- a/drivers/iio/adc/at91_adc.c
> > +++ b/drivers/iio/adc/at91_adc.c
> > @@ -988,7 +988,7 @@ static int at91_adc_probe(struct platform_device *pdev)
> >  	struct iio_dev *idev;
> >  	struct at91_adc_state *st;
> >  	u32 reg, prop;
> > -	char *s;
> > +	const char *s;
> >  
> >  	idev = devm_iio_device_alloc(&pdev->dev, sizeof(struct at91_adc_state));
> >  	if (!idev)
> > @@ -1023,7 +1023,7 @@ static int at91_adc_probe(struct platform_device *pdev)
> >  
> >  	st->res = st->caps->high_res_bits;
> >  	if (st->caps->low_res_bits &&
> > -	    !of_property_read_string(node, "atmel,adc-use-res", (const char **)&s)
> > +	    !of_property_read_string(node, "atmel,adc-use-res", &s)
> >  	    && !strcmp(s, "lowres"))
> >  		st->res = st->caps->low_res_bits;
> >  
> > 
> > ---
> > base-commit: 248951ddc14de84de3910f9b13f51491a8cd91df
> > change-id: 20260722-master-23179d7c00c4
> > 
> > Best regards,  
> 
> Makes sense.
> 
> Reviewed-by: David Lechner <dlechner@baylibre.com>
> 
> Although perhaps could be simplified instead by using
> of_property_match_string().

Whilst I would prefer that it 'might' break a bad device tree given
the current code is a match against one of the two values.  If we start
matching explicitly against them any issues would become a probe failure.

So given it's ancient and I don't want to mess too much with it, applied
this lower risk patch.

Jonathan


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

end of thread, other threads:[~2026-07-25 23:22 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-07-22 19:39 [PATCH] iio: adc: at91_adc: use const char * for DT string property Amin GATTOUT
2026-07-22 19:47 ` David Lechner
2026-07-25 23:22   ` Jonathan Cameron

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

all inboxes | Powered by JetHome®