From patchwork Fri Aug 23 12:51:11 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Krzysztof Kozlowski X-Patchwork-Id: 13775162 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 5E44FC531DC for ; Fri, 23 Aug 2024 12:59:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Cc:To:In-Reply-To:References :Message-Id:Content-Transfer-Encoding:Content-Type:MIME-Version:Subject:Date: From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=pPH0zYeEKEXW0yb0C0QcNli7uy5nXQcT3Asm3cghOnA=; b=1163Wr1dCPU3jiLgxrwvIfhnu0 1OjujZGjKVoic2iQtRq9r25VKps7ysl4CplHH3uEMt0CgeK+T7x2hXkl1KXEZFx0J9RVDvlgbupjl EJYb3WtSmF1UXKggVQtH4EKz+m2I09Nkj+iGcQ3em8Gmyo4oZI3ud5k3ogj1jUMl/QVN4MmoG4fhM Yt2XqwILwCdiKjHXPFwg+xitI55zr+fYq8AfsTvtDzYGiyVLLwInVyBYicIJb10X0xvDl2lW40E96 hcGUXBL58uLUrHnbXe7VA9HZ2BSWnwVuNxNcL8ID9I/C9ytrEaP9w0uGSe3O8QJmKfc+T9qNa+NDh nPo9K6nw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1shTsf-0000000Gmrk-07gt; Fri, 23 Aug 2024 12:59:05 +0000 Received: from desiato.infradead.org ([2001:8b0:10b:1:d65d:64ff:fe57:4e05]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1shTlc-0000000GlFz-2sUb for linux-arm-kernel@bombadil.infradead.org; Fri, 23 Aug 2024 12:51:48 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=desiato.20200630; h=Cc:To:In-Reply-To:References: Message-Id:Content-Transfer-Encoding:Content-Type:MIME-Version:Subject:Date: From:Sender:Reply-To:Content-ID:Content-Description; bh=pPH0zYeEKEXW0yb0C0QcNli7uy5nXQcT3Asm3cghOnA=; b=AuqGWAN2XmeuCBDFwJnVGAm7bQ dynR68jtgM1ERwvZeYqqgoAHmf23KlG/k5DAfu6zqSdTKZgt2dSRe69lQZazMREzA3tUlRln8Dazi 1eRtBULJx2d8p6l6IWiliG4cqkWEPbo0c0D2pswaYgvkWH8F+vBIAV9cNoj85KqGbmC20mosJF7c9 4tb6nTwKDDM5kNBvlVBHWJkaNRPxu/QV2stuRutliQ8J7VLmkGHr4jAP1bHMoG7B9+brAubE1s7hF ETnl6tdi30vfH4vXFnnQp+FZgHVfTktP7SNDkRWQATivUJwj9x2bhWTFxovfOKRDUZZsMzE7jvgtc RM8FEpgQ==; Received: from mail-lf1-x135.google.com ([2a00:1450:4864:20::135]) by desiato.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1shTlX-0000000A8WS-3oIb for linux-arm-kernel@lists.infradead.org; Fri, 23 Aug 2024 12:51:46 +0000 Received: by mail-lf1-x135.google.com with SMTP id 2adb3069b0e04-5334eec7485so331407e87.3 for ; Fri, 23 Aug 2024 05:51:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1724417500; x=1725022300; darn=lists.infradead.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=pPH0zYeEKEXW0yb0C0QcNli7uy5nXQcT3Asm3cghOnA=; b=ZmkLZTRpXzdlgZzDFVJ31zXiZT+hRluWj/bCYIr5NM0I8UyrjEkU0tfU6hBshhTpjf wsoFSPfDPwY8n/vr+fCNcvd5ZMJL/xRcU/22tXNn4HvGeDcNm54b1XCSw9nyY+kWcQA1 LVEilFWfbbsgB6Injo5hGBf1w6eo7IDA8GuirBEN0hpYqU/trCyXURxKHzXtRMblETIK HPZfjU2mIf7OfJy36DTHVaSVjEAYhN4GoZsdAraoFyPQ2lifAmJ8vDFWGnbUpcykIzYG MEyhr58XX6P2E8xp0EUAj+aiwIH/oDGIfp/9gz7FIgFx3bg5/xjmlCxYPoE9s6mQi0HQ kRPg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1724417500; x=1725022300; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=pPH0zYeEKEXW0yb0C0QcNli7uy5nXQcT3Asm3cghOnA=; b=lNLfH+Xm9TRNNDnjmrU8SV/UuAiksKpsZhbSf0jz5xskOiyw60uUf4nZCAPCxtxK4V hmcf1Y93yQjxxXGpFohV9Y7Qt0yAqzXgEyHVGsNYESZjjR6vrVe4cxwe7nO0BWrc2sww lM2Ai563WhSHS6fXsrq6H2bu8Gw2QDCwRkcJJZFCzwuCg4sWzBn4Eh9ybJbWsaTXliaJ uA/Uv6AulASVUY66HJf8vKJT/jjazFXAQfaP9yxoF02/RVcnHPtg8PMRmJbUeuCRFjGw ykQz9qbw/aHLaFoVXt19EbpG/mRF1Q/50WGBZwREa7popvD3BoImOnTtkYHRlPqq5tuc Z8fw== X-Forwarded-Encrypted: i=1; AJvYcCX78kyvjP5EC/EXXXBzxwlxONS6Tbx59md3ENrB4YW9LE0CeX38aA2AwvrmliimXG4ySCblMSD2Ned6whFjNET9@lists.infradead.org X-Gm-Message-State: AOJu0Yxa58n2ex9Yxmn8UggeLgKt6e0UIXnS6ynkX4WZ/pnxnKaoe9Pg 65+iB1fWC55OnxDLyTVp8CWsLFTaQk0YYPdujza3AwBgurNie8qfz/Bxwl4xqE0= X-Google-Smtp-Source: AGHT+IEx9QTBZ6Ig4dC6hFm6sSZWyp2NrZPz8Q5OQ6LiyVq1B5Hos95uvD5/wXcqZMFiFAQUCs44Kw== X-Received: by 2002:a05:6512:ea8:b0:52f:cf7e:b1bc with SMTP id 2adb3069b0e04-5343876c2a6mr830569e87.1.1724417499775; Fri, 23 Aug 2024 05:51:39 -0700 (PDT) Received: from [127.0.1.1] ([178.197.222.82]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a868f4f384bsm255931666b.192.2024.08.23.05.51.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 23 Aug 2024 05:51:39 -0700 (PDT) From: Krzysztof Kozlowski Date: Fri, 23 Aug 2024 14:51:11 +0200 Subject: [PATCH 07/10] pmdomain: qcom: rpmhpd: Simplify locking with guard() MIME-Version: 1.0 Message-Id: <20240823-cleanup-h-guard-pm-domain-v1-7-8320722eaf39@linaro.org> References: <20240823-cleanup-h-guard-pm-domain-v1-0-8320722eaf39@linaro.org> In-Reply-To: <20240823-cleanup-h-guard-pm-domain-v1-0-8320722eaf39@linaro.org> To: Ulf Hansson , Heiko Stuebner , Shawn Guo , Sascha Hauer , Pengutronix Kernel Team , Fabio Estevam , Bjorn Andersson , Konrad Dybcio , Geert Uytterhoeven , Magnus Damm Cc: linux-pm@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-rockchip@lists.infradead.org, linux-kernel@vger.kernel.org, imx@lists.linux.dev, linux-arm-msm@vger.kernel.org, linux-renesas-soc@vger.kernel.org, Krzysztof Kozlowski X-Mailer: b4 0.14.1 X-Developer-Signature: v=1; a=openpgp-sha256; l=1388; i=krzysztof.kozlowski@linaro.org; h=from:subject:message-id; bh=y0QBIaJnf0/fSVbWVB0Xkg+ZYq4xy8XVXKh8rGpZrnE=; b=owEBbQKS/ZANAwAKAcE3ZuaGi4PXAcsmYgBmyIXK0zZ4ZGoxkalISx0Oa0HQbALLrTngWax7j L5WXrBsTjyJAjMEAAEKAB0WIQTd0mIoPREbIztuuKjBN2bmhouD1wUCZsiFygAKCRDBN2bmhouD 1xawD/4+ne9u+0w9Ge4yGMtpLBPqws51qJWUNwZocPNFdFCwDtnWIBM/MFNMy6G7mVaitbYRu8S NufmqYkj3DXtJ2sKLwHYQ+wbGJkH2CKegDUkrberoehE5ecSQYeq+L8IeWTDwZ9t/8rORPyEAn3 0x+pkG6t7Pup4fVh2PrYBqNBLimMVjnwPz/u3f9Da+qwY2cQzBoPcqDso2D9mBwsquclFCwEpQR RWeucQ/vUYJtFQqNxObOMA/GEDW+JSHCT4mD2CN1z1T2ASa0Co/ordw0ZJc4WuU4KjCZk9xq9Dj 5GPBqEWzwt5f9DxLtaELBbhsyGQLEa13QryylbpEhT4Ax9ArnWkugphkF+OWJ5ewm8g5uB5xEqR KoLcKhf8VO506EI2bhmXkAW8+vnZmUMVyHnFQzvkDEeI7IjHYozxMcG8iYb+/3HEhwyZOL68qBx 32uk1Gw5Yu5BWFddNZeihHUePRt4KK8NHdUfvtPQiHYylFkpEFwViCU4s3Gwuz1A8vDyFBVWvfZ KzAVDDXyVLMfYt/VO5iVeN4dwHtmPf9xQzkIIwd0gDwPKgC062VVJVqdTysn95/R+LPN6zp8qej cO2gtpfnk+e8mUL7UlFd3ZonuKOUmlacOqS2E1+zGdH5umSfmjMv+B2cyoGRXy7d/2Gac7Miz36 HqfXODj1mLYdYeA== X-Developer-Key: i=krzysztof.kozlowski@linaro.org; a=openpgp; fpr=9BD07E0E0C51F8D59677B7541B93437D3B41629B X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240823_135144_346921_817DC43E X-CRM114-Status: GOOD ( 14.40 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Simplify error handling (less gotos) over locks with guard(). Signed-off-by: Krzysztof Kozlowski Reviewed-by: Konrad Dybcio --- drivers/pmdomain/qcom/rpmhpd.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/drivers/pmdomain/qcom/rpmhpd.c b/drivers/pmdomain/qcom/rpmhpd.c index d2cb4271a1ca..65505e1e2219 100644 --- a/drivers/pmdomain/qcom/rpmhpd.c +++ b/drivers/pmdomain/qcom/rpmhpd.c @@ -1,6 +1,7 @@ // SPDX-License-Identifier: GPL-2.0 /* Copyright (c) 2018, The Linux Foundation. All rights reserved.*/ +#include #include #include #include @@ -775,9 +776,9 @@ static int rpmhpd_set_performance_state(struct generic_pm_domain *domain, unsigned int level) { struct rpmhpd *pd = domain_to_rpmhpd(domain); - int ret = 0, i; + int ret, i; - mutex_lock(&rpmhpd_lock); + guard(mutex)(&rpmhpd_lock); for (i = 0; i < pd->level_count; i++) if (level <= pd->level[i]) @@ -797,14 +798,12 @@ static int rpmhpd_set_performance_state(struct generic_pm_domain *domain, ret = rpmhpd_aggregate_corner(pd, i); if (ret) - goto out; + return ret; } pd->corner = i; -out: - mutex_unlock(&rpmhpd_lock); - return ret; + return 0; } static int rpmhpd_update_level_mapping(struct rpmhpd *rpmhpd)