Commit 8ae237ec authored by Ikjoon Jang's avatar Ikjoon Jang Committed by Sebastian Reichel

power: supply: sbs-battery: keep error code when get_property() fails

Commit 395a7251 (power: supply: sbs-battery: don't assume
i2c errors as battery disconnect) overwrites the original error code
returned from internal functions. On such a sporadic i2c error,
a user will get a wrong value without errors.

Fixes: 395a7251 (power: supply: sbs-battery: don't assume i2c errors as battery disconnect)
Signed-off-by: default avatarIkjoon Jang <ikjn@chromium.org>
Signed-off-by: default avatarSebastian Reichel <sebastian.reichel@collabora.com>
parent 5069185f
......@@ -962,11 +962,10 @@ static int sbs_get_property(struct power_supply *psy,
if (!chip->gpio_detect && chip->is_present != (ret >= 0)) {
bool old_present = chip->is_present;
union power_supply_propval val;
ret = sbs_get_battery_presence_and_health(
int err = sbs_get_battery_presence_and_health(
client, POWER_SUPPLY_PROP_PRESENT, &val);
sbs_update_presence(chip, !ret && val.intval);
sbs_update_presence(chip, !err && val.intval);
if (old_present != chip->is_present)
power_supply_changed(chip->power_supply);
......@@ -976,19 +975,14 @@ static int sbs_get_property(struct power_supply *psy,
if (!ret) {
/* Convert units to match requirements for power supply class */
sbs_unit_adjustment(client, psp, val);
}
dev_dbg(&client->dev,
"%s: property = %d, value = %x\n", __func__, psp, val->intval);
if (ret && chip->is_present)
return ret;
"%s: property = %d, value = %x\n", __func__,
psp, val->intval);
} else if (!chip->is_present) {
/* battery not present, so return NODATA for properties */
if (ret)
return -ENODATA;
return 0;
ret = -ENODATA;
}
return ret;
}
static void sbs_supply_changed(struct sbs_info *chip)
......
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