Linux-GPIO Archive mirror
 help / color / mirror / Atom feed
From: Bartosz Golaszewski <brgl@kernel.org>
To: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Cc: "Nuno Sá" <nuno.sa@analog.com>,
	"Andy Shevchenko" <andy@kernel.org>,
	"Linus Walleij" <linusw@kernel.org>,
	"Bartosz Golaszewski" <brgl@kernel.org>,
	linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org,
	linux-gpio@vger.kernel.org,
	"Jonathan Cameron" <Jonathan.Cameron@huawei.com>,
	"Jonathan Cameron" <jic23@kernel.org>,
	"David Lechner" <dlechner@baylibre.com>
Subject: Re: [PATCH v4 1/4] iio: adc: ti-ads7950: switch to using guard() notation
Date: Mon, 30 Mar 2026 05:15:42 -0400	[thread overview]
Message-ID: <CAMRc=Mc0hMh2vL1qPo2SdKqvOKDEJaXm6rGKYeuA6mc8va2FWA@mail.gmail.com> (raw)
In-Reply-To: <20260329-ti-ads7950-facelift-v4-1-c568c508c49a@gmail.com>

On Mon, 30 Mar 2026 00:47:06 +0200, Dmitry Torokhov
<dmitry.torokhov@gmail.com> said:
> guard() notation allows early returns when encountering errors, making
> control flow more obvious. Use it.
>
> Reviewed-by: David Lechner <dlechner@baylibre.com>
> Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
> ---
>  drivers/iio/adc/ti-ads7950.c | 83 +++++++++++++++++---------------------------
>  1 file changed, 31 insertions(+), 52 deletions(-)
>
> diff --git a/drivers/iio/adc/ti-ads7950.c b/drivers/iio/adc/ti-ads7950.c
> index 028acd42741f..6e9ea9cc33bf 100644
> --- a/drivers/iio/adc/ti-ads7950.c
> +++ b/drivers/iio/adc/ti-ads7950.c
> @@ -299,18 +299,19 @@ static irqreturn_t ti_ads7950_trigger_handler(int irq, void *p)
>  	struct ti_ads7950_state *st = iio_priv(indio_dev);
>  	int ret;
>
> -	mutex_lock(&st->slock);
> -	ret = spi_sync(st->spi, &st->ring_msg);
> -	if (ret < 0)
> -		goto out;
> -
> -	iio_push_to_buffers_with_ts_unaligned(indio_dev, &st->rx_buf[2],
> -					      sizeof(*st->rx_buf) *
> -					      TI_ADS7950_MAX_CHAN,
> -					      iio_get_time_ns(indio_dev));
> -
> -out:
> -	mutex_unlock(&st->slock);
> +	do {
> +		guard(mutex)(&st->slock);

Am I missing something? Why isn't it just a:

	scoped_guard(mutex, &st->slock) {
		...
	}

?

Bart

  reply	other threads:[~2026-03-30  9:15 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-03-29 22:47 [PATCH v4 0/4] ti-ads7950: fix gpio handling and facelift Dmitry Torokhov
2026-03-29 22:47 ` [PATCH v4 1/4] iio: adc: ti-ads7950: switch to using guard() notation Dmitry Torokhov
2026-03-30  9:15   ` Bartosz Golaszewski [this message]
2026-03-30  9:18     ` Dmitry Torokhov
2026-03-30  9:21       ` Bartosz Golaszewski
2026-04-12 18:36         ` Jonathan Cameron
2026-03-29 22:47 ` [PATCH v4 2/4] iio: adc: ti-ads7950: simplify check for spi_setup() failures Dmitry Torokhov
2026-03-30  9:15   ` Bartosz Golaszewski
2026-03-29 22:47 ` [PATCH v4 3/4] iio: adc: ti-ads7950: switch to using devm_regulator_get_enable_read_voltage() Dmitry Torokhov
2026-03-30  9:17   ` Bartosz Golaszewski
2026-03-29 22:47 ` [PATCH v4 4/4] iio: adc: ti-ads7950: complete conversion to using managed resources Dmitry Torokhov
2026-03-30  9:20   ` Bartosz Golaszewski
2026-03-30  9:24     ` Dmitry Torokhov
2026-03-30 10:15       ` Andy Shevchenko

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='CAMRc=Mc0hMh2vL1qPo2SdKqvOKDEJaXm6rGKYeuA6mc8va2FWA@mail.gmail.com' \
    --to=brgl@kernel.org \
    --cc=Jonathan.Cameron@huawei.com \
    --cc=andy@kernel.org \
    --cc=dlechner@baylibre.com \
    --cc=dmitry.torokhov@gmail.com \
    --cc=jic23@kernel.org \
    --cc=linusw@kernel.org \
    --cc=linux-gpio@vger.kernel.org \
    --cc=linux-iio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=nuno.sa@analog.com \
    /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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).