Skip to content

Commit

Permalink
regulator: rk808: Use rdev_get_id() to access id of regulator
Browse files Browse the repository at this point in the history
RK808_ID_DCDC1 is 0, no need to do subtract RK808_ID_DCDC1.

Signed-off-by: Axel Lin <axel.lin@ingics.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
  • Loading branch information
Axel Lin authored and Mark Brown committed Oct 24, 2016
1 parent 1001354 commit bf8e276
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions drivers/regulator/rk808-regulator.c
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ static const struct regulator_linear_range rk808_ldo3_voltage_ranges[] = {
static int rk808_buck1_2_get_voltage_sel_regmap(struct regulator_dev *rdev)
{
struct rk808_regulator_data *pdata = rdev_get_drvdata(rdev);
int id = rdev->desc->id - RK808_ID_DCDC1;
int id = rdev_get_id(rdev);
struct gpio_desc *gpio = pdata->dvs_gpio[id];
unsigned int val;
int ret;
Expand Down Expand Up @@ -193,7 +193,7 @@ static int rk808_buck1_2_set_voltage_sel(struct regulator_dev *rdev,
unsigned sel)
{
struct rk808_regulator_data *pdata = rdev_get_drvdata(rdev);
int id = rdev->desc->id - RK808_ID_DCDC1;
int id = rdev_get_id(rdev);
struct gpio_desc *gpio = pdata->dvs_gpio[id];
unsigned int reg = rdev->desc->vsel_reg;
unsigned old_sel;
Expand Down Expand Up @@ -232,7 +232,7 @@ static int rk808_buck1_2_set_voltage_time_sel(struct regulator_dev *rdev,
unsigned int new_selector)
{
struct rk808_regulator_data *pdata = rdev_get_drvdata(rdev);
int id = rdev->desc->id - RK808_ID_DCDC1;
int id = rdev_get_id(rdev);
struct gpio_desc *gpio = pdata->dvs_gpio[id];

/* if there is no dvs1/2 pin, we don't need wait extra time here. */
Expand All @@ -245,8 +245,7 @@ static int rk808_buck1_2_set_voltage_time_sel(struct regulator_dev *rdev,
static int rk808_set_ramp_delay(struct regulator_dev *rdev, int ramp_delay)
{
unsigned int ramp_value = RK808_RAMP_RATE_10MV_PER_US;
unsigned int reg = rk808_buck_config_regs[rdev->desc->id -
RK808_ID_DCDC1];
unsigned int reg = rk808_buck_config_regs[rdev_get_id(rdev)];

switch (ramp_delay) {
case 1 ... 2000:
Expand Down

0 comments on commit bf8e276

Please sign in to comment.