gpiolib: Make taking gpio_lookup_lock consistent
authorAndy Shevchenko <andriy.shevchenko@linux.intel.com>
Wed, 16 Apr 2025 09:55:09 +0000 (12:55 +0300)
committerBartosz Golaszewski <brgl@bgdev.pl>
Thu, 17 Apr 2025 13:22:05 +0000 (15:22 +0200)
There are two ways to take a lock: plain call to the mutex_lock()
or using guard()() / scoped_guard(). The driver inconsistently uses
both. Make taking gpio_lookup_lock consistent.

Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Link: https://lore.kernel.org/r/20250416095645.2027695-2-andriy.shevchenko@linux.intel.com
Signed-off-by: Bartosz Golaszewski <brgl@bgdev.pl>
drivers/gpio/gpiolib.c

index f208901ba478890fb179fd937285bb99e969f0c6..40ae0e09fb9f0a98ffd3b8911cdfc388ba1d2d45 100644 (file)
@@ -4363,12 +4363,10 @@ void gpiod_add_lookup_tables(struct gpiod_lookup_table **tables, size_t n)
 {
        unsigned int i;
 
-       mutex_lock(&gpio_lookup_lock);
+       guard(mutex)(&gpio_lookup_lock);
 
        for (i = 0; i < n; i++)
                list_add_tail(&tables[i]->list, &gpio_lookup_list);
-
-       mutex_unlock(&gpio_lookup_lock);
 }
 
 /**
@@ -4427,11 +4425,9 @@ void gpiod_remove_lookup_table(struct gpiod_lookup_table *table)
        if (!table)
                return;
 
-       mutex_lock(&gpio_lookup_lock);
+       guard(mutex)(&gpio_lookup_lock);
 
        list_del(&table->list);
-
-       mutex_unlock(&gpio_lookup_lock);
 }
 EXPORT_SYMBOL_GPL(gpiod_remove_lookup_table);