Skip to content

Commit

Permalink
gpiolib: fix chip order in gpio list
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Julien Grossholtz authored and Linus Walleij committed Jan 13, 2016
1 parent 7817998 commit 96098df
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions drivers/gpio/gpiolib.c
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down

0 comments on commit 96098df

Please sign in to comment.