power: supply: sc2731_charger: Avoid repeated charge/discharge
authorBaolin Wang <baolin.wang@linaro.org>
Mon, 12 Nov 2018 10:52:37 +0000 (18:52 +0800)
committerSebastian Reichel <sebastian.reichel@collabora.com>
Wed, 5 Dec 2018 22:53:14 +0000 (23:53 +0100)
Add info->charging validation to avoid repeated charge or discharge
operation.

Signed-off-by: Baolin Wang <baolin.wang@linaro.org>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
drivers/power/supply/sc2731_charger.c

index a012d6c..49b3f0c 100644 (file)
@@ -328,7 +328,7 @@ static void sc2731_charger_work(struct work_struct *data)
 
        mutex_lock(&info->lock);
 
-       if (info->limit > 0) {
+       if (info->limit > 0 && !info->charging) {
                /* set current limitation and start to charge */
                ret = sc2731_charger_set_current_limit(info, info->limit);
                if (ret)
@@ -343,7 +343,7 @@ static void sc2731_charger_work(struct work_struct *data)
                        goto out;
 
                info->charging = true;
-       } else {
+       } else if (!info->limit && info->charging) {
                /* Stop charging */
                info->charging = false;
                sc2731_charger_stop_charge(info);