Commit 2ba53d04 authored by Mauro Carvalho Chehab's avatar Mauro Carvalho Chehab Committed by Greg Kroah-Hartman

staging: hikey9xx: hi6421v600-regulator: use some regmap helpers

Now that the driver was ported to use regmap, let's use
some help functions in order to simplify the code a little
bit.
Suggested-by: default avatarMark Brown <broonie@kernel.org>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab+huawei@kernel.org>
Link: https://lore.kernel.org/r/5bdd7988fb9bf5d3ebee03724cf73cc04d9bc47b.1611949675.git.mchehab+huawei@kernel.orgSigned-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent fb02e3eb
......@@ -95,17 +95,6 @@ static const unsigned int ldo34_voltages[] = {
.eco_uA = ecoamp, \
}
static int hi6421_spmi_regulator_is_enabled(struct regulator_dev *rdev)
{
struct hi6421_spmi_reg_info *sreg = rdev_get_drvdata(rdev);
struct hi6421_spmi_pmic *pmic = sreg->pmic;
u32 reg_val;
regmap_read(pmic->map, rdev->desc->enable_reg, &reg_val);
return ((reg_val & rdev->desc->enable_mask) != 0);
}
static int hi6421_spmi_regulator_enable(struct regulator_dev *rdev)
{
struct hi6421_spmi_reg_info *sreg = rdev_get_drvdata(rdev);
......@@ -136,34 +125,6 @@ static int hi6421_spmi_regulator_disable(struct regulator_dev *rdev)
rdev->desc->enable_mask, 0);
}
static int hi6421_spmi_regulator_get_voltage_sel(struct regulator_dev *rdev)
{
struct hi6421_spmi_reg_info *sreg = rdev_get_drvdata(rdev);
struct hi6421_spmi_pmic *pmic = sreg->pmic;
u32 reg_val;
regmap_read(pmic->map, rdev->desc->vsel_reg, &reg_val);
return (reg_val & rdev->desc->vsel_mask) >> (ffs(rdev->desc->vsel_mask) - 1);
}
static int hi6421_spmi_regulator_set_voltage_sel(struct regulator_dev *rdev,
unsigned int selector)
{
struct hi6421_spmi_reg_info *sreg = rdev_get_drvdata(rdev);
struct hi6421_spmi_pmic *pmic = sreg->pmic;
u32 reg_val;
if (selector >= rdev->desc->n_voltages)
return -EINVAL;
reg_val = selector << (ffs(rdev->desc->vsel_mask) - 1);
/* set voltage selector */
return regmap_update_bits(pmic->map, rdev->desc->vsel_reg,
rdev->desc->vsel_mask, reg_val);
}
static unsigned int hi6421_spmi_regulator_get_mode(struct regulator_dev *rdev)
{
struct hi6421_spmi_reg_info *sreg = rdev_get_drvdata(rdev);
......@@ -214,13 +175,13 @@ hi6421_spmi_regulator_get_optimum_mode(struct regulator_dev *rdev,
}
static const struct regulator_ops hi6421_spmi_ldo_rops = {
.is_enabled = hi6421_spmi_regulator_is_enabled,
.is_enabled = regulator_is_enabled_regmap,
.enable = hi6421_spmi_regulator_enable,
.disable = hi6421_spmi_regulator_disable,
.list_voltage = regulator_list_voltage_table,
.map_voltage = regulator_map_voltage_iterate,
.get_voltage_sel = hi6421_spmi_regulator_get_voltage_sel,
.set_voltage_sel = hi6421_spmi_regulator_set_voltage_sel,
.get_voltage_sel = regulator_get_voltage_sel_regmap,
.set_voltage_sel = regulator_set_voltage_sel_regmap,
.get_mode = hi6421_spmi_regulator_get_mode,
.set_mode = hi6421_spmi_regulator_set_mode,
.get_optimum_mode = hi6421_spmi_regulator_get_optimum_mode,
......
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