[PATCH v2 08/10] iio: light: veml6030: power off device in probe error paths

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Move devm_add_action_or_reset() with a device shut down action above the
hardware initialization function to ensure that any error path after
powering on the device leads to a power off.

The power off action is carried out by setting the VEML6030_ALS_SD bit
of the VEML6030_REG_ALS_CONF, which is harmless in error paths were the
device is already off. On the other hand, making use of the registered
action in all error paths makes them more homogeneous by avoiding
special action depending on the current power state of the device.

Signed-off-by: Javier Carrasco <javier.carrasco.cruz@xxxxxxxxx>
---
 drivers/iio/light/veml6030.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/iio/light/veml6030.c b/drivers/iio/light/veml6030.c
index 861bdf2edd4d..19c69bfad8cb 100644
--- a/drivers/iio/light/veml6030.c
+++ b/drivers/iio/light/veml6030.c
@@ -853,12 +853,12 @@ static int veml6030_probe(struct i2c_client *client)
 		indio_dev->info = &veml6030_info_no_irq;
 	}
 
-	ret = veml6030_hw_init(indio_dev);
+	ret = devm_add_action_or_reset(&client->dev,
+				       veml6030_als_shut_down_action, data);
 	if (ret < 0)
 		return ret;
 
-	ret = devm_add_action_or_reset(&client->dev,
-					veml6030_als_shut_down_action, data);
+	ret = veml6030_hw_init(indio_dev);
 	if (ret < 0)
 		return ret;
 

-- 
2.43.0





[Index of Archives]     [Device Tree Compilter]     [Device Tree Spec]     [Linux Driver Backports]     [Video for Linux]     [Linux USB Devel]     [Linux PCI Devel]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [XFree86]     [Yosemite Backpacking]


  Powered by Linux