power: tps80031-battery: Exit driver if battery is not detected
syed rafiuddin [Fri, 7 Oct 2011 08:46:40 +0000 (13:46 +0530)]
Exit fuel-gauge driver if battery presence is not detected.

bug 873965

Reviewed-on: http://git-master/r/61830
(cherry picked from commit 149469646e1e5e7ece787ef9546de60a97b46802)

Change-Id: I00139f1a92822875fb1409a918c580b83d4789f0
Reviewed-on: http://git-master/r/64090
Reviewed-by: Varun Colbert <vcolbert@nvidia.com>
Tested-by: Varun Colbert <vcolbert@nvidia.com>

Rebase-Id: Rebb08c9d9cbe6a3bb2a3bcaf4cc89beceb55c480

drivers/power/tps80031_battery_gauge.c
include/linux/mfd/tps80031.h

index 19a0797..5895c47 100644 (file)
@@ -420,6 +420,12 @@ static int tps80031_battery_probe(struct platform_device *pdev)
                return -ENOMEM;
        }
 
+       if (!pdata->battery_present) {
+               dev_err(dev, "%s() No battery detected, exiting..\n",
+                               __func__);
+               return -ENODEV;
+       }
+
        di->dev =  &pdev->dev;
 
        ret = tps80031_reg_read(di, SLAVE_ID2, CONTROLLER_STAT1, &retval);
index 731dd07..0be3424 100644 (file)
@@ -155,6 +155,7 @@ struct tps80031_platform_data {
 
 struct tps80031_bg_platform_data {
        int irq_base;
+       int battery_present;
 };
 
 /*