aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/gpio/gpio-ich.c
diff options
context:
space:
mode:
authorJean Delvare <khali@linux-fr.org>2013-03-05 15:22:38 -0500
committerLinus Walleij <linus.walleij@linaro.org>2013-03-27 04:11:09 -0400
commit25f27db48e9d741cf3494f36e287d3c34a0fdba3 (patch)
treeaef9f0205a7d1ebbcf0d0a7c3021297adcdcb510 /drivers/gpio/gpio-ich.c
parent753c5983ddd38022a680a36f5d66b23b185c9b62 (diff)
gpio-ich: Check for pin availability at request time
Stop checking for pin availability in direction and get functions. These functions can be called repeatedly, so checking every time is bad for performance. Now that requesting GPIO pins is no longer optional, checking for availability at pin request time is enough. Signed-off-by: Jean Delvare <khali@linux-fr.org> Cc: Peter Tyser <ptyser@xes-inc.com> Cc: Grant Likely <grant.likely@secretlab.ca> Cc: Linus Walleij <linus.walleij@linaro.org> Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Diffstat (limited to 'drivers/gpio/gpio-ich.c')
-rw-r--r--drivers/gpio/gpio-ich.c15
1 files changed, 3 insertions, 12 deletions
diff --git a/drivers/gpio/gpio-ich.c b/drivers/gpio/gpio-ich.c
index f9dbd503fc40..31682178c59b 100644
--- a/drivers/gpio/gpio-ich.c
+++ b/drivers/gpio/gpio-ich.c
@@ -135,9 +135,6 @@ static bool ichx_gpio_check_available(struct gpio_chip *gpio, unsigned nr)
135 135
136static int ichx_gpio_direction_input(struct gpio_chip *gpio, unsigned nr) 136static int ichx_gpio_direction_input(struct gpio_chip *gpio, unsigned nr)
137{ 137{
138 if (!ichx_gpio_check_available(gpio, nr))
139 return -ENXIO;
140
141 /* 138 /*
142 * Try setting pin as an input and verify it worked since many pins 139 * Try setting pin as an input and verify it worked since many pins
143 * are output-only. 140 * are output-only.
@@ -151,9 +148,6 @@ static int ichx_gpio_direction_input(struct gpio_chip *gpio, unsigned nr)
151static int ichx_gpio_direction_output(struct gpio_chip *gpio, unsigned nr, 148static int ichx_gpio_direction_output(struct gpio_chip *gpio, unsigned nr,
152 int val) 149 int val)
153{ 150{
154 if (!ichx_gpio_check_available(gpio, nr))
155 return -ENXIO;
156
157 /* Set GPIO output value. */ 151 /* Set GPIO output value. */
158 ichx_write_bit(GPIO_LVL, nr, val, 0); 152 ichx_write_bit(GPIO_LVL, nr, val, 0);
159 153
@@ -169,9 +163,6 @@ static int ichx_gpio_direction_output(struct gpio_chip *gpio, unsigned nr,
169 163
170static int ichx_gpio_get(struct gpio_chip *chip, unsigned nr) 164static int ichx_gpio_get(struct gpio_chip *chip, unsigned nr)
171{ 165{
172 if (!ichx_gpio_check_available(chip, nr))
173 return -ENXIO;
174
175 return ichx_read_bit(GPIO_LVL, nr); 166 return ichx_read_bit(GPIO_LVL, nr);
176} 167}
177 168
@@ -180,9 +171,6 @@ static int ich6_gpio_get(struct gpio_chip *chip, unsigned nr)
180 unsigned long flags; 171 unsigned long flags;
181 u32 data; 172 u32 data;
182 173
183 if (!ichx_gpio_check_available(chip, nr))
184 return -ENXIO;
185
186 /* 174 /*
187 * GPI 0 - 15 need to be read from the power management registers on 175 * GPI 0 - 15 need to be read from the power management registers on
188 * a ICH6/3100 bridge. 176 * a ICH6/3100 bridge.
@@ -207,6 +195,9 @@ static int ich6_gpio_get(struct gpio_chip *chip, unsigned nr)
207 195
208static int ichx_gpio_request(struct gpio_chip *chip, unsigned nr) 196static int ichx_gpio_request(struct gpio_chip *chip, unsigned nr)
209{ 197{
198 if (!ichx_gpio_check_available(chip, nr))
199 return -ENXIO;
200
210 /* 201 /*
211 * Note we assume the BIOS properly set a bridge's USE value. Some 202 * Note we assume the BIOS properly set a bridge's USE value. Some
212 * chips (eg Intel 3100) have bogus USE values though, so first see if 203 * chips (eg Intel 3100) have bogus USE values though, so first see if