mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/
synced 2026-11-10 20:48:12 +00:00
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:
parent
d07bf43d17
commit
8adc81ba2e
1 changed files with 18 additions and 26 deletions
Loading…
Add table
Add a link
Reference in a new issue