diff options
author | Cristina Opriceana <cristina.opriceana@gmail.com> | 2015-04-01 11:50:17 -0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2015-04-02 04:27:39 -0400 |
commit | 1ca510b0ea6da1a4ff3a385f0613e045f670304e (patch) | |
tree | b7e58e65e0c1f5b433cf8d1d22a496e1af7013bf /drivers/iio | |
parent | c471c989addf4d806c62ece60d6cfd6d9ad50c95 (diff) |
iio: light: ltr501: Powerdown device on error
Power down device when an error occurs in order to avoid wasting
power. Move powerdown function up to be seen by the new call and
align parameters for the ltr501_write_contr() call.
Signed-off-by: Cristina Opriceana <cristina.opriceana@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/iio')
-rw-r--r-- | drivers/iio/light/ltr501.c | 18 |
1 files changed, 10 insertions, 8 deletions
diff --git a/drivers/iio/light/ltr501.c b/drivers/iio/light/ltr501.c index 62b7072af4de..78b87839c4b9 100644 --- a/drivers/iio/light/ltr501.c +++ b/drivers/iio/light/ltr501.c | |||
@@ -333,6 +333,13 @@ static int ltr501_init(struct ltr501_data *data) | |||
333 | data->ps_contr); | 333 | data->ps_contr); |
334 | } | 334 | } |
335 | 335 | ||
336 | static int ltr501_powerdown(struct ltr501_data *data) | ||
337 | { | ||
338 | return ltr501_write_contr(data->client, | ||
339 | data->als_contr & ~LTR501_CONTR_ACTIVE, | ||
340 | data->ps_contr & ~LTR501_CONTR_ACTIVE); | ||
341 | } | ||
342 | |||
336 | static int ltr501_probe(struct i2c_client *client, | 343 | static int ltr501_probe(struct i2c_client *client, |
337 | const struct i2c_device_id *id) | 344 | const struct i2c_device_id *id) |
338 | { | 345 | { |
@@ -370,7 +377,7 @@ static int ltr501_probe(struct i2c_client *client, | |||
370 | ret = iio_triggered_buffer_setup(indio_dev, NULL, | 377 | ret = iio_triggered_buffer_setup(indio_dev, NULL, |
371 | ltr501_trigger_handler, NULL); | 378 | ltr501_trigger_handler, NULL); |
372 | if (ret) | 379 | if (ret) |
373 | return ret; | 380 | goto powerdown_on_error; |
374 | 381 | ||
375 | ret = iio_device_register(indio_dev); | 382 | ret = iio_device_register(indio_dev); |
376 | if (ret) | 383 | if (ret) |
@@ -380,16 +387,11 @@ static int ltr501_probe(struct i2c_client *client, | |||
380 | 387 | ||
381 | error_unreg_buffer: | 388 | error_unreg_buffer: |
382 | iio_triggered_buffer_cleanup(indio_dev); | 389 | iio_triggered_buffer_cleanup(indio_dev); |
390 | powerdown_on_error: | ||
391 | ltr501_powerdown(data); | ||
383 | return ret; | 392 | return ret; |
384 | } | 393 | } |
385 | 394 | ||
386 | static int ltr501_powerdown(struct ltr501_data *data) | ||
387 | { | ||
388 | return ltr501_write_contr(data->client, | ||
389 | data->als_contr & ~LTR501_CONTR_ACTIVE, | ||
390 | data->ps_contr & ~LTR501_CONTR_ACTIVE); | ||
391 | } | ||
392 | |||
393 | static int ltr501_remove(struct i2c_client *client) | 395 | static int ltr501_remove(struct i2c_client *client) |
394 | { | 396 | { |
395 | struct iio_dev *indio_dev = i2c_get_clientdata(client); | 397 | struct iio_dev *indio_dev = i2c_get_clientdata(client); |