Re: [PATCH v2 4/6] iio: light: vcnl4000: move power state function into device-managed action

From: Andy Shevchenko

Date: Thu Apr 09 2026 - 05:35:16 EST


On Sun, Apr 05, 2026 at 07:08:41PM +0300, Erikas Bitovtas wrote:
> Move power state setting into a device-managed action to get rid of
> fail_poweroff goto label and remove it from vcnl4000_remove() function.

...

> static int vcnl4000_probe(struct i2c_client *client)
> {

> + ret = devm_add_action_or_reset(dev, vcnl4000_cleanup, indio_dev);
> + if (ret)
> + return ret;

> ret = pm_runtime_set_active(dev);
> if (ret < 0)
> - goto fail_poweroff;
> + return ret;
>
> ret = iio_device_register(indio_dev);
> if (ret < 0)
> - goto fail_poweroff;

Shouldn't we undo the _set_active()?

> + 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