Re: [PATCH v4 2/3] iio: adc: at91_adc: use local struct device pointer in probe

From: Andy Shevchenko

Date: Tue Nov 17 2026 - 11:51:06 EST


On Tue, Nov 17, 2026 at 04:05:09PM +0200, Abdelnasser Hussein wrote:
> Introduce a local struct device pointer in at91_adc_probe() and use it
> in place of &pdev->dev and &idev->dev throughout the function.As a
> result, messages previously logged against the IIO device are now
> printed using the platform device being probed.
>
> switch devm_iio_device_alloc() to use sizeof(*st) instead of
> spelling out the full private structure type.

...

> + struct device *dev = &pdev->dev;
> + struct device_node *node = dev->of_node;

Before doing this, switch to device_property_*() / fwnode_property_*() APIs
first.

...

> - st->caps = of_device_get_match_data(&pdev->dev);
> + st->caps = of_device_get_match_data(dev);

In a separate patch (perhaps in the first one in this block, convert this
to use device_get_match_data() and add an error check (for now until we able
the driver_override case to address differently.

> st->use_external = of_property_read_bool(node, "atmel,adc-use-external-triggers");
>
> if (of_property_read_u32(node, "atmel,adc-channels-used", &prop))
> - return dev_err_probe(&idev->dev, -EINVAL,
> + return dev_err_probe(dev, -EINVAL,
> "Missing adc-channels-used property in the DT.\n");
> st->channels_mask = prop;
>
> st->sleep_mode = of_property_read_bool(node, "atmel,adc-sleep-mode");
>
> if (of_property_read_u32(node, "atmel,adc-startup-time", &prop))
> - return dev_err_probe(&idev->dev, -EINVAL,
> + return dev_err_probe(dev, -EINVAL,
> "Missing adc-startup-time property in the DT.\n");
> st->startup_time = prop;

...

> if (st->caps->has_tsmr)
> - ret = devm_request_irq(&pdev->dev, st->irq,
> + ret = devm_request_irq(dev, st->irq,
> at91_adc_9x5_interrupt, 0,
> - pdev->dev.driver->name, idev);
> + dev->driver->name, idev);
> else
> - ret = devm_request_irq(&pdev->dev, st->irq,
> + ret = devm_request_irq(dev, st->irq,
> at91_adc_rl_interrupt, 0,
> - pdev->dev.driver->name, idev);
> + dev->driver->name, idev);
> if (ret)

> - return dev_err_probe(&pdev->dev, ret,
> + return dev_err_probe(dev, ret,
> "Failed to allocate IRQ.\n");

In a separate patch, before this one drop this dup message. It's printed
by the devm_request_irq().

...

> adc_clk_khz = adc_clk / 1000;

At some point better to use HZ_PER_KHZ instead of odd 1000.

--
With Best Regards,
Andy Shevchenko