aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPaul Kocialkowski <contact@paulk.fr>2016-08-28 13:34:46 -0400
committerSebastian Reichel <sre@kernel.org>2016-08-28 20:39:06 -0400
commitae0f74be6e3db97b23f33be2219044576525176a (patch)
tree8fb85232216a9baa4e10ef53afa3d81aab079319
parent1c4593edbd4a893691fa826c36e71946a5d54c1d (diff)
power: bq24735-charger: Assume not charging when charger is missing
When the charger is missing (disconnected), it is safe to assume that the charger chip is no charging. This is especially relevant when a status GPIO is present and the charger is getting disconnected. bq24735_charger_is_charging will be triggered due to the interrupt then, it will attempt to read whether it is charging through i2c, which will fail as the charger is disconnected. This also fixes that specific issue. Signed-off-by: Paul Kocialkowski <contact@paulk.fr> Signed-off-by: Sebastian Reichel <sre@kernel.org>
-rw-r--r--drivers/power/supply/bq24735-charger.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/drivers/power/supply/bq24735-charger.c b/drivers/power/supply/bq24735-charger.c
index fa454c19ce17..dc460bb03d84 100644
--- a/drivers/power/supply/bq24735-charger.c
+++ b/drivers/power/supply/bq24735-charger.c
@@ -201,8 +201,12 @@ static bool bq24735_charger_is_present(struct bq24735 *charger)
201 201
202static int bq24735_charger_is_charging(struct bq24735 *charger) 202static int bq24735_charger_is_charging(struct bq24735 *charger)
203{ 203{
204 int ret = bq24735_read_word(charger->client, BQ24735_CHG_OPT); 204 int ret;
205
206 if (!bq24735_charger_is_present(charger))
207 return 0;
205 208
209 ret = bq24735_read_word(charger->client, BQ24735_CHG_OPT);
206 if (ret < 0) 210 if (ret < 0)
207 return ret; 211 return ret;
208 212