public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
To: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>,
	linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org
Cc: Linus Walleij <linus.walleij@linaro.org>,
	Bartosz Golaszewski <brgl@bgdev.pl>,
	Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Subject: [PATCH v2 1/8] gpiolib: Make taking gpio_lookup_lock consistent
Date: Wed, 16 Apr 2025 12:55:09 +0300	[thread overview]
Message-ID: <20250416095645.2027695-2-andriy.shevchenko@linux.intel.com> (raw)
In-Reply-To: <20250416095645.2027695-1-andriy.shevchenko@linux.intel.com>

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>
---
 drivers/gpio/gpiolib.c | 8 ++------
 1 file changed, 2 insertions(+), 6 deletions(-)

diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c
index b8993d2d31e1..7d9cc1a9c535 100644
--- a/drivers/gpio/gpiolib.c
+++ b/drivers/gpio/gpiolib.c
@@ -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);
 
-- 
2.47.2


  reply	other threads:[~2025-04-16  9:56 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-04-16  9:55 [PATCH v2 0/8] gpiolib: Some cleanups Andy Shevchenko
2025-04-16  9:55 ` Andy Shevchenko [this message]
2025-04-16  9:55 ` [PATCH v2 2/8] gpiolib: Convert to use guard()() for gpio_machine_hogs_mutex Andy Shevchenko
2025-04-16  9:55 ` [PATCH v2 3/8] gpiolib: Print actual error when descriptor contains an error pointer Andy Shevchenko
2025-04-16  9:55 ` [PATCH v2 4/8] gpiolib: Revert "Don't WARN on gpiod_put() for optional GPIO" Andy Shevchenko
2025-04-16  9:55 ` [PATCH v2 5/8] gpiolib: Move validate_desc() and Co upper in the code Andy Shevchenko
2025-04-16  9:55 ` [PATCH v2 6/8] gpiolib: Call validate_desc() when VALIDATE_DESC() can't be used Andy Shevchenko
2025-04-16  9:55 ` [PATCH v2 7/8] gpiolib: Reuse return variable in gpiod_to_irq() Andy Shevchenko
2025-04-16  9:55 ` [PATCH v2 8/8] gpiolib: Remove redundant assignment of return variable Andy Shevchenko
2025-04-17 12:51 ` [PATCH v2 0/8] gpiolib: Some cleanups Bartosz Golaszewski

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20250416095645.2027695-2-andriy.shevchenko@linux.intel.com \
    --to=andriy.shevchenko@linux.intel.com \
    --cc=bartosz.golaszewski@linaro.org \
    --cc=brgl@bgdev.pl \
    --cc=linus.walleij@linaro.org \
    --cc=linux-gpio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox