Re: [PATCH v2 5/6] iio: light: vcnl4000: make pm_runtime_enable() device-managed

From: Andy Shevchenko

Date: Thu Apr 09 2026 - 05:38:26 EST


On Sun, Apr 05, 2026 at 07:08:42PM +0300, Erikas Bitovtas wrote:
> Replace pm_runtime_set_active() and pm_runtime_enable() with their
> device-managed counterpart to remove them from vcnl4000_remove().

...

> - ret = pm_runtime_set_active(dev);
> + ret = devm_pm_runtime_set_active_enabled(dev);
> if (ret < 0)
> return ret;
>
> + pm_runtime_set_autosuspend_delay(dev, VCNL4000_SLEEP_DELAY_MS);
> + pm_runtime_use_autosuspend(dev);

This moves the calls, now what if registration takes longer time than
autosuspend and device be off while user space or another caller can
access it?

> ret = iio_device_register(indio_dev);
> if (ret < 0)
> return ret;
>
> - pm_runtime_enable(dev);
> - pm_runtime_set_autosuspend_delay(dev, VCNL4000_SLEEP_DELAY_MS);
> - pm_runtime_use_autosuspend(dev);
> -
> return 0;
> }

--
With Best Regards,
Andy Shevchenko