From: Phil Reid Date: Tue, 11 Jul 2017 09:43:43 +0000 (+0800) Subject: power: supply: sbs-battery: Add delay when changing capacity mode bit X-Git-Tag: v4.14-rc1~74^2~30 X-Git-Url: https://git.kernel.dk/?a=commitdiff_plain;h=adcf04c9f8fce54e65f11bae2fbd37c1282ef128;p=linux-2.6-block.git power: supply: sbs-battery: Add delay when changing capacity mode bit At least with the Inspired Energy compatible batteries a delay is required after setting the capacity mode bit from amp to watts or the reverse. Setting the bit and then immediately pooling the status register results in an unknown error being returned in the register. Add the delay results in and ok status being return. This was also seen when reading the charge and energy registers where the wrong value was returned for the requested mode. Signed-off-by: Phil Reid Tested-by: Michael Heinemann Signed-off-by: Sebastian Reichel --- diff --git a/drivers/power/supply/sbs-battery.c b/drivers/power/supply/sbs-battery.c index a5eacc4b35e3..b19a73176910 100644 --- a/drivers/power/supply/sbs-battery.c +++ b/drivers/power/supply/sbs-battery.c @@ -14,6 +14,7 @@ * more details. */ +#include #include #include #include @@ -527,6 +528,8 @@ static enum sbs_battery_mode sbs_set_battery_mode(struct i2c_client *client, if (ret < 0) return ret; + usleep_range(1000, 2000); + return original_val & BATTERY_MODE_MASK; }