linux-pm.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] power: supply: bq27xxx: Report charge full state correctly
@ 2024-02-26 19:37 Sicelo A. Mhlongo
  2024-02-27 20:16 ` Sebastian Reichel
  0 siblings, 1 reply; 2+ messages in thread
From: Sicelo A. Mhlongo @ 2024-02-26 19:37 UTC (permalink / raw)
  To: sre, linux-pm; +Cc: maemo-leste, pali, Sicelo A. Mhlongo

When reporting the charging status, the existing code reports the battery
as full only when the reported current flowing is exactly 0mA, which is
unlikely in practice.

Fix the reporting by giving priority to the battery's full state
indication/flag.

Tested on the Nokia N900 with bq27200 fuel gauge.

Signed-off-by: Sicelo A. Mhlongo <absicsz@gmail.com>
---
 drivers/power/supply/bq27xxx_battery.c | 15 ++++++---------
 1 file changed, 6 insertions(+), 9 deletions(-)

diff --git a/drivers/power/supply/bq27xxx_battery.c b/drivers/power/supply/bq27xxx_battery.c
index 1c4a9d137744..810f6eb468ad 100644
--- a/drivers/power/supply/bq27xxx_battery.c
+++ b/drivers/power/supply/bq27xxx_battery.c
@@ -1816,17 +1816,14 @@ static int bq27xxx_battery_current_and_status(
 		val_curr->intval = curr;
 
 	if (val_status) {
-		if (curr > 0) {
+		if (bq27xxx_battery_is_full(di, flags))
+			val_status->intval = POWER_SUPPLY_STATUS_FULL;
+		else if (curr > 0)
 			val_status->intval = POWER_SUPPLY_STATUS_CHARGING;
-		} else if (curr < 0) {
+		else if (curr < 0)
 			val_status->intval = POWER_SUPPLY_STATUS_DISCHARGING;
-		} else {
-			if (bq27xxx_battery_is_full(di, flags))
-				val_status->intval = POWER_SUPPLY_STATUS_FULL;
-			else
-				val_status->intval =
-					POWER_SUPPLY_STATUS_NOT_CHARGING;
-		}
+		else
+			val_status->intval = POWER_SUPPLY_STATUS_NOT_CHARGING;
 	}
 
 	return 0;
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] power: supply: bq27xxx: Report charge full state correctly
  2024-02-26 19:37 [PATCH] power: supply: bq27xxx: Report charge full state correctly Sicelo A. Mhlongo
@ 2024-02-27 20:16 ` Sebastian Reichel
  0 siblings, 0 replies; 2+ messages in thread
From: Sebastian Reichel @ 2024-02-27 20:16 UTC (permalink / raw)
  To: sre, linux-pm, Sicelo A. Mhlongo; +Cc: maemo-leste, pali


On Mon, 26 Feb 2024 21:37:22 +0200, Sicelo A. Mhlongo wrote:
> When reporting the charging status, the existing code reports the battery
> as full only when the reported current flowing is exactly 0mA, which is
> unlikely in practice.
> 
> Fix the reporting by giving priority to the battery's full state
> indication/flag.
> 
> [...]

Applied, thanks!

[1/1] power: supply: bq27xxx: Report charge full state correctly
      commit: 8fbb11162504f2de167a8ccd2d2c55a849d2c5ea

Best regards,
-- 
Sebastian Reichel <sebastian.reichel@collabora.com>


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2024-02-27 20:16 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-02-26 19:37 [PATCH] power: supply: bq27xxx: Report charge full state correctly Sicelo A. Mhlongo
2024-02-27 20:16 ` Sebastian Reichel

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).