regulator: wm831x-ldo: Check return value of wm831x_reg_read()
authorAxel Lin <axel.lin@gmail.com>
Tue, 31 Jul 2012 13:28:26 +0000 (21:28 +0800)
committerMark Brown <broonie@opensource.wolfsonmicro.com>
Tue, 28 Aug 2012 18:00:25 +0000 (11:00 -0700)
wm831x_reg_read() returns negative error code on failure.
This prevents using the error code as the value read.

Signed-off-by: Axel Lin <axel.lin@gmail.com>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
drivers/regulator/wm831x-ldo.c

index 5cb70ca1e98d1f1843347fe14d7291d7a041eceb..56a6de3dd8834022fd68add8feea2fa43ce283f2 100644 (file)
@@ -205,6 +205,8 @@ static int wm831x_gp_ldo_get_status(struct regulator_dev *rdev)
 
        /* Is it reporting under voltage? */
        ret = wm831x_reg_read(wm831x, WM831X_LDO_UV_STATUS);
+       if (ret < 0)
+               return ret;
        if (ret & mask)
                return REGULATOR_STATUS_ERROR;
 
@@ -469,6 +471,8 @@ static int wm831x_aldo_get_status(struct regulator_dev *rdev)
 
        /* Is it reporting under voltage? */
        ret = wm831x_reg_read(wm831x, WM831X_LDO_UV_STATUS);
+       if (ret < 0)
+               return ret;
        if (ret & mask)
                return REGULATOR_STATUS_ERROR;