From nobody Thu Dec 18 20:37:39 2025 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 032F9C6FA8F for ; Wed, 30 Aug 2023 18:45:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236172AbjH3Sbh (ORCPT ); Wed, 30 Aug 2023 14:31:37 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52112 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1343950AbjH3Rff (ORCPT ); Wed, 30 Aug 2023 13:35:35 -0400 Received: from rere.qmqm.pl (rere.qmqm.pl [91.227.64.183]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DE91F198 for ; Wed, 30 Aug 2023 10:35:32 -0700 (PDT) Received: from remote.user (localhost [127.0.0.1]) by rere.qmqm.pl (Postfix) with ESMTPSA id 4RbWfC14KfzMG; Wed, 30 Aug 2023 19:35:31 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=rere.qmqm.pl; s=1; t=1693416931; bh=PnYjkE6gtqAOfIRwVhLGjxruQguXRdfkE9L0v73w0Nk=; h=Date:In-Reply-To:References:Subject:From:To:Cc:From; b=GgzllHXWm363dOzSs4WrNZTcC8K6hBGPjynUno9kvKFwdaJkSvzJLTsap7Q+RAafv xyzsp7mkfmBZjcgjd3pOaIcyggzv4MzhDAzcn3Z1CAlF/bMjGn6m4KQSngoODsx0oD H1pCOOwPLcvv4d+h4m0/hcK2Tb0qQmlvODeHpYqngaOgt2oioFWMqbPxsUiHenOxcd sh/T9grNhX4EqAiAecBpppb6r0MU96bIfSuApO8v42IBq1WLoIB/GqCe1dOWl/hSZJ OtKFU18gYLreBuZB8OhrjrJfvqilC5fYab3aRSMKB1s1Ya7PagSI+rLnWiN/Mcihi9 jOQhcQXqnJbnQ== X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.8 at mail Date: Wed, 30 Aug 2023 19:35:30 +0200 Message-Id: <121c27939458ca3c1424b38fd6cee2d81cef831e.1693416477.git.mirq-linux@rere.qmqm.pl> In-Reply-To: References: Subject: [PATCH v2 1/7] regulator/core: regulator_lock_nested: remove `lock` MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable From: =?UTF-8?q?Micha=C5=82=20Miros=C5=82aw?= To: Liam Girdwood , Mark Brown Cc: linux-kernel@vger.kernel.org, Douglas Anderson , Stephen Boyd Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org `lock` is only false when the `rdev` is already locked and the owner is `current`. In this case `ret` is always zero. By removing `lock`, we thus remove `mutex_owner` write avoidance, but make the code flow more understandable. Reviewed-by: Douglas Anderson Signed-off-by: Micha=C5=82 Miros=C5=82aw --- drivers/regulator/core.c | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c index d8e1caaf207e..215b721e5cd4 100644 --- a/drivers/regulator/core.c +++ b/drivers/regulator/core.c @@ -141,27 +141,19 @@ static bool regulator_ops_is_valid(struct regulator_d= ev *rdev, int ops) static inline int regulator_lock_nested(struct regulator_dev *rdev, struct ww_acquire_ctx *ww_ctx) { - bool lock =3D false; int ret =3D 0; =20 mutex_lock(®ulator_nesting_mutex); =20 if (!ww_mutex_trylock(&rdev->mutex, ww_ctx)) { - if (rdev->mutex_owner =3D=3D current) - rdev->ref_cnt++; - else - lock =3D true; - - if (lock) { + if (rdev->mutex_owner !=3D current) { mutex_unlock(®ulator_nesting_mutex); ret =3D ww_mutex_lock(&rdev->mutex, ww_ctx); mutex_lock(®ulator_nesting_mutex); } - } else { - lock =3D true; } =20 - if (lock && ret !=3D -EDEADLK) { + if (ret !=3D -EDEADLK) { rdev->ref_cnt++; rdev->mutex_owner =3D current; } --=20 2.39.2