power: bq2419x: disable charging function if charger fails to probe
Kerwin Wan [Tue, 19 Mar 2013 08:27:29 +0000 (16:27 +0800)]
Bug 1238542

Change-Id: I24d5e1407049af508799fac504b74681b73a2069
Signed-off-by: Kerwin Wan <kerwinw@nvidia.com>
Reviewed-on: http://git-master/r/210648
Reviewed-by: Laxman Dewangan <ldewangan@nvidia.com>
GVS: Gerrit_Virtual_Submit

drivers/power/bq2419x-charger.c
include/linux/mfd/bq2419x.h

index 71ba78b..54d79de 100644 (file)
@@ -252,6 +252,17 @@ static int __devinit bq2419x_charger_probe(struct platform_device *pdev)
 
        if (!bcharger_pdata) {
                dev_err(&pdev->dev, "No Platform data");
+
+               charger = devm_kzalloc(&pdev->dev, sizeof(*charger), GFP_KERNEL);
+               if (!charger) {
+                       dev_err(&pdev->dev, "Memory alloc failed\n");
+                       return -ENOMEM;
+               }
+               charger->chip = dev_get_drvdata(pdev->dev.parent);
+               ret = regmap_update_bits(charger->chip->regmap, BQ2419X_PWR_ON_REG,
+                                       ENABLE_CHARGE_MASK, DISABLE_CHARGE);
+               if (ret < 0)
+                       dev_err(&pdev->dev, "register update failed, err %d\n", ret);
                return -EIO;
        }
 
index 14c441c..ef09e08 100644 (file)
@@ -45,6 +45,7 @@ struct regmap;
 #define BQ24192i_IC_VER         0x18
 #define ENABLE_CHARGE_MASK      0x30
 #define ENABLE_CHARGE           0x10
+#define DISABLE_CHARGE          0x00
 
 #define BQ2419X_REG0                   0x0
 #define BQ2419X_EN_HIZ                 BIT(7)