Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp1935884pxk; Sat, 19 Sep 2020 07:06:04 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzAtRB/Z7f6CkRDvzzJr1Egvt4WVDIkfwS1+DAuD5+eI2vRsNV3F7X/rxk/XPNA/w9QlKLe X-Received: by 2002:aa7:d4d0:: with SMTP id t16mr43958396edr.83.1600524364091; Sat, 19 Sep 2020 07:06:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1600524364; cv=none; d=google.com; s=arc-20160816; b=YbFWbU9eE2yvwUmawZiMypNzTspho1/4JTDDwgvVY1CXDrIuGOtVPEMNbhTg4D6aF4 XP5tuRiFyUs66qjr6P2vgoPgFr8c5qQn8qqm0Th+2pVF+tcLuLiL5R1k2DWzAukSUQ2y UZGUvNwf8mmj7zfsFZ8zHmd4OL8B9uG+yFp5rhKe4mhXU1HRTxDHIBrESfBqOvaKrY9g uGdHqTzdhAfI3bGsIDQejcA+1DGvBjxpoeKYwrLtvg8QzdIAK++04gzrS6xqHK/WEYyQ fUW4+yXF6JqJlUQ3b++jeFesczuI2wKisI9pSVC7if91u/OjRb3VU7t9NpjPUCVk1rTg 3lZg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:references:in-reply-to:message-id:date:subject :to:from:dkim-signature; bh=J+YeAL/sLuBFdi4pF6oYzRsvh58bWNxWcp7CEgFwaAo=; b=LK65dlF8eRwWbti+vLbNFRvjylu1LM3syZd99r96dm08APzX7K5kKiwvuBsNajktef aM4eiwZSm2PRBhyYJIqykQk07Vs+DO2FEl04ZSdVW43E6opi+2DdpIz/X0jE7FxBOkZH Wz2UxZaPoUP1FVx9L0E6VsUDbWugmfl6eVbtoePoosNgTQ8OcaarBdek/1IU7Z4moB5x bN0bta3BTi7+yDGtXYXniBtoY8nx3HxsmwsvrPWYdaiLK0dLrK0mN/cE3/E2am95UNcM cEM5GGR4fT/VtKN5qrvmWIEo5M9v70r5fOTcxefOeH79rke179aifNoxK2N9yiHF3zjc QOlw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=SRdV0o88; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id z1si4495885ejd.673.2020.09.19.07.05.40; Sat, 19 Sep 2020 07:06:04 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=SRdV0o88; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726515AbgISOEi (ORCPT + 99 others); Sat, 19 Sep 2020 10:04:38 -0400 Received: from mail.kernel.org ([198.145.29.99]:41318 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726159AbgISOEg (ORCPT ); Sat, 19 Sep 2020 10:04:36 -0400 Received: from localhost.localdomain (unknown [194.230.155.191]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 6250923119; Sat, 19 Sep 2020 14:04:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1600524275; bh=NPVHKsTIcPLqsD4JdOC7choTv9Cwr4e7aqMqj1vQEdc=; h=From:To:Subject:Date:In-Reply-To:References:From; b=SRdV0o88M4vpqaXBk2ifx0PZaqd165Fipx4yUOEUKEnGnQU1ESoRfhWZf0dYlp+V5 U0cSfz9NiMsFftGpi7X5M/yQNlgbxSfFBWchegTGb4If8mzkYNBFF5zwKmTmG1X6hX Qugq5N5UagFsWLX79fTokYx/WyMinVe0hAMaESoY= From: Krzysztof Kozlowski To: Sebastian Reichel , Rob Herring , =?UTF-8?q?Pali=20Roh=C3=A1r?= , Dan Murphy , Krzysztof Kozlowski , linux-pm@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v2 2/6] power: supply: bq27xxx: report "not charging" on all types Date: Sat, 19 Sep 2020 16:04:14 +0200 Message-Id: <20200919140418.3705-3-krzk@kernel.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200919140418.3705-1-krzk@kernel.org> References: <20200919140418.3705-1-krzk@kernel.org> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Commit 6f24ff97e323 ("power: supply: bq27xxx_battery: Add the BQ27Z561 Battery monitor") and commit d74534c27775 ("power: bq27xxx_battery: Add support for additional bq27xxx family devices") added support for new device types by copying most of the code and adding necessary quirks. However they did not copy the code in bq27xxx_battery_status() responsible for returning POWER_SUPPLY_STATUS_NOT_CHARGING. Unify the bq27xxx_battery_status() so for all types when charger is supplied, it will return "not charging" status. Signed-off-by: Krzysztof Kozlowski --- Not tested on BQ27Z561 or other types of batteries. Tested however on bq34z100. --- drivers/power/supply/bq27xxx_battery.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/drivers/power/supply/bq27xxx_battery.c b/drivers/power/supply/bq27xxx_battery.c index 92de7b720182..65806f668b1f 100644 --- a/drivers/power/supply/bq27xxx_battery.c +++ b/drivers/power/supply/bq27xxx_battery.c @@ -1765,8 +1765,6 @@ static int bq27xxx_battery_status(struct bq27xxx_device_info *di, status = POWER_SUPPLY_STATUS_FULL; else if (di->cache.flags & BQ27000_FLAG_CHGS) status = POWER_SUPPLY_STATUS_CHARGING; - else if (power_supply_am_i_supplied(di->bat) > 0) - status = POWER_SUPPLY_STATUS_NOT_CHARGING; else status = POWER_SUPPLY_STATUS_DISCHARGING; } else if (di->opts & BQ27Z561_O_BITS) { @@ -1785,6 +1783,10 @@ static int bq27xxx_battery_status(struct bq27xxx_device_info *di, status = POWER_SUPPLY_STATUS_CHARGING; } + if ((status == POWER_SUPPLY_STATUS_DISCHARGING) && + (power_supply_am_i_supplied(di->bat) > 0)) + status = POWER_SUPPLY_STATUS_NOT_CHARGING; + val->intval = status; return 0; -- 2.17.1