Skip to content

Commit

Permalink
sbs-battery: Probe should try talking to the device
Browse files Browse the repository at this point in the history
Turns out this driver doesn't actually try talking to the device at
probe time, so if it's incorrectly configured in the device tree or
platform data (or if the battery has been removed from the system),
then probe will succeed and every access will sit there and time out.
The end result is a possibly laggy system that thinks it has a battery
but can never read status, which isn't very useful.

Instead, just read any register (I chose status) at probe, and if that
fails, don't register the device.

Signed-off-by: Olof Johansson <olof@lixom.net>
Acked-by: Rhyland Klein <rklein@nvidia.com>
Signed-off-by: Anton Vorontsov <anton.vorontsov@linaro.org>
  • Loading branch information
Olof Johansson authored and Anton Vorontsov committed Sep 20, 2012
1 parent 1502cfe commit a22b41a
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions drivers/power/sbs-battery.c
Original file line number Diff line number Diff line change
Expand Up @@ -759,6 +759,16 @@ static int __devinit sbs_probe(struct i2c_client *client,
chip->irq = irq;

skip_gpio:
/*
* Before we register, we need to make sure we can actually talk
* to the battery.
*/
rc = sbs_read_word_data(client, sbs_data[REG_STATUS].addr);
if (rc < 0) {
dev_err(&client->dev, "%s: Failed to get device status\n",
__func__);
goto exit_psupply;
}

rc = power_supply_register(&client->dev, &chip->power_supply);
if (rc) {
Expand Down

0 comments on commit a22b41a

Please sign in to comment.