* [PATCH] regulator: ab8500: fix voltage selector regression
@ 2012-08-20 12:18 Linus Walleij
2012-08-20 14:51 ` Axel Lin
0 siblings, 1 reply; 3+ messages in thread
From: Linus Walleij @ 2012-08-20 12:18 UTC (permalink / raw)
To: Liam Girdwood, Mark Brown, linux-kernel
Cc: Mattias Wallin, Linus Walleij, Axel Lin
From: Linus Walleij <linus.walleij@linaro.org>
Commit 3bf6e90e476fb34ca47b6dda270f41d9cebcb1ac
"regulator: Convert ab8499 to use get_voltage_sel()"
and commit ae713d394d9e2aacaab620acd3212855f1f06b00
"regulator: Convert ab8500 to set_voltage_sel"
corrupted the voltage selector mechanism is two ways:
The function for getting the selector stopped respecting
the bit shift to get the selector out, and the function
for setting the selector hacked in a non-generic kludge
that does not scale. Besides, the regulator info struct
for the AB8500 already contains the proper shift values.
This sanitize the code so it works as expected again.
Cc: Axel Lin <axel.lin@gmail.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
---
drivers/regulator/ab8500.c | 17 +++++++----------
1 file changed, 7 insertions(+), 10 deletions(-)
diff --git a/drivers/regulator/ab8500.c b/drivers/regulator/ab8500.c
index 8807166..c659127 100644
--- a/drivers/regulator/ab8500.c
+++ b/drivers/regulator/ab8500.c
@@ -195,17 +195,14 @@ static int ab8500_regulator_get_voltage_sel(struct regulator_dev *rdev)
}
dev_vdbg(rdev_get_dev(rdev),
- "%s-get_voltage (bank, reg, mask, value): 0x%x, 0x%x, 0x%x,"
- " 0x%x\n",
- info->desc.name, info->voltage_bank, info->voltage_reg,
- info->voltage_mask, regval);
+ "%s-get_voltage (bank, reg, mask, shift, value): "
+ "0x%x, 0x%x, 0x%x, 0x%x, 0x%x\n",
+ info->desc.name, info->voltage_bank,
+ info->voltage_reg, info->voltage_mask,
+ info->voltage_shift, regval);
- /* vintcore has a different layout */
val = regval & info->voltage_mask;
- if (info->desc.id == AB8500_LDO_INTCORE)
- return val >> 0x3;
- else
- return val;
+ return val >> info->voltage_shift;
}
static int ab8500_regulator_set_voltage_sel(struct regulator_dev *rdev,
@@ -221,7 +218,7 @@ static int ab8500_regulator_set_voltage_sel(struct regulator_dev *rdev,
}
/* set the registers for the request */
- regval = (u8)selector;
+ regval = (u8)selector << info->voltage_shift;
ret = abx500_mask_and_set_register_interruptible(info->dev,
info->voltage_bank, info->voltage_reg,
info->voltage_mask, regval);
--
1.7.11.3
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] regulator: ab8500: fix voltage selector regression
2012-08-20 12:18 [PATCH] regulator: ab8500: fix voltage selector regression Linus Walleij
@ 2012-08-20 14:51 ` Axel Lin
2012-08-20 15:18 ` Linus Walleij
0 siblings, 1 reply; 3+ messages in thread
From: Axel Lin @ 2012-08-20 14:51 UTC (permalink / raw)
To: Linus Walleij
Cc: Liam Girdwood, Mark Brown, linux-kernel, Mattias Wallin,
Linus Walleij
於 一,2012-08-20 於 14:18 +0200,Linus Walleij 提到:
> From: Linus Walleij <linus.walleij@linaro.org>
>
> Commit 3bf6e90e476fb34ca47b6dda270f41d9cebcb1ac
> "regulator: Convert ab8499 to use get_voltage_sel()"
> and commit ae713d394d9e2aacaab620acd3212855f1f06b00
> "regulator: Convert ab8500 to set_voltage_sel"
> corrupted the voltage selector mechanism is two ways:
I'm not very sure the commits you mentioned is the root cause,
because it looks that here is no behavior change with both commits.
Does it really work if you revert above commits you mention?
>
> The function for getting the selector stopped respecting
> the bit shift to get the selector out, and the function
> for setting the selector hacked in a non-generic kludge
> that does not scale. Besides, the regulator info struct
> for the AB8500 already contains the proper shift values.
>
> This sanitize the code so it works as expected again.
I got below build error after apply this patch to regulator tree.
CC drivers/regulator/ab8500.o
drivers/regulator/ab8500.c: In function
'ab8500_regulator_get_voltage_sel':
drivers/regulator/ab8500.c:197:2: error: 'struct ab8500_regulator_info'
has no member named 'voltage_shift'
drivers/regulator/ab8500.c:205:20: error: 'struct ab8500_regulator_info'
has no member named 'voltage_shift'
drivers/regulator/ab8500.c: In function
'ab8500_regulator_set_voltage_sel':
drivers/regulator/ab8500.c:221:31: error: 'struct ab8500_regulator_info'
has no member named 'voltage_shift'
drivers/regulator/ab8500.c: In function
'ab8500_regulator_get_voltage_sel':
drivers/regulator/ab8500.c:206:1: warning: control reaches end of
non-void function [-Wreturn-type]
make[2]: *** [drivers/regulator/ab8500.o] Error 1
make[1]: *** [drivers/regulator] Error 2
make: *** [drivers] Error 2
Regards,
Axel
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] regulator: ab8500: fix voltage selector regression
2012-08-20 14:51 ` Axel Lin
@ 2012-08-20 15:18 ` Linus Walleij
0 siblings, 0 replies; 3+ messages in thread
From: Linus Walleij @ 2012-08-20 15:18 UTC (permalink / raw)
To: Axel Lin
Cc: Linus Walleij, Liam Girdwood, Mark Brown, linux-kernel,
Mattias Wallin
On Mon, Aug 20, 2012 at 4:51 PM, Axel Lin <axel.lin@gmail.com> wrote:
> 於 一,2012-08-20 於 14:18 +0200,Linus Walleij 提到:
>> From: Linus Walleij <linus.walleij@linaro.org>
>>
>> Commit 3bf6e90e476fb34ca47b6dda270f41d9cebcb1ac
>> "regulator: Convert ab8499 to use get_voltage_sel()"
>> and commit ae713d394d9e2aacaab620acd3212855f1f06b00
>> "regulator: Convert ab8500 to set_voltage_sel"
>> corrupted the voltage selector mechanism is two ways:
>
> I'm not very sure the commits you mentioned is the root cause,
> because it looks that here is no behavior change with both commits.
> Does it really work if you revert above commits you mention?
No you're right, I've screwed up completely... I confused
two codebases. I'll fix a proper patch adding the proper
voltage shift fields to the regulator info.
Sorry about this Axel!
Yours,
Linus Walleij
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2012-08-20 15:18 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-08-20 12:18 [PATCH] regulator: ab8500: fix voltage selector regression Linus Walleij
2012-08-20 14:51 ` Axel Lin
2012-08-20 15:18 ` Linus Walleij
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox