* [PATCH] power: supply: bq27xxx: Don't report missing battery properties as invalid
@ 2026-11-08 3:09 Hex Lindqvist
0 siblings, 0 replies; only message in thread
From: Hex Lindqvist @ 2026-11-08 3:09 UTC (permalink / raw)
To: Sebastian Reichel; +Cc: Pali Rohár, Matt Ranostay, linux-pm, linux-kernel
When the device tree leaves out energy-full-design-microwatt-hours or
charge-full-design-microamp-hours, power_supply_get_battery_info() sets
the field to -EINVAL. bq27xxx_battery_settings() then compares it with
an unsigned limit, so -EINVAL becomes a large positive number and the
missing property is also reported as invalid:
bq27xxx-battery 10-0055: missing battery:energy-full-design-microwatt-hours
bq27xxx-battery 10-0055: invalid battery:energy-full-design-microwatt-hours -22
Skip the range check when the value is -EINVAL, as the check for
voltage-min-design-microvolt below already does. The field is -EINVAL
either way, so only the message goes away.
Tested on a OnePlus 6T (bq27411), whose device tree has the charge but
not the energy property: only the "missing" warning remains.
An AI assistant helped find and test this change and drafted this
message.
Fixes: ccce440956c7 ("power: supply: bq27xxx: Add power_supply_battery_info support")
Signed-off-by: Hex Lindqvist <hex@freenixos.com>
---
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 09272249b4f7..18ba375dbbb6 100644
--- a/drivers/power/supply/bq27xxx_battery.c
+++ b/drivers/power/supply/bq27xxx_battery.c
@@ -1548,7 +1548,8 @@ static void bq27xxx_battery_settings(struct bq27xxx_device_info *di)
/* assume min == 0 */
max = di->dm_regs[BQ27XXX_DM_DESIGN_ENERGY].max;
- if (info->energy_full_design_uwh > max * 1000) {
+ if (info->energy_full_design_uwh != -EINVAL &&
+ info->energy_full_design_uwh > max * 1000) {
dev_err(di->dev, "invalid battery:energy-full-design-microwatt-hours %d\n",
info->energy_full_design_uwh);
info->energy_full_design_uwh = -EINVAL;
@@ -1556,7 +1557,8 @@ static void bq27xxx_battery_settings(struct bq27xxx_device_info *di)
/* assume min == 0 */
max = di->dm_regs[BQ27XXX_DM_DESIGN_CAPACITY].max;
- if (info->charge_full_design_uah > max * 1000) {
+ if (info->charge_full_design_uah != -EINVAL &&
+ info->charge_full_design_uah > max * 1000) {
dev_err(di->dev, "invalid battery:charge-full-design-microamp-hours %d\n",
info->charge_full_design_uah);
info->charge_full_design_uah = -EINVAL;
base-commit: 6628e7d4c6b25c8d18f1345e3a20d21829aae7e4
--
2.56.0
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2026-11-08 3:09 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-08 3:09 [PATCH] power: supply: bq27xxx: Don't report missing battery properties as invalid Hex Lindqvist
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®