aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStephan Gerhold <[email protected]>2024-07-12 12:00:03 +0200
committerSebastian Reichel <[email protected]>2024-07-27 00:18:40 +0200
commitd6cca7631a4b54a8995e3bc53e5afb11d3b0c8ff (patch)
treece266b4f41eea3922499e18ad613168e0d3f550a
parentbf9d5cb588755ee41ac12a8976dccf44ae18281b (diff)
power: supply: qcom_battmgr: Ignore extra __le32 in info payload
Some newer ADSP firmware versions on X1E80100 report an extra __le32 at the end of the battery information request payload, causing qcom_battmgr to fail to initialize. Adjust the check to ignore the extra field in the info payload so we can support both old and newer firmware versions. Tested-by: Srinivas Kandagatla <[email protected]> Signed-off-by: Stephan Gerhold <[email protected]> Tested-by: Johan Hovold <[email protected]> Reviewed-by: Dmitry Baryshkov <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Sebastian Reichel <[email protected]>
-rw-r--r--drivers/power/supply/qcom_battmgr.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/drivers/power/supply/qcom_battmgr.c b/drivers/power/supply/qcom_battmgr.c
index 44c6301f5f17..a99937cd733b 100644
--- a/drivers/power/supply/qcom_battmgr.c
+++ b/drivers/power/supply/qcom_battmgr.c
@@ -1007,7 +1007,9 @@ static void qcom_battmgr_sc8280xp_callback(struct qcom_battmgr *battmgr,
battmgr->error = 0;
break;
case BATTMGR_BAT_INFO:
- if (payload_len != sizeof(resp->info)) {
+ /* some firmware versions report an extra __le32 at the end of the payload */
+ if (payload_len != sizeof(resp->info) &&
+ payload_len != (sizeof(resp->info) + sizeof(__le32))) {
dev_warn(battmgr->dev,
"invalid payload length for battery information request: %zd\n",
payload_len);