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

regulator: tps65218: Convert to use regulator_get_current_limit_regmap

Use regulator_get_current_limit_regmap helper to save some code.

Signed-off-by: Axel Lin <axel.lin@ingics.com>
Signed-off-by: Mark Brown <broonie@kernel.org>

authored by

Axel Lin and committed by
Mark Brown
7cfcecfb 7c6b8e3b

+19 -29
+19 -29
drivers/regulator/tps65218-regulator.c
··· 29 29 #include <linux/mfd/tps65218.h> 30 30 31 31 #define TPS65218_REGULATOR(_name, _of, _id, _type, _ops, _n, _vr, _vm, _er, \ 32 - _em, _cr, _cm, _lr, _nlr, _delay, _fuv, _sr, _sm) \ 32 + _em, _cr, _cm, _lr, _nlr, _delay, _fuv, _sr, _sm, \ 33 + _ct, _ncl) \ 33 34 { \ 34 35 .name = _name, \ 35 36 .of_match = _of, \ ··· 43 42 .vsel_mask = _vm, \ 44 43 .csel_reg = _cr, \ 45 44 .csel_mask = _cm, \ 45 + .curr_table = _ct, \ 46 + .n_current_limits = _ncl, \ 46 47 .enable_reg = _er, \ 47 48 .enable_mask = _em, \ 48 49 .volt_table = NULL, \ ··· 191 188 .set_suspend_disable = tps65218_pmic_set_suspend_disable, 192 189 }; 193 190 194 - static const int ls3_currents[] = { 100000, 200000, 500000, 1000000 }; 195 - 191 + static const unsigned int ls3_currents[] = { 100000, 200000, 500000, 1000000 }; 196 192 197 193 static int tps65218_pmic_set_input_current_lim(struct regulator_dev *dev, 198 194 int lim_uA) ··· 231 229 TPS65218_PROTECT_L1); 232 230 } 233 231 234 - static int tps65218_pmic_get_current_limit(struct regulator_dev *dev) 235 - { 236 - int retval; 237 - unsigned int index; 238 - struct tps65218 *tps = rdev_get_drvdata(dev); 239 - 240 - retval = regmap_read(tps->regmap, dev->desc->csel_reg, &index); 241 - if (retval < 0) 242 - return retval; 243 - 244 - index = (index & dev->desc->csel_mask) >> 245 - __builtin_ctz(dev->desc->csel_mask); 246 - 247 - return ls3_currents[index]; 248 - } 249 - 250 232 static const struct regulator_ops tps65218_ls23_ops = { 251 233 .is_enabled = regulator_is_enabled_regmap, 252 234 .enable = tps65218_pmic_enable, 253 235 .disable = tps65218_pmic_disable, 254 236 .set_input_current_limit = tps65218_pmic_set_input_current_lim, 255 237 .set_current_limit = tps65218_pmic_set_current_limit, 256 - .get_current_limit = tps65218_pmic_get_current_limit, 238 + .get_current_limit = regulator_get_current_limit_regmap, 257 239 }; 258 240 259 241 /* Operations permitted on DCDC5, DCDC6 */ ··· 256 270 TPS65218_CONTROL_DCDC1_MASK, TPS65218_REG_ENABLE1, 257 271 TPS65218_ENABLE1_DC1_EN, 0, 0, dcdc1_dcdc2_ranges, 258 272 2, 4000, 0, TPS65218_REG_SEQ3, 259 - TPS65218_SEQ3_DC1_SEQ_MASK), 273 + TPS65218_SEQ3_DC1_SEQ_MASK, NULL, 0), 260 274 TPS65218_REGULATOR("DCDC2", "regulator-dcdc2", TPS65218_DCDC_2, 261 275 REGULATOR_VOLTAGE, tps65218_dcdc12_ops, 64, 262 276 TPS65218_REG_CONTROL_DCDC2, 263 277 TPS65218_CONTROL_DCDC2_MASK, TPS65218_REG_ENABLE1, 264 278 TPS65218_ENABLE1_DC2_EN, 0, 0, dcdc1_dcdc2_ranges, 265 279 2, 4000, 0, TPS65218_REG_SEQ3, 266 - TPS65218_SEQ3_DC2_SEQ_MASK), 280 + TPS65218_SEQ3_DC2_SEQ_MASK, NULL, 0), 267 281 TPS65218_REGULATOR("DCDC3", "regulator-dcdc3", TPS65218_DCDC_3, 268 282 REGULATOR_VOLTAGE, tps65218_ldo1_dcdc34_ops, 64, 269 283 TPS65218_REG_CONTROL_DCDC3, 270 284 TPS65218_CONTROL_DCDC3_MASK, TPS65218_REG_ENABLE1, 271 285 TPS65218_ENABLE1_DC3_EN, 0, 0, ldo1_dcdc3_ranges, 2, 272 - 0, 0, TPS65218_REG_SEQ4, TPS65218_SEQ4_DC3_SEQ_MASK), 286 + 0, 0, TPS65218_REG_SEQ4, TPS65218_SEQ4_DC3_SEQ_MASK, 287 + NULL, 0), 273 288 TPS65218_REGULATOR("DCDC4", "regulator-dcdc4", TPS65218_DCDC_4, 274 289 REGULATOR_VOLTAGE, tps65218_ldo1_dcdc34_ops, 53, 275 290 TPS65218_REG_CONTROL_DCDC4, 276 291 TPS65218_CONTROL_DCDC4_MASK, TPS65218_REG_ENABLE1, 277 292 TPS65218_ENABLE1_DC4_EN, 0, 0, dcdc4_ranges, 2, 278 - 0, 0, TPS65218_REG_SEQ4, TPS65218_SEQ4_DC4_SEQ_MASK), 293 + 0, 0, TPS65218_REG_SEQ4, TPS65218_SEQ4_DC4_SEQ_MASK, 294 + NULL, 0), 279 295 TPS65218_REGULATOR("DCDC5", "regulator-dcdc5", TPS65218_DCDC_5, 280 296 REGULATOR_VOLTAGE, tps65218_dcdc56_pmic_ops, 1, -1, 281 297 -1, TPS65218_REG_ENABLE1, TPS65218_ENABLE1_DC5_EN, 0, 282 298 0, NULL, 0, 0, 1000000, TPS65218_REG_SEQ5, 283 - TPS65218_SEQ5_DC5_SEQ_MASK), 299 + TPS65218_SEQ5_DC5_SEQ_MASK, NULL, 0), 284 300 TPS65218_REGULATOR("DCDC6", "regulator-dcdc6", TPS65218_DCDC_6, 285 301 REGULATOR_VOLTAGE, tps65218_dcdc56_pmic_ops, 1, -1, 286 302 -1, TPS65218_REG_ENABLE1, TPS65218_ENABLE1_DC6_EN, 0, 287 303 0, NULL, 0, 0, 1800000, TPS65218_REG_SEQ5, 288 - TPS65218_SEQ5_DC6_SEQ_MASK), 304 + TPS65218_SEQ5_DC6_SEQ_MASK, NULL, 0), 289 305 TPS65218_REGULATOR("LDO1", "regulator-ldo1", TPS65218_LDO_1, 290 306 REGULATOR_VOLTAGE, tps65218_ldo1_dcdc34_ops, 64, 291 307 TPS65218_REG_CONTROL_LDO1, 292 308 TPS65218_CONTROL_LDO1_MASK, TPS65218_REG_ENABLE2, 293 309 TPS65218_ENABLE2_LDO1_EN, 0, 0, ldo1_dcdc3_ranges, 294 310 2, 0, 0, TPS65218_REG_SEQ6, 295 - TPS65218_SEQ6_LDO1_SEQ_MASK), 311 + TPS65218_SEQ6_LDO1_SEQ_MASK, NULL, 0), 296 312 TPS65218_REGULATOR("LS2", "regulator-ls2", TPS65218_LS_2, 297 313 REGULATOR_CURRENT, tps65218_ls23_ops, 0, 0, 0, 298 314 TPS65218_REG_ENABLE2, TPS65218_ENABLE2_LS2_EN, 299 315 TPS65218_REG_CONFIG2, TPS65218_CONFIG2_LS2ILIM_MASK, 300 - NULL, 0, 0, 0, 0, 0), 316 + NULL, 0, 0, 0, 0, 0, ls3_currents, 317 + ARRAY_SIZE(ls3_currents)), 301 318 TPS65218_REGULATOR("LS3", "regulator-ls3", TPS65218_LS_3, 302 319 REGULATOR_CURRENT, tps65218_ls23_ops, 0, 0, 0, 303 320 TPS65218_REG_ENABLE2, TPS65218_ENABLE2_LS3_EN, 304 321 TPS65218_REG_CONFIG2, TPS65218_CONFIG2_LS3ILIM_MASK, 305 - NULL, 0, 0, 0, 0, 0), 322 + NULL, 0, 0, 0, 0, 0, ls3_currents, 323 + ARRAY_SIZE(ls3_currents)), 306 324 }; 307 325 308 326 static int tps65218_regulator_probe(struct platform_device *pdev)