diff options
author | Antti P Miettinen <amiettinen@nvidia.com> | 2011-10-18 18:24:25 +0300 |
---|---|---|
committer | Dan Willemsen <dwillemsen@nvidia.com> | 2011-11-30 21:49:26 -0800 |
commit | 2e156d3288a8d5086ee828602e21efa7bce566d2 (patch) | |
tree | f1f313d5e982d38fbce0b65e8a20a4372bf3db69 /drivers/regulator/tps6591x-regulator.c | |
parent | 753cdc02611cd5792dcee1b805b470aceae9f28d (diff) |
regulator: tps6591x: Fix set_voltage to return selector value
Current regulator_ops interface expects selector value to be returned.
Not doing so results in uninitialized variables used.
Bug 886170
Change-Id: I004ee168eb0f003eb71c36d5fcd6c8106a1fc054
Reviewed-on: http://git-master/r/56648
Reviewed-by: Antti Miettinen <amiettinen@nvidia.com>
Tested-by: Antti Miettinen <amiettinen@nvidia.com>
Reviewed-by: Yu-Huan Hsu <yhsu@nvidia.com>
Rebase-Id: R5fa05ad3dc7cda25b634efbf956ae99280bab40d
Diffstat (limited to 'drivers/regulator/tps6591x-regulator.c')
-rw-r--r-- | drivers/regulator/tps6591x-regulator.c | 55 |
1 files changed, 38 insertions, 17 deletions
diff --git a/drivers/regulator/tps6591x-regulator.c b/drivers/regulator/tps6591x-regulator.c index 87689d70fafa..6a4dba8a997e 100644 --- a/drivers/regulator/tps6591x-regulator.c +++ b/drivers/regulator/tps6591x-regulator.c @@ -174,7 +174,8 @@ static void wait_for_voltage_change(struct tps6591x_regulator *ri, int uV) static int __tps6591x_vio_set_voltage(struct device *parent, struct tps6591x_regulator *ri, - int min_uV, int max_uV) + int min_uV, int max_uV, + unsigned *selector) { int uV; uint8_t mask; @@ -187,6 +188,8 @@ static int __tps6591x_vio_set_voltage(struct device *parent, /* use the first in-range value */ if (min_uV <= uV && uV <= max_uV) { + if (selector) + *selector = val; reg_val = ri->supply_reg.cache_val; val <<= ri->supply_reg.shift_bits; @@ -209,12 +212,14 @@ static int __tps6591x_vio_set_voltage(struct device *parent, } static int tps6591x_vio_set_voltage(struct regulator_dev *rdev, - int min_uV, int max_uV) + int min_uV, int max_uV, + unsigned *selector) { struct tps6591x_regulator *ri = rdev_get_drvdata(rdev); struct device *parent = to_tps6591x_dev(rdev); - return __tps6591x_vio_set_voltage(parent, ri, min_uV, max_uV); + return __tps6591x_vio_set_voltage(parent, ri, min_uV, max_uV, + selector); } static int tps6591x_vio_get_voltage(struct regulator_dev *rdev) @@ -243,8 +248,9 @@ static int tps6591x_ldo_list_voltage(struct regulator_dev *rdev, } static int __tps6591x_ldo1_set_voltage(struct device *parent, - struct tps6591x_regulator *ri, - int min_uV, int max_uV) + struct tps6591x_regulator *ri, + int min_uV, int max_uV, + unsigned *selector) { int val, uV; uint8_t mask; @@ -256,6 +262,8 @@ static int __tps6591x_ldo1_set_voltage(struct device *parent, /* use the first in-range value */ if (min_uV <= uV && uV <= max_uV) { + if (selector) + *selector = val; reg_val = ri->supply_reg.cache_val; val += 4; val <<= ri->supply_reg.shift_bits; @@ -277,12 +285,14 @@ static int __tps6591x_ldo1_set_voltage(struct device *parent, } static int tps6591x_ldo1_set_voltage(struct regulator_dev *rdev, - int min_uV, int max_uV) + int min_uV, int max_uV, + unsigned *selector) { struct tps6591x_regulator *ri = rdev_get_drvdata(rdev); struct device *parent = to_tps6591x_dev(rdev); - return __tps6591x_ldo1_set_voltage(parent, ri, min_uV, max_uV); + return __tps6591x_ldo1_set_voltage(parent, ri, min_uV, max_uV, + selector); } static int tps6591x_ldo1_get_voltage(struct regulator_dev *rdev) @@ -307,7 +317,9 @@ static int tps6591x_ldo1_get_voltage(struct regulator_dev *rdev) } static int __tps6591x_ldo3_set_voltage(struct device *parent, - struct tps6591x_regulator *ri, int min_uV, int max_uV) + struct tps6591x_regulator *ri, + int min_uV, int max_uV, + unsigned *selector) { int val, uV; uint8_t mask; @@ -319,6 +331,8 @@ static int __tps6591x_ldo3_set_voltage(struct device *parent, /* use the first in-range value */ if (min_uV <= uV && uV <= max_uV) { + if (selector) + *selector = val; reg_val = ri->supply_reg.cache_val; val += 2; val <<= ri->supply_reg.shift_bits; @@ -341,12 +355,14 @@ static int __tps6591x_ldo3_set_voltage(struct device *parent, } static int tps6591x_ldo3_set_voltage(struct regulator_dev *rdev, - int min_uV, int max_uV) + int min_uV, int max_uV, + unsigned *selector) { struct tps6591x_regulator *ri = rdev_get_drvdata(rdev); struct device *parent = to_tps6591x_dev(rdev); - return __tps6591x_ldo3_set_voltage(parent, ri, min_uV, max_uV); + return __tps6591x_ldo3_set_voltage(parent, ri, min_uV, max_uV, + selector); } static int tps6591x_ldo3_get_voltage(struct regulator_dev *rdev) @@ -372,7 +388,8 @@ static int tps6591x_ldo3_get_voltage(struct regulator_dev *rdev) static int __tps6591x_vdd_set_voltage(struct device *parent, struct tps6591x_regulator *ri, - int min_uV, int max_uV) + int min_uV, int max_uV, + unsigned *selector) { int val, uV, ret; uint8_t mask; @@ -384,6 +401,8 @@ static int __tps6591x_vdd_set_voltage(struct device *parent, /* use the first in-range value */ if (min_uV <= uV && uV <= max_uV) { + if (selector) + *selector = val; op_reg_val = ri->op_reg.cache_val; val += 3; if (op_reg_val & 0x80) { @@ -418,12 +437,14 @@ static int __tps6591x_vdd_set_voltage(struct device *parent, } static int tps6591x_vdd_set_voltage(struct regulator_dev *rdev, - int min_uV, int max_uV) + int min_uV, int max_uV, + unsigned *selector) { struct tps6591x_regulator *ri = rdev_get_drvdata(rdev); struct device *parent = to_tps6591x_dev(rdev); - return __tps6591x_vdd_set_voltage(parent, ri, min_uV, max_uV); + return __tps6591x_vdd_set_voltage(parent, ri, min_uV, max_uV, + selector); } static int tps6591x_vdd_get_voltage(struct regulator_dev *rdev) @@ -700,7 +721,7 @@ static inline int tps6591x_regulator_preinit(struct device *parent, case TPS6591X_ID_VIO: ret = __tps6591x_vio_set_voltage(parent, ri, tps6591x_pdata->init_uV, - tps6591x_pdata->init_uV); + tps6591x_pdata->init_uV, 0); break; case TPS6591X_ID_LDO_1: @@ -708,7 +729,7 @@ static inline int tps6591x_regulator_preinit(struct device *parent, case TPS6591X_ID_LDO_4: ret = __tps6591x_ldo1_set_voltage(parent, ri, tps6591x_pdata->init_uV, - tps6591x_pdata->init_uV); + tps6591x_pdata->init_uV, 0); break; case TPS6591X_ID_LDO_3: @@ -718,7 +739,7 @@ static inline int tps6591x_regulator_preinit(struct device *parent, case TPS6591X_ID_LDO_8: ret = __tps6591x_ldo3_set_voltage(parent, ri, tps6591x_pdata->init_uV, - tps6591x_pdata->init_uV); + tps6591x_pdata->init_uV, 0); break; case TPS6591X_ID_VDD_1: @@ -726,7 +747,7 @@ static inline int tps6591x_regulator_preinit(struct device *parent, case TPS6591X_ID_VDDCTRL: ret = __tps6591x_vdd_set_voltage(parent, ri, tps6591x_pdata->init_uV, - tps6591x_pdata->init_uV); + tps6591x_pdata->init_uV, 0); break; default: |