Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1303934 > unrolled thread

[PATCH] gpiolib: fix chip order in gpio list

Started byJulien Grossholtz <julien.grossholtz@savoirfairelinux.com>
First post2016-01-07 23:00 +0100
Last post2016-01-14 08:10 +0100
Articles 3 — 3 participants

Back to article view | Back to linux.kernel


Contents

  [PATCH] gpiolib: fix chip order in gpio list Julien Grossholtz <julien.grossholtz@savoirfairelinux.com> - 2016-01-07 23:00 +0100
    Re: [PATCH] gpiolib: fix chip order in gpio list Linus Walleij <linus.walleij@linaro.org> - 2016-01-13 11:20 +0100
      Re: [PATCH] gpiolib: fix chip order in gpio list Bamvor Zhang Jian <bamvor.zhangjian@linaro.org> - 2016-01-14 08:10 +0100

#1303934 — [PATCH] gpiolib: fix chip order in gpio list

FromJulien Grossholtz <julien.grossholtz@savoirfairelinux.com>
Date2016-01-07 23:00 +0100
Subject[PATCH] gpiolib: fix chip order in gpio list
Message-ID<qOqLa-5yd-29@gated-at.bofh.it>
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

[toc] | [next] | [standalone]


#1308247

FromLinus Walleij <linus.walleij@linaro.org>
Date2016-01-13 11:20 +0100
Message-ID<qQqGZ-6FS-5@gated-at.bofh.it>
In reply to#1303934
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

[toc] | [prev] | [next] | [standalone]


#1309049

FromBamvor Zhang Jian <bamvor.zhangjian@linaro.org>
Date2016-01-14 08:10 +0100
Message-ID<qQKcF-3zU-1@gated-at.bofh.it>
In reply to#1308247
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
>

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web