diff mbox series

[2/7] power: supply: bq27xxx: report "not charging" on all types

Message ID 20200908201319.3567-2-krzk@kernel.org (mailing list archive)
State Not Applicable, archived
Headers show
Series [1/7] dt-bindings: power: bq27xxx: add bq34z100 | expand

Commit Message

Krzysztof Kozlowski Sept. 8, 2020, 8:13 p.m. UTC
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(-)

Comments

Dan Murphy Sept. 8, 2020, 8:54 p.m. UTC | #1
Krzysztof

On 9/8/20 3:13 PM, Krzysztof Kozlowski wrote:
> 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.

If this is a fix then please populate the Fixes tag.

But not sure how both commits are tied here

Dan
Krzysztof Kozlowski Sept. 9, 2020, 6:35 a.m. UTC | #2
On Tue, 8 Sep 2020 at 22:54, Dan Murphy <dmurphy@ti.com> wrote:
>
> Krzysztof
>
> On 9/8/20 3:13 PM, Krzysztof Kozlowski wrote:
> > 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.
>
> If this is a fix then please populate the Fixes tag.
>
> But not sure how both commits are tied here

I am not convinced that it is a fix. It's rather missing functionality
on these new devices. The commits did not break anything. They just
did not implement "not charging" for new types.

Best Regards,
Krzysztof
diff mbox series

Patch

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;