linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Krzysztof Kozlowski <krzk@kernel.org>
To: "Sebastian Reichel" <sre@kernel.org>,
	"Rob Herring" <robh+dt@kernel.org>,
	"Pali Rohár" <pali@kernel.org>, "Dan Murphy" <dmurphy@ti.com>,
	"Krzysztof Kozlowski" <krzk@kernel.org>,
	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	[thread overview]
Message-ID: <20200919140418.3705-3-krzk@kernel.org> (raw)
In-Reply-To: <20200919140418.3705-1-krzk@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 <krzk@kernel.org>

---

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


  parent reply	other threads:[~2020-09-19 14:04 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-09-19 14:04 [PATCH v2 0/6] power: supply: bq27xxx: add bq34z100 Krzysztof Kozlowski
2020-09-19 14:04 ` [PATCH v2 1/6] dt-bindings: power: " Krzysztof Kozlowski
2020-09-19 14:04 ` Krzysztof Kozlowski [this message]
2020-09-19 14:04 ` [PATCH v2 3/6] power: supply: bq27xxx: adjust whitespace and use BIT() for bitflags Krzysztof Kozlowski
2020-09-19 14:04 ` [PATCH v2 4/6] power: supply: bq27xxx: add separate flag for single SoC register Krzysztof Kozlowski
2020-09-19 14:04 ` [PATCH v2 5/6] power: supply: bq27xxx: add separate flag for capacity inaccurate Krzysztof Kozlowski
2020-09-19 14:04 ` [PATCH v2 6/6] power: supply: bq27xxx: add support for TI bq34z100 Krzysztof Kozlowski
2020-10-01 22:34 ` [PATCH v2 0/6] power: supply: bq27xxx: add bq34z100 Sebastian Reichel

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200919140418.3705-3-krzk@kernel.org \
    --to=krzk@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=dmurphy@ti.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=pali@kernel.org \
    --cc=robh+dt@kernel.org \
    --cc=sre@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).