diff options
author | Axel Lin <axel.lin@ingics.com> | 2012-12-08 19:05:45 -0500 |
---|---|---|
committer | Mark Brown <broonie@opensource.wolfsonmicro.com> | 2012-12-09 22:38:09 -0500 |
commit | 985884db501d7026257d122c3cc32a7005a9a864 (patch) | |
tree | 96379e7eb17813863a6fefe27a08064f2da841de /drivers/regulator | |
parent | 5d6e6ffc400dbc3ea0cc58b8b6f9d9ac748d6572 (diff) |
regulator: anatop: Use linear_min_sel with linear mapping
By setting linear_min_sel to anatop_reg->min_bit_val, we can avoid
adjust the anatop_reg->min_bit_val offset in [set|get]_voltage_sel.
With this chance we can refactor this driver to use
regulator_[get|set]_voltage_sel_regmap.
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')
-rw-r--r-- | drivers/regulator/anatop-regulator.c | 15 |
1 files changed, 7 insertions, 8 deletions
diff --git a/drivers/regulator/anatop-regulator.c b/drivers/regulator/anatop-regulator.c index 1af97686f444..b78b622d24c5 100644 --- a/drivers/regulator/anatop-regulator.c +++ b/drivers/regulator/anatop-regulator.c | |||
@@ -48,18 +48,16 @@ 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 val, mask; | 51 | u32 mask; |
52 | 52 | ||
53 | if (!anatop_reg->control_reg) | 53 | if (!anatop_reg->control_reg) |
54 | return -ENOTSUPP; | 54 | return -ENOTSUPP; |
55 | 55 | ||
56 | val = anatop_reg->min_bit_val + selector; | ||
57 | dev_dbg(®->dev, "%s: calculated val %d\n", __func__, val); | ||
58 | mask = ((1 << anatop_reg->vol_bit_width) - 1) << | 56 | mask = ((1 << anatop_reg->vol_bit_width) - 1) << |
59 | anatop_reg->vol_bit_shift; | 57 | anatop_reg->vol_bit_shift; |
60 | val <<= anatop_reg->vol_bit_shift; | 58 | selector <<= anatop_reg->vol_bit_shift; |
61 | regmap_update_bits(anatop_reg->anatop, anatop_reg->control_reg, | 59 | regmap_update_bits(anatop_reg->anatop, anatop_reg->control_reg, |
62 | mask, val); | 60 | mask, selector); |
63 | 61 | ||
64 | return 0; | 62 | return 0; |
65 | } | 63 | } |
@@ -77,7 +75,7 @@ static int anatop_regmap_get_voltage_sel(struct regulator_dev *reg) | |||
77 | anatop_reg->vol_bit_shift; | 75 | anatop_reg->vol_bit_shift; |
78 | val = (val & mask) >> anatop_reg->vol_bit_shift; | 76 | val = (val & mask) >> anatop_reg->vol_bit_shift; |
79 | 77 | ||
80 | return val - anatop_reg->min_bit_val; | 78 | return val; |
81 | } | 79 | } |
82 | 80 | ||
83 | static struct regulator_ops anatop_rops = { | 81 | static struct regulator_ops anatop_rops = { |
@@ -158,10 +156,11 @@ static int __devinit anatop_regulator_probe(struct platform_device *pdev) | |||
158 | goto anatop_probe_end; | 156 | goto anatop_probe_end; |
159 | } | 157 | } |
160 | 158 | ||
161 | rdesc->n_voltages = (sreg->max_voltage - sreg->min_voltage) | 159 | rdesc->n_voltages = (sreg->max_voltage - sreg->min_voltage) / 25000 + 1 |
162 | / 25000 + 1; | 160 | + sreg->min_bit_val; |
163 | rdesc->min_uV = sreg->min_voltage; | 161 | rdesc->min_uV = sreg->min_voltage; |
164 | rdesc->uV_step = 25000; | 162 | rdesc->uV_step = 25000; |
163 | rdesc->linear_min_sel = sreg->min_bit_val; | ||
165 | 164 | ||
166 | config.dev = &pdev->dev; | 165 | config.dev = &pdev->dev; |
167 | config.init_data = initdata; | 166 | config.init_data = initdata; |