diff mbox series

[v2] counter: rz-mtu3-cnt: Reorder locking sequence for consistency

Message ID 20230721153933.332108-1-biju.das.jz@bp.renesas.com (mailing list archive)
State Handled Elsewhere
Headers show
Series [v2] counter: rz-mtu3-cnt: Reorder locking sequence for consistency | expand

Commit Message

Biju Das July 21, 2023, 3:39 p.m. UTC
All functions except rz_mtu3_count_enable_write(), calls
pm_runtime_{get,put} inside the lock. For consistency do the same here.

Reported-by: Pavel Machek <pavel@denx.de>
Closes: https://patchwork.kernel.org/project/cip-dev/patch/20230606075235.183132-6-biju.das.jz@bp.renesas.com/
Signed-off-by: Biju Das <biju.das.jz@bp.renesas.com>
---
v1->v2:
 * Updated commit header to make it clear this is not addressing a bug,
   rather it's just cleanup.
---
 drivers/counter/rz-mtu3-cnt.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Comments

Geert Uytterhoeven July 24, 2023, 2:47 p.m. UTC | #1
Hi Biju,

Thanks for your patch!

On Fri, Jul 21, 2023 at 5:39 PM Biju Das <biju.das.jz@bp.renesas.com> wrote:
> All functions except rz_mtu3_count_enable_write(), calls

call

> pm_runtime_{get,put} inside the lock. For consistency do the same here.
>
> Reported-by: Pavel Machek <pavel@denx.de>
> Closes: https://patchwork.kernel.org/project/cip-dev/patch/20230606075235.183132-6-biju.das.jz@bp.renesas.com/

This is not a direct link to Pavel's report, but to the bread started
by your patch.  Why not a link to lore?

Closes: https://lore.kernel.org/r/ZH8Fmom8vZ4DwxqA@duo.ucw.cz

> Signed-off-by: Biju Das <biju.das.jz@bp.renesas.com>
> ---
> v1->v2:
>  * Updated commit header to make it clear this is not addressing a bug,
>    rather it's just cleanup.

Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be>

Gr{oetje,eeting}s,

                        Geert
Biju Das July 24, 2023, 3:22 p.m. UTC | #2
Hi Geert,

Thanks for the feedback.

> On Fri, Jul 21, 2023 at 5:39 PM Biju Das <biju.das.jz@bp.renesas.com>
> wrote:
> > All functions except rz_mtu3_count_enable_write(), calls
> 
> call

OK.

> 
> > pm_runtime_{get,put} inside the lock. For consistency do the same
> here.
> >
> > Reported-by: Pavel Machek <pavel@denx.de>
> > Closes:
> 
> This is not a direct link to Pavel's report, but to the bread started by
> your patch.  Why not a link to lore?

OK, will use the link to lore.

Cheers,
Biju
diff mbox series

Patch

diff --git a/drivers/counter/rz-mtu3-cnt.c b/drivers/counter/rz-mtu3-cnt.c
index 48c83933aa2f..ee821493b166 100644
--- a/drivers/counter/rz-mtu3-cnt.c
+++ b/drivers/counter/rz-mtu3-cnt.c
@@ -500,8 +500,8 @@  static int rz_mtu3_count_enable_write(struct counter_device *counter,
 	int ret = 0;
 
 	if (enable) {
-		pm_runtime_get_sync(ch->dev);
 		mutex_lock(&priv->lock);
+		pm_runtime_get_sync(ch->dev);
 		ret = rz_mtu3_initialize_counter(counter, count->id);
 		if (ret == 0)
 			priv->count_is_enabled[count->id] = true;
@@ -510,8 +510,8 @@  static int rz_mtu3_count_enable_write(struct counter_device *counter,
 		mutex_lock(&priv->lock);
 		rz_mtu3_terminate_counter(counter, count->id);
 		priv->count_is_enabled[count->id] = false;
-		mutex_unlock(&priv->lock);
 		pm_runtime_put(ch->dev);
+		mutex_unlock(&priv->lock);
 	}
 
 	return ret;