All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Ethan Tidmore" <ethantidmore06@gmail.com>
To: "David Lechner" <dlechner@baylibre.com>,
	"Ethan Tidmore" <ethantidmore06@gmail.com>,
	"Antoniu Miclaus" <antoniu.miclaus@analog.com>,
	"Jonathan Cameron" <jic23@kernel.org>,
	"Lars-Peter Clausen" <lars@metafoo.de>,
	"Michael Hennerich" <Michael.Hennerich@analog.com>
Cc: "Nuno Sá" <nuno.sa@analog.com>,
	"Andy Shevchenko" <andy@kernel.org>,
	linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH 2/3] iio: filter: admv8818: Simplify locking with guard()
Date: Mon, 02 Mar 2026 16:34:34 -0600	[thread overview]
Message-ID: <DGSNKQJ58INF.1ACGVKBMLTBT2@gmail.com> (raw)
In-Reply-To: <f7203222-eaac-4757-9328-c34660a27eb2@baylibre.com>

On Fri Feb 27, 2026 at 10:08 AM CST, David Lechner wrote:
> On 2/27/26 12:14 AM, Ethan Tidmore wrote:
>> Use guard() instead of manual locking to simplify code.
>> 
>> Signed-off-by: Ethan Tidmore <ethantidmore06@gmail.com>
>> ---
>
>
>> @@ -352,13 +344,8 @@ static int __admv8818_read_hpf_freq(struct admv8818_state *st, u64 *hpf_freq)
>>  
>>  static int admv8818_read_hpf_freq(struct admv8818_state *st, u64 *hpf_freq)
>>  {
>> -	int ret;
>> -
>> -	mutex_lock(&st->lock);
>> -	ret = __admv8818_read_hpf_freq(st, hpf_freq);
>> -	mutex_unlock(&st->lock);
>> -
>> -	return ret;
>> +	guard(mutex)(&st->lock);
>> +	return __admv8818_read_hpf_freq(st, hpf_freq);
>>  }
>
> admv8818_read_hpf_freq() is the only caller of __admv8818_read_hpf_freq()
> so we can drop the wrapper, move the guard to __admv8818_read_hpf_freq()
> and rename it to admv8818_read_hpf_freq().
>
> I didn't check all functions, but might be others places where we can do
> this as well.

So this can be easily done with a few wrappers but these two functions
have this odd scenario:

	guard(mutex)(&st->lock);

	ret = __admv8818_hpf_select(st, hpf_corner_target);
	if (ret)
		return ret;

	return __admv8818_lpf_select(st, lpf_corner_target);

Where if I deleted that guard() and just made those hold the lock
separately this would be a behaviour change. Wondering if there was a
nice way to get around this?

Thanks,

ET

  reply	other threads:[~2026-03-02 22:34 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-02-27  6:14 [PATCH 0/3] iio: filter: admv8818: Bug fix and other improvements Ethan Tidmore
2026-02-27  6:14 ` [PATCH 1/3] iio: filter: admv8818: Add missing error code Ethan Tidmore
2026-02-27  6:42   ` Ethan Tidmore
2026-02-27  7:06     ` Andy Shevchenko
2026-02-27 16:01       ` David Lechner
2026-02-27 16:06         ` Andy Shevchenko
2026-02-27  7:04   ` Andy Shevchenko
2026-02-27 16:02   ` David Lechner
2026-02-27  6:14 ` [PATCH 2/3] iio: filter: admv8818: Simplify locking with guard() Ethan Tidmore
2026-02-27  7:08   ` Andy Shevchenko
2026-02-27 16:08   ` David Lechner
2026-03-02 22:34     ` Ethan Tidmore [this message]
2026-02-27  6:14 ` [PATCH 3/3] iio: filter: admv8818: Minor cleanups Ethan Tidmore
2026-02-27  7:18   ` 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=DGSNKQJ58INF.1ACGVKBMLTBT2@gmail.com \
    --to=ethantidmore06@gmail.com \
    --cc=Michael.Hennerich@analog.com \
    --cc=andy@kernel.org \
    --cc=antoniu.miclaus@analog.com \
    --cc=dlechner@baylibre.com \
    --cc=jic23@kernel.org \
    --cc=lars@metafoo.de \
    --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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.