iio: Place drivers on standby on error
cover iio: Place drivers on standby on error
This patchset places drivers on standby when an error occurs to avoid wasting power.
Cristina Opriceana (2):
iio: magnetometer: mag3110: Place driver on standby on error
iio: light: ltr501: Powerdown device on error
drivers/iio/light/ltr501.c | 18 ++++++++++-------- drivers/iio/magnetometer/mag3110.c | 18 ++++++++++-------- 2 files changed, 20 insertions(+), 16 deletions(-)
Signature · 1 line
1.9.1
PATCH 1/2 iio: magnetometer: mag3110: Place driver on standby on error
Place driver on standby mode on error in order to prevent wasting power. Move standby function above to be seen by the new call.
--- drivers/iio/magnetometer/mag3110.c | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-)
drivers/iio/magnetometer/mag3110.c +10 -8
@@ -321,6 +321,12 @@ static const struct iio_info mag3110_info = {static const unsigned long mag3110_scan_masks[] = {0x7 ,0xf ,0 }; +static int mag3110_standby (struct mag3110_data *data) +{ +return i2c_smbus_write_byte_data (data->client,MAG3110_CTRL_REG1 , + data->ctrl_reg1 & ~MAG3110_CTRL_AC ); +} +static int mag3110_probe (struct i2c_client *client,const struct i2c_device_id *id) {
@@ -360,12 +366,12 @@ static int mag3110_probe(struct i2c_client *client, ret =i2c_smbus_write_byte_data (client,MAG3110_CTRL_REG2 ,MAG3110_CTRL_AUTO_MRST_EN );if (ret <0 ) -return ret; + goto standby_on_error; ret =iio_triggered_buffer_setup (indio_dev,NULL , mag3110_trigger_handler,NULL );if (ret <0 ) -return ret; + goto standby_on_error; ret =iio_device_register (indio_dev);if (ret <0 )
@@ -374,15 +380,11 @@ static int mag3110_probe(struct i2c_client *client, buffer_cleanup:iio_triggered_buffer_cleanup (indio_dev); +standby_on_error: +mag3110_standby (iio_priv (indio_dev));return ret; } -static int mag3110_standby (struct mag3110_data *data) -{ -return i2c_smbus_write_byte_data (data->client,MAG3110_CTRL_REG1 , - data->ctrl_reg1 & ~MAG3110_CTRL_AC ); -} -static int mag3110_remove (struct i2c_client *client) {struct iio_dev *indio_dev =i2c_get_clientdata (client);
Signature · 1 line
1.9.1
PATCH 2/2 iio: light: ltr501: Powerdown device on error
In reply to Cristina OpriceanaPower down device when an error occurs in order to avoid wasting power. Also move powerdown function up to be seen by the new call.
--- drivers/iio/light/ltr501.c | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-)
drivers/iio/light/ltr501.c +10 -8
@@ -333,6 +333,13 @@ static int ltr501_init(struct ltr501_data *data) 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,const struct i2c_device_id *id) {
@@ -370,7 +377,7 @@ static int ltr501_probe(struct i2c_client *client, ret =iio_triggered_buffer_setup (indio_dev,NULL , ltr501_trigger_handler,NULL );if (ret) -return ret; + goto powerdown_on_error; ret =iio_device_register (indio_dev);if (ret)
@@ -380,16 +387,11 @@ static int ltr501_probe(struct i2c_client *client, error_unreg_buffer:iio_triggered_buffer_cleanup (indio_dev); +powerdown_on_error: +ltr501_powerdown (data);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) {struct iio_dev *indio_dev =i2c_get_clientdata (client);
Signature · 1 line
1.9.1
Re: [PATCH 2/2] iio: light: ltr501: Powerdown device on error
Quoted 13 lines · Cristina Opriceana
Power down device when an error occurs in order to avoid wasting power. Also move powerdown function up to be seen by the new call.
Signed-off-by Cristina Opriceana <[email protected]>--- drivers/iio/light/ltr501.c | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-)drivers/iio/light/ltr501.c +0
-0
drivers/iio/light/ltr501.c static int ltr501_init(struct ltr501_data *data) · line 342
Quoted 10 lines
drivers/iio/light/ltr501.c +7
-0@@ -333,6 +333,13 @@ static int ltr501_init(struct ltr501_data *data) 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 ); +} +
While at it please also fix the alignment for ltr501_write_contr parameters. Don't forget
to mention this in the commit message. When running checkpatch.pl please use --strict parameter.
thanks,
Daniel.
Re: [PATCH 2/2] iio: light: ltr501: Powerdown device on error
Quoted 31 lines · Daniel Baluta
Quoted 13 lines · Cristina Opriceana
Power down device when an error occurs in order to avoid wasting power. Also move powerdown function up to be seen by the new call.
Signed-off-by Cristina Opriceana <[email protected]>--- drivers/iio/light/ltr501.c | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-)drivers/iio/light/ltr501.c +0
-0drivers/iio/light/ltr501.c static int ltr501_init(struct ltr501_data *data) · line 342
Quoted 10 lines
drivers/iio/light/ltr501.c +7
-0@@ -333,6 +333,13 @@ static int ltr501_init(struct ltr501_data *data) 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 ); +} +While at it please also fix the alignment for
ltr501_write_contrparameters. Don't forget
to mention this in the commit message. When running checkpatch.pl please use --strict parameter.
Quoted 2 lines
thanks,
Daniel.
Another patch would be fine or should I send a v2?
Cristina
Re: [PATCH 2/2] iio: light: ltr501: Powerdown device on error
In reply to Daniel BalutaQuoted 18 lines · Daniel Baluta
Quoted 16 lines · Cristina Opriceana
Power down device when an error occurs in order to avoid wasting power. Also move powerdown function up to be seen by the new call.
Signed-off-by Cristina Opriceana <[email protected]>--- drivers/iio/light/ltr501.c | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-)drivers/iio/light/ltr501.c +0
-0@@ -333,6 +333,13 @@ static int ltr501_init(struct ltr501_data *data) data->ps_contr); }
Quoted 11 lines
drivers/iio/light/ltr501.c static int ltr501_init(struct ltr501_data *data) · line 342
Quoted 7 lines
drivers/iio/light/ltr501.c +7
-0+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 ); +} +Don't forget
to mention this in the commit message. When running checkpatch.pl please use --strict parameter.
Okay, I'll make a v2. Ignore my previous question.
Thanks,
Cristina
Quoted 2 lines
thanks,
Daniel.