[PATCH v5 4/8] iio: adc: at91_adc: convert to device_property_*() APIs

Andy Shevchenko andriy.shevchenko at intel.com
Mon Nov 23 02:02:30 PST 2026


On Mon, Nov 23, 2026 at 09:00:57AM +0200, Abdelnasser Hussein wrote:
> Use the firmware-agnostic device_property_*() helpers instead of the
> OF-specific property readers, so the driver does not depend on a device
> node being available in probe.
> 
> Update at91_adc_probe_dt_ts() to take a struct device and read its
> properties through device_property_read_u32() as well.  Since the helper
> no longer uses DT-specific APIs, rename it from at91_adc_probe_dt_ts() to
> at91_adc_probe_ts().  This removes the need for a struct device_node
> pointer in at91_adc_probe(); as a result, at91_adc_probe_ts() now logs
> against dev (&pdev->dev) instead of &idev->dev.
> 
> Drop the " in the DT" suffix from the missing property messages to match
> the firmware-agnostic property APIs.
> 
> With no OF APIs or struct device_node left in the file, drop the
> <linux/of.h> include and add <linux/mod_devicetable.h> for struct
> of_device_id.

...

>  static int at91_adc_probe(struct platform_device *pdev)
>  {
>  	unsigned int prsc, mstrclk, ticks, adc_clk, adc_clk_khz, shtim;
> -	struct device_node *node = pdev->dev.of_node;

	struct device *dev = &pdev->dev;
	const char *propname;

>  	int ret;
>  	struct iio_dev *idev;
>  	struct at91_adc_state *st;

...

> -	st->use_external = of_property_read_bool(node, "atmel,adc-use-external-triggers");
> +	st->use_external = device_property_read_bool(&pdev->dev,
> +						     "atmel,adc-use-external-triggers");

	propname = "atmel,adc-use-external-triggers";
	st->use_external = device_property_read_bool(dev, propname);

> -	if (of_property_read_u32(node, "atmel,adc-channels-used", &prop))
> +	if (device_property_read_u32(&pdev->dev, "atmel,adc-channels-used", &prop))
>  		return dev_err_probe(&idev->dev, -EINVAL,
> -				     "Missing adc-channels-used property in the DT.\n");
> +				     "Missing adc-channels-used property.\n");

	propname = "atmel,adc-channels-used";
	if (device_property_read_u32(dev, propname, &prop))
		return dev_err_probe(&idev->dev, -EINVAL, "Missing %s property.\n", propname);

BUT... this needs to be fixed first to unshadow error code

	propname = "atmel,adc-channels-used";
	ret = device_property_read_u32(dev, propname, &prop);
	if (ret)
		return dev_err_probe(&idev->dev, ret, "Missing %s property.\n", propname);

AND... what the heck is idev->dev now? Please, fix that before even this patch,
use same device pointer in the call and in the message. In the end it should be

	propname = "atmel,adc-channels-used";
	ret = device_property_read_u32(dev, propname, &prop);
	if (ret)
		return dev_err_probe(dev, ret, "Missing %s property.\n", propname);

>  	st->channels_mask = prop;

All the same for other properties.

...

>  	st->res = st->caps->high_res_bits;
>  	if (st->caps->low_res_bits &&
> -	    !of_property_read_string(node, "atmel,adc-use-res", &s)

> +	    !device_property_read_string(&pdev->dev, "atmel,adc-use-res", &s)
>  	    && !strcmp(s, "lowres"))

This is device_property_match_string() I believe.

>  		st->res = st->caps->low_res_bits;

-- 
With Best Regards,
Andy Shevchenko





More information about the linux-arm-kernel mailing list