power: supply: lego_ev3_battery improvements
Subsystems (2)
David Lechner
reviewercover power: supply: lego_ev3_battery improvements
This series improves error handling and accuracy of the LEGO MINDSTORMS EV3 battery driver.
David Lechner (2):
power: supply: lego_ev3_battery: Don't ignore
iio_read_channel_processed() return value
power: supply: lego_ev3_battery: fix Vce offset
drivers/power/supply/lego_ev3_battery.c | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-)
Signature · 1 line
2.17.1
David Lechner
reviewerPATCH 1/2 power: supply: lego_ev3_battery: Don't ignore iio_read_channel_processed() return value
This changes the LEGO MINDSTORMS EV3 power supply driver to return an error if iio_read_channel_processed() fails.
--- drivers/power/supply/lego_ev3_battery.c | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-)
drivers/power/supply/lego_ev3_battery.c +14 -4
@@ -39,7 +39,7 @@ static int lego_ev3_battery_get_property(struct power_supply *psy, union power_supply_propval *val) {struct lego_ev3_battery *batt =power_supply_get_drvdata (psy); -int val2; +int ret, val2;switch (psp) {case POWER_SUPPLY_PROP_TECHNOLOGY :
@@ -47,11 +47,18 @@ static int lego_ev3_battery_get_property(struct power_supply *psy,break ;case POWER_SUPPLY_PROP_VOLTAGE_NOW :/* battery voltage is iio channel * 2 + Vce of transistor */ -iio_read_channel_processed (batt->iio_v, &val->intval); + ret =iio_read_channel_processed (batt->iio_v, &val->intval); +if (ret) +return ret; + val->intval *=2000 ; val->intval +=200000 ; +/* plus adjust for shunt resistor drop */ -iio_read_channel_processed (batt->iio_i, &val2); + ret =iio_read_channel_processed (batt->iio_i, &val2); +if (ret) +return ret; + val2 *=1000 ; val2 /=15 ; val->intval += val2;
@@ -64,7 +71,10 @@ static int lego_ev3_battery_get_property(struct power_supply *psy,break ;case POWER_SUPPLY_PROP_CURRENT_NOW :/* battery current is iio channel / 15 / 0.05 ohms */ -iio_read_channel_processed (batt->iio_i, &val->intval); + ret =iio_read_channel_processed (batt->iio_i, &val->intval); +if (ret) +return ret; + val->intval *=20000 ; val->intval /=15 ;break ;
Signature · 1 line
2.17.1
Re: [PATCH 1/2] power: supply: lego_ev3_battery: Don't ignore iio_read_channel_processed() return value
Hi,
Quoted 5 lines · David Lechner
This changes the LEGO MINDSTORMS EV3 power supply driver to return an error if
iio_read_channel_processed()fails.Signed-off-by David Lechner <[email protected]>---
Thanks, queued to power-supply's for-next branch.
-- Sebastian
Quoted 52 lines
drivers/power/supply/lego_ev3_battery.c | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-)drivers/power/supply/lego_ev3_battery.c +14
-4@@ -39,7 +39,7 @@ static int lego_ev3_battery_get_property(struct power_supply *psy, union power_supply_propval *val) {struct lego_ev3_battery *batt =power_supply_get_drvdata (psy); -int val2; +int ret, val2;switch (psp) {case POWER_SUPPLY_PROP_TECHNOLOGY :@@ -47,11 +47,18 @@ static int lego_ev3_battery_get_property(struct power_supply *psy,break ;case POWER_SUPPLY_PROP_VOLTAGE_NOW :/* battery voltage is iio channel * 2 + Vce of transistor */ -iio_read_channel_processed (batt->iio_v, &val->intval); + ret =iio_read_channel_processed (batt->iio_v, &val->intval); +if (ret) +return ret; + val->intval *=2000 ; val->intval +=200000 ; +/* plus adjust for shunt resistor drop */ -iio_read_channel_processed (batt->iio_i, &val2); + ret =iio_read_channel_processed (batt->iio_i, &val2); +if (ret) +return ret; + val2 *=1000 ; val2 /=15 ; val->intval += val2;@@ -64,7 +71,10 @@ static int lego_ev3_battery_get_property(struct power_supply *psy,break ;case POWER_SUPPLY_PROP_CURRENT_NOW :/* battery current is iio channel / 15 / 0.05 ohms */ -iio_read_channel_processed (batt->iio_i, &val->intval); + ret =iio_read_channel_processed (batt->iio_i, &val->intval); +if (ret) +return ret; + val->intval *=20000 ; val->intval /=15 ;break ;Signature · 1 line
2.17.1
David Lechner
reviewerPATCH 2/2 power: supply: lego_ev3_battery: fix Vce offset
In reply to David LechnerThis fixes the value that accounts for the Vce of a transistor in the LEGO MINDSTORMS EV3 power supply driver. The old value (200mV) was the max value from the data sheet. After testing, the actual value has been found to be 50mV. By using 50mV we get a more accurate voltage indication.
--- drivers/power/supply/lego_ev3_battery.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/power/supply/lego_ev3_battery.c +1 -1
@@ -52,7 +52,7 @@ static int lego_ev3_battery_get_property(struct power_supply *psy,return ret; val->intval *=2000 ; - val->intval +=200000 ; + val->intval +=50000 ;/* plus adjust for shunt resistor drop */ ret =iio_read_channel_processed (batt->iio_i, &val2);
Signature · 1 line
2.17.1
Re: [PATCH 2/2] power: supply: lego_ev3_battery: fix Vce offset
Hi,
Quoted 8 lines · David Lechner
This fixes the value that accounts for the Vce of a transistor in the LEGO MINDSTORMS EV3 power supply driver. The old value (200mV) was the max value from the data sheet. After testing, the actual value has been found to be 50mV. By using 50mV we get a more accurate voltage indication.
Signed-off-by David Lechner <[email protected]>---
Thanks, queued to power-supply's for-next branch.
-- Sebastian
Quoted 19 lines
drivers/power/supply/lego_ev3_battery.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/power/supply/lego_ev3_battery.c +1
-1@@ -52,7 +52,7 @@ static int lego_ev3_battery_get_property(struct power_supply *psy,return ret; val->intval *=2000 ; - val->intval +=200000 ; + val->intval +=50000 ;/* plus adjust for shunt resistor drop */ ret =iio_read_channel_processed (batt->iio_i, &val2);Signature · 1 line
2.17.1