public inbox for linux-arm-kernel@lists.infradead.org
 help / color / mirror / Atom feed
* [PATCH] iio: adc: stm32-dfsdm: handle label as an optional property
@ 2024-11-14 10:24 Olivier Moysan
  2024-11-24 13:02 ` Jonathan Cameron
  0 siblings, 1 reply; 2+ messages in thread
From: Olivier Moysan @ 2024-11-14 10:24 UTC (permalink / raw)
  To: Jonathan Cameron, Lars-Peter Clausen, Maxime Coquelin,
	Alexandre Torgue, Olivier Moysan
  Cc: Jonathan Cameron, linux-iio, linux-stm32, linux-arm-kernel,
	linux-kernel

The label property is defined as optional in the DFSDM binding.
Parse the label property only when it is defined in the device tree.

Fixes: 3208fa0cd919 ("iio: adc: stm32-dfsdm: adopt generic channels bindings")
Signed-off-by: Olivier Moysan <olivier.moysan@foss.st.com>
---
 drivers/iio/adc/stm32-dfsdm-adc.c | 13 ++++++++-----
 1 file changed, 8 insertions(+), 5 deletions(-)

diff --git a/drivers/iio/adc/stm32-dfsdm-adc.c b/drivers/iio/adc/stm32-dfsdm-adc.c
index 2037f73426d4..e304e3714020 100644
--- a/drivers/iio/adc/stm32-dfsdm-adc.c
+++ b/drivers/iio/adc/stm32-dfsdm-adc.c
@@ -691,11 +691,14 @@ static int stm32_dfsdm_generic_channel_parse_of(struct stm32_dfsdm *dfsdm,
 		return -EINVAL;
 	}
 
-	ret = fwnode_property_read_string(node, "label", &ch->datasheet_name);
-	if (ret < 0) {
-		dev_err(&indio_dev->dev,
-			" Error parsing 'label' for idx %d\n", ch->channel);
-		return ret;
+	if (fwnode_property_present(node, "label")) {
+		/* label is optional */
+		ret = fwnode_property_read_string(node, "label", &ch->datasheet_name);
+		if (ret < 0) {
+			dev_err(&indio_dev->dev,
+				" Error parsing 'label' for idx %d\n", ch->channel);
+			return ret;
+		}
 	}
 
 	df_ch =  &dfsdm->ch_list[ch->channel];
-- 
2.25.1



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

* Re: [PATCH] iio: adc: stm32-dfsdm: handle label as an optional property
  2024-11-14 10:24 [PATCH] iio: adc: stm32-dfsdm: handle label as an optional property Olivier Moysan
@ 2024-11-24 13:02 ` Jonathan Cameron
  0 siblings, 0 replies; 2+ messages in thread
From: Jonathan Cameron @ 2024-11-24 13:02 UTC (permalink / raw)
  To: Olivier Moysan
  Cc: Lars-Peter Clausen, Maxime Coquelin, Alexandre Torgue,
	Jonathan Cameron, linux-iio, linux-stm32, linux-arm-kernel,
	linux-kernel

On Thu, 14 Nov 2024 11:24:59 +0100
Olivier Moysan <olivier.moysan@foss.st.com> wrote:

> The label property is defined as optional in the DFSDM binding.
> Parse the label property only when it is defined in the device tree.
> 
> Fixes: 3208fa0cd919 ("iio: adc: stm32-dfsdm: adopt generic channels bindings")
> Signed-off-by: Olivier Moysan <olivier.moysan@foss.st.com>
This could be done by just ignoring the return of fw_node_property_read_string()
but your fix will do a little more such as report an error if the property is
the wrong type etc, so I'll take it.

Applied to the fixes-togreg branch of iio.git.

Thanks,

Jonathan

> ---
>  drivers/iio/adc/stm32-dfsdm-adc.c | 13 ++++++++-----
>  1 file changed, 8 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/iio/adc/stm32-dfsdm-adc.c b/drivers/iio/adc/stm32-dfsdm-adc.c
> index 2037f73426d4..e304e3714020 100644
> --- a/drivers/iio/adc/stm32-dfsdm-adc.c
> +++ b/drivers/iio/adc/stm32-dfsdm-adc.c
> @@ -691,11 +691,14 @@ static int stm32_dfsdm_generic_channel_parse_of(struct stm32_dfsdm *dfsdm,
>  		return -EINVAL;
>  	}
>  
> -	ret = fwnode_property_read_string(node, "label", &ch->datasheet_name);
> -	if (ret < 0) {
> -		dev_err(&indio_dev->dev,
> -			" Error parsing 'label' for idx %d\n", ch->channel);
> -		return ret;
> +	if (fwnode_property_present(node, "label")) {
> +		/* label is optional */
> +		ret = fwnode_property_read_string(node, "label", &ch->datasheet_name);
> +		if (ret < 0) {
> +			dev_err(&indio_dev->dev,
> +				" Error parsing 'label' for idx %d\n", ch->channel);
> +			return ret;
> +		}
>  	}
>  
>  	df_ch =  &dfsdm->ch_list[ch->channel];



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

end of thread, other threads:[~2024-11-24 13:10 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-11-14 10:24 [PATCH] iio: adc: stm32-dfsdm: handle label as an optional property Olivier Moysan
2024-11-24 13:02 ` Jonathan Cameron

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