From: Chris Morgan <macroalpha82@gmail.com>
To: linux-pm@vger.kernel.org
Cc: linux-rockchip@lists.infradead.org, devicetree@vger.kernel.org,
maccraft123mc@gmail.com, zhangqing@rock-chips.com,
zyw@rock-chips.com, sre@kernel.org, heiko@sntech.de,
conor+dt@kernel.org, krzk+dt@kernel.org, robh@kernel.org,
lee@kernel.org, Chris Morgan <macromorgan@hotmail.com>,
Jacob Cook <jacobmcook1984@gmail.com>
Subject: [PATCH 1/5] power: supply: rk817-charger: Fix NVRAM SoC Value
Date: Mon, 26 Oct 2026 12:48:30 -0500 [thread overview]
Message-ID: <20261026174834.1652309-2-macroalpha82@gmail.com> (raw)
In-Reply-To: <20261026174834.1652309-1-macroalpha82@gmail.com>
From: Chris Morgan <macromorgan@hotmail.com>
The NVRAM value is stored as a value between 0 (0%) and 100000 (100%),
but the bounds checking checks and truncates with a max of 10000,
causing a value of 100% to get read as 10%.
Fixes: 11cb8da0189b ("power: supply: Add charger driver for Rockchip RK817")
Suggested-by: Jacob Cook <jacobmcook1984@gmail.com>
Signed-off-by: Chris Morgan <macromorgan@hotmail.com>
---
drivers/power/supply/rk817_charger.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/drivers/power/supply/rk817_charger.c b/drivers/power/supply/rk817_charger.c
index 5558b182a1a6..86da0462fb59 100644
--- a/drivers/power/supply/rk817_charger.c
+++ b/drivers/power/supply/rk817_charger.c
@@ -728,7 +728,7 @@ static int rk817_read_battery_nvram_values(struct rk817_charger *charger)
/*
* Read the nvram for state of charge. Sanity check for values greater
- * than 100 (10000) or less than 0, because other things (BSP kernels,
+ * than 100 (100000) or less than 0, because other things (BSP kernels,
* U-Boot, or even i2cset) can write to this register. If the value is
* off it should get corrected automatically when the voltage drops to
* the min (soc is 0) or when the battery is full (soc is 100).
@@ -738,8 +738,8 @@ static int rk817_read_battery_nvram_values(struct rk817_charger *charger)
if (ret < 0)
return ret;
charger->soc = get_unaligned_le24(bulk_reg);
- if (charger->soc > 10000)
- charger->soc = 10000;
+ if (charger->soc > 100000)
+ charger->soc = 100000;
if (charger->soc < 0)
charger->soc = 0;
--
2.53.0
next prev parent reply other threads:[~2026-10-26 17:48 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-26 17:48 [PATCH 0/5] Fix Incorrect State of Charge for RK817 Chris Morgan
2026-10-26 17:48 ` Chris Morgan [this message]
2026-10-26 17:48 ` [PATCH 2/5] power: supply: rk817-charger: Resolve boot state of charge from the coulomb counter Chris Morgan
2026-10-26 17:48 ` [PATCH 3/5] power: supply: rk817-charger: Correct the gauge across system sleep Chris Morgan
2026-10-26 17:48 ` [PATCH 4/5] dt-bindings: power: supply: rk817-charger: Add rockchip,gate-function-disable Chris Morgan
2026-10-26 19:23 ` Heiko Stübner
2026-10-27 15:53 ` Chris Morgan
2026-10-27 22:40 ` Heiko Stübner
2026-10-28 14:16 ` Chris Morgan
2026-10-28 13:08 ` Krzysztof Kozlowski
2026-10-26 17:48 ` [PATCH 5/5] power: supply: rk817-charger: Clear SYS_CAN_SD register by default Chris Morgan
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=20261026174834.1652309-2-macroalpha82@gmail.com \
--to=macroalpha82@gmail.com \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=heiko@sntech.de \
--cc=jacobmcook1984@gmail.com \
--cc=krzk+dt@kernel.org \
--cc=lee@kernel.org \
--cc=linux-pm@vger.kernel.org \
--cc=linux-rockchip@lists.infradead.org \
--cc=maccraft123mc@gmail.com \
--cc=macromorgan@hotmail.com \
--cc=robh@kernel.org \
--cc=sre@kernel.org \
--cc=zhangqing@rock-chips.com \
--cc=zyw@rock-chips.com \
/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