From: David Lechner <dlechner@baylibre.com>
To: Bartosz Golaszewski <brgl@bgdev.pl>,
Linus Walleij <linus.walleij@linaro.org>
Cc: linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org,
Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
Subject: Re: [PATCH v2 1/2] gpio: adnp: use lock guards for the I2C lock
Date: Thu, 21 May 2026 19:46:37 -0500 [thread overview]
Message-ID: <cde2abb2-4cc8-4fc9-b34a-0c5d2b95779f@baylibre.com> (raw)
In-Reply-To: <20250306-gpiochip-set-conversion-v2-1-a76e72e21425@linaro.org>
On 3/6/25 11:19 AM, Bartosz Golaszewski wrote:
> From: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
>
> Reduce the code complexity by using automatic lock guards with the I2C
> mutex.
>
> Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
> ---
...
> @@ -248,32 +232,24 @@ static irqreturn_t adnp_irq(int irq, void *data)
>
> for (i = 0; i < num_regs; i++) {
> unsigned int base = i << adnp->reg_shift, bit;
> - u8 changed, level, isr, ier;
> + u8 changed, level = 0, isr = 0, ier = 0;
> unsigned long pending;
> int err;
>
> - mutex_lock(&adnp->i2c_lock);
> + scoped_guard(mutex, &adnp->i2c_lock) {
> + err = adnp_read(adnp, GPIO_PLR(adnp) + i, &level);
> + if (err < 0)
> + continue;
I think this unintentionally changes the flow here. scoped_guard() is a
for loop, so the continue now breaks out of the scoped_guard() rather
than the outer for loop.
>
> - err = adnp_read(adnp, GPIO_PLR(adnp) + i, &level);
> - if (err < 0) {
> - mutex_unlock(&adnp->i2c_lock);
> - continue;
> + err = adnp_read(adnp, GPIO_ISR(adnp) + i, &isr);
> + if (err < 0)
> + continue;
> +
> + err = adnp_read(adnp, GPIO_IER(adnp) + i, &ier);
> + if (err < 0)
> + continue;
> }
>
> - err = adnp_read(adnp, GPIO_ISR(adnp) + i, &isr);
> - if (err < 0) {
> - mutex_unlock(&adnp->i2c_lock);
> - continue;
> - }
> -
> - err = adnp_read(adnp, GPIO_IER(adnp) + i, &ier);
> - if (err < 0) {
> - mutex_unlock(&adnp->i2c_lock);
> - continue;
> - }
> -
> - mutex_unlock(&adnp->i2c_lock);
> -
> /* determine pins that changed levels */
> changed = level ^ adnp->irq_level[i];
>
next prev parent reply other threads:[~2026-05-22 0:46 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-03-06 17:19 [PATCH v2 0/2] gpio: convert more drivers to using the new value setters Bartosz Golaszewski
2025-03-06 17:19 ` [PATCH v2 1/2] gpio: adnp: use lock guards for the I2C lock Bartosz Golaszewski
2025-03-14 10:09 ` Linus Walleij
2026-05-22 0:46 ` David Lechner [this message]
2026-05-22 7:36 ` Bartosz Golaszewski
2025-03-06 17:19 ` [PATCH v2 2/2] gpio: adnp: use new line value setter callbacks Bartosz Golaszewski
2025-03-14 10:09 ` Linus Walleij
2025-03-10 10:55 ` [PATCH v2 0/2] gpio: convert more drivers to using the new value setters 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=cde2abb2-4cc8-4fc9-b34a-0c5d2b95779f@baylibre.com \
--to=dlechner@baylibre.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
all inboxes | Powered by JetHome®