mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Jonathan Cameron <jic23@kernel.org>
To: Cosmin Tanislav <cosmin-gabriel.tanislav.xa@renesas.com>
Cc: Biju Das <biju.das.jz@bp.renesas.com>,
	William Breathitt Gray <wbg@kernel.org>,
	Lee Jones <lee@kernel.org>,
	linux-iio@vger.kernel.org, linux-renesas-soc@vger.kernel.org,
	linux-kernel@vger.kernel.org, stable@vger.kernel.org
Subject: Re: [PATCH 01/15] counter: rz-mtu3-cnt: put runtime PM on initialization error path
Date: Thu, 17 Sep 2026 01:46:16 +0100	[thread overview]
Message-ID: <20260917014616.17b5f0f2@jic23-hlaptop> (raw)
In-Reply-To: <20260914203614.2035277-2-cosmin-gabriel.tanislav.xa@renesas.com>

On Mon, 14 Sep 2026 23:36:00 +0300
Cosmin Tanislav <cosmin-gabriel.tanislav.xa@renesas.com> wrote:

> If rz_mtu3_initialize_counter() fails, the runtime PM usage count is not
> decremented.
> 
> rz_mtu3_initialize_counter() will fail if the requested channel is busy.
> 
> Call pm_runtime_put() in the error path to decrement the usage count,
> and flip the check to keep the success path straightforward.
> 
> Cc: stable@vger.kernel.org
> Fixes: 0be8907359df ("counter: Add Renesas RZ/G2L MTU3a counter driver")
> Signed-off-by: Cosmin Tanislav <cosmin-gabriel.tanislav.xa@renesas.com>
> ---
>  drivers/counter/rz-mtu3-cnt.c | 8 ++++++--
>  1 file changed, 6 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/counter/rz-mtu3-cnt.c b/drivers/counter/rz-mtu3-cnt.c
> index 7bfb6979193c..48f183f0b54f 100644
> --- a/drivers/counter/rz-mtu3-cnt.c
> +++ b/drivers/counter/rz-mtu3-cnt.c
> @@ -506,8 +506,12 @@ static int rz_mtu3_count_enable_write(struct counter_device *counter,
>  	if (enable) {
>  		pm_runtime_get_sync(counter->parent);
>  		ret = rz_mtu3_initialize_counter(counter, count->id);
> -		if (ret == 0)
> -			priv->count_is_enabled[count->id] = true;
> +		if (ret) {
> +			pm_runtime_put(counter->parent);
> +			goto exit;

I'd use a guard() for the mutex and return here and one more case
above. Not quite the minimal fix, but will give a more readable result.

> +		}
> +
> +		priv->count_is_enabled[count->id] = true;
>  	} else {
>  		rz_mtu3_terminate_counter(counter, count->id);
>  		priv->count_is_enabled[count->id] = false;


  reply	other threads:[~2026-09-17  0:46 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-14 20:35 [PATCH 00/15] MTU3 counter fixes and improvements Cosmin Tanislav
2026-09-14 20:36 ` [PATCH 01/15] counter: rz-mtu3-cnt: put runtime PM on initialization error path Cosmin Tanislav
2026-09-17  0:46   ` Jonathan Cameron [this message]
2026-09-17  6:36     ` Cosmin-Gabriel Tanislav
2026-09-14 20:36 ` [PATCH 02/15] counter: rz-mtu3-cnt: do not assign struct rz_mtu3_channel::dev Cosmin Tanislav
2026-09-14 20:36 ` [PATCH 03/15] counter: rz-mtu3-cnt: remove manual runtime PM handling Cosmin Tanislav
2026-09-14 20:36 ` [PATCH 04/15] counter: rz-mtu3-cnt: use device-managed pm_runtime_enable() Cosmin Tanislav
2026-09-14 20:36 ` [PATCH 05/15] counter: rz-mtu3-cnt: read enable value from cache Cosmin Tanislav
2026-09-14 20:36 ` [PATCH 06/15] counter: rz-mtu3-cnt: disable channel before releasing Cosmin Tanislav
2026-09-14 20:36 ` [PATCH 07/15] counter: rz-mtu3-cnt: unify ceiling values Cosmin Tanislav
2026-09-14 20:36 ` [PATCH 08/15] counter: rz-mtu3-cnt: cache " Cosmin Tanislav
2026-09-14 20:36 ` [PATCH 09/15] counter: rz-mtu3-cnt: cache count values Cosmin Tanislav
2026-09-14 20:36 ` [PATCH 10/15] counter: rz-mtu3-cnt: cache function values Cosmin Tanislav
2026-09-14 20:36 ` [PATCH 11/15] counter: rz-mtu3-cnt: cache external input phase clock value Cosmin Tanislav
2026-09-14 20:36 ` [PATCH 12/15] counter: rz-mtu3-cnt: cache direction values Cosmin Tanislav
2026-09-14 20:36 ` [PATCH 13/15] counter: rz-mtu3-cnt: keep cascade_counts_enable in sync with usage Cosmin Tanislav
2026-09-14 20:36 ` [PATCH 14/15] counter: rz-mtu3-cnt: drop conditional locks Cosmin Tanislav
2026-09-14 20:36 ` [PATCH 15/15] counter: rz-mtu3-cnt: use pm_runtime_resume_and_get() Cosmin Tanislav
2026-09-16 10:53 ` [PATCH 00/15] MTU3 counter fixes and improvements Lee Jones
2026-09-16 12:14   ` Cosmin-Gabriel Tanislav

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=20260917014616.17b5f0f2@jic23-hlaptop \
    --to=jic23@kernel.org \
    --cc=biju.das.jz@bp.renesas.com \
    --cc=cosmin-gabriel.tanislav.xa@renesas.com \
    --cc=lee@kernel.org \
    --cc=linux-iio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-renesas-soc@vger.kernel.org \
    --cc=stable@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

all inboxes | Powered by JetHome®