regulator: max8925: Convert to get_voltage_sel
PATCH 1/3 regulator: max8925: Convert to get_voltage_sel
Signed-off-by Axel Lin <[email protected]>
--- drivers/regulator/max8925-regulator.c | 8 ++++---- 1 files changed, 4 insertions(+), 4 deletions(-)
drivers/regulator/max8925-regulator.c +4 -4
@@ -78,7 +78,7 @@ static int max8925_set_voltage(struct regulator_dev *rdev,return max8925_set_bits (info->i2c, info->vol_reg, mask, data); } -static int max8925_get_voltage (struct regulator_dev *rdev) +static int max8925_get_voltage_sel (struct regulator_dev *rdev) {struct max8925_regulator_info *info =rdev_get_drvdata (rdev);unsigned char data, mask;
@@ -90,7 +90,7 @@ static int max8925_get_voltage(struct regulator_dev *rdev) mask = rdev->desc->n_voltages -1 ; data = ret & mask; -return max8925_list_voltage (rdev, data); +return data; }static int max8925_enable (struct regulator_dev *rdev)
@@ -162,7 +162,7 @@ static int max8925_set_dvm_disable(struct regulator_dev *rdev)static struct regulator_ops max8925_regulator_sdv_ops = { .list_voltage = max8925_list_voltage, .set_voltage = max8925_set_voltage, - .get_voltage = max8925_get_voltage, + .get_voltage_sel = max8925_get_voltage_sel, .enable = max8925_enable, .disable = max8925_disable, .is_enabled = max8925_is_enabled,
@@ -174,7 +174,7 @@ static struct regulator_ops max8925_regulator_sdv_ops = {static struct regulator_ops max8925_regulator_ldo_ops = { .list_voltage = max8925_list_voltage, .set_voltage = max8925_set_voltage, - .get_voltage = max8925_get_voltage, + .get_voltage_sel = max8925_get_voltage_sel, .enable = max8925_enable, .disable = max8925_disable, .is_enabled = max8925_is_enabled,
Signature · 1 line
1.7.5.4
PATCH 2/3 regulator: max8925: Convert to regulator_list_voltage_linear()
Signed-off-by Axel Lin <[email protected]>
--- drivers/regulator/max8925-regulator.c | 25 ++++++++----------------- 1 files changed, 8 insertions(+), 17 deletions(-)
drivers/regulator/max8925-regulator.c +8 -17
@@ -38,9 +38,7 @@ struct max8925_regulator_info {struct i2c_client *i2c;struct max8925_chip *chip; -int min_uV;int max_uV; -int step_uV;int vol_reg;int enable_reg; };
@@ -48,18 +46,12 @@ struct max8925_regulator_info {static inline int check_range (struct max8925_regulator_info *info,int min_uV,int max_uV) { -if (min_uV < info->min_uV || min_uV > info->max_uV) +if (min_uV < info->desc.min_uV || min_uV > info->max_uV)return -EINVAL ;return 0 ; } -static int max8925_list_voltage (struct regulator_dev *rdev,unsigned index) -{ -struct max8925_regulator_info *info =rdev_get_drvdata (rdev); -return info->min_uV + index * info->step_uV; -} -static int max8925_set_voltage (struct regulator_dev *rdev,int min_uV,int max_uV,unsigned int *selector) {
@@ -71,7 +63,7 @@ static int max8925_set_voltage(struct regulator_dev *rdev, min_uV, max_uV);return -EINVAL ; } - data =DIV_ROUND_UP (min_uV - info->min_uV, info->step_uV); + data =DIV_ROUND_UP (min_uV - info->desc.min_uV, info->desc.uV_step); *selector = data; mask = rdev->desc->n_voltages -1 ;
@@ -160,7 +152,7 @@ static int max8925_set_dvm_disable(struct regulator_dev *rdev) }static struct regulator_ops max8925_regulator_sdv_ops = { - .list_voltage = max8925_list_voltage, + .list_voltage = regulator_list_voltage_linear, .set_voltage = max8925_set_voltage, .get_voltage_sel = max8925_get_voltage_sel, .enable = max8925_enable,
@@ -172,7 +164,7 @@ static struct regulator_ops max8925_regulator_sdv_ops = { };static struct regulator_ops max8925_regulator_ldo_ops = { - .list_voltage = max8925_list_voltage, + .list_voltage = regulator_list_voltage_linear, .set_voltage = max8925_set_voltage, .get_voltage_sel = max8925_get_voltage_sel, .enable = max8925_enable,
@@ -189,10 +181,10 @@ static struct regulator_ops max8925_regulator_ldo_ops = { .id = MAX8925_ID_SD##_id, \ .owner = THIS_MODULE, \ .n_voltages = 64, \ + .min_uV = min * 1000, \ + .uV_step = step * 1000, \ }, \ - .min_uV = min * 1000, \ .max_uV = max * 1000, \ - .step_uV = step * 1000, \ .vol_reg = MAX8925_SDV##_id, \ .enable_reg = MAX8925_SDCTL##_id, \ }
@@ -206,10 +198,10 @@ static struct regulator_ops max8925_regulator_ldo_ops = { .id = MAX8925_ID_LDO##_id, \ .owner = THIS_MODULE, \ .n_voltages = 64, \ + .min_uV = min * 1000, \ + .uV_step = step * 1000, \ }, \ - .min_uV = min * 1000, \ .max_uV = max * 1000, \ - .step_uV = step * 1000, \ .vol_reg = MAX8925_LDOVOUT##_id, \ .enable_reg = MAX8925_LDOCTL##_id, \ }
@@ -320,4 +312,3 @@ MODULE_LICENSE("GPL");MODULE_AUTHOR ("Haojian Zhuang <[email protected]>" );MODULE_DESCRIPTION ("Regulator Driver for Maxim 8925 PMIC" );MODULE_ALIAS ("platform:max8925-regulator" ); -
Signature · 1 line
1.7.5.4
PATCH 3/3 regulator: max8925: Convert to set_voltage_sel() and map_voltage()
In reply to Axel LinSigned-off-by Axel Lin <[email protected]>
--- drivers/regulator/max8925-regulator.c | 23 ++++++++--------------- 1 files changed, 8 insertions(+), 15 deletions(-)
drivers/regulator/max8925-regulator.c +8 -15
@@ -52,22 +52,13 @@ static inline int check_range(struct max8925_regulator_info *info,return 0 ; } -static int max8925_set_voltage (struct regulator_dev *rdev, -int min_uV,int max_uV,unsigned int *selector) +static int max8925_set_voltage_sel (struct regulator_dev *rdev, +unsigned int selector) {struct max8925_regulator_info *info =rdev_get_drvdata (rdev); -unsigned char data, mask; - -if (check_range (info, min_uV, max_uV)) { -dev_err (info->chip->dev,"invalid voltage range (%d, %d) uV\n" , - min_uV, max_uV); -return -EINVAL ; - } - data =DIV_ROUND_UP (min_uV - info->desc.min_uV, info->desc.uV_step); - *selector = data; - mask = rdev->desc->n_voltages -1 ; +unsigned char mask = rdev->desc->n_voltages -1 ; -return max8925_set_bits (info->i2c, info->vol_reg, mask, data); +return max8925_set_bits (info->i2c, info->vol_reg, mask, selector); }static int max8925_get_voltage_sel (struct regulator_dev *rdev)
@@ -152,8 +143,9 @@ static int max8925_set_dvm_disable(struct regulator_dev *rdev) }static struct regulator_ops max8925_regulator_sdv_ops = { + .map_voltage = regulator_map_voltage_linear, .list_voltage = regulator_list_voltage_linear, - .set_voltage = max8925_set_voltage, + .set_voltage_sel = max8925_set_voltage_sel, .get_voltage_sel = max8925_get_voltage_sel, .enable = max8925_enable, .disable = max8925_disable,
@@ -164,8 +156,9 @@ static struct regulator_ops max8925_regulator_sdv_ops = { };static struct regulator_ops max8925_regulator_ldo_ops = { + .map_voltage = regulator_map_voltage_linear, .list_voltage = regulator_list_voltage_linear, - .set_voltage = max8925_set_voltage, + .set_voltage_sel = max8925_set_voltage_sel, .get_voltage_sel = max8925_get_voltage_sel, .enable = max8925_enable, .disable = max8925_disable,
Signature · 1 line
1.7.5.4
Mark Brown
AppliedQuoted 1 line · Axel Lin
Signed-off-by Axel Lin <[email protected]>
Applied all, thanks.