Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

regulator: rc5t583: Convert to regulator_list_voltage_linear()

Signed-off-by: Axel Lin <axel.lin@gmail.com>
Acked-by: Laxman Dewangan <ldewangan@nvidia.com>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>

authored by

Axel Lin and committed by
Mark Brown
3209be17 40baecee

+9 -19
+9 -19
drivers/regulator/rc5t583-regulator.c
··· 41 41 uint8_t deepsleep_reg; 42 42 43 43 /* Chip constraints on regulator behavior */ 44 - int min_uV; 45 44 int max_uV; 46 - int step_uV; 47 45 48 46 /* Regulator specific turn-on delay and voltage settling time*/ 49 47 int enable_uv_per_us; ··· 60 62 struct regulator_dev *rdev; 61 63 }; 62 64 63 - static int rc5t583_list_voltage(struct regulator_dev *rdev, unsigned selector) 64 - { 65 - struct rc5t583_regulator *reg = rdev_get_drvdata(rdev); 66 - struct rc5t583_regulator_info *ri = reg->reg_info; 67 - return ri->min_uV + (ri->step_uV * selector); 68 - } 69 - 70 65 static int rc5t583_set_voltage(struct regulator_dev *rdev, 71 66 int min_uV, int max_uV, unsigned *selector) 72 67 { 73 68 struct rc5t583_regulator *reg = rdev_get_drvdata(rdev); 74 - struct rc5t583_regulator_info *ri = reg->reg_info; 75 69 int sel, ret; 76 70 77 - if (min_uV < ri->min_uV) 78 - min_uV = ri->min_uV; 71 + if (min_uV < rdev->desc->min_uV) 72 + min_uV = rdev->desc->min_uV; 79 73 80 - sel = DIV_ROUND_UP(min_uV - ri->min_uV, ri->step_uV); 74 + sel = DIV_ROUND_UP(min_uV - rdev->desc->min_uV, rdev->desc->uV_step); 81 75 82 76 if (sel >= rdev->desc->n_voltages) { 83 77 dev_err(&rdev->dev, "Invalid selector 0x%02x\n", sel); ··· 90 100 { 91 101 struct rc5t583_regulator *reg = rdev_get_drvdata(rdev); 92 102 int vsel = regulator_get_voltage_sel_regmap(rdev); 93 - int curr_uV = rc5t583_list_voltage(rdev, vsel); 103 + int curr_uV = regulator_list_voltage_linear(rdev, vsel); 94 104 95 105 return DIV_ROUND_UP(curr_uV, reg->reg_info->enable_uv_per_us); 96 106 } ··· 100 110 { 101 111 struct rc5t583_regulator *reg = rdev_get_drvdata(rdev); 102 112 int old_uV, new_uV; 103 - old_uV = rc5t583_list_voltage(rdev, old_selector); 113 + old_uV = regulator_list_voltage_linear(rdev, old_selector); 104 114 105 115 if (old_uV < 0) 106 116 return old_uV; 107 117 108 - new_uV = rc5t583_list_voltage(rdev, new_selector); 118 + new_uV = regulator_list_voltage_linear(rdev, new_selector); 109 119 if (new_uV < 0) 110 120 return new_uV; 111 121 ··· 121 131 .enable_time = rc5t583_regulator_enable_time, 122 132 .get_voltage_sel = regulator_get_voltage_sel_regmap, 123 133 .set_voltage = rc5t583_set_voltage, 124 - .list_voltage = rc5t583_list_voltage, 134 + .list_voltage = regulator_list_voltage_linear, 125 135 .set_voltage_time_sel = rc5t583_set_voltage_time_sel, 126 136 }; 127 137 ··· 131 141 .reg_disc_reg = RC5T583_REG_##_disc_reg, \ 132 142 .disc_bit = _disc_bit, \ 133 143 .deepsleep_reg = RC5T583_REG_##_id##DAC_DS, \ 134 - .min_uV = _min_mv * 1000, \ 135 144 .max_uV = _max_mv * 1000, \ 136 - .step_uV = _step_uV, \ 137 145 .enable_uv_per_us = _enable_mv * 1000, \ 138 146 .change_uv_per_us = 40 * 1000, \ 139 147 .deepsleep_id = RC5T583_DS_##_id, \ ··· 146 158 .vsel_mask = _vout_mask, \ 147 159 .enable_reg = RC5T583_REG_##_en_reg, \ 148 160 .enable_mask = BIT(_en_bit), \ 161 + .min_uV = _min_mv * 1000, \ 162 + .uV_step = _step_uV, \ 149 163 }, \ 150 164 } 151 165