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

regulator: lp3972: Convert to get_voltage_sel

regulator_list_voltage_table() returns -EINVAL if selector >= n_voltages.
Thus we don't need to check if reg is greater than LP3972_BUCK_VOL_MAX_IDX in
lp3972_[ldo|dcdc]_get_voltage_sel.

LP3972_BUCK_VOL_MIN_IDX and LP3972_BUCK_VOL_MAX_IDX are not used, remove them.

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

authored by

Axel Lin and committed by
Mark Brown
c8c14a39 d1c3ed66

+6 -16
+6 -16
drivers/regulator/lp3972.c
··· 165 165 #define LP3972_BUCK_VOL_ENABLE_REG(x) (buck_vol_enable_addr[x]) 166 166 #define LP3972_BUCK_VOL1_REG(x) (buck_base_addr[x]) 167 167 #define LP3972_BUCK_VOL_MASK 0x1f 168 - #define LP3972_BUCK_VOL_MIN_IDX(x) ((x) ? 0x01 : 0x00) 169 - #define LP3972_BUCK_VOL_MAX_IDX(x) ((x) ? 0x19 : 0x1f) 170 168 171 169 static int lp3972_i2c_read(struct i2c_client *i2c, char reg, int count, 172 170 u16 *dest) ··· 255 257 mask, 0); 256 258 } 257 259 258 - static int lp3972_ldo_get_voltage(struct regulator_dev *dev) 260 + static int lp3972_ldo_get_voltage_sel(struct regulator_dev *dev) 259 261 { 260 262 struct lp3972 *lp3972 = rdev_get_drvdata(dev); 261 263 int ldo = rdev_get_id(dev) - LP3972_LDO1; ··· 265 267 reg = lp3972_reg_read(lp3972, LP3972_LDO_VOL_CONTR_REG(ldo)); 266 268 val = (reg >> LP3972_LDO_VOL_CONTR_SHIFT(ldo)) & mask; 267 269 268 - return dev->desc->volt_table[val]; 270 + return val; 269 271 } 270 272 271 273 static int lp3972_ldo_set_voltage_sel(struct regulator_dev *dev, ··· 312 314 .is_enabled = lp3972_ldo_is_enabled, 313 315 .enable = lp3972_ldo_enable, 314 316 .disable = lp3972_ldo_disable, 315 - .get_voltage = lp3972_ldo_get_voltage, 317 + .get_voltage_sel = lp3972_ldo_get_voltage_sel, 316 318 .set_voltage_sel = lp3972_ldo_set_voltage_sel, 317 319 }; 318 320 ··· 351 353 return val; 352 354 } 353 355 354 - static int lp3972_dcdc_get_voltage(struct regulator_dev *dev) 356 + static int lp3972_dcdc_get_voltage_sel(struct regulator_dev *dev) 355 357 { 356 358 struct lp3972 *lp3972 = rdev_get_drvdata(dev); 357 359 int buck = rdev_get_id(dev) - LP3972_DCDC1; 358 360 u16 reg; 359 - int val; 360 361 361 362 reg = lp3972_reg_read(lp3972, LP3972_BUCK_VOL1_REG(buck)); 362 363 reg &= LP3972_BUCK_VOL_MASK; 363 - if (reg <= LP3972_BUCK_VOL_MAX_IDX(buck)) 364 - val = dev->desc->volt_table[reg]; 365 - else { 366 - val = 0; 367 - dev_warn(&dev->dev, "chip reported incorrect voltage value." 368 - " reg = %d\n", reg); 369 - } 370 364 371 - return val; 365 + return reg; 372 366 } 373 367 374 368 static int lp3972_dcdc_set_voltage_sel(struct regulator_dev *dev, ··· 392 402 .is_enabled = lp3972_dcdc_is_enabled, 393 403 .enable = lp3972_dcdc_enable, 394 404 .disable = lp3972_dcdc_disable, 395 - .get_voltage = lp3972_dcdc_get_voltage, 405 + .get_voltage_sel = lp3972_dcdc_get_voltage_sel, 396 406 .set_voltage_sel = lp3972_dcdc_set_voltage_sel, 397 407 }; 398 408