lp8727_charger: Return if the battery is discharging
authorKim, Milo <Milo.Kim@ti.com>
Fri, 31 Aug 2012 09:26:06 +0000 (09:26 +0000)
committerAnton Vorontsov <anton.vorontsov@linaro.org>
Fri, 21 Sep 2012 01:05:55 +0000 (18:05 -0700)
If the charger is pulled out, just return as DISCHARGING. Then no need for
additional 'else' statement.

Signed-off-by: Milo(Woogyom) Kim <milo.kim@ti.com>
Signed-off-by: Anton Vorontsov <anton.vorontsov@linaro.org>
drivers/power/lp8727_charger.c

index 2507b2b..13a787a 100644 (file)
@@ -336,15 +336,16 @@ static int lp8727_battery_get_property(struct power_supply *psy,
 
        switch (psp) {
        case POWER_SUPPLY_PROP_STATUS:
-               if (lp8727_is_charger_attached(psy->name, pchg->devid)) {
-                       lp8727_read_byte(pchg, LP8727_STATUS1, &read);
+               if (!lp8727_is_charger_attached(psy->name, pchg->devid)) {
+                       val->intval = POWER_SUPPLY_STATUS_DISCHARGING;
+                       return 0;
+               }
+
+               lp8727_read_byte(pchg, LP8727_STATUS1, &read);
 
-                       val->intval = (read & LP8727_CHGSTAT) == LP8727_STAT_EOC ?
+               val->intval = (read & LP8727_CHGSTAT) == LP8727_STAT_EOC ?
                                POWER_SUPPLY_STATUS_FULL :
                                POWER_SUPPLY_STATUS_CHARGING;
-               } else {
-                       val->intval = POWER_SUPPLY_STATUS_DISCHARGING;
-               }
                break;
        case POWER_SUPPLY_PROP_HEALTH:
                lp8727_read_byte(pchg, LP8727_STATUS2, &read);