From patchwork Fri Jul 21 15:39:33 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Biju Das X-Patchwork-Id: 13322177 X-Patchwork-Delegate: geert@linux-m68k.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 23E73EB64DC for ; Fri, 21 Jul 2023 15:39:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232082AbjGUPjx (ORCPT ); Fri, 21 Jul 2023 11:39:53 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42064 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231186AbjGUPjw (ORCPT ); Fri, 21 Jul 2023 11:39:52 -0400 Received: from relmlie6.idc.renesas.com (relmlor2.renesas.com [210.160.252.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 55F153586; Fri, 21 Jul 2023 08:39:40 -0700 (PDT) X-IronPort-AV: E=Sophos;i="6.01,220,1684767600"; d="scan'208";a="174037620" Received: from unknown (HELO relmlir5.idc.renesas.com) ([10.200.68.151]) by relmlie6.idc.renesas.com with ESMTP; 22 Jul 2023 00:39:38 +0900 Received: from localhost.localdomain (unknown [10.226.92.55]) by relmlir5.idc.renesas.com (Postfix) with ESMTP id 4F1CF40104F7; Sat, 22 Jul 2023 00:39:36 +0900 (JST) From: Biju Das To: William Breathitt Gray Cc: Biju Das , linux-iio@vger.kernel.org, linux-renesas-soc@vger.kernel.org, Geert Uytterhoeven , Pavel Machek , Prabhakar Mahadev Lad Subject: [PATCH v2] counter: rz-mtu3-cnt: Reorder locking sequence for consistency Date: Fri, 21 Jul 2023 16:39:33 +0100 Message-Id: <20230721153933.332108-1-biju.das.jz@bp.renesas.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-renesas-soc@vger.kernel.org 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 Closes: https://patchwork.kernel.org/project/cip-dev/patch/20230606075235.183132-6-biju.das.jz@bp.renesas.com/ Signed-off-by: Biju Das Reviewed-by: Geert Uytterhoeven --- 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(-) 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;