regulator: da9062: Simplify da9062_buck_set_mode for BUCK_MODE_MANUAL case
authorAxel Lin <axel.lin@ingics.com>
Mon, 7 Oct 2019 11:50:09 +0000 (19:50 +0800)
committerMark Brown <broonie@kernel.org>
Tue, 8 Oct 2019 16:27:52 +0000 (17:27 +0100)
The sleep flag bit decides the mode for BUCK_MODE_MANUAL case, simplify
the logic as the result is the same.

Signed-off-by: Axel Lin <axel.lin@ingics.com>
Reviewed-by: Adam Thomson <Adam.Thomson.Opensource@diasemi.com>
Link: https://lore.kernel.org/r/20191007115009.25672-2-axel.lin@ingics.com
Signed-off-by: Mark Brown <broonie@kernel.org>
drivers/regulator/da9062-regulator.c

index 9bb8950..4b24518 100644 (file)
@@ -136,7 +136,7 @@ static int da9062_buck_set_mode(struct regulator_dev *rdev, unsigned mode)
 static unsigned da9062_buck_get_mode(struct regulator_dev *rdev)
 {
        struct da9062_regulator *regl = rdev_get_drvdata(rdev);
-       unsigned int val, mode = 0;
+       unsigned int val;
        int ret;
 
        ret = regmap_field_read(regl->mode, &val);
@@ -146,7 +146,6 @@ static unsigned da9062_buck_get_mode(struct regulator_dev *rdev)
        switch (val) {
        default:
        case BUCK_MODE_MANUAL:
-               mode = REGULATOR_MODE_FAST | REGULATOR_MODE_STANDBY;
                /* Sleep flag bit decides the mode */
                break;
        case BUCK_MODE_SLEEP:
@@ -162,11 +161,9 @@ static unsigned da9062_buck_get_mode(struct regulator_dev *rdev)
                return 0;
 
        if (val)
-               mode &= REGULATOR_MODE_STANDBY;
+               return REGULATOR_MODE_STANDBY;
        else
-               mode &= REGULATOR_MODE_NORMAL | REGULATOR_MODE_FAST;
-
-       return mode;
+               return REGULATOR_MODE_FAST;
 }
 
 /*