* [PATCH] power: supply: sysfs: Ratelimit "unavailable enum value" warning
@ 2026-10-05 13:56 Robert Killick via B4 Relay
0 siblings, 0 replies; only message in thread
From: Robert Killick via B4 Relay @ 2026-10-05 13:56 UTC (permalink / raw)
To: Sebastian Reichel; +Cc: linux-pm, linux-kernel, Robert Killick
From: Robert Killick <robert@killick.dev>
power_supply_show_enum_with_available() warns every time a driver
reports a value that is not in its declared set of available values.
For usb_type this happens on every sysfs read and on every uevent, so a
driver that reports such a value and calls power_supply_changed()
frequently can flood the kernel log.
This can happen with drivers that pass a firmware-provided value
through unchanged, as qcom_battmgr does for usb_type. On a OnePlus 10
Pro (SM8450), whose firmware reports a vendor-specific usb_type, this
produced ~128 warnings per second and kept systemd-journald at ~30% CPU.
The bug that causes the bad value needs fixing in the driver itself,
but one misbehaving driver should not be able to flood the kernel log.
Use dev_warn_ratelimited(), as power_supply_show_property() already
does for its own errors, so the problem is still reported, just not on
every read.
Signed-off-by: Robert Killick <robert@killick.dev>
---
drivers/power/supply/power_supply_sysfs.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/drivers/power/supply/power_supply_sysfs.c b/drivers/power/supply/power_supply_sysfs.c
index b0f524d152cf..9704557ffe1d 100644
--- a/drivers/power/supply/power_supply_sysfs.c
+++ b/drivers/power/supply/power_supply_sysfs.c
@@ -310,7 +310,8 @@ static ssize_t power_supply_show_enum_with_available(
}
if (!match) {
- dev_warn(dev, "driver reporting unavailable enum value %d\n", value);
+ dev_warn_ratelimited(dev, "driver reporting unavailable enum value %d\n",
+ value);
return -EINVAL;
}
---
base-commit: 4fc88ba435dadbc05990951e3f3fbd8ccd2df140
change-id: 20261002-ratelimit-enum-warn-f360abcae8be
Best regards,
--
Robert Killick <robert@killick.dev>
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2026-10-05 13:56 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-10-05 13:56 [PATCH] power: supply: sysfs: Ratelimit "unavailable enum value" warning Robert Killick via B4 Relay
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®