diff options
author | Richard Zhao <richard.zhao@linaro.org> | 2012-05-13 09:18:02 +0800 |
---|---|---|
committer | Samuel Ortiz <sameo@linux.intel.com> | 2012-05-20 17:27:07 +0200 |
commit | b09530ef844f0bf29ed3677080c02b179be84818 (patch) | |
tree | ed2d3e791823a3e394f0718815895aee37114bfe /drivers/regulator/anatop-regulator.c | |
parent | 08b4c118af35d4d67eca2052aaa8d4a5f7d0aecb (diff) | |
download | op-kernel-dev-b09530ef844f0bf29ed3677080c02b179be84818.zip op-kernel-dev-b09530ef844f0bf29ed3677080c02b179be84818.tar.gz |
mfd: Make anatop register accessor more flexible and rename meaningfully
- rename to anatop_read_reg and anatop_write_reg
- anatop_read_reg directly return reg value
- anatop_write_reg write reg with mask
Signed-off-by: Richard Zhao <richard.zhao@freescale.com>
Reviewed-by: Ying-Chun Liu (PaulLiu) <paul.liu@linaro.org>
Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
Diffstat (limited to 'drivers/regulator/anatop-regulator.c')
-rw-r--r-- | drivers/regulator/anatop-regulator.c | 18 |
1 files changed, 8 insertions, 10 deletions
diff --git a/drivers/regulator/anatop-regulator.c b/drivers/regulator/anatop-regulator.c index 81fd606..0a34085 100644 --- a/drivers/regulator/anatop-regulator.c +++ b/drivers/regulator/anatop-regulator.c @@ -47,7 +47,7 @@ static int anatop_set_voltage(struct regulator_dev *reg, int min_uV, int max_uV, unsigned *selector) { struct anatop_regulator *anatop_reg = rdev_get_drvdata(reg); - u32 val, sel; + u32 val, sel, mask; int uv; uv = min_uV; @@ -71,11 +71,10 @@ static int anatop_set_voltage(struct regulator_dev *reg, int min_uV, val = anatop_reg->min_bit_val + sel; *selector = sel; dev_dbg(®->dev, "%s: calculated val %d\n", __func__, val); - anatop_set_bits(anatop_reg->mfd, - anatop_reg->control_reg, - anatop_reg->vol_bit_shift, - anatop_reg->vol_bit_width, - val); + mask = ((1 << anatop_reg->vol_bit_width) - 1) << + anatop_reg->vol_bit_shift; + val <<= anatop_reg->vol_bit_shift; + anatop_write_reg(anatop_reg->mfd, anatop_reg->control_reg, val, mask); return 0; } @@ -88,10 +87,9 @@ static int anatop_get_voltage_sel(struct regulator_dev *reg) if (!anatop_reg->control_reg) return -ENOTSUPP; - val = anatop_get_bits(anatop_reg->mfd, - anatop_reg->control_reg, - anatop_reg->vol_bit_shift, - anatop_reg->vol_bit_width); + val = anatop_read_reg(anatop_reg->mfd, anatop_reg->control_reg); + val = (val & ((1 << anatop_reg->vol_bit_width) - 1)) >> + anatop_reg->vol_bit_shift; return val - anatop_reg->min_bit_val; } |