public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] regulator: Move VCOINCELL to be the last element of mc13892_regulators array
@ 2011-05-05 15:32 Axel Lin
  2011-05-06  9:38 ` Mark Brown
  2011-05-09 15:03 ` Liam Girdwood
  0 siblings, 2 replies; 6+ messages in thread
From: Axel Lin @ 2011-05-05 15:32 UTC (permalink / raw)
  To: linux-kernel; +Cc: Yong Shen, Liam Girdwood, Mark Brown

In include/linux/mfd/mc13892.h, we define MC13892_VCOINCELL as 23.
Thus VCOINCELL should be defined as 23th element in mc13892_regulators array, not the first one.
This actually fixes an off-by-one bug while accessing mc13892_regulators array.

For example,
In mc13892_regulator_probe, we use MC13892_VCAM as array index of mc13892_regulators array.
        mc13892_regulators[MC13892_VCAM].desc.ops->set_mode
                = mc13892_vcam_set_mode;
Currently, it access mc13892_regulators[12] ,which is VAUDIO not VCAM.

Signed-off-by: Axel Lin <axel.lin@gmail.com>
---
I don't have this hardware handy, just found this bug while reading the code.
I appreciate if someone can test it.

Axel

 drivers/regulator/mc13892-regulator.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/drivers/regulator/mc13892-regulator.c b/drivers/regulator/mc13892-regulator.c
index 1b8f739..ba909cb 100644
--- a/drivers/regulator/mc13892-regulator.c
+++ b/drivers/regulator/mc13892-regulator.c
@@ -259,7 +259,6 @@ static struct regulator_ops mc13892_sw_regulator_ops;
 			mc13xxx_regulator_ops)
 
 static struct mc13xxx_regulator mc13892_regulators[] = {
-	MC13892_DEFINE_REGU(VCOINCELL, POWERCTL0, POWERCTL0, mc13892_vcoincell),
 	MC13892_SW_DEFINE(SW1, SWITCHERS0, SWITCHERS0, mc13892_sw1),
 	MC13892_SW_DEFINE(SW2, SWITCHERS1, SWITCHERS1, mc13892_sw),
 	MC13892_SW_DEFINE(SW3, SWITCHERS2, SWITCHERS2, mc13892_sw),
@@ -293,6 +292,7 @@ static struct mc13xxx_regulator mc13892_regulators[] = {
 	MC13892_GPO_DEFINE(GPO4, POWERMISC, mc13892_gpo),
 	MC13892_GPO_DEFINE(PWGT1SPI, POWERMISC, mc13892_pwgtdrv),
 	MC13892_GPO_DEFINE(PWGT2SPI, POWERMISC, mc13892_pwgtdrv),
+	MC13892_DEFINE_REGU(VCOINCELL, POWERCTL0, POWERCTL0, mc13892_vcoincell),
 };
 
 static int mc13892_powermisc_rmw(struct mc13xxx_regulator_priv *priv, u32 mask,
-- 
1.7.1




^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH] regulator: Move VCOINCELL to be the last element of mc13892_regulators array
  2011-05-05 15:32 [PATCH] regulator: Move VCOINCELL to be the last element of mc13892_regulators array Axel Lin
@ 2011-05-06  9:38 ` Mark Brown
  2011-05-09 15:03 ` Liam Girdwood
  1 sibling, 0 replies; 6+ messages in thread
From: Mark Brown @ 2011-05-06  9:38 UTC (permalink / raw)
  To: Axel Lin; +Cc: linux-kernel, Yong Shen, Liam Girdwood

On Thu, May 05, 2011 at 11:32:58PM +0800, Axel Lin wrote:
> In include/linux/mfd/mc13892.h, we define MC13892_VCOINCELL as 23.
> Thus VCOINCELL should be defined as 23th element in mc13892_regulators array, not the first one.
> This actually fixes an off-by-one bug while accessing mc13892_regulators array.

Acked-by: Mark Brown <broonie@opensource.wolfsonmicro.com>

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] regulator: Move VCOINCELL to be the last element of mc13892_regulators array
  2011-05-05 15:32 [PATCH] regulator: Move VCOINCELL to be the last element of mc13892_regulators array Axel Lin
  2011-05-06  9:38 ` Mark Brown
@ 2011-05-09 15:03 ` Liam Girdwood
  2011-05-10  8:54   ` Axel Lin
  1 sibling, 1 reply; 6+ messages in thread
From: Liam Girdwood @ 2011-05-09 15:03 UTC (permalink / raw)
  To: Axel Lin; +Cc: linux-kernel, Yong Shen, Mark Brown

On Thu, 2011-05-05 at 23:32 +0800, Axel Lin wrote:
> In include/linux/mfd/mc13892.h, we define MC13892_VCOINCELL as 23.
> Thus VCOINCELL should be defined as 23th element in mc13892_regulators array, not the first one.
> This actually fixes an off-by-one bug while accessing mc13892_regulators array.
> 
> For example,
> In mc13892_regulator_probe, we use MC13892_VCAM as array index of mc13892_regulators array.
>         mc13892_regulators[MC13892_VCAM].desc.ops->set_mode
>                 = mc13892_vcam_set_mode;
> Currently, it access mc13892_regulators[12] ,which is VAUDIO not VCAM.
> 
> Signed-off-by: Axel Lin <axel.lin@gmail.com>
> ---
> I don't have this hardware handy, just found this bug while reading the code.
> I appreciate if someone can test it.
> 
> Axel

Applied, Btw is this fix also for 2.6.39 ?

Thanks

Liam


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] regulator: Move VCOINCELL to be the last element of mc13892_regulators array
  2011-05-09 15:03 ` Liam Girdwood
@ 2011-05-10  8:54   ` Axel Lin
  2011-05-10  9:37     ` Liam Girdwood
  0 siblings, 1 reply; 6+ messages in thread
From: Axel Lin @ 2011-05-10  8:54 UTC (permalink / raw)
  To: Liam Girdwood; +Cc: linux-kernel, Yong Shen, Mark Brown

hi Liam,

> Applied, Btw is this fix also for 2.6.39 ?

I check this patch again and found this actually is not a bug
because MC13xxx_DEFINE explictly defines the order of each entry in the array.

#define MC13xxx_DEFINE(prefix, _name, _reg, _vsel_reg, _voltages, _ops) \
        [prefix ## _name] = {                           \
                .desc = {                                               \
                        .name = #prefix "_" #_name,                     \
                        .n_voltages = ARRAY_SIZE(_voltages),            \
                        .ops = &_ops,                   \
                        .type = REGULATOR_VOLTAGE,                      \
                        .id = prefix ## _name,          \
                        .owner = THIS_MODULE,                           \
                },                                                      \
                .reg = prefix ## _reg,                          \
                .enable_bit = prefix ## _reg ## _ ## _name ## EN,       \
                .vsel_reg = prefix ## _vsel_reg,                        \
                .vsel_shift = prefix ## _vsel_reg ## _ ## _name ## VSEL,\
                .vsel_mask = prefix ## _vsel_reg ## _ ## _name ## VSEL_M,\
                .voltages =  _voltages,                                 \
        }

Regards,
Axel

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] regulator: Move VCOINCELL to be the last element of mc13892_regulators array
  2011-05-10  8:54   ` Axel Lin
@ 2011-05-10  9:37     ` Liam Girdwood
  2011-05-10 11:00       ` Axel Lin
  0 siblings, 1 reply; 6+ messages in thread
From: Liam Girdwood @ 2011-05-10  9:37 UTC (permalink / raw)
  To: axel.lin; +Cc: linux-kernel, Yong Shen, Mark Brown

On Tue, 2011-05-10 at 16:54 +0800, Axel Lin wrote:
> hi Liam,
> 
> > Applied, Btw is this fix also for 2.6.39 ?
> 
> I check this patch again and found this actually is not a bug
> because MC13xxx_DEFINE explictly defines the order of each entry in the array.
> 

:(

I've already pushed this into next, can you send a fix asap.

Thanks

Liam


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] regulator: Move VCOINCELL to be the last element of mc13892_regulators array
  2011-05-10  9:37     ` Liam Girdwood
@ 2011-05-10 11:00       ` Axel Lin
  0 siblings, 0 replies; 6+ messages in thread
From: Axel Lin @ 2011-05-10 11:00 UTC (permalink / raw)
  To: Liam Girdwood; +Cc: linux-kernel, Yong Shen, Mark Brown

2011/5/10 Liam Girdwood <lrg@slimlogic.co.uk>:
> On Tue, 2011-05-10 at 16:54 +0800, Axel Lin wrote:
>> hi Liam,
>>
>> > Applied, Btw is this fix also for 2.6.39 ?
>>
>> I check this patch again and found this actually is not a bug
>> because MC13xxx_DEFINE explictly defines the order of each entry in the array.
>>
>
> :(

Sorry.

>
> I've already pushed this into next, can you send a fix asap.

Do you want me to send a patch to revert the change? ( Though I think
the change is harmless. )
If yes, I can do it.

Regards,
Axel
>
> Thanks
>
> Liam
>
>

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2011-05-10 11:00 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-05-05 15:32 [PATCH] regulator: Move VCOINCELL to be the last element of mc13892_regulators array Axel Lin
2011-05-06  9:38 ` Mark Brown
2011-05-09 15:03 ` Liam Girdwood
2011-05-10  8:54   ` Axel Lin
2011-05-10  9:37     ` Liam Girdwood
2011-05-10 11:00       ` Axel Lin

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox