ceres: power: check battery presence
Syed Rafiuddin [Sun, 30 Dec 2012 14:59:05 +0000 (19:59 +0530)]
check presence of battery based on fg driver

Bug 1178638

Change-Id: I0b6beb7bc6d3c441d4c93f4037d0a5af108233b7
Signed-off-by: Syed Rafiuddin <srafiuddin@nvidia.com>
Signed-off-by: Darbha Sriharsha <dsriharsha@nvidia.com>
Reviewed-on: http://git-master/r/#change,187632
(cherry picked from commit 221766dfd5f5cebf56a84c0c6557bd5e07d34e1d)
Reviewed-on: http://git-master/r/213897
Reviewed-by: Automatic_Commit_Validation_User
Reviewed-by: Laxman Dewangan <ldewangan@nvidia.com>
GVS: Gerrit_Virtual_Submit

drivers/power/max17048_battery.c
include/linux/max17048_battery.h

index 7155d7b..c4693b7 100644 (file)
@@ -458,6 +458,21 @@ static int max17048_initialize(struct max17048_chip *chip)
        return 0;
 }
 
+int max17048_check_battery()
+{
+       uint16_t version;
+
+       if (!max17048_data)
+               return -ENODEV;
+
+       version = max17048_get_version(max17048_data->client);
+       if (version != MAX17048_VERSION_NO)
+               return -ENODEV;
+
+       return 0;
+}
+EXPORT_SYMBOL_GPL(max17048_check_battery);
+
 static int max17048_probe(struct i2c_client *client,
                        const struct i2c_device_id *id)
 {
@@ -476,8 +491,8 @@ static int max17048_probe(struct i2c_client *client,
        max17048_data = chip;
        i2c_set_clientdata(client, chip);
 
-       version = max17048_get_version(client);
-       if (version != MAX17048_VERSION_NO) {
+       version = max17048_check_battery();
+       if (version < 0) {
                ret = -ENODEV;
                goto error2;
        }
index 40b6bc5..3ed602f 100644 (file)
@@ -1,6 +1,6 @@
 /*
  * Copyright (C) 2009 Samsung Electronics
- * Copyright (C) 2012 Nvidia Cooperation
+ * Copyright (C) 2012 Nvidia Corporation
  * Minkyu Kang <mk7.kang@samsung.com>
  *
  * This program is free software; you can redistribute it and/or modify
@@ -37,4 +37,5 @@ struct max17048_platform_data {
 };
 
 void max17048_battery_status(int status, int chrg_type);
+int max17048_check_battery(void);
 #endif