From: Jonathan Cameron <Jonathan.Cameron@xxxxxxxxxx> A very simple example of how using devm_ managed calls for everything can reduce complexity error handling and removal ordering in a driver. Note I don't have one of these to test so if anyone has a chance to do so or give these a quick look at that would be much appreciated. Note this is a fairly old driver, so relative unlikely original authors still have access. Cc: Phani Movva <Phani.Movva@xxxxxxxxxx> Cc: Naidu Tellapati <naidu.tellapati@xxxxxxxxxx> Jonathan Cameron (5): iio: adc: cc10001: Add local struct device *dev variable to avoid repitition iio: adc: cc10001: Add devm_add_action_or_reset() to disable regulator. iio: adc: cc10001: Use devm_clk_get_enabled() to avoid boilerplate. iio: adc: cc10001: Use devm_ to call device power down. iio: adc: cc10001: Switch remaining IIO calls in probe to devm_ forms. drivers/iio/adc/cc10001_adc.c | 89 +++++++++++++---------------------- 1 file changed, 34 insertions(+), 55 deletions(-) -- 2.37.2