Re: [PATCH v4 6/8] iio: adc: ti-ads1015: Convert to managed resources

Andy Shevchenko <[email protected]>
Newsgroups org.kernel.vger.linux-iio,org.kernel.vger.linux-kernel
Organization Intel Finland Oy - BIC 0357606-4 - c/o Alberga Business Park, 6 krs, Bertel Jungin Aukio 5, 02600 Espoo
Message-ID <[email protected]>
On Thu, Aug 27, 2026 at 10:50:58PM +0530, Archit Anant wrote:
> Use managed resource helpers for the mutex and runtime PM setup.
> 
> Replace mutex_init() with devm_mutex_init() and replace the separate
> pm_runtime_set_active() and devm_pm_runtime_enable() calls with
> devm_pm_runtime_set_active_enabled().
> 
> This simplifies resource management and ensures resources are
> automatically cleaned up on probe failure and device removal.

...

>  	data = iio_priv(indio_dev);
>  	i2c_set_clientdata(client, indio_dev);
>  
> -	mutex_init(&data->lock);
> +	ret = devm_mutex_init(dev, &data->lock);
> +	if (ret)
> +		return ret;

This part is good and maybe introduced in a separate commit (depends on the
resolution for the below).

...

> -	ret = pm_runtime_set_active(dev);
> -	if (ret)
> -		return ret;
>  	pm_runtime_set_autosuspend_delay(dev, ADS1015_SLEEP_DELAY_MS);
>  	pm_runtime_use_autosuspend(dev);
> -	ret = devm_pm_runtime_enable(dev);
> +	ret = devm_pm_runtime_set_active_enabled(dev);
>  	if (ret)
>  		return ret;

This should be done with care. There were some changes lately that actually
moved from devm_*() back to regular calls due to some races in runtime PM.

-- 
With Best Regards,
Andy Shevchenko
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.