All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] gpiolib: fix chip order in gpio list
@ 2016-01-07 21:46 Julien Grossholtz
  2016-01-13 10:11 ` Linus Walleij
  0 siblings, 1 reply; 3+ messages in thread
From: Julien Grossholtz @ 2016-01-07 21:46 UTC (permalink / raw)
  To: linus.walleij, gnurou
  Cc: linux-gpio, linux-kernel, kernel, bamvor.zhangjian, Julien Grossholtz

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 ship after
the last element of the gpio list.

Signed-off-by: Julien Grossholtz <julien.grossholtz@savoirfairelinux.com>
---
 drivers/gpio/gpiolib.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c
index 3db34e7..a180573 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");
-- 
2.5.0


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] gpiolib: fix chip order in gpio list
  2016-01-07 21:46 [PATCH] gpiolib: fix chip order in gpio list Julien Grossholtz
@ 2016-01-13 10:11 ` Linus Walleij
  2016-01-14  7:09   ` Bamvor Zhang Jian
  0 siblings, 1 reply; 3+ messages in thread
From: Linus Walleij @ 2016-01-13 10:11 UTC (permalink / raw)
  To: Julien Grossholtz, Bamvor Zhang Jian
  Cc: Alexandre Courbot, linux-gpio, linux-kernel, kernel

On Thu, Jan 7, 2016 at 10:46 PM, Julien Grossholtz
<julien.grossholtz@savoirfairelinux.com> wrote:

> 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 ship after
> the last element of the gpio list.
>
> Signed-off-by: Julien Grossholtz <julien.grossholtz@savoirfairelinux.com>

Patch looks correct to me so applied.

Bamvor: please comment if you see some problems.

Yours,
Linus Walleij

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] gpiolib: fix chip order in gpio list
  2016-01-13 10:11 ` Linus Walleij
@ 2016-01-14  7:09   ` Bamvor Zhang Jian
  0 siblings, 0 replies; 3+ messages in thread
From: Bamvor Zhang Jian @ 2016-01-14  7:09 UTC (permalink / raw)
  To: Linus Walleij, Julien Grossholtz
  Cc: Alexandre Courbot, linux-gpio, linux-kernel, kernel, Bamvor Zhang Jian

On 01/13/2016 06:11 PM, Linus Walleij wrote:
> On Thu, Jan 7, 2016 at 10:46 PM, Julien Grossholtz
> <julien.grossholtz@savoirfairelinux.com> wrote:
>
>> 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 ship after
s/ship/chip
>> the last element of the gpio list.
>>
>> Signed-off-by: Julien Grossholtz <julien.grossholtz@savoirfairelinux.com>
>
> Patch looks correct to me so applied.
>
> Bamvor: please comment if you see some problems.
Nope, it could pass all the testcases I wrote.

Regards

Bamvor
>
> Yours,
> Linus Walleij
>

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2016-01-14  7:09 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-01-07 21:46 [PATCH] gpiolib: fix chip order in gpio list Julien Grossholtz
2016-01-13 10:11 ` Linus Walleij
2016-01-14  7:09   ` Bamvor Zhang Jian

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.