diff options
author | Alexandre Courbot <acourbot@nvidia.com> | 2013-02-02 11:29:26 -0500 |
---|---|---|
committer | Grant Likely <grant.likely@secretlab.ca> | 2013-02-09 04:23:30 -0500 |
commit | 125eef96f6cfadddbac8f6b9fccc9848988e7c6e (patch) | |
tree | 70c2cf06b32ba24460df717381a4f53e63401afc /drivers/gpio/gpiolib.c | |
parent | 65493e3ac429623df021e0859d97691f4b42615a (diff) |
gpiolib: use gpio_chips list in gpiochip_find
Using the GPIO chips list is much faster than parsing the entire GPIO
number space.
Signed-off-by: Alexandre Courbot <acourbot@nvidia.com>
Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Grant Likely <grant.likely@secretlab.ca>
Diffstat (limited to 'drivers/gpio/gpiolib.c')
-rw-r--r-- | drivers/gpio/gpiolib.c | 17 |
1 files changed, 7 insertions, 10 deletions
diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c index c1d8f7bdcd8f..5a79cb955d9f 100644 --- a/drivers/gpio/gpiolib.c +++ b/drivers/gpio/gpiolib.c | |||
@@ -1195,20 +1195,17 @@ struct gpio_chip *gpiochip_find(void *data, | |||
1195 | int (*match)(struct gpio_chip *chip, | 1195 | int (*match)(struct gpio_chip *chip, |
1196 | void *data)) | 1196 | void *data)) |
1197 | { | 1197 | { |
1198 | struct gpio_chip *chip = NULL; | 1198 | struct gpio_chip *chip; |
1199 | unsigned long flags; | 1199 | unsigned long flags; |
1200 | int i; | ||
1201 | 1200 | ||
1202 | spin_lock_irqsave(&gpio_lock, flags); | 1201 | spin_lock_irqsave(&gpio_lock, flags); |
1203 | for (i = 0; i < ARCH_NR_GPIOS; i++) { | 1202 | list_for_each_entry(chip, &gpio_chips, list) |
1204 | if (!gpio_desc[i].chip) | 1203 | if (match(chip, data)) |
1205 | continue; | ||
1206 | |||
1207 | if (match(gpio_desc[i].chip, data)) { | ||
1208 | chip = gpio_desc[i].chip; | ||
1209 | break; | 1204 | break; |
1210 | } | 1205 | |
1211 | } | 1206 | /* No match? */ |
1207 | if (&chip->list == &gpio_chips) | ||
1208 | chip = NULL; | ||
1212 | spin_unlock_irqrestore(&gpio_lock, flags); | 1209 | spin_unlock_irqrestore(&gpio_lock, flags); |
1213 | 1210 | ||
1214 | return chip; | 1211 | return chip; |