lkml.org 
[lkml]   [2013]   [Feb]   [5]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH 1/2] gpio: gpio-generic: Fix bug in big endian bit conversion
Date
The swap to convert LE to BE in bgpio_pin2mask_be should be on byte level, not
on bit level.

Signed-off-by: Andreas Larsson <andreas@gaisler.com>
---
drivers/gpio/gpio-generic.c | 5 ++++-
1 files changed, 4 insertions(+), 1 deletions(-)

diff --git a/drivers/gpio/gpio-generic.c b/drivers/gpio/gpio-generic.c
index 05fcc0f..7f11537 100644
--- a/drivers/gpio/gpio-generic.c
+++ b/drivers/gpio/gpio-generic.c
@@ -112,7 +112,10 @@ static unsigned long bgpio_pin2mask(struct bgpio_chip *bgc, unsigned int pin)
static unsigned long bgpio_pin2mask_be(struct bgpio_chip *bgc,
unsigned int pin)
{
- return 1 << (bgc->bits - 1 - pin);
+ unsigned int bit = pin & 0x7; /* Bit number within byte */
+ unsigned int base = pin - bit; /* Pin that is bit 0 within byte */
+
+ return 1 << ((bgc->bits - base - 8) + bit); /* shifted base + bit */
}

static int bgpio_get(struct gpio_chip *gc, unsigned int gpio)
--
1.7.0.4


\
 
 \ /
  Last update: 2013-02-05 12:01    [W:0.853 / U:0.008 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site