sparc64: Fix get_user_pages_fast() wrt. THP.
[firefly-linux-kernel-4.4.55.git] / drivers / power / charger-manager.c
index adb3a4b59cb3a369b569dc235eddfbd8e07dc0bc..6ba047f5ac2c35d413773368cd39f3d6bb14ae1f 100644 (file)
@@ -239,44 +239,37 @@ static bool is_full_charged(struct charger_manager *cm)
        int uV;
 
        /* If there is no battery, it cannot be charged */
-       if (!is_batt_present(cm)) {
-               val.intval = 0;
-               goto out;
-       }
+       if (!is_batt_present(cm))
+               return false;
 
        if (cm->fuel_gauge && desc->fullbatt_full_capacity > 0) {
+               val.intval = 0;
+
                /* Not full if capacity of fuel gauge isn't full */
                ret = cm->fuel_gauge->get_property(cm->fuel_gauge,
                                POWER_SUPPLY_PROP_CHARGE_FULL, &val);
-               if (!ret && val.intval > desc->fullbatt_full_capacity) {
-                       val.intval = 1;
-                       goto out;
-               }
+               if (!ret && val.intval > desc->fullbatt_full_capacity)
+                       return true;
        }
 
        /* Full, if it's over the fullbatt voltage */
        if (desc->fullbatt_uV > 0) {
                ret = get_batt_uV(cm, &uV);
-               if (!ret && uV >= desc->fullbatt_uV) {
-                       val.intval = 1;
-                       goto out;
-               }
+               if (!ret && uV >= desc->fullbatt_uV)
+                       return true;
        }
 
        /* Full, if the capacity is more than fullbatt_soc */
        if (cm->fuel_gauge && desc->fullbatt_soc > 0) {
+               val.intval = 0;
+
                ret = cm->fuel_gauge->get_property(cm->fuel_gauge,
                                POWER_SUPPLY_PROP_CAPACITY, &val);
-               if (!ret && val.intval >= desc->fullbatt_soc) {
-                       val.intval = 1;
-                       goto out;
-               }
+               if (!ret && val.intval >= desc->fullbatt_soc)
+                       return true;
        }
 
-       val.intval = 0;
-
-out:
-       return val.intval ? true : false;
+       return false;
 }
 
 /**
@@ -489,8 +482,9 @@ static void fullbatt_vchk(struct work_struct *work)
                return;
        }
 
-       diff = desc->fullbatt_uV;
-       diff -= batt_uV;
+       diff = desc->fullbatt_uV - batt_uV;
+       if (diff < 0)
+               return;
 
        dev_info(cm->dev, "VBATT dropped %duV after full-batt.\n", diff);