lkml.org 
[lkml]   [2023]   [Nov]   [28]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH 2/2] gpio: use a mutex to protect the list of GPIO devices
On Mon, Nov 27, 2023 at 08:37:16PM +0100, Bartosz Golaszewski 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.

...

> + scoped_guard(mutex, &gpio_devices_lock) {

This is a lot of churn with this because of switching to RAII.
Can the body be firstly moved to a helper?

> + /*
> + * TODO: this allocates a Linux GPIO number base in the global
> + * GPIO numberspace for this chip. In the long run we want to
> + * get *rid* of this numberspace and use only descriptors, but
> + * it may be a pipe dream. It will not happen before we get rid
> + * of the sysfs interface anyways.
> + */

...

> list_for_each_entry(gdev, &gpio_devices, list)
> + if (index-- == 0)
> return gdev;

I believe this is better with outer {}.

--
With Best Regards,
Andy Shevchenko


\
 
 \ /
  Last update: 2023-11-28 17:09    [W:0.090 / U:0.192 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site