Linux IIO development
 help / color / mirror / Atom feed
From: "Maxwell Doose" <m32285159@gmail.com>
To: "Joao Paulo Menezes Linaris" <jplinaris@usp.br>,
	<ilpo.jarvinen@linux.intel.com>, <wbg@kernel.org>
Cc: "Guilherme Dias" <guilhermeabreu200105@usp.br>,
	<linux-iio@vger.kernel.org>
Subject: Re: [PATCH] counter: intel-qep: Replace manual mutex logic with lock guards
Date: Fri, 08 May 2026 00:18:00 -0500	[thread overview]
Message-ID: <DID1HLASZ0VS.359G8NOYVYG0W@gmail.com> (raw)
In-Reply-To: <20260508034057.23595-1-jplinaris@usp.br>

Hi Joao, comments inline.

On Thu May 7, 2026 at 10:40 PM CDT, Joao Paulo Menezes Linaris wrote:
> Use scoped_guard() for handling mutex lock instead of locking and
> unlocking mutex explicitly. This improves readability by eliminating
> the need for gotos and by clearly indicating mutex will be locked only
> when execution is in guard scope.
>
> Signed-off-by: Joao Paulo Menezes Linaris <jplinaris@usp.br>
> Co-developed-by: Guilherme Dias <guilhermeabreu200105@usp.br>
> Signed-off-by: Guilherme Dias <guilhermeabreu200105@usp.br>
> ---
> v1 -> v2:
>  - fold the commit message properly
>  - replace scoped_guard() with guard()
>  - remove unnecessary comments
>

If this is the v2 then the subject should be:

[PATCH v2] counter: ...rest of subject here...

You can do this by running git format-patch -1 -v2.

> +	guard(mutex)(&qep->lock);
> +	if (qep->enabled)
> +		return -EBUSY;
>  

Would recommend putting blank lines between guard(mutex)() and other
code, Andy usually treats the guard()()s as separate things.

>
>  	pm_runtime_get_sync(qep->dev);
>  	intel_qep_writel(qep, INTEL_QEPMAX, max);
>  	pm_runtime_put(qep->dev);
>  
> -out:
> -	mutex_unlock(&qep->lock);
> -	return ret;
> +	return 0;
>  }
>  
>  static int intel_qep_enable_read(struct counter_device *counter,
> @@ -226,10 +221,10 @@ static int intel_qep_enable_write(struct counter_device *counter,
>  	u32 reg;
>  	bool changed;
>  
> -	mutex_lock(&qep->lock);
> +	guard(mutex)(&qep->lock);
>

Again (and so on and so forth).

best regards,
max


  reply	other threads:[~2026-05-08  5:18 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-05-08  3:40 [PATCH] counter: intel-qep: Replace manual mutex logic with lock guards Joao Paulo Menezes Linaris
2026-05-08  5:18 ` Maxwell Doose [this message]
  -- strict thread matches above, loose matches on Subject: below --
2026-04-22 21:05 Joao Paulo Menezes Linaris
2026-04-23 11:42 ` Ilpo Järvinen
2026-04-30 22:03   ` Joao Paulo Menezes Linaris

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=DID1HLASZ0VS.359G8NOYVYG0W@gmail.com \
    --to=m32285159@gmail.com \
    --cc=guilhermeabreu200105@usp.br \
    --cc=ilpo.jarvinen@linux.intel.com \
    --cc=jplinaris@usp.br \
    --cc=linux-iio@vger.kernel.org \
    --cc=wbg@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