[PATCH] power: supply: ds2780: Fix ds2780_get_capacity() returning raw value

Xueqin Luo posted 1 patch 3 weeks, 4 days ago
drivers/power/supply/ds2780_battery.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
[PATCH] power: supply: ds2780: Fix ds2780_get_capacity() returning raw value
Posted by Xueqin Luo 3 weeks, 4 days ago
ds2780_get_capacity() returns the raw register value instead of 0 on
success.  The capacity is already stored in *capacity, so the function
should return 0 to indicate success.

Fixes: 275ac74629c4 ("w1: add Maxim/Dallas DS2780 Stand-Alone Fuel Gauge IC support")
Signed-off-by: Xueqin Luo <luoxueqin@kylinos.cn>
---
 drivers/power/supply/ds2780_battery.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/power/supply/ds2780_battery.c b/drivers/power/supply/ds2780_battery.c
index 5b57bbba79d4..ef2446386c2a 100644
--- a/drivers/power/supply/ds2780_battery.c
+++ b/drivers/power/supply/ds2780_battery.c
@@ -304,7 +304,7 @@ static int ds2780_get_capacity(struct ds2780_device_info *dev_info,
 		return ret;
 
 	*capacity = raw;
-	return raw;
+	return 0;
 }
 
 static int ds2780_get_status(struct ds2780_device_info *dev_info, int *status)
-- 
2.43.0
Re: [PATCH] power: supply: ds2780: Fix ds2780_get_capacity() returning raw value
Posted by Sebastian Reichel 2 weeks, 2 days ago
On Tue, 01 Sep 2026 15:29:54 +0800, Xueqin Luo wrote:
> ds2780_get_capacity() returns the raw register value instead of 0 on
> success.  The capacity is already stored in *capacity, so the function
> should return 0 to indicate success.

Applied, thanks!

[1/1] power: supply: ds2780: Fix ds2780_get_capacity() returning raw value
      commit: a58cbc8b36ec0cd00d2ba3de7d003de818a27523

Best regards,
-- 
Sebastian Reichel <sebastian.reichel@collabora.com>