[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAMRc=MddJ4gguNs2bHyQH6pFnApv6whjGgGPZP0aMEZ6C8a6_w@mail.gmail.com>
Date: Thu, 2 Jan 2025 14:22:10 +0100
From: Bartosz Golaszewski <brgl@...ev.pl>
To: Koichiro Den <koichiro.den@...onical.com>
Cc: linux-gpio@...r.kernel.org, linus.walleij@...aro.org,
linux-kernel@...r.kernel.org
Subject: Re: [PATCH 2/4] gpio: virtuser: fix handling of multiple conn_ids in
lookup table
On Tue, Dec 24, 2024 at 7:08 AM Koichiro Den <koichiro.den@...onical.com> wrote:
>
> Creating a virtuser device via configfs with multiple conn_ids fails due
> to incorrect indexing of lookup entries. Correct the indexing logic to
> ensure proper functionality when multiple gpio_virtuser_lookup are
> created.
>
> Fixes: 91581c4b3f29 ("gpio: virtuser: new virtual testing driver for the GPIO API")
> Signed-off-by: Koichiro Den <koichiro.den@...onical.com>
> ---
> drivers/gpio/gpio-virtuser.c | 8 ++++----
> 1 file changed, 4 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/gpio/gpio-virtuser.c b/drivers/gpio/gpio-virtuser.c
> index a81e15a4b807..c9700c1e4126 100644
> --- a/drivers/gpio/gpio-virtuser.c
> +++ b/drivers/gpio/gpio-virtuser.c
> @@ -1410,7 +1410,7 @@ gpio_virtuser_make_lookup_table(struct gpio_virtuser_device *dev)
> size_t num_entries = gpio_virtuser_get_lookup_count(dev);
> struct gpio_virtuser_lookup_entry *entry;
> struct gpio_virtuser_lookup *lookup;
> - unsigned int i = 0;
> + unsigned int i = 0, idx;
>
> lockdep_assert_held(&dev->lock);
>
> @@ -1424,12 +1424,12 @@ gpio_virtuser_make_lookup_table(struct gpio_virtuser_device *dev)
> return -ENOMEM;
>
> list_for_each_entry(lookup, &dev->lookup_list, siblings) {
> + idx = 0;
> list_for_each_entry(entry, &lookup->entry_list, siblings) {
> - table->table[i] =
> + table->table[i++] =
> GPIO_LOOKUP_IDX(entry->key,
> entry->offset < 0 ? U16_MAX : entry->offset,
> - lookup->con_id, i, entry->flags);
> - i++;
> + lookup->con_id, idx++, entry->flags);
> }
> }
>
> --
> 2.43.0
>
Thanks, somehow that escaped my attention, I never needed to use two
different con_ids.
Bart
Powered by blists - more mailing lists