* [PATCH] regulator: Use mc13xxx_reg_write instead of mc13xxx_reg_rmw in mc13892_sw_regulator_set_voltage
@ 2011-05-09 9:49 Axel Lin
2011-05-09 9:56 ` Mark Brown
0 siblings, 1 reply; 3+ messages in thread
From: Axel Lin @ 2011-05-09 9:49 UTC (permalink / raw)
To: linux-kernel; +Cc: Yong Shen, Uwe Kleine-Koenig, Liam Girdwood, Mark Brown
Currently, we call mc13xxx_reg_read and mc13xxx_reg_rmw for the same register.
This can be converted to simply a mc13xxx_reg_read and a mc13xxx_reg_write,
thus save a redundant register read.
Signed-off-by: Axel Lin <axel.lin@gmail.com>
---
hi Uwe, Yong,
I don't have this hardware handy,
I appreciate if you can help to test this patch if you think this patch is ok.
Regards,
Axel
drivers/regulator/mc13892-regulator.c | 16 ++++++++++------
1 files changed, 10 insertions(+), 6 deletions(-)
diff --git a/drivers/regulator/mc13892-regulator.c b/drivers/regulator/mc13892-regulator.c
index 1b8f739..33d43b2 100644
--- a/drivers/regulator/mc13892-regulator.c
+++ b/drivers/regulator/mc13892-regulator.c
@@ -431,7 +431,8 @@ static int mc13892_sw_regulator_set_voltage(struct regulator_dev *rdev,
int min_uV, int max_uV, unsigned *selector)
{
struct mc13xxx_regulator_priv *priv = rdev_get_drvdata(rdev);
- int hi, value, val, mask, id = rdev_get_id(rdev);
+ int hi, value, mask, id = rdev_get_id(rdev);
+ u32 valread;
int ret;
dev_dbg(rdev_get_dev(rdev), "%s id: %d min_uV: %d max_uV: %d\n",
@@ -447,15 +448,16 @@ static int mc13892_sw_regulator_set_voltage(struct regulator_dev *rdev,
mc13xxx_lock(priv->mc13xxx);
ret = mc13xxx_reg_read(priv->mc13xxx,
- mc13892_regulators[id].vsel_reg, &val);
+ mc13892_regulators[id].vsel_reg, &valread);
if (ret)
goto err;
- hi = val & MC13892_SWITCHERS0_SWxHI;
if (value > 1375)
hi = 1;
- if (value < 1100)
+ else if (value < 1100)
hi = 0;
+ else
+ hi = valread & MC13892_SWITCHERS0_SWxHI;
if (hi) {
value = (value - 1100000) / 25000;
@@ -464,8 +466,10 @@ static int mc13892_sw_regulator_set_voltage(struct regulator_dev *rdev,
value = (value - 600000) / 25000;
mask = mc13892_regulators[id].vsel_mask | MC13892_SWITCHERS0_SWxHI;
- ret = mc13xxx_reg_rmw(priv->mc13xxx, mc13892_regulators[id].vsel_reg,
- mask, value << mc13892_regulators[id].vsel_shift);
+ valread = (valread & ~mask) |
+ (value << mc13892_regulators[id].vsel_shift);
+ ret = mc13xxx_reg_write(priv->mc13xxx, mc13892_regulators[id].vsel_reg,
+ valread);
err:
mc13xxx_unlock(priv->mc13xxx);
--
1.7.1
^ permalink raw reply related [flat|nested] 3+ messages in thread* Re: [PATCH] regulator: Use mc13xxx_reg_write instead of mc13xxx_reg_rmw in mc13892_sw_regulator_set_voltage
2011-05-09 9:49 [PATCH] regulator: Use mc13xxx_reg_write instead of mc13xxx_reg_rmw in mc13892_sw_regulator_set_voltage Axel Lin
@ 2011-05-09 9:56 ` Mark Brown
2011-05-09 16:02 ` Liam Girdwood
0 siblings, 1 reply; 3+ messages in thread
From: Mark Brown @ 2011-05-09 9:56 UTC (permalink / raw)
To: Axel Lin; +Cc: linux-kernel, Yong Shen, Uwe Kleine-Koenig, Liam Girdwood
On Mon, May 09, 2011 at 05:49:40PM +0800, Axel Lin wrote:
> Currently, we call mc13xxx_reg_read and mc13xxx_reg_rmw for the same register.
> This can be converted to simply a mc13xxx_reg_read and a mc13xxx_reg_write,
> thus save a redundant register read.
>
> Signed-off-by: Axel Lin <axel.lin@gmail.com>
Acked-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] regulator: Use mc13xxx_reg_write instead of mc13xxx_reg_rmw in mc13892_sw_regulator_set_voltage
2011-05-09 9:56 ` Mark Brown
@ 2011-05-09 16:02 ` Liam Girdwood
0 siblings, 0 replies; 3+ messages in thread
From: Liam Girdwood @ 2011-05-09 16:02 UTC (permalink / raw)
To: Mark Brown; +Cc: Axel Lin, linux-kernel, Yong Shen, Uwe Kleine-Koenig
On Mon, 2011-05-09 at 11:56 +0200, Mark Brown wrote:
> On Mon, May 09, 2011 at 05:49:40PM +0800, Axel Lin wrote:
> > Currently, we call mc13xxx_reg_read and mc13xxx_reg_rmw for the same register.
> > This can be converted to simply a mc13xxx_reg_read and a mc13xxx_reg_write,
> > thus save a redundant register read.
> >
> > Signed-off-by: Axel Lin <axel.lin@gmail.com>
>
> Acked-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
> --
Applied.
Thanks
Liam
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2011-05-09 16:02 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-05-09 9:49 [PATCH] regulator: Use mc13xxx_reg_write instead of mc13xxx_reg_rmw in mc13892_sw_regulator_set_voltage Axel Lin
2011-05-09 9:56 ` Mark Brown
2011-05-09 16:02 ` Liam Girdwood
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox