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: 150820 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp2992976ljp; Mon, 12 Nov 2018 02:53:16 -0800 (PST) X-Google-Smtp-Source: AJdET5fC7SoK9PXMfWLAs+WEPd6zpL6UDnFAFA4JlAs+3HAEqbjp2YXYq2dXeHS6eZWVtzgYEv+E X-Received: by 2002:a17:902:2f84:: with SMTP id t4-v6mr432389plb.239.1542019996164; Mon, 12 Nov 2018 02:53:16 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1542019996; cv=none; d=google.com; s=arc-20160816; b=wPmZdVDxVbWezK48N6Mboh3Tk8gcF96s72EW0jPSLAz8ciVcNEjfMvZqdJk7bscRHu dI1T+tx3xy/Im63tO1EXmytsiMljDnr+7NhMSGgum+id8EllsAR0/KrIgvuvMBwd9tvI 7jyWFsBs5rh/J8uLY4hxoIc9a1Myry3HJCRUqTEDEFD0ZTgzo+h0U+DBBfMvDrEFqlA3 07/6NZIyAT1+A2g02V2hreJf6KlKAgwct8UrNcjKAdaChocP4skjkYhbboGvEs1b4Z9n yOykXtHYb/uYmldfQ1fZ7VJIKQHgrLxVXYEim0AyFGvtUuI4H829JMpgHNT19iDcNCMY WlWA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:references :in-reply-to:message-id:date:subject:cc:to:from:dkim-signature; bh=WRUiqIUtLnq5Kt3BfAdxw6WClpYGJFwMdYAB6FisGEA=; b=PNzfKrEIh88NIWSf1rZFX2TMc1M02Ztco8QfPOBn1sdbrVWzY1iTtaTmZKhLNNY/nw M0ebJpMtnWk7vFLlmOnz8O/5/vBCJnzBbB4feJZ/uopbPNXkAqNMnggdNzsNgtOyeLSI rzVdua/tkRY90ax4Xl4Xde0iOCYnntUF8t59CHrxu9AQ2xGOSG+fPW7YzQsv/4EL42Yo GoiN6wsOHrCsOYqIrmq3z9/A04Xms68YcX6WocfoBV9YgYM38VmQq5UFcD84Tfug3Dh4 a9YTgApCBOGliCiL5Jm6Mx5MzhCp/FDUTIl5ccOWe4ERs0qozJTRzlXrhTad6YwXHoIV 0onA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=h1xsJXjt; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id r18-v6si19953457pfc.253.2018.11.12.02.53.15; Mon, 12 Nov 2018 02:53:16 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=h1xsJXjt; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729279AbeKLUp4 (ORCPT + 32 others); Mon, 12 Nov 2018 15:45:56 -0500 Received: from mail-pf1-f196.google.com ([209.85.210.196]:42121 "EHLO mail-pf1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729212AbeKLUpz (ORCPT ); Mon, 12 Nov 2018 15:45:55 -0500 Received: by mail-pf1-f196.google.com with SMTP id u10-v6so4142103pfn.9 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=K3Rbje46ap0kqMIaW7JdqLxp1Lna0He8goMqPKIoECx5PeDH1r+GeLnHWmqK4gGiwP bX0YWCgiuIRSfvyXuvK3VwQeMARAiTspAohTdWbcx+hOH7/6tTUxIqCFwmfumc9/9exV 1R3wO6uqIJYHK58/umrxadZu/JkBZPjlbEV3RE1ZiIqOUzrvmYqpFT5kj2ecaAvvSaY0 WyPVwofiV+qIjWemuGlJWUXAEEa7IPduYt2NNuK9n6B+Zi8F5TCfZppFlWiiK4lTMcKg qxNXOx7LONfvRblQGWESlotuXV9snO6HpT+GuZQMtvpLun+8PTCnjHRyxAKR1ocuhF4q yf1w== X-Gm-Message-State: AGRZ1gKpRQifrvFmLEadvCDOTpnHcI2cfNxkv9FaRl4IdaVKojELTGfM M7TFxlpWeJj/czxNgbLhOMm2vw== 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-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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(-) -- 1.7.9.5 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);