summaryrefslogtreecommitdiff
path: root/drivers/gpio/gpiolib.c
diff options
context:
space:
mode:
authorJulien Grossholtz <julien.grossholtz@savoirfairelinux.com>2016-01-08 00:46:45 +0300
committerLinus Walleij <linus.walleij@linaro.org>2016-01-13 12:57:49 +0300
commit96098df125c0a966631ec114081d8f5630a0e4b8 (patch)
tree9fff67b9fc70a91072fdb1f482fe12eee7b5f748 /drivers/gpio/gpiolib.c
parent78179989a06636d8362e2eee01b261d02b1500d2 (diff)
downloadlinux-96098df125c0a966631ec114081d8f5630a0e4b8.tar.xz
gpiolib: fix chip order in gpio list
In some situations the gpio_list order is not correct. As a consequence gpiochip_find_base returns the same base number twice. This happens when a first ship is added with manual base number, then other ships are added using automatic base number. To prevent this behaviour, this patch add the new chip after the last element of the gpio list. Signed-off-by: Julien Grossholtz <julien.grossholtz@savoirfairelinux.com> Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Diffstat (limited to 'drivers/gpio/gpiolib.c')
-rw-r--r--drivers/gpio/gpiolib.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c
index 3db34e74bc34..a1805734aef8 100644
--- a/drivers/gpio/gpiolib.c
+++ b/drivers/gpio/gpiolib.c
@@ -226,8 +226,10 @@ static int gpiochip_add_to_list(struct gpio_chip *chip)
*/
iterator = list_last_entry(&gpio_chips, struct gpio_chip, list);
- if (iterator->base + iterator->ngpio <= chip->base)
- goto found;
+ if (iterator->base + iterator->ngpio <= chip->base) {
+ list_add(&chip->list, &iterator->list);
+ return 0;
+ }
dev_err(chip->parent,
"GPIO integer space overlap, cannot add chip\n");