Linux-ARM-Kernel Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Andy Shevchenko <andriy.shevchenko@intel.com>
To: Abdelnasser Hussein <abdelnasserhussein11@gmail.com>
Cc: jic23@kernel.org, linux-iio@vger.kernel.org,
	dlechner@baylibre.com, nuno.sa@analog.com, andy@kernel.org,
	nicolas.ferre@microchip.com, alexandre.belloni@bootlin.com,
	claudiu.beznea@tuxon.dev, giorgitchankvetadze1997@gmail.com,
	amin.gattout@gmail.com, antoniu.miclaus@analog.com,
	gregkh@linuxfoundation.org, mripard@kernel.org,
	linux-arm-kernel@lists.infradead.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH v4 2/3] iio: adc: at91_adc: use local struct device pointer in probe
Date: Tue, 17 Nov 2026 18:50:54 +0200	[thread overview]
Message-ID: <avyF7vllhuE-cJA0@ashevche-desk.local> (raw)
In-Reply-To: <20261117140510.391907-3-abdelnasserhussein11@gmail.com>

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




  reply	other threads:[~2026-11-17 16:51 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-17 14:05 [PATCH v4 0/3] iio: adc: at91_adc: fix trigger NULL deref and convert to devm_* Abdelnasser Hussein
2026-11-17 14:05 ` [PATCH v4 1/3] iio: adc: at91_adc: fix NULL pointer dereference on trigger remove Abdelnasser Hussein
2026-11-17 16:44   ` Andy Shevchenko
2026-11-17 16:45     ` Andy Shevchenko
2026-11-17 14:05 ` [PATCH v4 2/3] iio: adc: at91_adc: use local struct device pointer in probe Abdelnasser Hussein
2026-11-17 16:50   ` Andy Shevchenko [this message]
2026-11-17 14:05 ` [PATCH v4 3/3] iio: adc: at91_adc: convert to device-managed resources Abdelnasser Hussein
2026-11-17 16:57   ` Andy Shevchenko

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=avyF7vllhuE-cJA0@ashevche-desk.local \
    --to=andriy.shevchenko@intel.com \
    --cc=abdelnasserhussein11@gmail.com \
    --cc=alexandre.belloni@bootlin.com \
    --cc=amin.gattout@gmail.com \
    --cc=andy@kernel.org \
    --cc=antoniu.miclaus@analog.com \
    --cc=claudiu.beznea@tuxon.dev \
    --cc=dlechner@baylibre.com \
    --cc=giorgitchankvetadze1997@gmail.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=jic23@kernel.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-iio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mripard@kernel.org \
    --cc=nicolas.ferre@microchip.com \
    --cc=nuno.sa@analog.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox