summaryrefslogtreecommitdiff
path: root/drivers/power
diff options
context:
space:
mode:
authorVarun Wadekar <vwadekar@nvidia.com>2010-12-09 14:22:50 +0530
committerBharat Nihalani <bnihalani@nvidia.com>2010-12-09 03:12:06 -0800
commit1d3553618c786c0c62b36027238029611e7c0d7a (patch)
tree7e6866e1dd7dc14c1e43e88ef047c6c0fd80ccb2 /drivers/power
parent2947168d5dfa642cd77ab034fc0bea69382350e2 (diff)
[ARM] tegra: bq20z75: check for battery presence in probe
Bug 749251 Change-Id: Ie25dc97b73ef518a1835b7feecc6c1c5708a3d40 Signed-off-by: Varun Wadekar <vwadekar@nvidia.com> Reviewed-on: http://git-master/r/12467 Reviewed-by: Bharat Nihalani <bnihalani@nvidia.com>
Diffstat (limited to 'drivers/power')
-rw-r--r--drivers/power/bq20z75_battery.c24
1 files changed, 19 insertions, 5 deletions
diff --git a/drivers/power/bq20z75_battery.c b/drivers/power/bq20z75_battery.c
index ebef464b38fd..b0d0468b4ae6 100644
--- a/drivers/power/bq20z75_battery.c
+++ b/drivers/power/bq20z75_battery.c
@@ -388,8 +388,8 @@ static void battery_poll_timer_func(unsigned long unused)
static int bq20z75_probe(struct i2c_client *client,
const struct i2c_device_id *id)
{
- int rc;
- int i;
+ int rc, i, flags;
+ int supply_index = SUPPLY_TYPE_BATTERY;
bq20z75_device = kzalloc(sizeof(*bq20z75_device), GFP_KERNEL);
if (!bq20z75_device)
@@ -398,6 +398,18 @@ static int bq20z75_probe(struct i2c_client *client,
memset(bq20z75_device, 0, sizeof(*bq20z75_device));
bq20z75_device->client = client;
+ flags = bq20z75_device->client->flags;
+ bq20z75_device->client->flags &= ~I2C_M_IGNORE_NAK;
+
+ rc = i2c_smbus_read_word_data(bq20z75_device->client,
+ bq20z75_data[REG_SERIAL_NUMBER].addr);
+ if (rc < 0) {
+ dev_err(&bq20z75_device->client->dev,
+ "%s: no battery present(%d)\n", __func__, rc);
+ supply_index = SUPPLY_TYPE_AC;
+ }
+
+ bq20z75_device->client->flags = flags;
bq20z75_device->irq = client->irq;
i2c_set_clientdata(client, bq20z75_device);
@@ -411,11 +423,13 @@ static int bq20z75_probe(struct i2c_client *client,
goto fail_irq;
}
- for (i = 0; i < ARRAY_SIZE(bq20z75_supply); i++) {
- rc = power_supply_register(&client->dev, &bq20z75_supply[i]);
+ for (i = supply_index; i < ARRAY_SIZE(bq20z75_supply); i++) {
+ rc = power_supply_register(&client->dev,
+ &bq20z75_supply[i]);
if (rc) {
dev_err(&bq20z75_device->client->dev,
- "%s: Failed to register power supply\n", __func__);
+ "%s: Failed to register power supply\n",
+ __func__);
goto fail_power_register;
}
}