iio: adc: ti-ads1015: use devm helpers to fix probe error paths

Once ads1015_probe() gets past ads1015_set_conv_mode(CONTINUOUS), two
resources leak on its error paths and on driver unbind:

  - pm_runtime_enable() is left enabled if iio_device_register() fails;
    on subsequent probe/rebind the runtime PM tracking complains about
    an unbalanced enable.
  - The CONTINUOUS conversion mode written to the chip is never restored
    on any error path after that point, so on probe failure the chip is
    left running.

Convert all three teardown operations of ads1015_remove() to devm so
that the error paths and the unbind path share the same unwind in
reverse-of-setup order:

  - ads1015_set_conv_mode(SINGLESHOT) becomes a devm action registered
    immediately after CONTINUOUS mode is enabled.
  - pm_runtime_enable() becomes devm_pm_runtime_enable().
  - iio_device_register() becomes devm_iio_device_register(), so the
    iio device is unregistered first on unbind.

ads1015_remove() is no longer needed and is dropped.

Signed-off-by: Stepan Ionichev <sozdayvek@gmail.com>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
This commit is contained in:
Stepan Ionichev 2026-05-29 23:37:08 +05:00 • committed by Jonathan Cameron
commit 8adc81ba2e