* [PATCH RFT v2] regulator: ab8500: Update info->update_val only when successfully update register
@ 2013-03-28 9:23 Axel Lin
2013-03-28 10:01 ` Bengt Jönsson
2013-03-29 17:52 ` Mark Brown
0 siblings, 2 replies; 3+ messages in thread
From: Axel Lin @ 2013-03-28 9:23 UTC (permalink / raw)
To: Mark Brown
Cc: Bengt Jonsson, Lee Jones, Yvan FILLION, Liam Girdwood,
linux-kernel
Don't update info->update_val if write to the register fails.
Signed-off-by: Axel Lin <axel.lin@ingics.com>
---
v2:
On the second thought, I think it's ok to update info->update_val when
regulator is disabled, the mode will change when the regulator is enabled.
Hi Bengt,
I just got your Ack for v1.
Can you review this v2 again, and let Mark know which version do you prefer.
Thanks.
Axel
drivers/regulator/ab8500.c | 27 +++++++++++++++++++--------
1 file changed, 19 insertions(+), 8 deletions(-)
diff --git a/drivers/regulator/ab8500.c b/drivers/regulator/ab8500.c
index 12e2740..7814ac3 100644
--- a/drivers/regulator/ab8500.c
+++ b/drivers/regulator/ab8500.c
@@ -182,8 +182,8 @@ static unsigned int ab8500_regulator_get_optimum_mode(
static int ab8500_regulator_set_mode(struct regulator_dev *rdev,
unsigned int mode)
{
- int ret = 0;
-
+ int ret;
+ u8 update_val;
struct ab8500_regulator_info *info = rdev_get_drvdata(rdev);
if (info == NULL) {
@@ -193,31 +193,42 @@ static int ab8500_regulator_set_mode(struct regulator_dev *rdev,
switch (mode) {
case REGULATOR_MODE_NORMAL:
- info->update_val = info->update_val_normal;
+ update_val = info->update_val_normal;
break;
case REGULATOR_MODE_IDLE:
- info->update_val = info->update_val_idle;
+ update_val = info->update_val_idle;
break;
default:
return -EINVAL;
}
+ /* ab8500 regulators share mode and enable in the same register bits.
+ off = 0b00
+ low power mode= 0b11
+ full powermode = 0b01
+ (HW control mode = 0b10)
+ Thus we don't write to the register when regulator is disabled.
+ */
if (info->is_enabled) {
ret = abx500_mask_and_set_register_interruptible(info->dev,
info->update_bank, info->update_reg,
- info->update_mask, info->update_val);
- if (ret < 0)
+ info->update_mask, update_val);
+ if (ret < 0) {
dev_err(rdev_get_dev(rdev),
"couldn't set regulator mode\n");
+ return ret;
+ }
dev_vdbg(rdev_get_dev(rdev),
"%s-set_mode (bank, reg, mask, value): "
"0x%x, 0x%x, 0x%x, 0x%x\n",
info->desc.name, info->update_bank, info->update_reg,
- info->update_mask, info->update_val);
+ info->update_mask, update_val);
}
- return ret;
+ info->update_val = update_val;
+
+ return 0;
}
static unsigned int ab8500_regulator_get_mode(struct regulator_dev *rdev)
--
1.7.10.4
^ permalink raw reply related [flat|nested] 3+ messages in thread* Re: [PATCH RFT v2] regulator: ab8500: Update info->update_val only when successfully update register
2013-03-28 9:23 [PATCH RFT v2] regulator: ab8500: Update info->update_val only when successfully update register Axel Lin
@ 2013-03-28 10:01 ` Bengt Jönsson
2013-03-29 17:52 ` Mark Brown
1 sibling, 0 replies; 3+ messages in thread
From: Bengt Jönsson @ 2013-03-28 10:01 UTC (permalink / raw)
To: Axel Lin
Cc: Mark Brown, Lee Jones, Yvan FILLION, Liam Girdwood,
linux-kernel@vger.kernel.org
On 03/28/2013 10:23 AM, Axel Lin wrote:
> Don't update info->update_val if write to the register fails.
>
> Signed-off-by: Axel Lin <axel.lin@ingics.com>
> ---
> v2:
> On the second thought, I think it's ok to update info->update_val when
> regulator is disabled, the mode will change when the regulator is enabled.
That is better of course. I did not notice before.
> Hi Bengt,
> I just got your Ack for v1.
> Can you review this v2 again, and let Mark know which version do you prefer.
>
> Thanks.
> Axel
I prefer this v2, thanks.
Acked-by: Bengt Jonsson <bengt.g.jonsson@stericsson.com>
> drivers/regulator/ab8500.c | 27 +++++++++++++++++++--------
> 1 file changed, 19 insertions(+), 8 deletions(-)
>
> diff --git a/drivers/regulator/ab8500.c b/drivers/regulator/ab8500.c
> index 12e2740..7814ac3 100644
> --- a/drivers/regulator/ab8500.c
> +++ b/drivers/regulator/ab8500.c
> @@ -182,8 +182,8 @@ static unsigned int ab8500_regulator_get_optimum_mode(
> static int ab8500_regulator_set_mode(struct regulator_dev *rdev,
> unsigned int mode)
> {
> - int ret = 0;
> -
> + int ret;
> + u8 update_val;
> struct ab8500_regulator_info *info = rdev_get_drvdata(rdev);
>
> if (info == NULL) {
> @@ -193,31 +193,42 @@ static int ab8500_regulator_set_mode(struct regulator_dev *rdev,
>
> switch (mode) {
> case REGULATOR_MODE_NORMAL:
> - info->update_val = info->update_val_normal;
> + update_val = info->update_val_normal;
> break;
> case REGULATOR_MODE_IDLE:
> - info->update_val = info->update_val_idle;
> + update_val = info->update_val_idle;
> break;
> default:
> return -EINVAL;
> }
>
> + /* ab8500 regulators share mode and enable in the same register bits.
> + off = 0b00
> + low power mode= 0b11
> + full powermode = 0b01
> + (HW control mode = 0b10)
> + Thus we don't write to the register when regulator is disabled.
> + */
> if (info->is_enabled) {
> ret = abx500_mask_and_set_register_interruptible(info->dev,
> info->update_bank, info->update_reg,
> - info->update_mask, info->update_val);
> - if (ret < 0)
> + info->update_mask, update_val);
> + if (ret < 0) {
> dev_err(rdev_get_dev(rdev),
> "couldn't set regulator mode\n");
> + return ret;
> + }
>
> dev_vdbg(rdev_get_dev(rdev),
> "%s-set_mode (bank, reg, mask, value): "
> "0x%x, 0x%x, 0x%x, 0x%x\n",
> info->desc.name, info->update_bank, info->update_reg,
> - info->update_mask, info->update_val);
> + info->update_mask, update_val);
> }
>
> - return ret;
> + info->update_val = update_val;
> +
> + return 0;
> }
>
> static unsigned int ab8500_regulator_get_mode(struct regulator_dev *rdev)
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [PATCH RFT v2] regulator: ab8500: Update info->update_val only when successfully update register
2013-03-28 9:23 [PATCH RFT v2] regulator: ab8500: Update info->update_val only when successfully update register Axel Lin
2013-03-28 10:01 ` Bengt Jönsson
@ 2013-03-29 17:52 ` Mark Brown
1 sibling, 0 replies; 3+ messages in thread
From: Mark Brown @ 2013-03-29 17:52 UTC (permalink / raw)
To: Axel Lin
Cc: Bengt Jonsson, Lee Jones, Yvan FILLION, Liam Girdwood,
linux-kernel
[-- Attachment #1: Type: text/plain, Size: 140 bytes --]
On Thu, Mar 28, 2013 at 05:23:00PM +0800, Axel Lin wrote:
> Don't update info->update_val if write to the register fails.
Applied, thanks.
[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 836 bytes --]
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2013-03-29 17:52 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-03-28 9:23 [PATCH RFT v2] regulator: ab8500: Update info->update_val only when successfully update register Axel Lin
2013-03-28 10:01 ` Bengt Jönsson
2013-03-29 17:52 ` Mark Brown
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox