Commit c8c14a393ba3329552147870103f2d004bbcbcac

Authored by Axel Lin
Committed by Mark Brown
1 parent d1c3ed669a

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>

Showing 1 changed file with 6 additions and 16 deletions Side-by-side Diff

drivers/regulator/lp3972.c
... ... @@ -165,8 +165,6 @@
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)
... ... @@ -257,7 +255,7 @@
257 255 mask, 0);
258 256 }
259 257  
260   -static int lp3972_ldo_get_voltage(struct regulator_dev *dev)
  258 +static int lp3972_ldo_get_voltage_sel(struct regulator_dev *dev)
261 259 {
262 260 struct lp3972 *lp3972 = rdev_get_drvdata(dev);
263 261 int ldo = rdev_get_id(dev) - LP3972_LDO1;
... ... @@ -267,7 +265,7 @@
267 265 reg = lp3972_reg_read(lp3972, LP3972_LDO_VOL_CONTR_REG(ldo));
268 266 val = (reg >> LP3972_LDO_VOL_CONTR_SHIFT(ldo)) & mask;
269 267  
270   - return dev->desc->volt_table[val];
  268 + return val;
271 269 }
272 270  
273 271 static int lp3972_ldo_set_voltage_sel(struct regulator_dev *dev,
... ... @@ -314,7 +312,7 @@
314 312 .is_enabled = lp3972_ldo_is_enabled,
315 313 .enable = lp3972_ldo_enable,
316 314 .disable = lp3972_ldo_disable,
317   - .get_voltage = lp3972_ldo_get_voltage,
  315 + .get_voltage_sel = lp3972_ldo_get_voltage_sel,
318 316 .set_voltage_sel = lp3972_ldo_set_voltage_sel,
319 317 };
320 318  
321 319  
322 320  
323 321  
... ... @@ -353,24 +351,16 @@
353 351 return val;
354 352 }
355 353  
356   -static int lp3972_dcdc_get_voltage(struct regulator_dev *dev)
  354 +static int lp3972_dcdc_get_voltage_sel(struct regulator_dev *dev)
357 355 {
358 356 struct lp3972 *lp3972 = rdev_get_drvdata(dev);
359 357 int buck = rdev_get_id(dev) - LP3972_DCDC1;
360 358 u16 reg;
361   - int val;
362 359  
363 360 reg = lp3972_reg_read(lp3972, LP3972_BUCK_VOL1_REG(buck));
364 361 reg &= LP3972_BUCK_VOL_MASK;
365   - if (reg <= LP3972_BUCK_VOL_MAX_IDX(buck))
366   - val = dev->desc->volt_table[reg];
367   - else {
368   - val = 0;
369   - dev_warn(&dev->dev, "chip reported incorrect voltage value."
370   - " reg = %d\n", reg);
371   - }
372 362  
373   - return val;
  363 + return reg;
374 364 }
375 365  
376 366 static int lp3972_dcdc_set_voltage_sel(struct regulator_dev *dev,
... ... @@ -402,7 +392,7 @@
402 392 .is_enabled = lp3972_dcdc_is_enabled,
403 393 .enable = lp3972_dcdc_enable,
404 394 .disable = lp3972_dcdc_disable,
405   - .get_voltage = lp3972_dcdc_get_voltage,
  395 + .get_voltage_sel = lp3972_dcdc_get_voltage_sel,
406 396 .set_voltage_sel = lp3972_dcdc_set_voltage_sel,
407 397 };
408 398