diff options
author | Axel Lin <axel.lin@ingics.com> | 2012-12-08 19:07:43 -0500 |
---|---|---|
committer | Mark Brown <broonie@opensource.wolfsonmicro.com> | 2012-12-09 22:38:59 -0500 |
commit | e1b0144f9997d3d52c46785143699d82dd525f1d (patch) | |
tree | 3c2178d52d94a1c18f76e8102039f7daa6545493 /drivers/regulator/anatop-regulator.c | |
parent | 985884db501d7026257d122c3cc32a7005a9a864 (diff) |
regulator: anatop: Use regulator_[get|set]_voltage_sel_regmap
Call regulator_[get|set]_voltage_sel_regmap instead of open code.
Signed-off-by: Axel Lin <axel.lin@ingics.com>
Reviewed-by: Ying-Chun Liu <paulliu@debian.org>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Diffstat (limited to 'drivers/regulator/anatop-regulator.c')
-rw-r--r-- | drivers/regulator/anatop-regulator.c | 21 |
1 files changed, 6 insertions, 15 deletions
diff --git a/drivers/regulator/anatop-regulator.c b/drivers/regulator/anatop-regulator.c index b78b622d24c5..b6182e17b0dc 100644 --- a/drivers/regulator/anatop-regulator.c +++ b/drivers/regulator/anatop-regulator.c | |||
@@ -48,34 +48,21 @@ static int anatop_regmap_set_voltage_sel(struct regulator_dev *reg, | |||
48 | unsigned selector) | 48 | unsigned selector) |
49 | { | 49 | { |
50 | struct anatop_regulator *anatop_reg = rdev_get_drvdata(reg); | 50 | struct anatop_regulator *anatop_reg = rdev_get_drvdata(reg); |
51 | u32 mask; | ||
52 | 51 | ||
53 | if (!anatop_reg->control_reg) | 52 | if (!anatop_reg->control_reg) |
54 | return -ENOTSUPP; | 53 | return -ENOTSUPP; |
55 | 54 | ||
56 | mask = ((1 << anatop_reg->vol_bit_width) - 1) << | 55 | return regulator_set_voltage_sel_regmap(reg, selector); |
57 | anatop_reg->vol_bit_shift; | ||
58 | selector <<= anatop_reg->vol_bit_shift; | ||
59 | regmap_update_bits(anatop_reg->anatop, anatop_reg->control_reg, | ||
60 | mask, selector); | ||
61 | |||
62 | return 0; | ||
63 | } | 56 | } |
64 | 57 | ||
65 | static int anatop_regmap_get_voltage_sel(struct regulator_dev *reg) | 58 | static int anatop_regmap_get_voltage_sel(struct regulator_dev *reg) |
66 | { | 59 | { |
67 | struct anatop_regulator *anatop_reg = rdev_get_drvdata(reg); | 60 | struct anatop_regulator *anatop_reg = rdev_get_drvdata(reg); |
68 | u32 val, mask; | ||
69 | 61 | ||
70 | if (!anatop_reg->control_reg) | 62 | if (!anatop_reg->control_reg) |
71 | return -ENOTSUPP; | 63 | return -ENOTSUPP; |
72 | 64 | ||
73 | regmap_read(anatop_reg->anatop, anatop_reg->control_reg, &val); | 65 | return regulator_get_voltage_sel_regmap(reg); |
74 | mask = ((1 << anatop_reg->vol_bit_width) - 1) << | ||
75 | anatop_reg->vol_bit_shift; | ||
76 | val = (val & mask) >> anatop_reg->vol_bit_shift; | ||
77 | |||
78 | return val; | ||
79 | } | 66 | } |
80 | 67 | ||
81 | static struct regulator_ops anatop_rops = { | 68 | static struct regulator_ops anatop_rops = { |
@@ -161,11 +148,15 @@ static int __devinit anatop_regulator_probe(struct platform_device *pdev) | |||
161 | rdesc->min_uV = sreg->min_voltage; | 148 | rdesc->min_uV = sreg->min_voltage; |
162 | rdesc->uV_step = 25000; | 149 | rdesc->uV_step = 25000; |
163 | rdesc->linear_min_sel = sreg->min_bit_val; | 150 | rdesc->linear_min_sel = sreg->min_bit_val; |
151 | rdesc->vsel_reg = sreg->control_reg; | ||
152 | rdesc->vsel_mask = ((1 << sreg->vol_bit_width) - 1) << | ||
153 | sreg->vol_bit_shift; | ||
164 | 154 | ||
165 | config.dev = &pdev->dev; | 155 | config.dev = &pdev->dev; |
166 | config.init_data = initdata; | 156 | config.init_data = initdata; |
167 | config.driver_data = sreg; | 157 | config.driver_data = sreg; |
168 | config.of_node = pdev->dev.of_node; | 158 | config.of_node = pdev->dev.of_node; |
159 | config.regmap = sreg->anatop; | ||
169 | 160 | ||
170 | /* register regulator */ | 161 | /* register regulator */ |
171 | rdev = regulator_register(rdesc, &config); | 162 | rdev = regulator_register(rdesc, &config); |