[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAMRc=MdBEm71uVYwRYiLvi2ROTDH5O5exa9Nq5qQc=yQOiXpew@mail.gmail.com>
Date: Tue, 12 Sep 2023 13:34:46 +0200
From: Bartosz Golaszewski <brgl@...ev.pl>
To: Andy Shevchenko <andriy.shevchenko@...ux.intel.com>
Cc: Linus Walleij <linus.walleij@...aro.org>,
Mika Westerberg <mika.westerberg@...ux.intel.com>,
linux-gpio@...r.kernel.org, linux-kernel@...r.kernel.org,
linux-acpi@...r.kernel.org,
Bartosz Golaszewski <bartosz.golaszewski@...aro.org>
Subject: Re: [PATCH v2 07/11] gpiolib: replace find_chip_by_name() with gpio_device_find_by_label()
On Tue, Sep 12, 2023 at 1:08 PM Andy Shevchenko
<andriy.shevchenko@...ux.intel.com> wrote:
>
> On Tue, Sep 12, 2023 at 12:07:23PM +0200, Bartosz Golaszewski wrote:
> > From: Bartosz Golaszewski <bartosz.golaszewski@...aro.org>
> >
> > Remove all remaining uses of find_chip_by_name() (and subsequently:
> > gpiochip_find()) from gpiolib.c and use the new
> > gpio_device_find_by_label() instead.
>
> ...
>
> > for (hog = &hogs[0]; hog->chip_label; hog++) {
> > + struct gpio_device *gdev __free(gpio_device_put) = NULL;
>
> In the loop?! How does it work when loop goes second iteration and so on?
>
This works fine, the variable goes out of scope (reference is put) on
every iteration.
Bart
> > list_add_tail(&hog->list, &gpio_machine_hogs);
> >
> > /*
> > * The chip may have been registered earlier, so check if it
> > * exists and, if so, try to hog the line now.
> > */
> > - gc = find_chip_by_name(hog->chip_label);
> > - if (gc)
> > - gpiochip_machine_hog(gc, hog);
> > + gdev = gpio_device_find_by_label(hog->chip_label);
> > + if (gdev)
> > + gpiochip_machine_hog(gpio_device_get_chip(gdev), hog);
>
> So, do we expect the chip_label be different between hogs? Ah, seems so
> as it covers _all_ hogs in the system.
>
> > }
>
> Even if the __free() scope works fine, I think this algorithm should be
> revisited to make sure we have iterating only on hogs of the same chip.
> Hence, the hogs should be placed into tree structure with a label being
> the key in it.
>
> ...
>
> > + struct gpio_device *gdev __free(gpio_device_put) = NULL;
>
> > + gc = gpio_device_get_chip(gdev);
>
> Similar wish here, perhaps maple tree can be utilized in the future for both of them.
>
> --
> With Best Regards,
> Andy Shevchenko
>
>
Powered by blists - more mailing lists