Commit 6e92cecb authored by David Lechner's avatar David Lechner Committed by Sebastian Reichel

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.
Signed-off-by: default avatarDavid Lechner <david@lechnology.com>
Signed-off-by: default avatarSebastian Reichel <sebastian.reichel@collabora.co.uk>
parent 0d949905
...@@ -39,7 +39,7 @@ static int lego_ev3_battery_get_property(struct power_supply *psy, ...@@ -39,7 +39,7 @@ static int lego_ev3_battery_get_property(struct power_supply *psy,
union power_supply_propval *val) union power_supply_propval *val)
{ {
struct lego_ev3_battery *batt = power_supply_get_drvdata(psy); struct lego_ev3_battery *batt = power_supply_get_drvdata(psy);
int val2; int ret, val2;
switch (psp) { switch (psp) {
case POWER_SUPPLY_PROP_TECHNOLOGY: case POWER_SUPPLY_PROP_TECHNOLOGY:
...@@ -47,11 +47,18 @@ static int lego_ev3_battery_get_property(struct power_supply *psy, ...@@ -47,11 +47,18 @@ static int lego_ev3_battery_get_property(struct power_supply *psy,
break; break;
case POWER_SUPPLY_PROP_VOLTAGE_NOW: case POWER_SUPPLY_PROP_VOLTAGE_NOW:
/* battery voltage is iio channel * 2 + Vce of transistor */ /* 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 *= 2000;
val->intval += 200000; val->intval += 200000;
/* plus adjust for shunt resistor drop */ /* 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 *= 1000;
val2 /= 15; val2 /= 15;
val->intval += val2; val->intval += val2;
...@@ -64,7 +71,10 @@ static int lego_ev3_battery_get_property(struct power_supply *psy, ...@@ -64,7 +71,10 @@ static int lego_ev3_battery_get_property(struct power_supply *psy,
break; break;
case POWER_SUPPLY_PROP_CURRENT_NOW: case POWER_SUPPLY_PROP_CURRENT_NOW:
/* battery current is iio channel / 15 / 0.05 ohms */ /* 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 *= 20000;
val->intval /= 15; val->intval /= 15;
break; break;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment