aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/gpio
diff options
context:
space:
mode:
authorBrunner Michael <Michael.Brunner@kontron.com>2013-07-31 14:55:39 -0400
committerLinus Walleij <linus.walleij@linaro.org>2013-08-16 11:56:53 -0400
commit2e7f6122642773fa467ab80adc30ef20c80dbda6 (patch)
tree032a790961d1c0bc78859d3c21fbbb4937bfbd70 /drivers/gpio
parent40a625daa88653d7942dc85483f6f289cd687cb7 (diff)
gpio: Fix bit masking in Kontron PLD GPIO driver
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@kontron.com> Signed-off-by: Guenter Roeck <linux@roeck-us.net> Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Diffstat (limited to 'drivers/gpio')
-rw-r--r--drivers/gpio/gpio-kempld.c24
1 files changed, 9 insertions, 15 deletions
diff --git a/drivers/gpio/gpio-kempld.c b/drivers/gpio/gpio-kempld.c
index 3f0e13b05953..efdc3924d7df 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,
46 46
47 status = kempld_read8(pld, reg); 47 status = kempld_read8(pld, reg);
48 if (val) 48 if (val)
49 status |= (1 << bit); 49 status |= KEMPLD_GPIO_MASK(bit);
50 else 50 else
51 status &= ~(1 << bit); 51 status &= ~KEMPLD_GPIO_MASK(bit);
52 kempld_write8(pld, reg, status); 52 kempld_write8(pld, reg, status);
53} 53}
54 54
@@ -60,7 +60,7 @@ static int kempld_gpio_get_bit(struct kempld_device_data *pld, u8 reg, u8 bit)
60 status = kempld_read8(pld, reg); 60 status = kempld_read8(pld, reg);
61 kempld_release_mutex(pld); 61 kempld_release_mutex(pld);
62 62
63 return !!(status & (1 << bit)); 63 return !!(status & KEMPLD_GPIO_MASK(bit));
64} 64}
65 65
66static int kempld_gpio_get(struct gpio_chip *chip, unsigned offset) 66static 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)
69 = container_of(chip, struct kempld_gpio_data, chip); 69 = container_of(chip, struct kempld_gpio_data, chip);
70 struct kempld_device_data *pld = gpio->pld; 70 struct kempld_device_data *pld = gpio->pld;
71 71
72 return kempld_gpio_get_bit(pld, KEMPLD_GPIO_LVL_NUM(offset), 72 return kempld_gpio_get_bit(pld, KEMPLD_GPIO_LVL_NUM(offset), offset);
73 KEMPLD_GPIO_MASK(offset));
74} 73}
75 74
76static void kempld_gpio_set(struct gpio_chip *chip, unsigned offset, int value) 75static 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)
80 struct kempld_device_data *pld = gpio->pld; 79 struct kempld_device_data *pld = gpio->pld;
81 80
82 kempld_get_mutex(pld); 81 kempld_get_mutex(pld);
83 kempld_gpio_bitop(pld, KEMPLD_GPIO_LVL_NUM(offset), 82 kempld_gpio_bitop(pld, KEMPLD_GPIO_LVL_NUM(offset), offset, value);
84 KEMPLD_GPIO_MASK(offset), value);
85 kempld_release_mutex(pld); 83 kempld_release_mutex(pld);
86} 84}
87 85
@@ -92,8 +90,7 @@ static int kempld_gpio_direction_input(struct gpio_chip *chip, unsigned offset)
92 struct kempld_device_data *pld = gpio->pld; 90 struct kempld_device_data *pld = gpio->pld;
93 91
94 kempld_get_mutex(pld); 92 kempld_get_mutex(pld);
95 kempld_gpio_bitop(pld, KEMPLD_GPIO_DIR_NUM(offset), 93 kempld_gpio_bitop(pld, KEMPLD_GPIO_DIR_NUM(offset), offset, 0);
96 KEMPLD_GPIO_MASK(offset), 0);
97 kempld_release_mutex(pld); 94 kempld_release_mutex(pld);
98 95
99 return 0; 96 return 0;
@@ -107,10 +104,8 @@ static int kempld_gpio_direction_output(struct gpio_chip *chip, unsigned offset,
107 struct kempld_device_data *pld = gpio->pld; 104 struct kempld_device_data *pld = gpio->pld;
108 105
109 kempld_get_mutex(pld); 106 kempld_get_mutex(pld);
110 kempld_gpio_bitop(pld, KEMPLD_GPIO_LVL_NUM(offset), 107 kempld_gpio_bitop(pld, KEMPLD_GPIO_LVL_NUM(offset), offset, value);
111 KEMPLD_GPIO_MASK(offset), value); 108 kempld_gpio_bitop(pld, KEMPLD_GPIO_DIR_NUM(offset), offset, 1);
112 kempld_gpio_bitop(pld, KEMPLD_GPIO_DIR_NUM(offset),
113 KEMPLD_GPIO_MASK(offset), 1);
114 kempld_release_mutex(pld); 109 kempld_release_mutex(pld);
115 110
116 return 0; 111 return 0;
@@ -122,8 +117,7 @@ static int kempld_gpio_get_direction(struct gpio_chip *chip, unsigned offset)
122 = container_of(chip, struct kempld_gpio_data, chip); 117 = container_of(chip, struct kempld_gpio_data, chip);
123 struct kempld_device_data *pld = gpio->pld; 118 struct kempld_device_data *pld = gpio->pld;
124 119
125 return kempld_gpio_get_bit(pld, KEMPLD_GPIO_DIR_NUM(offset), 120 return kempld_gpio_get_bit(pld, KEMPLD_GPIO_DIR_NUM(offset), offset);
126 KEMPLD_GPIO_MASK(offset));
127} 121}
128 122
129static int kempld_gpio_pincount(struct kempld_device_data *pld) 123static int kempld_gpio_pincount(struct kempld_device_data *pld)