Patchwork [U-Boot] M28: Fix OB1 bug in GPIO driver

login
register
mail settings
Submitter Robert Deliën
Date Nov. 22, 2011, 2:14 p.m.
Message ID <B0658F55E67EDE4A914644632835B2CAF7E57B@DEUTERIUM.delien.local>
Download mbox | patch
Permalink /patch/127088/
State Accepted
Delegated to: Stefano Babic
Headers show

Comments

Robert Deliën - Nov. 22, 2011, 2:14 p.m.
This patch fixes a small off-by-one bug in the GPIO driver for the mxs platform that allowed the selection gpio pins of one bank more than the SoC actually has.

Signed-off-by: Robert Deliën <robert at delien.nl>
Marek Vasut - Nov. 22, 2011, 6:14 p.m.
> This patch fixes a small off-by-one bug in the GPIO driver for the mxs
> platform that allowed the selection gpio pins of one bank more than the
> SoC actually has.
> 
> Signed-off-by: Robert Deliën <robert at delien.nl>
> 
> diff --git a/drivers/gpio/mxs_gpio.c b/drivers/gpio/mxs_gpio.c
> index b7e9591..539738b 100644
> --- a/drivers/gpio/mxs_gpio.c
> +++ b/drivers/gpio/mxs_gpio.c
> @@ -120,7 +120,7 @@ int gpio_direction_output(int gp, int value)
> 
>  int gpio_request(int gp, const char *label)
>  {
> -       if (PAD_BANK(gp) > PINCTRL_BANKS)
> +       if (PAD_BANK(gp) >= PINCTRL_BANKS)
>                 return -EINVAL;
> 
>         return 0;

Acked-by: Marek Vasut <marek.vasut@gmail.com>

I'd like to see Stefano review this too.

M
Marek Vasut - Nov. 22, 2011, 10:35 p.m.
> > Sure, I wrote the code, I know what it does and where you see the
> > problem. It's just to be dead sure. Anyway, I acked it so it means I
> > agree with the change.
> 
> Of course. Thanks. Hence my elaboration, to make your checks easier.

Please, ALWAYS Cc the mailing list
Marek Vasut - Nov. 22, 2011, 10:49 p.m.
> This patch fixes a small off-by-one bug in the GPIO driver for the mxs
> platform that allowed the selection gpio pins of one bank more than the
> SoC actually has.
> 
> Signed-off-by: Robert Deliën <robert at delien.nl>
> 
> diff --git a/drivers/gpio/mxs_gpio.c b/drivers/gpio/mxs_gpio.c
> index b7e9591..539738b 100644
> --- a/drivers/gpio/mxs_gpio.c
> +++ b/drivers/gpio/mxs_gpio.c
> @@ -120,7 +120,7 @@ int gpio_direction_output(int gp, int value)
> 
>  int gpio_request(int gp, const char *label)
>  {
> -       if (PAD_BANK(gp) > PINCTRL_BANKS)
> +       if (PAD_BANK(gp) >= PINCTRL_BANKS)
>                 return -EINVAL;
> 
>         return 0;

Stefano, can you please apply ?

Acked-by: Marek Vasut <marek.vasut@gmail.com>
Stefano Babic - Nov. 25, 2011, 8:14 a.m.
On 22/11/2011 15:14, Robert Deliën wrote:
> This patch fixes a small off-by-one bug in the GPIO driver for the mxs platform that allowed the selection gpio pins of one bank more than the SoC actually has.
> 
> Signed-off-by: Robert Deliën <robert at delien.nl>
> 
> diff --git a/drivers/gpio/mxs_gpio.c b/drivers/gpio/mxs_gpio.c
> index b7e9591..539738b 100644
> --- a/drivers/gpio/mxs_gpio.c
> +++ b/drivers/gpio/mxs_gpio.c
> @@ -120,7 +120,7 @@ int gpio_direction_output(int gp, int value)
>  
>  int gpio_request(int gp, const char *label)
>  {
> -       if (PAD_BANK(gp) > PINCTRL_BANKS)
> +       if (PAD_BANK(gp) >= PINCTRL_BANKS)
>                 return -EINVAL;
>  
>         return 0;
> 

Applied to u-boot-imx, thanks.

Best regards,
Stefano Babic

Patch

diff --git a/drivers/gpio/mxs_gpio.c b/drivers/gpio/mxs_gpio.c
index b7e9591..539738b 100644
--- a/drivers/gpio/mxs_gpio.c
+++ b/drivers/gpio/mxs_gpio.c
@@ -120,7 +120,7 @@  int gpio_direction_output(int gp, int value)
 
 int gpio_request(int gp, const char *label)
 {
-       if (PAD_BANK(gp) > PINCTRL_BANKS)
+       if (PAD_BANK(gp) >= PINCTRL_BANKS)
                return -EINVAL;
 
        return 0;