mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Hex Lindqvist <hex@freenixos.com>
To: Sebastian Reichel <sre@kernel.org>
Cc: "Pali Rohár" <pali@kernel.org>,
	"Matt Ranostay" <matt@ranostay.sg>,
	linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH] power: supply: bq27xxx: Don't report missing battery properties as invalid
Date: Sat,  7 Nov 2026 19:09:45 -0800	[thread overview]
Message-ID: <20261108030945.92766-1-hex@freenixos.com> (raw)

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


                 reply	other threads:[~2026-11-08  3:09 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=20261108030945.92766-1-hex@freenixos.com \
    --to=hex@freenixos.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=matt@ranostay.sg \
    --cc=pali@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

all inboxes | Powered by JetHome®