mirror of https://github.com/torvalds/linux.git
power: supply: wm831x: Check wm831x_set_bits() return value
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: 626b6cd5f5 ("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>
This commit is contained in:
parent
15aca30cc6
commit
ea14bae6df
|
|
@ -144,6 +144,7 @@ static int wm831x_usb_limit_change(struct notifier_block *nb,
|
||||||
struct wm831x_power,
|
struct wm831x_power,
|
||||||
usb_notify);
|
usb_notify);
|
||||||
unsigned int i, best;
|
unsigned int i, best;
|
||||||
|
int ret;
|
||||||
|
|
||||||
/* Find the highest supported limit */
|
/* Find the highest supported limit */
|
||||||
best = 0;
|
best = 0;
|
||||||
|
|
@ -156,8 +157,13 @@ static int wm831x_usb_limit_change(struct notifier_block *nb,
|
||||||
dev_dbg(wm831x_power->wm831x->dev,
|
dev_dbg(wm831x_power->wm831x->dev,
|
||||||
"Limiting USB current to %umA", wm831x_usb_limits[best]);
|
"Limiting USB current to %umA", wm831x_usb_limits[best]);
|
||||||
|
|
||||||
wm831x_set_bits(wm831x_power->wm831x, WM831X_POWER_STATE,
|
ret = wm831x_set_bits(wm831x_power->wm831x, WM831X_POWER_STATE,
|
||||||
WM831X_USB_ILIM_MASK, best);
|
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;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue