public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] iio: adc: vf610: Add missing check for device_property_read_u32_array
@ 2026-01-28  4:27 Chen Ni
  2026-01-28  6:02 ` Bough Chen
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Chen Ni @ 2026-01-28  4:27 UTC (permalink / raw)
  To: haibo.chen, jic23, dlechner, nuno.sa, andy
  Cc: linux-iio, imx, linux-kernel, Chen Ni

Add check for the return value of device_property_read_u32_array() and
return the error if it fails in order to catch the error.

Signed-off-by: Chen Ni <nichen@iscas.ac.cn>
---
 drivers/iio/adc/vf610_adc.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/drivers/iio/adc/vf610_adc.c b/drivers/iio/adc/vf610_adc.c
index d7182ed0d2a7..d53723ccc5b2 100644
--- a/drivers/iio/adc/vf610_adc.c
+++ b/drivers/iio/adc/vf610_adc.c
@@ -871,7 +871,10 @@ static int vf610_adc_probe(struct platform_device *pdev)
 
 	info->vref_uv = regulator_get_voltage(info->vref);
 
-	device_property_read_u32_array(dev, "fsl,adck-max-frequency", info->max_adck_rate, 3);
+	ret = device_property_read_u32_array(dev, "fsl,adck-max-frequency",
+					     info->max_adck_rate, 3);
+	if (ret)
+		return ret;
 
 	info->adc_feature.default_sample_time = DEFAULT_SAMPLE_TIME;
 	device_property_read_u32(dev, "min-sample-time", &info->adc_feature.default_sample_time);
-- 
2.25.1


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

* RE: [PATCH] iio: adc: vf610: Add missing check for device_property_read_u32_array
  2026-01-28  4:27 [PATCH] iio: adc: vf610: Add missing check for device_property_read_u32_array Chen Ni
@ 2026-01-28  6:02 ` Bough Chen
  2026-01-28  9:09 ` Andy Shevchenko
  2026-01-28  9:29 ` Nuno Sá
  2 siblings, 0 replies; 6+ messages in thread
From: Bough Chen @ 2026-01-28  6:02 UTC (permalink / raw)
  To: Chen Ni, jic23@kernel.org, dlechner@baylibre.com,
	nuno.sa@analog.com, andy@kernel.org
  Cc: linux-iio@vger.kernel.org, imx@lists.linux.dev,
	linux-kernel@vger.kernel.org

> -----Original Message-----
> From: Chen Ni <nichen@iscas.ac.cn>
> Sent: 2026年1月28日 12:27
> To: Bough Chen <haibo.chen@nxp.com>; jic23@kernel.org;
> dlechner@baylibre.com; nuno.sa@analog.com; andy@kernel.org
> Cc: linux-iio@vger.kernel.org; imx@lists.linux.dev; linux-kernel@vger.kernel.org;
> Chen Ni <nichen@iscas.ac.cn>
> Subject: [PATCH] iio: adc: vf610: Add missing check for
> device_property_read_u32_array
> 
> Add check for the return value of device_property_read_u32_array() and return
> the error if it fails in order to catch the error.

Reviewed-by: Haibo Chen <haibo.chen@nxp.com>

Best Regards
Haibo Chen
> 
> Signed-off-by: Chen Ni <nichen@iscas.ac.cn>
> ---
>  drivers/iio/adc/vf610_adc.c | 5 ++++-
>  1 file changed, 4 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/iio/adc/vf610_adc.c b/drivers/iio/adc/vf610_adc.c index
> d7182ed0d2a7..d53723ccc5b2 100644
> --- a/drivers/iio/adc/vf610_adc.c
> +++ b/drivers/iio/adc/vf610_adc.c
> @@ -871,7 +871,10 @@ static int vf610_adc_probe(struct platform_device
> *pdev)
> 
>  	info->vref_uv = regulator_get_voltage(info->vref);
> 
> -	device_property_read_u32_array(dev, "fsl,adck-max-frequency",
> info->max_adck_rate, 3);
> +	ret = device_property_read_u32_array(dev, "fsl,adck-max-frequency",
> +					     info->max_adck_rate, 3);
> +	if (ret)
> +		return ret;
> 
>  	info->adc_feature.default_sample_time = DEFAULT_SAMPLE_TIME;
>  	device_property_read_u32(dev, "min-sample-time",
> &info->adc_feature.default_sample_time);
> --
> 2.25.1


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

* Re: [PATCH] iio: adc: vf610: Add missing check for device_property_read_u32_array
  2026-01-28  4:27 [PATCH] iio: adc: vf610: Add missing check for device_property_read_u32_array Chen Ni
  2026-01-28  6:02 ` Bough Chen
@ 2026-01-28  9:09 ` Andy Shevchenko
  2026-01-28  9:29 ` Nuno Sá
  2 siblings, 0 replies; 6+ messages in thread
From: Andy Shevchenko @ 2026-01-28  9:09 UTC (permalink / raw)
  To: Chen Ni
  Cc: haibo.chen, jic23, dlechner, nuno.sa, andy, linux-iio, imx,
	linux-kernel

On Wed, Jan 28, 2026 at 12:27:00PM +0800, Chen Ni wrote:
> Add check for the return value of device_property_read_u32_array() and
> return the error if it fails in order to catch the error.

Why? Is this mandatory property or optional?

-- 
With Best Regards,
Andy Shevchenko



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

* Re: [PATCH] iio: adc: vf610: Add missing check for device_property_read_u32_array
  2026-01-28  4:27 [PATCH] iio: adc: vf610: Add missing check for device_property_read_u32_array Chen Ni
  2026-01-28  6:02 ` Bough Chen
  2026-01-28  9:09 ` Andy Shevchenko
@ 2026-01-28  9:29 ` Nuno Sá
  2026-01-29 17:40   ` Jonathan Cameron
  2 siblings, 1 reply; 6+ messages in thread
From: Nuno Sá @ 2026-01-28  9:29 UTC (permalink / raw)
  To: Chen Ni, haibo.chen, jic23, dlechner, nuno.sa, andy
  Cc: linux-iio, imx, linux-kernel

On Wed, 2026-01-28 at 12:27 +0800, Chen Ni wrote:
> Add check for the return value of device_property_read_u32_array() and
> return the error if it fails in order to catch the error.
> 
> Signed-off-by: Chen Ni <nichen@iscas.ac.cn>
> ---
>  drivers/iio/adc/vf610_adc.c | 5 ++++-
>  1 file changed, 4 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/iio/adc/vf610_adc.c b/drivers/iio/adc/vf610_adc.c
> index d7182ed0d2a7..d53723ccc5b2 100644
> --- a/drivers/iio/adc/vf610_adc.c
> +++ b/drivers/iio/adc/vf610_adc.c
> @@ -871,7 +871,10 @@ static int vf610_adc_probe(struct platform_device *pdev)
>  
>  	info->vref_uv = regulator_get_voltage(info->vref);
>  
> -	device_property_read_u32_array(dev, "fsl,adck-max-frequency", info->max_adck_rate, 3);
> +	ret = device_property_read_u32_array(dev, "fsl,adck-max-frequency",
> +					     info->max_adck_rate, 3);
> +	if (ret)
> +		return ret;

As Andy pointed out, this is changing behavior so it needs to be properly justified. Also since we
are here, maybe use ARRAY_SIZE(info->max_adck_rate).

- Nuno Sá

>  
>  	info->adc_feature.default_sample_time = DEFAULT_SAMPLE_TIME;
>  	device_property_read_u32(dev, "min-sample-time", &info->adc_feature.default_sample_time);

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

* Re: [PATCH] iio: adc: vf610: Add missing check for device_property_read_u32_array
  2026-01-28  9:29 ` Nuno Sá
@ 2026-01-29 17:40   ` Jonathan Cameron
  2026-01-30  5:25     ` Andy Shevchenko
  0 siblings, 1 reply; 6+ messages in thread
From: Jonathan Cameron @ 2026-01-29 17:40 UTC (permalink / raw)
  To: Nuno Sá
  Cc: Chen Ni, haibo.chen, dlechner, nuno.sa, andy, linux-iio, imx,
	linux-kernel

On Wed, 28 Jan 2026 09:29:47 +0000
Nuno Sá <noname.nuno@gmail.com> wrote:

> On Wed, 2026-01-28 at 12:27 +0800, Chen Ni wrote:
> > Add check for the return value of device_property_read_u32_array() and
> > return the error if it fails in order to catch the error.
> > 
> > Signed-off-by: Chen Ni <nichen@iscas.ac.cn>
> > ---
> >  drivers/iio/adc/vf610_adc.c | 5 ++++-
> >  1 file changed, 4 insertions(+), 1 deletion(-)
> > 
> > diff --git a/drivers/iio/adc/vf610_adc.c b/drivers/iio/adc/vf610_adc.c
> > index d7182ed0d2a7..d53723ccc5b2 100644
> > --- a/drivers/iio/adc/vf610_adc.c
> > +++ b/drivers/iio/adc/vf610_adc.c
> > @@ -871,7 +871,10 @@ static int vf610_adc_probe(struct platform_device *pdev)
> >  
> >  	info->vref_uv = regulator_get_voltage(info->vref);
> >  
> > -	device_property_read_u32_array(dev, "fsl,adck-max-frequency", info->max_adck_rate, 3);
> > +	ret = device_property_read_u32_array(dev, "fsl,adck-max-frequency",
> > +					     info->max_adck_rate, 3);
> > +	if (ret)
> > +		return ret;  
> 
> As Andy pointed out, this is changing behavior so it needs to be properly justified. Also since we
> are here, maybe use ARRAY_SIZE(info->max_adck_rate).
> 
Given the driver has a fallback for info->max_adck_rate[x] == 0
I think this is intentional.  It would be clearer if this had done.

	info->max_adck_rate[0] = 8;
	info->max_adck_rate[1] = 8;
	info->max_adck_rate[2] = 8;
	device_property_read_u32_array(dev, "fsl,adck-max-frequency", info->max_adck_rate, 3);

though rather than where it has the fallback in vf610_adc_calculate_rates()


> - Nuno Sá
> 
> >  
> >  	info->adc_feature.default_sample_time = DEFAULT_SAMPLE_TIME;
> >  	device_property_read_u32(dev, "min-sample-time", &info->adc_feature.default_sample_time);  


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

* Re: [PATCH] iio: adc: vf610: Add missing check for device_property_read_u32_array
  2026-01-29 17:40   ` Jonathan Cameron
@ 2026-01-30  5:25     ` Andy Shevchenko
  0 siblings, 0 replies; 6+ messages in thread
From: Andy Shevchenko @ 2026-01-30  5:25 UTC (permalink / raw)
  To: Jonathan Cameron
  Cc: Nuno Sá, Chen Ni, haibo.chen, dlechner, nuno.sa, andy,
	linux-iio, imx, linux-kernel

On Thu, Jan 29, 2026 at 05:40:21PM +0000, Jonathan Cameron wrote:
> On Wed, 28 Jan 2026 09:29:47 +0000
> Nuno Sá <noname.nuno@gmail.com> wrote:
> > On Wed, 2026-01-28 at 12:27 +0800, Chen Ni wrote:

...

> Given the driver has a fallback for info->max_adck_rate[x] == 0
> I think this is intentional.  It would be clearer if this had done.
> 
> 	info->max_adck_rate[0] = 8;
> 	info->max_adck_rate[1] = 8;
> 	info->max_adck_rate[2] = 8;

Just in case, we have memset32() if it fits :-)

> 	device_property_read_u32_array(dev, "fsl,adck-max-frequency", info->max_adck_rate, 3);
> 
> though rather than where it has the fallback in vf610_adc_calculate_rates()
> 

-- 
With Best Regards,
Andy Shevchenko



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

end of thread, other threads:[~2026-01-30  5:25 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-01-28  4:27 [PATCH] iio: adc: vf610: Add missing check for device_property_read_u32_array Chen Ni
2026-01-28  6:02 ` Bough Chen
2026-01-28  9:09 ` Andy Shevchenko
2026-01-28  9:29 ` Nuno Sá
2026-01-29 17:40   ` Jonathan Cameron
2026-01-30  5:25     ` Andy Shevchenko

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