Commit 9a767d43 authored by Roel Kluin's avatar Roel Kluin Committed by Liam Girdwood

regulator: Fix check of unsigned return value and transmit errors in wm831x_gp_ldo_get_mode()

If ret is unsigned, the checks for negative wm831x_reg_read() return values
are wrong. The error value should be transmitted to its caller, e.g.
wm831x_gp_ldo_get_status() which tests for a negative return value.
Signed-off-by: default avatarRoel Kluin <roel.kluin@gmail.com>
Acked-by: default avatarMark Brown <broonie@opensource.wolfsonmicro.com>
Signed-off-by: default avatarLiam Girdwood <lrg@slimlogic.co.uk>
parent 60ef66fc
...@@ -175,18 +175,18 @@ static unsigned int wm831x_gp_ldo_get_mode(struct regulator_dev *rdev) ...@@ -175,18 +175,18 @@ static unsigned int wm831x_gp_ldo_get_mode(struct regulator_dev *rdev)
struct wm831x *wm831x = ldo->wm831x; struct wm831x *wm831x = ldo->wm831x;
int ctrl_reg = ldo->base + WM831X_LDO_CONTROL; int ctrl_reg = ldo->base + WM831X_LDO_CONTROL;
int on_reg = ldo->base + WM831X_LDO_ON_CONTROL; int on_reg = ldo->base + WM831X_LDO_ON_CONTROL;
unsigned int ret; int ret;
ret = wm831x_reg_read(wm831x, on_reg); ret = wm831x_reg_read(wm831x, on_reg);
if (ret < 0) if (ret < 0)
return 0; return ret;
if (!(ret & WM831X_LDO1_ON_MODE)) if (!(ret & WM831X_LDO1_ON_MODE))
return REGULATOR_MODE_NORMAL; return REGULATOR_MODE_NORMAL;
ret = wm831x_reg_read(wm831x, ctrl_reg); ret = wm831x_reg_read(wm831x, ctrl_reg);
if (ret < 0) if (ret < 0)
return 0; return ret;
if (ret & WM831X_LDO1_LP_MODE) if (ret & WM831X_LDO1_LP_MODE)
return REGULATOR_MODE_STANDBY; return REGULATOR_MODE_STANDBY;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment