Commit d8eb6fa7 authored by Axel Lin's avatar Axel Lin Committed by Mark Brown

regulator: st-pwm: Convert to get_voltage_sel

Also remove test for selector in st_pwm_regulator_set_voltage_sel, the checking
is already done in .list_voltage.
Signed-off-by: default avatarAxel Lin <axel.lin@ingics.com>
Acked-by: default avatarLee Jones <lee.jones@linaro.org>
Signed-off-by: default avatarMark Brown <broonie@linaro.org>
parent 4a5d3013
...@@ -39,11 +39,11 @@ struct st_pwm_voltages { ...@@ -39,11 +39,11 @@ struct st_pwm_voltages {
unsigned int dutycycle; unsigned int dutycycle;
}; };
static int st_pwm_regulator_get_voltage(struct regulator_dev *dev) static int st_pwm_regulator_get_voltage_sel(struct regulator_dev *dev)
{ {
struct st_pwm_regulator_data *drvdata = rdev_get_drvdata(dev); struct st_pwm_regulator_data *drvdata = rdev_get_drvdata(dev);
return drvdata->pdata->duty_cycle_table[drvdata->state].uV; return drvdata->state;
} }
static int st_pwm_regulator_set_voltage_sel(struct regulator_dev *dev, static int st_pwm_regulator_set_voltage_sel(struct regulator_dev *dev,
...@@ -53,9 +53,6 @@ static int st_pwm_regulator_set_voltage_sel(struct regulator_dev *dev, ...@@ -53,9 +53,6 @@ static int st_pwm_regulator_set_voltage_sel(struct regulator_dev *dev,
int dutycycle; int dutycycle;
int ret; int ret;
if (selector >= dev->desc->n_voltages)
return -EINVAL;
dutycycle = (ST_PWM_REG_PERIOD / 100) * dutycycle = (ST_PWM_REG_PERIOD / 100) *
drvdata->pdata->duty_cycle_table[selector].dutycycle; drvdata->pdata->duty_cycle_table[selector].dutycycle;
...@@ -92,7 +89,7 @@ static int st_pwm_regulator_list_voltage(struct regulator_dev *dev, ...@@ -92,7 +89,7 @@ static int st_pwm_regulator_list_voltage(struct regulator_dev *dev,
static struct regulator_ops st_pwm_regulator_voltage_ops = { static struct regulator_ops st_pwm_regulator_voltage_ops = {
.set_voltage_sel = st_pwm_regulator_set_voltage_sel, .set_voltage_sel = st_pwm_regulator_set_voltage_sel,
.get_voltage = st_pwm_regulator_get_voltage, .get_voltage_sel = st_pwm_regulator_get_voltage_sel,
.list_voltage = st_pwm_regulator_list_voltage, .list_voltage = st_pwm_regulator_list_voltage,
.map_voltage = regulator_map_voltage_iterate, .map_voltage = regulator_map_voltage_iterate,
}; };
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment