]> Gentwo Git Trees - linux/.git/commitdiff
power: supply: wm831x: Check wm831x_set_bits() return value
authorIvan Abramov <i.abramov@mt-integration.ru>
Thu, 9 Oct 2025 17:05:52 +0000 (20:05 +0300)
committerSebastian Reichel <sebastian.reichel@collabora.com>
Mon, 3 Nov 2025 00:01:57 +0000 (01:01 +0100)
Since wm831x_set_bits() may return error, log failure and exit from
wm831x_usb_limit_change() in such case.

Found by Linux Verification Center (linuxtesting.org) with SVACE.

Fixes: 626b6cd5f52e ("power: wm831x_power: Support USB charger current limit management")
Signed-off-by: Ivan Abramov <i.abramov@mt-integration.ru>
Link: https://patch.msgid.link/20251009170553.566561-1-i.abramov@mt-integration.ru
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
drivers/power/supply/wm831x_power.c

index 6acdba7885ca5741a9658b4c8f4f55c5566b5388..78fa0573ef25c726b041082e8ce99b94654c1650 100644 (file)
@@ -144,6 +144,7 @@ static int wm831x_usb_limit_change(struct notifier_block *nb,
                                                         struct wm831x_power,
                                                         usb_notify);
        unsigned int i, best;
+       int ret;
 
        /* Find the highest supported limit */
        best = 0;
@@ -156,8 +157,13 @@ static int wm831x_usb_limit_change(struct notifier_block *nb,
        dev_dbg(wm831x_power->wm831x->dev,
                "Limiting USB current to %umA", wm831x_usb_limits[best]);
 
-       wm831x_set_bits(wm831x_power->wm831x, WM831X_POWER_STATE,
-                       WM831X_USB_ILIM_MASK, best);
+       ret = wm831x_set_bits(wm831x_power->wm831x, WM831X_POWER_STATE,
+                             WM831X_USB_ILIM_MASK, best);
+       if (ret < 0) {
+               dev_err(wm831x_power->wm831x->dev,
+                       "Failed to set USB current limit: %d\n", ret);
+               return ret;
+       }
 
        return 0;
 }