lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20130809192516.GB10417@roeck-us.net>
Date:	Fri, 9 Aug 2013 12:25:16 -0700
From:	Guenter Roeck <linux@...ck-us.net>
To:	Michael Brunner <mibru@....de>
Cc:	"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
	Kevin Strasser <strassek@...r.orst.edu>,
	Darren Hart <dvhart@...ux.intel.com>,
	Samuel Ortiz <sameo@...ux.intel.com>,
	Chris Healy <chealy@...co-us.com>,
	Linus Walleij <linus.walleij@...aro.org>,
	linux-gpio@...r.kernel.org
Subject: Re: [PATCH] gpio: Fix bit masking in Kontron PLD GPIO driver

On Fri, Aug 09, 2013 at 05:33:26PM +0200, Michael Brunner wrote:
> This patch fixes the bit masking within the GPIO driver. The masking is
> basically done twice which causes the wrong GPIOs to be addressed.
> 
> Signed-off-by: Michael Brunner <michael.brunner@...tron.com>

Reviewed-by: Guenter Roeck <linux@...ck-us.net>

> ---
>  drivers/gpio/gpio-kempld.c |   24 +++++++++---------------
>  1 file changed, 9 insertions(+), 15 deletions(-)
> 
> diff --git a/drivers/gpio/gpio-kempld.c b/drivers/gpio/gpio-kempld.c
> index d3ed563..6118b66 100644
> --- a/drivers/gpio/gpio-kempld.c
> +++ b/drivers/gpio/gpio-kempld.c
> @@ -46,9 +46,9 @@ static void kempld_gpio_bitop(struct kempld_device_data *pld,
>  
>         status = kempld_read8(pld, reg);
>         if (val)
> -               status |= (1 << bit);
> +               status |= KEMPLD_GPIO_MASK(bit);
>         else
> -               status &= ~(1 << bit);
> +               status &= ~KEMPLD_GPIO_MASK(bit);
>         kempld_write8(pld, reg, status);
>  }
>  
> @@ -60,7 +60,7 @@ static int kempld_gpio_get_bit(struct kempld_device_data *pld, u8 reg, u8 bit)
>         status = kempld_read8(pld, reg);
>         kempld_release_mutex(pld);
>  
> -       return !!(status & (1 << bit));
> +       return !!(status & KEMPLD_GPIO_MASK(bit));
>  }
>  
>  static int kempld_gpio_get(struct gpio_chip *chip, unsigned offset)
> @@ -69,8 +69,7 @@ static int kempld_gpio_get(struct gpio_chip *chip, unsigned offset)
>                 = container_of(chip, struct kempld_gpio_data, chip);
>         struct kempld_device_data *pld = gpio->pld;
>  
> -       return kempld_gpio_get_bit(pld, KEMPLD_GPIO_LVL_NUM(offset),
> -                                  KEMPLD_GPIO_MASK(offset));
> +       return kempld_gpio_get_bit(pld, KEMPLD_GPIO_LVL_NUM(offset), offset);
>  }
>  
>  static void kempld_gpio_set(struct gpio_chip *chip, unsigned offset, int value)
> @@ -80,8 +79,7 @@ static void kempld_gpio_set(struct gpio_chip *chip, unsigned offset, int value)
>         struct kempld_device_data *pld = gpio->pld;
>  
>         kempld_get_mutex(pld);
> -       kempld_gpio_bitop(pld, KEMPLD_GPIO_LVL_NUM(offset),
> -                         KEMPLD_GPIO_MASK(offset), value);
> +       kempld_gpio_bitop(pld, KEMPLD_GPIO_LVL_NUM(offset), offset, value);
>         kempld_release_mutex(pld);
>  }
>  
> @@ -92,8 +90,7 @@ static int kempld_gpio_direction_input(struct gpio_chip *chip, unsigned offset)
>         struct kempld_device_data *pld = gpio->pld;
>  
>         kempld_get_mutex(pld);
> -       kempld_gpio_bitop(pld, KEMPLD_GPIO_DIR_NUM(offset),
> -                         KEMPLD_GPIO_MASK(offset), 0);
> +       kempld_gpio_bitop(pld, KEMPLD_GPIO_DIR_NUM(offset), offset, 0);
>         kempld_release_mutex(pld);
>  
>         return 0;
> @@ -107,10 +104,8 @@ static int kempld_gpio_direction_output(struct gpio_chip *chip, unsigned offset,
>         struct kempld_device_data *pld = gpio->pld;
>  
>         kempld_get_mutex(pld);
> -       kempld_gpio_bitop(pld, KEMPLD_GPIO_LVL_NUM(offset),
> -                         KEMPLD_GPIO_MASK(offset), value);
> -       kempld_gpio_bitop(pld, KEMPLD_GPIO_DIR_NUM(offset),
> -                         KEMPLD_GPIO_MASK(offset), 1);
> +       kempld_gpio_bitop(pld, KEMPLD_GPIO_LVL_NUM(offset), offset, value);
> +       kempld_gpio_bitop(pld, KEMPLD_GPIO_DIR_NUM(offset), offset, 1);
>         kempld_release_mutex(pld);
>  
>         return 0;
> @@ -122,8 +117,7 @@ static int kempld_gpio_get_direction(struct gpio_chip *chip, unsigned offset)
>                 = container_of(chip, struct kempld_gpio_data, chip);
>         struct kempld_device_data *pld = gpio->pld;
>  
> -       return kempld_gpio_get_bit(pld, KEMPLD_GPIO_DIR_NUM(offset),
> -                                  KEMPLD_GPIO_MASK(offset));
> +       return kempld_gpio_get_bit(pld, KEMPLD_GPIO_DIR_NUM(offset), offset);
>  }
>  
>  static int kempld_gpio_pincount(struct kempld_device_data *pld)
> 
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ