All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] power: supply: max17040: handle missing status supplier
@ 2026-07-01  1:20 jianing.li
  0 siblings, 0 replies; 7+ messages in thread
From: jianing.li @ 2026-07-01  1:20 UTC (permalink / raw)
  To: Sebastian Reichel
  Cc: Iskren Chernev, Krzysztof Kozlowski, Marek Szyprowski,
	Matheus Castello, linux-pm, linux-kernel, jianing . li, stable

MAX17040 does not report charger state itself, so the driver forwards
POWER_SUPPLY_PROP_STATUS to a supplier power supply. If no supplier is
registered, power_supply_get_property_from_supplier() returns -ENODEV and
leaves the output value untouched.

max17040_get_property() currently ignores that error and returns success,
so userspace can read an uninitialized status value from the battery power
supply. This happens on systems that use the fuel gauge without a charger
supplier relationship in firmware.

Return POWER_SUPPLY_STATUS_UNKNOWN when no supplier provides STATUS, and
propagate other supplier lookup errors.

Fixes: f4b782af61ae ("power: max17040: pass status property from supplier")
Cc: stable@vger.kernel.org # 6.7+
Signed-off-by: jianing.li <m13940358460@163.com>
---
 drivers/power/supply/max17040_battery.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/drivers/power/supply/max17040_battery.c b/drivers/power/supply/max17040_battery.c
index 60c38e822b52..bba6d91c9b9b 100644
--- a/drivers/power/supply/max17040_battery.c
+++ b/drivers/power/supply/max17040_battery.c
@@ -405,7 +405,11 @@ static int max17040_get_property(struct power_supply *psy,
 		val->intval = chip->low_soc_alert;
 		break;
 	case POWER_SUPPLY_PROP_STATUS:
-		power_supply_get_property_from_supplier(psy, psp, val);
+		ret = power_supply_get_property_from_supplier(psy, psp, val);
+		if (ret == -ENODEV)
+			val->intval = POWER_SUPPLY_STATUS_UNKNOWN;
+		else if (ret)
+			return ret;
 		break;
 	case POWER_SUPPLY_PROP_TEMP:
 		if (!chip->channel_temp)
-- 
2.39.0


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH] power: supply: max17040: handle missing status supplier
@ 2026-07-01  1:21 jianing.li
  2026-07-01  5:43 ` Greg KH
  0 siblings, 1 reply; 7+ messages in thread
From: jianing.li @ 2026-07-01  1:21 UTC (permalink / raw)
  To: Sebastian Reichel
  Cc: Iskren Chernev, Krzysztof Kozlowski, Marek Szyprowski,
	Matheus Castello, linux-pm, linux-kernel, jianing . li, stable

MAX17040 does not report charger state itself, so the driver forwards
POWER_SUPPLY_PROP_STATUS to a supplier power supply. If no supplier is
registered, power_supply_get_property_from_supplier() returns -ENODEV and
leaves the output value untouched.

max17040_get_property() currently ignores that error and returns success,
so userspace can read an uninitialized status value from the battery power
supply. This happens on systems that use the fuel gauge without a charger
supplier relationship in firmware.

Return POWER_SUPPLY_STATUS_UNKNOWN when no supplier provides STATUS, and
propagate other supplier lookup errors.

Fixes: f4b782af61ae ("power: max17040: pass status property from supplier")
Cc: stable@vger.kernel.org # 6.7+
Signed-off-by: jianing.li <m13940358460@163.com>
---
 drivers/power/supply/max17040_battery.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/drivers/power/supply/max17040_battery.c b/drivers/power/supply/max17040_battery.c
index 60c38e822b52..bba6d91c9b9b 100644
--- a/drivers/power/supply/max17040_battery.c
+++ b/drivers/power/supply/max17040_battery.c
@@ -405,7 +405,11 @@ static int max17040_get_property(struct power_supply *psy,
 		val->intval = chip->low_soc_alert;
 		break;
 	case POWER_SUPPLY_PROP_STATUS:
-		power_supply_get_property_from_supplier(psy, psp, val);
+		ret = power_supply_get_property_from_supplier(psy, psp, val);
+		if (ret == -ENODEV)
+			val->intval = POWER_SUPPLY_STATUS_UNKNOWN;
+		else if (ret)
+			return ret;
 		break;
 	case POWER_SUPPLY_PROP_TEMP:
 		if (!chip->channel_temp)
-- 
2.39.0


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [PATCH] power: supply: max17040: handle missing status supplier
  2026-07-01  1:21 [PATCH] power: supply: max17040: handle missing status supplier jianing.li
@ 2026-07-01  5:43 ` Greg KH
  2026-07-01  6:10   ` [PATCH v2] " Jianing Li
  2026-07-01  6:52   ` [PATCH] " Jianing Li
  0 siblings, 2 replies; 7+ messages in thread
From: Greg KH @ 2026-07-01  5:43 UTC (permalink / raw)
  To: jianing.li
  Cc: Sebastian Reichel, Iskren Chernev, Krzysztof Kozlowski,
	Marek Szyprowski, Matheus Castello, linux-pm, linux-kernel,
	stable

On Wed, Jul 01, 2026 at 09:21:01AM +0800, jianing.li wrote:
> MAX17040 does not report charger state itself, so the driver forwards
> POWER_SUPPLY_PROP_STATUS to a supplier power supply. If no supplier is
> registered, power_supply_get_property_from_supplier() returns -ENODEV and
> leaves the output value untouched.
> 
> max17040_get_property() currently ignores that error and returns success,
> so userspace can read an uninitialized status value from the battery power
> supply. This happens on systems that use the fuel gauge without a charger
> supplier relationship in firmware.
> 
> Return POWER_SUPPLY_STATUS_UNKNOWN when no supplier provides STATUS, and
> propagate other supplier lookup errors.
> 
> Fixes: f4b782af61ae ("power: max17040: pass status property from supplier")
> Cc: stable@vger.kernel.org # 6.7+
> Signed-off-by: jianing.li <m13940358460@163.com>

Please use your name, not an email alias.

And why send this 3 times?

thanks,

greg k-h

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH v2] power: supply: max17040: handle missing status supplier
  2026-07-01  5:43 ` Greg KH
@ 2026-07-01  6:10   ` Jianing Li
  2026-07-19  5:55     ` Jianing Li
  2026-07-20 22:32     ` Sebastian Reichel
  2026-07-01  6:52   ` [PATCH] " Jianing Li
  1 sibling, 2 replies; 7+ messages in thread
From: Jianing Li @ 2026-07-01  6:10 UTC (permalink / raw)
  To: Sebastian Reichel
  Cc: Greg KH, Iskren Chernev, Krzysztof Kozlowski, Marek Szyprowski,
	Matheus Castello, linux-pm, linux-kernel, Jianing Li, stable

MAX17040 does not report charger state itself, so the driver forwards
POWER_SUPPLY_PROP_STATUS to a supplier power supply. If no supplier is
registered, power_supply_get_property_from_supplier() returns -ENODEV and
leaves the output value untouched.

max17040_get_property() currently ignores that error and returns success,
so userspace can read an uninitialized status value from the battery power
supply. This happens on systems that use the fuel gauge without a charger
supplier relationship in firmware.

Return POWER_SUPPLY_STATUS_UNKNOWN when no supplier provides STATUS, and
propagate other supplier lookup errors.

Fixes: f4b782af61ae ("power: max17040: pass status property from supplier")
Cc: stable@vger.kernel.org # 6.7+
Signed-off-by: Jianing Li <m13940358460@163.com>
---
Changes in v2:
- Use real name in From and Signed-off-by.
- No code changes.

 drivers/power/supply/max17040_battery.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/drivers/power/supply/max17040_battery.c b/drivers/power/supply/max17040_battery.c
index 60c38e822b52..bba6d91c9b9b 100644
--- a/drivers/power/supply/max17040_battery.c
+++ b/drivers/power/supply/max17040_battery.c
@@ -405,7 +405,11 @@ static int max17040_get_property(struct power_supply *psy,
 		val->intval = chip->low_soc_alert;
 		break;
 	case POWER_SUPPLY_PROP_STATUS:
-		power_supply_get_property_from_supplier(psy, psp, val);
+		ret = power_supply_get_property_from_supplier(psy, psp, val);
+		if (ret == -ENODEV)
+			val->intval = POWER_SUPPLY_STATUS_UNKNOWN;
+		else if (ret)
+			return ret;
 		break;
 	case POWER_SUPPLY_PROP_TEMP:
 		if (!chip->channel_temp)
-- 
2.39.0


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [PATCH] power: supply: max17040: handle missing status supplier
  2026-07-01  5:43 ` Greg KH
  2026-07-01  6:10   ` [PATCH v2] " Jianing Li
@ 2026-07-01  6:52   ` Jianing Li
  1 sibling, 0 replies; 7+ messages in thread
From: Jianing Li @ 2026-07-01  6:52 UTC (permalink / raw)
  To: Greg KH
  Cc: Jianing Li, Sebastian Reichel, Iskren Chernev,
	Krzysztof Kozlowski, Marek Szyprowski, Matheus Castello, linux-pm,
	linux-kernel, stable

Hi Greg,

Sorry for the duplicate submissions. There was network instability on my
side, and I mistakenly thought the previous attempts had not been sent
successfully.

My real name is Jianing Li (李加宁). I sent a v2 with the From and
Signed-off-by fields fixed.

Thanks,
Jianing


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH v2] power: supply: max17040: handle missing status supplier
  2026-07-01  6:10   ` [PATCH v2] " Jianing Li
@ 2026-07-19  5:55     ` Jianing Li
  2026-07-20 22:32     ` Sebastian Reichel
  1 sibling, 0 replies; 7+ messages in thread
From: Jianing Li @ 2026-07-19  5:55 UTC (permalink / raw)
  To: Sebastian Reichel
  Cc: Jianing Li, Iskren Chernev, Krzysztof Kozlowski, Marek Szyprowski,
	Matheus Castello, Greg KH, linux-pm, linux-kernel, stable

Hi,

Gentle ping on this patch.

Thanks,
Jianing


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH v2] power: supply: max17040: handle missing status supplier
  2026-07-01  6:10   ` [PATCH v2] " Jianing Li
  2026-07-19  5:55     ` Jianing Li
@ 2026-07-20 22:32     ` Sebastian Reichel
  1 sibling, 0 replies; 7+ messages in thread
From: Sebastian Reichel @ 2026-07-20 22:32 UTC (permalink / raw)
  To: Sebastian Reichel, Jianing Li
  Cc: Greg KH, Iskren Chernev, Krzysztof Kozlowski, Marek Szyprowski,
	Matheus Castello, linux-pm, linux-kernel, stable


On Wed, 01 Jul 2026 14:10:42 +0800, Jianing Li wrote:
> MAX17040 does not report charger state itself, so the driver forwards
> POWER_SUPPLY_PROP_STATUS to a supplier power supply. If no supplier is
> registered, power_supply_get_property_from_supplier() returns -ENODEV and
> leaves the output value untouched.
> 
> max17040_get_property() currently ignores that error and returns success,
> so userspace can read an uninitialized status value from the battery power
> supply. This happens on systems that use the fuel gauge without a charger
> supplier relationship in firmware.
> 
> [...]

Applied, thanks!

[1/1] power: supply: max17040: handle missing status supplier
      commit: 725668c6b6aa3971fe850659102c250d0d676e18

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


^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2026-07-20 22:32 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-07-01  1:21 [PATCH] power: supply: max17040: handle missing status supplier jianing.li
2026-07-01  5:43 ` Greg KH
2026-07-01  6:10   ` [PATCH v2] " Jianing Li
2026-07-19  5:55     ` Jianing Li
2026-07-20 22:32     ` Sebastian Reichel
2026-07-01  6:52   ` [PATCH] " Jianing Li
  -- strict thread matches above, loose matches on Subject: below --
2026-07-01  1:20 jianing.li

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.