[PATCH v3 13/15] iio: adc: stm32-adc: convert to device properties

Jonathan Cameron jic23 at kernel.org
Sat Aug 6 11:15:38 PDT 2022


On Fri, 15 Jul 2022 14:29:01 +0200
Nuno Sá <nuno.sa at analog.com> wrote:

> Make the conversion to firmware agnostic device properties. As part of
> the conversion the IIO inkern interface 'of_xlate()' is also converted to
> 'fwnode_xlate()'. The goal is to completely drop 'of_xlate' and hence OF
> dependencies from IIO.
> 
> Signed-off-by: Nuno Sá <nuno.sa at analog.com>
> Reviewed-by: Andy Shevchenko <andy.shevchenko at gmail.com>
One query below. Otherwise LGTM (not that's true of the other patches I haven't
comment on at all)

> @@ -1885,8 +1887,12 @@ static int stm32_adc_get_legacy_chan_count(struct iio_dev *indio_dev, struct stm
>  		num_channels += ret;
>  	}
>  
> -	ret = of_property_count_elems_of_size(node, "st,adc-diff-channels",
> -					      sizeof(struct stm32_adc_diff_channel));
> +	/*
> +	 * each st,adc-diff-channels is a group of 2 u32 so we divide @ret
> +	 * to get the *real* number of channels.
> +	 */
> +	ret = device_property_count_u32(dev, "st,adc-diff-channels");

I think this can return an error code which should probably be handled.
More than possible that was true of original code though...

If it can't return an error for some reason I'm missing perhaps a
comment to explain why.

> +	ret /= (int)(sizeof(struct stm32_adc_diff_channel) / sizeof(u32));
>  	if (ret > adc_info->max_channels) {
>  		dev_err(&indio_dev->dev, "Bad st,adc-diff-channels?\n");
>  		return -EINVAL;



More information about the Linux-mediatek mailing list