Messages in this thread | | | From | Linus Walleij <> | Date | Tue, 28 Nov 2023 15:21:40 +0100 | Subject | Re: [PATCH 2/2] gpio: use a mutex to protect the list of GPIO devices |
| |
On Mon, Nov 27, 2023 at 8:37 PM Bartosz Golaszewski <brgl@bgdev.pl> wrote:
> From: Bartosz Golaszewski <bartosz.golaszewski@linaro.org> > > The global list of GPIO devices is never modified or accessed from > atomic context so it's fine to protect it using a mutex. Add a new > global lock dedicated to the gpio_devices list and use it whenever > accessing or modifying it. > > While at it: fold the sysfs registering of existing devices into > gpiolib.c and make gpio_devices static within its compilation unit. > > Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
Nice! I might have found some snag:
gpio_device_find() still does guard(spinlock_irqsave)(&gpio_lock); shouldn't that be switched to the mutex?
On top of this I can update my patch to the delete the comment for gpio_lock to just rename that thing to gpio_descriptor_lock and document it as such.
But when I think about it: gpio[_decriptor]_lock can now (after this patch) be moved into struct gpio_chip as it is really just protecting the descriptors on the same chip from simultaneous modification, especially desc->flags. This is a BIG WIN because it makes it a local lock not a global one, do you wanna try it or should I? (On top of these two patches, then.)
Yours, Linus Walleij
| |