From patchwork Mon Nov 12 10:52:37 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "(Exiting) Baolin Wang" X-Patchwork-Id: 10678497 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id EE8691759 for ; Mon, 12 Nov 2018 10:53:27 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id DDBCF29E25 for ; Mon, 12 Nov 2018 10:53:27 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D160929EFE; Mon, 12 Nov 2018 10:53:27 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 874EE29E25 for ; Mon, 12 Nov 2018 10:53:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729228AbeKLUp4 (ORCPT ); Mon, 12 Nov 2018 15:45:56 -0500 Received: from mail-pg1-f194.google.com ([209.85.215.194]:44364 "EHLO mail-pg1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727361AbeKLUpz (ORCPT ); Mon, 12 Nov 2018 15:45:55 -0500 Received: by mail-pg1-f194.google.com with SMTP id w3-v6so3897724pgs.11 for ; Mon, 12 Nov 2018 02:53:13 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :in-reply-to:references; bh=WRUiqIUtLnq5Kt3BfAdxw6WClpYGJFwMdYAB6FisGEA=; b=h1xsJXjtr4KUX4hiAU3XjR0GvBQ+IQqpczfSDmxf4WmzGS3osEcUSguvicWvWXCOpz ApGW2bVX4eJeWM0ZQ6M0IVBl6jyucT3Lx0cEZIA815UrCpBAsIfAHdQWtW8+kKwQFxzx cHAeJAWFXMgR5VVfVuq/uazUpolpjm5ig2DQ8= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:in-reply-to:references; bh=WRUiqIUtLnq5Kt3BfAdxw6WClpYGJFwMdYAB6FisGEA=; b=m4mTh3vrVS1jCGdf3v8C/zKdcHEG/gBNfEbmSzHY1lJCzFG95Fv978HASKFaqThrCd GhIGRW5auQMz9vY/2UFMFes2ZbpMSZNMQfdb8jkClKHHrb/KTozbef0AW6JPbQ+jZyBG 23C2X+YzysfBFayc6VPHjXjETprP+a9ghcVKb3Cvv6Od0RTctFPWrUipxhn8RTMYskpc GOtxJLLBST4X+1RUb9sG7jBSIK3VDAjlYLX6WxwOy8D5aN0IdM8kjkR+g1mopWjA/fi5 bWAcGLizeamQv/Lo6poDxf50n27pC1jk+V3hYkyAtWkp1DJ9B0naV8orvkLb4JJ7nYuM P3Hw== X-Gm-Message-State: AGRZ1gLZNYN9A1UIzCY5aHf9hHkvvbdf8eKVgVEosAidKzWkhS8FXzSk s3tF5vLAejJ2pRsef5L0F4dojlZu5YWQ42ps X-Google-Smtp-Source: AJdET5fi/0hkuSZLQv8DVN2iuIPkYkSADaMyZQJk/RZq8RPhUhPll42FhDRjETyssTZDEjmOZ+/b+w== X-Received: by 2002:a63:eb0e:: with SMTP id t14mr378059pgh.445.1542019992697; Mon, 12 Nov 2018 02:53:12 -0800 (PST) Received: from baolinwangubtpc.spreadtrum.com ([117.18.48.102]) by smtp.gmail.com with ESMTPSA id 186-v6sm17545705pfe.39.2018.11.12.02.53.10 (version=TLS1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 12 Nov 2018 02:53:12 -0800 (PST) From: Baolin Wang To: sre@kernel.org Cc: linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, yuanjiang.yu@unisoc.com, baolin.wang@linaro.org, broonie@kernel.org Subject: [PATCH 3/4] power: supply: sc2731_charger: Avoid repeated charge/discharge Date: Mon, 12 Nov 2018 18:52:37 +0800 Message-Id: <2298d92a4156f331f9e317d6bc6eed0ff88677bb.1542019800.git.baolin.wang@linaro.org> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <5d096dec07f6808a70edcfaad6e8f77039f21a9b.1542019800.git.baolin.wang@linaro.org> References: <5d096dec07f6808a70edcfaad6e8f77039f21a9b.1542019800.git.baolin.wang@linaro.org> In-Reply-To: <5d096dec07f6808a70edcfaad6e8f77039f21a9b.1542019800.git.baolin.wang@linaro.org> References: <5d096dec07f6808a70edcfaad6e8f77039f21a9b.1542019800.git.baolin.wang@linaro.org> Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Add info->charging validation to avoid repeated charge or discharge operation. Signed-off-by: Baolin Wang --- drivers/power/supply/sc2731_charger.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/power/supply/sc2731_charger.c b/drivers/power/supply/sc2731_charger.c index a012d6c..49b3f0c 100644 --- a/drivers/power/supply/sc2731_charger.c +++ b/drivers/power/supply/sc2731_charger.c @@ -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);