提交 1ca510b0 编写于 作者: C Cristina Opriceana 提交者: Greg Kroah-Hartman

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: NCristina Opriceana <cristina.opriceana@gmail.com>
Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
上级 c471c989
...@@ -333,6 +333,13 @@ static int ltr501_init(struct ltr501_data *data) ...@@ -333,6 +333,13 @@ static int ltr501_init(struct ltr501_data *data)
data->ps_contr); data->ps_contr);
} }
static int ltr501_powerdown(struct ltr501_data *data)
{
return ltr501_write_contr(data->client,
data->als_contr & ~LTR501_CONTR_ACTIVE,
data->ps_contr & ~LTR501_CONTR_ACTIVE);
}
static int ltr501_probe(struct i2c_client *client, static int ltr501_probe(struct i2c_client *client,
const struct i2c_device_id *id) const struct i2c_device_id *id)
{ {
...@@ -370,7 +377,7 @@ static int ltr501_probe(struct i2c_client *client, ...@@ -370,7 +377,7 @@ static int ltr501_probe(struct i2c_client *client,
ret = iio_triggered_buffer_setup(indio_dev, NULL, ret = iio_triggered_buffer_setup(indio_dev, NULL,
ltr501_trigger_handler, NULL); ltr501_trigger_handler, NULL);
if (ret) if (ret)
return ret; goto powerdown_on_error;
ret = iio_device_register(indio_dev); ret = iio_device_register(indio_dev);
if (ret) if (ret)
...@@ -380,16 +387,11 @@ static int ltr501_probe(struct i2c_client *client, ...@@ -380,16 +387,11 @@ static int ltr501_probe(struct i2c_client *client,
error_unreg_buffer: error_unreg_buffer:
iio_triggered_buffer_cleanup(indio_dev); iio_triggered_buffer_cleanup(indio_dev);
powerdown_on_error:
ltr501_powerdown(data);
return ret; return ret;
} }
static int ltr501_powerdown(struct ltr501_data *data)
{
return ltr501_write_contr(data->client,
data->als_contr & ~LTR501_CONTR_ACTIVE,
data->ps_contr & ~LTR501_CONTR_ACTIVE);
}
static int ltr501_remove(struct i2c_client *client) static int ltr501_remove(struct i2c_client *client)
{ {
struct iio_dev *indio_dev = i2c_get_clientdata(client); struct iio_dev *indio_dev = i2c_get_clientdata(client);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册