aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/power/sbs-battery.c
diff options
context:
space:
mode:
authorOlof Johansson <olof@lixom.net>2012-09-06 14:32:29 -0400
committerAnton Vorontsov <anton.vorontsov@linaro.org>2012-09-20 17:57:52 -0400
commita22b41a31e5382792151f193d185a3cd39593cfd (patch)
treeb63c1392dd28c602bc26cc8075f466a4077f5064 /drivers/power/sbs-battery.c
parent1502cfe19bac2f8490e4167f2b7cb50b9759b273 (diff)
sbs-battery: Probe should try talking to the device
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>
Diffstat (limited to 'drivers/power/sbs-battery.c')
-rw-r--r--drivers/power/sbs-battery.c10
1 files changed, 10 insertions, 0 deletions
diff --git a/drivers/power/sbs-battery.c b/drivers/power/sbs-battery.c
index a65e8f54157e..4146596d254b 100644
--- a/drivers/power/sbs-battery.c
+++ b/drivers/power/sbs-battery.c
@@ -759,6 +759,16 @@ static int __devinit sbs_probe(struct i2c_client *client,
759 chip->irq = irq; 759 chip->irq = irq;
760 760
761skip_gpio: 761skip_gpio:
762 /*
763 * Before we register, we need to make sure we can actually talk
764 * to the battery.
765 */
766 rc = sbs_read_word_data(client, sbs_data[REG_STATUS].addr);
767 if (rc < 0) {
768 dev_err(&client->dev, "%s: Failed to get device status\n",
769 __func__);
770 goto exit_psupply;
771 }
762 772
763 rc = power_supply_register(&client->dev, &chip->power_supply); 773 rc = power_supply_register(&client->dev, &chip->power_supply);
764 if (rc) { 774 if (rc) {