From patchwork Mon Dec 9 12:24:04 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Krzysztof Kozlowski X-Patchwork-Id: 13899473 Received: from mail-ej1-f42.google.com (mail-ej1-f42.google.com [209.85.218.42]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 286FA2236E5 for ; Mon, 9 Dec 2024 12:24:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.218.42 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733747058; cv=none; b=CzxfayxWIvaB3Mo0oXhYdUMKirAp3DHT9zWwI7gGLJ6/NzPR9Qpi6CdYK3sAHg8lQ/FuQLCYt/cyXfwabZ/O59z8BWUkFtpWfmYd91JEeoBnf5bQ9cJc0uQbuIcdpRWVSP3Oq775WRBbHbieoUQy9Edje5Ci08fpb7+gP20RR7g= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733747058; c=relaxed/simple; bh=4OE2UNumV4s+P2YUC0SiuAHNvh4UuP4uD4bB25xADG4=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=OzPPGtmU1E07Z+WKZTCOtQ/KhSDtMKdKST1Yu0spw/EiBT39XydXWPllVYlfmGdK0pSRLTA2l1WEx3cgqdmzRDRBaGLH0AZqDnbadEQ/TfiGSMrQmy9k2y9T/tRf2a+JlMyCtGO9jI2KFG+zsWwt0baA5HhImgcSlvtIammQlpc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org; spf=pass smtp.mailfrom=linaro.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b=h84n/pQb; arc=none smtp.client-ip=209.85.218.42 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="h84n/pQb" Received: by mail-ej1-f42.google.com with SMTP id a640c23a62f3a-aa69599b4b0so8563666b.3 for ; Mon, 09 Dec 2024 04:24:14 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1733747053; x=1734351853; darn=vger.kernel.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=eYnPC+3dnQ3xTBOM4P/CUIbuS3rg7DS/lMF/rRnPfpc=; b=h84n/pQboWq8MNlXDDWrDmlmtWfZU4esF7eLnQx1emFtcm2fMxuYD6J5XR1iwlo81W CY3gAtdN75j84IupY09vcoTnEqyQmCe+9h2ZJbaeEQzoPdO96SwhSqYIqW1ndrNHcZow y7fmdiRwcjfvPDCDPQGRwTGHcxZkz9c8iOmshY4Wn3ogPaAG86eZC6Q/rhAUjY7RWHEU dsp9enWG4kZkhYYjPtp4850OJG43UmiGZejVrrtyOFDp75Lw57/aZeeRCvb+guffVUQQ qq9T6IZRK7BH3YjCa4FjOyic3UuNAspeqZh7HjvQtSdWZYQ4qSrXFNweqzA8UEH9em9N 9/0A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1733747053; x=1734351853; 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=eYnPC+3dnQ3xTBOM4P/CUIbuS3rg7DS/lMF/rRnPfpc=; b=GyOdgW12ixV7gvr3Pl6MZoSJ+YTFsHgmEtYYJL+h60Olg7kirEIwqC3V+9kgqj7vYR whCBhdYkav2XbXvUk0RxrTMthSBGxnB3x/l3FLtrOT7ATfGG8s4IdMOpWs4YfsYtQI2/ NwlU5wlExrvyjULu8lqV840aGiPTSZK40nVzZS4crUIMbF372JTqsnaZv9I/fMFwrTWk Z64M2d/Cqireg3/WBTg4O8A667S91N/UJXNLOspn1zikBuPguOwvETbB3UPPAcr5dvjw u0mFiW/vs1ua7/s96twybIkA5GcJrw4tUqswzSTJlG61t8RPpAw9f02JURHXcxN30PWI /hOw== X-Gm-Message-State: AOJu0YwbfDENwlbrxDUC2sZKXzYXliiyVSdxgWSxDCT98N0+MFadz5QP c3vbJD6r9+33jHmdQrdcK8BvNS6gmk3ZYjM72NZ8k+sICZv+5AjkqoeyVdmGb4c= X-Gm-Gg: ASbGnct+sgOa1+302HvAPaPmj8gRBTYT6Aje4ciGkj/ylYIriaa29A3rSYyiMump+2S a/3ka4gs/kYaow3ZaN49miyjCmdlPOjyyeD/TCY/obXpRdejPTs4XghgR2oOeOpYDasBGDzNrNY PJQovNfeyn2SrFU8zKeBkTlQ5kHe0mLr3PsDINSt9KmXHotf5u9B/dfNJzzwvfI25CjQyjzxREw jm0vcn1PsUB6cW8G8JuR96SjTQvLCblFxmUVEbC6Jw8HVli8CuLc/2XAAnScBXYMw== X-Google-Smtp-Source: AGHT+IGA6c7ObX/AOXazYgFDpzOOBnfoe8Yqzc7iHHBjGsOsomSWtlEo9XgjPuAQbV9iNrzjXdFM6A== X-Received: by 2002:a17:907:180d:b0:aa6:9407:34e1 with SMTP id a640c23a62f3a-aa694074166mr69867966b.10.1733747053409; Mon, 09 Dec 2024 04:24:13 -0800 (PST) Received: from [127.0.1.1] ([178.197.223.165]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-aa66b96a249sm309925866b.159.2024.12.09.04.24.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 09 Dec 2024 04:24:12 -0800 (PST) From: Krzysztof Kozlowski Date: Mon, 09 Dec 2024 13:24:04 +0100 Subject: [PATCH RESEND 1/3] clk: qcom: rpm: simplify locking with guard() Precedence: bulk X-Mailing-List: linux-arm-msm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20241209-cleanup-h-guard-clk-qcom-v1-1-b1077540230c@linaro.org> References: <20241209-cleanup-h-guard-clk-qcom-v1-0-b1077540230c@linaro.org> In-Reply-To: <20241209-cleanup-h-guard-clk-qcom-v1-0-b1077540230c@linaro.org> To: Bjorn Andersson , Michael Turquette , Stephen Boyd Cc: linux-arm-msm@vger.kernel.org, linux-clk@vger.kernel.org, linux-kernel@vger.kernel.org, Krzysztof Kozlowski X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=openpgp-sha256; l=2493; i=krzysztof.kozlowski@linaro.org; h=from:subject:message-id; bh=4OE2UNumV4s+P2YUC0SiuAHNvh4UuP4uD4bB25xADG4=; b=owEBbQKS/ZANAwAKAcE3ZuaGi4PXAcsmYgBnVuFoTo9hkhnYTavcOtwQzo5Vc6u5rjORkxajj HdN4pZbS8GJAjMEAAEKAB0WIQTd0mIoPREbIztuuKjBN2bmhouD1wUCZ1bhaAAKCRDBN2bmhouD 12raD/96VfLAsBFtWhV3CZjopOabQG1tVIiYugRecFOeUe4huzVbCLV24Gqo6CtGetm5JOKfHz8 iOSOY+JilVXTGN/T9VCT4Y1i7fMcLnSTCtj75satrIA5mLoFRShxSQmz90dkJ0F/7JrIaiQclr4 XTEHI9O+9ixi3Qyoha3GeYDXlNnXvNuqJZHG8K/nhGiqhgyLASdqi4hwF5RickcC92c67eAkKp3 XvmvRFhuej/UHMCXyXF38kpM5XvOJw3VfV6p7A56yGJ+25c3ubuMS49pob3f5fAxPMShjJixZDu D4np7E0/HR6uPHdSBwn5hTNIs/xbID39CkOedY+jBf4pSHr3ANd2YhdAFtPzIY8OWeFyLapwFGP m/v/pr/u7UDpG8Iao7aKOfKQHH1ntv4CSbW842ouj1ialhf6u8Tu2+KK3jFam/rZcszMRtkU3tn 1NwjLkqtoQS5fLMLXM0NwY6hBKGx0E93IoJv4T6VbNFxzpveX1jQYLXPiOwVY3r4RkB9rzrpoFZ 5X2yWBqKwPg8Q6m/hTMCFt2EDkgyrbsgDHtzRDW3Lqu95IKhlhh+ulbH+7kL3mszVT9rie5XONW of1ch36rPll/SRPjtrYKn1RsyEQcfe8hboHNol/IBiNvb3nqhn9QCO8hakL4OPLlj/s7p+mm1ab 1AloIYvxm2ViWPw== X-Developer-Key: i=krzysztof.kozlowski@linaro.org; a=openpgp; fpr=9BD07E0E0C51F8D59677B7541B93437D3B41629B Simplify error handling (less gotos) over locks with guard(). Signed-off-by: Krzysztof Kozlowski --- drivers/clk/qcom/clk-rpm.c | 27 +++++++++++---------------- 1 file changed, 11 insertions(+), 16 deletions(-) diff --git a/drivers/clk/qcom/clk-rpm.c b/drivers/clk/qcom/clk-rpm.c index 9da034f8f2ff504404abc4f7a0d3b8fb841a6ce0..ccc112c21667ebf8522b06b37234f46c69b07698 100644 --- a/drivers/clk/qcom/clk-rpm.c +++ b/drivers/clk/qcom/clk-rpm.c @@ -4,6 +4,7 @@ * Copyright (c) 2014, The Linux Foundation. All rights reserved. */ +#include #include #include #include @@ -224,10 +225,10 @@ static void clk_rpm_unprepare(struct clk_hw *hw) unsigned long active_rate, sleep_rate; int ret; - mutex_lock(&rpm_clk_lock); + guard(mutex)(&rpm_clk_lock); if (!r->rate) - goto out; + return; /* Take peer clock's rate into account only if it's enabled. */ if (peer->enabled) @@ -237,17 +238,14 @@ static void clk_rpm_unprepare(struct clk_hw *hw) active_rate = r->branch ? !!peer_rate : peer_rate; ret = clk_rpm_set_rate_active(r, active_rate); if (ret) - goto out; + return; sleep_rate = r->branch ? !!peer_sleep_rate : peer_sleep_rate; ret = clk_rpm_set_rate_sleep(r, sleep_rate); if (ret) - goto out; + return; r->enabled = false; - -out: - mutex_unlock(&rpm_clk_lock); } static int clk_rpm_xo_prepare(struct clk_hw *hw) @@ -324,12 +322,12 @@ static int clk_rpm_set_rate(struct clk_hw *hw, unsigned long active_rate, sleep_rate; unsigned long this_rate = 0, this_sleep_rate = 0; unsigned long peer_rate = 0, peer_sleep_rate = 0; - int ret = 0; + int ret; - mutex_lock(&rpm_clk_lock); + guard(mutex)(&rpm_clk_lock); if (!r->enabled) - goto out; + return 0; to_active_sleep(r, rate, &this_rate, &this_sleep_rate); @@ -341,19 +339,16 @@ static int clk_rpm_set_rate(struct clk_hw *hw, active_rate = max(this_rate, peer_rate); ret = clk_rpm_set_rate_active(r, active_rate); if (ret) - goto out; + return ret; sleep_rate = max(this_sleep_rate, peer_sleep_rate); ret = clk_rpm_set_rate_sleep(r, sleep_rate); if (ret) - goto out; + return ret; r->rate = rate; -out: - mutex_unlock(&rpm_clk_lock); - - return ret; + return 0; } static long clk_rpm_round_rate(struct clk_hw *hw, unsigned long rate, From patchwork Mon Dec 9 12:24:05 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Krzysztof Kozlowski X-Patchwork-Id: 13899474 Received: from mail-ej1-f54.google.com (mail-ej1-f54.google.com [209.85.218.54]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6A9EA223704 for ; Mon, 9 Dec 2024 12:24:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.218.54 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733747059; cv=none; b=Oncj9UTbNhryG03ZUIMwmMxxlQ8BzKayFSLquxWymdL53l6W/cj+tn5sUAgfyYA6o1u6ZE1oIqiOchQyVvtrLW3AvgF2sSiQ/15V8wNWbcg1vqE7w1PNwbk/9ZDvbWSNeUcYZPLEGp1aUxJEOhH4RtcRV8B3Qvit9i2tvdAgAQg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733747059; c=relaxed/simple; bh=rkMjCrwS1+wByjVOGZBOyBmwHcPRefAACRVZAjVFMrg=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=KxgURKYKKwl4ztEUEgLY3gxEf/x+aK+pU0ODjFWeWYeY+wP3sM45fhQ76t5rPBF4IF7uakbWeQlmJKEdiJ7toGfMKb3bbEQ91pbFDN4wO+M7bDPs0uQNf+kWt45/nAhrlU+wDIqZgnr2Ejh1lbmROhMUaVT7crnuM8k39R3Pw/c= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org; spf=pass smtp.mailfrom=linaro.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b=TSkfFdnj; arc=none smtp.client-ip=209.85.218.54 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="TSkfFdnj" Received: by mail-ej1-f54.google.com with SMTP id a640c23a62f3a-aa67ceb4e31so27183066b.1 for ; Mon, 09 Dec 2024 04:24:16 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1733747055; x=1734351855; darn=vger.kernel.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=4VS86PQrU3aNTPQz7X0NdV1vS6PaGx8hn6CNMCEHmEw=; b=TSkfFdnj85CTjX7fstayGkA+yd08BtcXBT/3toiUjY3nBkkYZBXSHhN3uk3kBVpPMc vAexlKp7C2eSDL63Hz7EXl3hZSBshsIx/mqlkgt8AR2Yh2U1JYzuWX4u2GKtPjE/ujVs RAykGzOOb37O2A/EDHjXwX7tWS++CrZI5fNBDrTMVIl55WgvPENwXKfpEq0wKsYToyBG uDkaT0PcH/XRXTTBZhD/RgZzA26FxUcOKXXR/wbkCI8JHxMO3WFFKdnTAIOWpjpKiy02 7dhz+75DkHynof/09jlwwFvPdxmM9C33wIwuWayf3bHuZUsMy2WenQKMXRmVSLxNklM5 W4SQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1733747055; x=1734351855; 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=4VS86PQrU3aNTPQz7X0NdV1vS6PaGx8hn6CNMCEHmEw=; b=thgPxHuekXgXxsyp/gPvGR2RfVzDecsZ5S/bMmxWVPcOV3LitDbj4aATCe+B9GNc+Q zUW9EdvaVZQ7wCYIi5/fiQDpXNrgBHge3yXWgY6UkPM11L1bJjEnztn29D4v+Hm1r1Nx Wul+ik06Jotpjgoc1SNgnPUnwxg0Tbdz5zqSPVOOjSKmvpNqIDJ74U2o4FtSudZnmvty WQcfUhvkCFk7zXKSuL4j7R5O9OpggMEnKNrSn+K1xfWAV9GLJy1tMLq3/P6Kxh/PtbP3 PYBA9M9Oup61eBgeAzeoifXeoY25iQPabtGY/QxxJ1HluhUGgFE4yXhtJPSWT57LG4nz QMSQ== X-Gm-Message-State: AOJu0YwXIBH5GXbzUDqQi3iCjDxlGMLBiUQVHQTU37SR9A2nTLysrkfq ++m4a1fuc33BTI3/dTj8cmzId5+rGOnYCjaURQ9DByaQhSgvY9ZrYxvCT1uSGi8= X-Gm-Gg: ASbGncuwdgYg9A42BtwCSus2vDejh5Jh3ECtUcGWB/vHDdG+6qKwbeG01i4eiir0UVw MqvvzM6f761c5UF3R9ZlnC653n11Patbv/DN5uXYtnQ9ytGEFcOjzcYOKenawsgnup+bXZ0xd7x i8gPyVd0BzyOdYmACRYarU+VKJyxi5SVcfClUhfyx9ScTXIRk0TTlLX8Jz4yTCCt2CDSEEh3AQl 1qyafbfTpy1NvPlNYX7E164LVB5JRqnXjUPJUoSg6yqS/c0LYS07mLXQG8YYE0qDQ== X-Google-Smtp-Source: AGHT+IHMa1lVKER8h4Ap0+h8iEA/ASsQQiOkTcbxptlpeVP7AhBWBqczT0R0GsKDETc4Mf1TgulAPw== X-Received: by 2002:a17:907:874a:b0:aa5:3e81:5aa2 with SMTP id a640c23a62f3a-aa639feb836mr488047766b.4.1733747054666; Mon, 09 Dec 2024 04:24:14 -0800 (PST) Received: from [127.0.1.1] ([178.197.223.165]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-aa66b96a249sm309925866b.159.2024.12.09.04.24.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 09 Dec 2024 04:24:14 -0800 (PST) From: Krzysztof Kozlowski Date: Mon, 09 Dec 2024 13:24:05 +0100 Subject: [PATCH RESEND 2/3] clk: qcom: smd-rpm: simplify locking with guard() Precedence: bulk X-Mailing-List: linux-arm-msm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20241209-cleanup-h-guard-clk-qcom-v1-2-b1077540230c@linaro.org> References: <20241209-cleanup-h-guard-clk-qcom-v1-0-b1077540230c@linaro.org> In-Reply-To: <20241209-cleanup-h-guard-clk-qcom-v1-0-b1077540230c@linaro.org> To: Bjorn Andersson , Michael Turquette , Stephen Boyd Cc: linux-arm-msm@vger.kernel.org, linux-clk@vger.kernel.org, linux-kernel@vger.kernel.org, Krzysztof Kozlowski X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=openpgp-sha256; l=2526; i=krzysztof.kozlowski@linaro.org; h=from:subject:message-id; bh=rkMjCrwS1+wByjVOGZBOyBmwHcPRefAACRVZAjVFMrg=; b=owEBbQKS/ZANAwAKAcE3ZuaGi4PXAcsmYgBnVuFpiHvV0uVRDjZL66G52Y9rZuBpcDh97yVqm 7VCNFzDmjqJAjMEAAEKAB0WIQTd0mIoPREbIztuuKjBN2bmhouD1wUCZ1bhaQAKCRDBN2bmhouD 1z6bEACDJRMV3tKG8OzJzEzGyfz0lOZpMOl3jN/tTBoHX1ttuGWTy4ndNdqgrS10DEBZX6AukHR 2RkvqWkTyKKdNzNQuzOUVZceVDzp6+14dJh8OmLv9rh3T1CybD01NWxDyX9E7dHwpzdzjKuOzik ysttIokEqGs7IBZ/l/nokgkJYYEd29LH5YirY5+WRuNafy79CfiPlh6J+BUxTMaw+qQuWFmoD4t PQFyq2OQiBrgTYYxqsxrT4JmK2wXe6+MD2E7A6hE6VJdr1O23cjjMVX3b6+Y0+zZbP6h7VO6cUc VyQzxXWG70zOEUW0ncp8VxGy836HsZoZT6XQuxBfOW+3dq2jEzkzDA3JMmNc/gFNaqb2eOHd0ll P6LbKNLNdJScsdo+7cCv6RlcXMffERSL6CNnOY62KiEfAIJyXrxcvOL6RvGd7qZA6Dom2kJeNAq 6M3qnKP7ZQsFDIENjvEUPMTO95+zN6Ql5fL8pkAPLtsOESS6QvIBV7qnYM+dyTwGeTMJzqk9LZ6 g/725GdkH60DSX36J3YUYaUjUqos7CJFgBuENmayd8k+e+t3MOOzpeh9pEF0K++9Z8PV1kbpVOP LEy2KoplchfXrzS10mQIx+q5O2+boaYrOiH4dh5kiLIoLpYZv1npQMxIclDZpW2qHr0xOE8sctQ WzPlTI+EO1P8OkA== X-Developer-Key: i=krzysztof.kozlowski@linaro.org; a=openpgp; fpr=9BD07E0E0C51F8D59677B7541B93437D3B41629B Simplify error handling (less gotos) over locks with guard(). Signed-off-by: Krzysztof Kozlowski --- drivers/clk/qcom/clk-smd-rpm.c | 25 ++++++++++--------------- 1 file changed, 10 insertions(+), 15 deletions(-) diff --git a/drivers/clk/qcom/clk-smd-rpm.c b/drivers/clk/qcom/clk-smd-rpm.c index 45c5255bcd11bae69b83138ba1d5e52a8a3f3be8..b8cd9f7301194a539d5fb18f974a5600496a1032 100644 --- a/drivers/clk/qcom/clk-smd-rpm.c +++ b/drivers/clk/qcom/clk-smd-rpm.c @@ -4,6 +4,7 @@ * Copyright (c) 2014, The Linux Foundation. All rights reserved. */ +#include #include #include #include @@ -309,10 +310,10 @@ static void clk_smd_rpm_unprepare(struct clk_hw *hw) unsigned long active_rate, sleep_rate; int ret; - mutex_lock(&rpm_smd_clk_lock); + guard(mutex)(&rpm_smd_clk_lock); if (!r->rate) - goto out; + return; /* Take peer clock's rate into account only if it's enabled. */ if (peer->enabled) @@ -322,17 +323,14 @@ static void clk_smd_rpm_unprepare(struct clk_hw *hw) active_rate = r->branch ? !!peer_rate : peer_rate; ret = clk_smd_rpm_set_rate_active(r, active_rate); if (ret) - goto out; + return; sleep_rate = r->branch ? !!peer_sleep_rate : peer_sleep_rate; ret = clk_smd_rpm_set_rate_sleep(r, sleep_rate); if (ret) - goto out; + return; r->enabled = false; - -out: - mutex_unlock(&rpm_smd_clk_lock); } static int clk_smd_rpm_set_rate(struct clk_hw *hw, unsigned long rate, @@ -345,10 +343,10 @@ static int clk_smd_rpm_set_rate(struct clk_hw *hw, unsigned long rate, unsigned long peer_rate = 0, peer_sleep_rate = 0; int ret = 0; - mutex_lock(&rpm_smd_clk_lock); + guard(mutex)(&rpm_smd_clk_lock); if (!r->enabled) - goto out; + return 0; to_active_sleep(r, rate, &this_rate, &this_sleep_rate); @@ -360,19 +358,16 @@ static int clk_smd_rpm_set_rate(struct clk_hw *hw, unsigned long rate, active_rate = max(this_rate, peer_rate); ret = clk_smd_rpm_set_rate_active(r, active_rate); if (ret) - goto out; + return ret; sleep_rate = max(this_sleep_rate, peer_sleep_rate); ret = clk_smd_rpm_set_rate_sleep(r, sleep_rate); if (ret) - goto out; + return ret; r->rate = rate; -out: - mutex_unlock(&rpm_smd_clk_lock); - - return ret; + return 0; } static long clk_smd_rpm_round_rate(struct clk_hw *hw, unsigned long rate, From patchwork Mon Dec 9 12:24:06 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Krzysztof Kozlowski X-Patchwork-Id: 13899475 Received: from mail-ej1-f53.google.com (mail-ej1-f53.google.com [209.85.218.53]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D0C8022488E for ; Mon, 9 Dec 2024 12:24:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.218.53 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733747059; cv=none; b=i8ZnwteALMpfrV5Ntwx4B5x39hTDK6+GZzxjNrunk/Rf5iQXooQ7NyXipIuY+SjHwCfor90Nr6Q4ABUIhR0IJSZuYMvTFJyr4M3TVNbk/rtG2ylsO/M6Jx1XlNssnUI0IvNoqqvkw8kFNU7UJiDoIXGPeirKMSMH0ZILbMAriN4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733747059; c=relaxed/simple; bh=dXTvMwZ3IWa8w/PCirVYpiMdDockPwSZQVUAZm7Ua1o=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=gnxec4hgdcfX4hroVH+Tk3nWonJQtqOfFRKf2FW/pbEoWtDpmlzwZFQD5Z03ELAddr8pv0MIGrc4IR0ZeZUHz4Ms+rBto9P6XT2GnLarbVcJIdIfSn7hrV4jb7ekpWYoVUQ18R53uvCQCPLt7wj1vSR7n5VcOsGx4RfkeDEwAw0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org; spf=pass smtp.mailfrom=linaro.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b=ZwjWWKg/; arc=none smtp.client-ip=209.85.218.53 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="ZwjWWKg/" Received: by mail-ej1-f53.google.com with SMTP id a640c23a62f3a-aa680fafb3eso11770166b.3 for ; Mon, 09 Dec 2024 04:24:17 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1733747056; x=1734351856; darn=vger.kernel.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=JoCVrD28ayqu5D/DI17RscermoixTp22627F0aNO5EA=; b=ZwjWWKg/iwSlnFS+GTCOaFYbL/Y4ag4IGujXPUwQJ7U5gJfs9Z6M8NxNePkPFWv3y4 lMUNLBgNHer3UmMQVJEcXybf/nDsJX81h+juUNafmMuMUtbA6Os0ukHNci4yAnj01pKN tcUr66SbmlX+a+5Ilk4I12bdQKKdIqhMVmubbrVAXwH4cOkBd9ODOwrUuypzD9V0FhWP mLdLzkNrwGwWcJHC8RwRn+sLaFzqqBGYDSQ8rF1O1weHkM/GxDbr6a6oaEla6WbEB+Ta itX9PTo4/Rk2U9dTfYxnc28QEXup+J7jEGlRFvQohb/5aPQc+TjHX+EetdY4fSnk8zrh pshQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1733747056; x=1734351856; 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=JoCVrD28ayqu5D/DI17RscermoixTp22627F0aNO5EA=; b=a/yJE1gcmPueXeoBaSfpANPutD8+agzXzwYqUtA1WqOQUGMqu1FlrxYthBEQbVQmSZ wkQTLdY+cj1C6PqQ2UMzRJklPE5zrku4TgPkNttIwoTgel8WE+jP/JaGNR10WbxIMyvJ I4SP3rcf9OOYk33MG/MuHoNBPr3QDavNE3R+W/F6rvwoVXnwTDxNoYGZBM8zdVYrbFH4 N83tKKCStpwh+ojLe7GRmI9msTPuk7G24tlrA8ImsIVSp+YDUBvlXL7xQpfmyitYHDs8 3xophZTLoiPCqmHvYqpMnk4CKIvZvXA+//0Fg2Wy6ZmDPvlj/GRcNPZbZq7f0TSlW/hC b5NA== X-Gm-Message-State: AOJu0YyA34coIUfqa9XBC5pm0FwiYadavQPuTCAFWIJS9rMEE+tu9AUV +IV59U9+ccNn+M313Bne/VvLljJmhZ2jLFcOOMN88ATIlKpajOOTt+nOVzYcOFc= X-Gm-Gg: ASbGnctluIa+8P2VP6Byav7M9Izd85Hv497O2+HD9WMvGyVn7j5xXRynLzGzG9EEknu Z0/1eaouCp5pHhWfKwUk8rR/xX9WHAgT7MmLiVHEpg4W2acBop2MiSRUBY08CIfb7fqOfn/Ytgo 2xL4u5ctEZTtSEz83b1iBokQxUq1l1PFE9I1WUBI7NvBjv7ZrVaJhD0P6ku0z8H0oeM7LVWzNO1 66dFwBso/2wnF62H/jDoXLGT5H0M4y1703qiEE6sxvUbn5BgpfOs2HJ6c9CV2MCgg== X-Google-Smtp-Source: AGHT+IEL0p06Hwmo+9E/f1lCO4dyZG2n/TdjzYJd+woyN99M4MYMI2vd+kMHzKES2YH6I7KFGRLVew== X-Received: by 2002:a17:907:c008:b0:aa6:79e6:5b03 with SMTP id a640c23a62f3a-aa679e65d87mr176768466b.6.1733747056131; Mon, 09 Dec 2024 04:24:16 -0800 (PST) Received: from [127.0.1.1] ([178.197.223.165]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-aa66b96a249sm309925866b.159.2024.12.09.04.24.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 09 Dec 2024 04:24:15 -0800 (PST) From: Krzysztof Kozlowski Date: Mon, 09 Dec 2024 13:24:06 +0100 Subject: [PATCH RESEND 3/3] clk: qcom: spmi-pmic-div: simplify locking with guard() Precedence: bulk X-Mailing-List: linux-arm-msm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20241209-cleanup-h-guard-clk-qcom-v1-3-b1077540230c@linaro.org> References: <20241209-cleanup-h-guard-clk-qcom-v1-0-b1077540230c@linaro.org> In-Reply-To: <20241209-cleanup-h-guard-clk-qcom-v1-0-b1077540230c@linaro.org> To: Bjorn Andersson , Michael Turquette , Stephen Boyd Cc: linux-arm-msm@vger.kernel.org, linux-clk@vger.kernel.org, linux-kernel@vger.kernel.org, Krzysztof Kozlowski X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=openpgp-sha256; l=1606; i=krzysztof.kozlowski@linaro.org; h=from:subject:message-id; bh=dXTvMwZ3IWa8w/PCirVYpiMdDockPwSZQVUAZm7Ua1o=; b=kA0DAAoBwTdm5oaLg9cByyZiAGdW4WqjVaZZPkcN8v9OPTJHUcgo366JtrL28bgL8+92JHHiT okCMwQAAQoAHRYhBN3SYig9ERsjO264qME3ZuaGi4PXBQJnVuFqAAoJEME3ZuaGi4PX+/cQAJk+ Nt95XiYbAfyAfpF+qC/Os14df5UkJTTbXxd/sOxHbKrDVc8xSx1fyqDWRaTcOD5Pe0wiD4glAzh FlXAenPqrW8yS3Vsne+gjpl3Yy9MknYypm+Wieyxvw3Uc0WUYJ9J3uf24bzJk/a0RGQIG/lq/Qw oOH6GoFnzTfQCDQeILelFLUkuYrnxQi+k1rs5rdVVL+8JYOBNoOVnjcA3DGFXvHmfWlV+f5xJcF JtcXMOUMZVrhra+7Tp7oLXbgaANGpci3rsCG+1cYV0OHsa0nqSivyPVfaIvX2PeBYJuiRUxbnBM /07FS0Cgmh4IYDM/zGJUQpXv66VARq3957sN/+kxJa3aOGa7KUjn8GQTZiu/pr5vr3QHA81ou76 CbqlYK4hEWS59pz/LAp5afj6TZIHqK+4v/oHQfttCrpGI+nojazSGCIlC0oA5Pkvz6rDlllc19n YEo90GQZW5Z06eYCyzJ2UocPPDpWsGI3vU9aNgpXoT4RYLSvrWUXLcLR3WyF72Vsa8mCH/oEVab oDk2Vl6hs7wb/GtKKh2ljMeeXrL1k+JuSnERSXmF7hPTqNNvlJF7bO7xJVX6MJZOtxhuz5ELHyT j8Je7O7bNIj7bs58E1Gfvfdo69Pk9YphLl8kHumVDITdXye1khfPUhziiSbxHT8okOoRoCITbw0 ymeVV X-Developer-Key: i=krzysztof.kozlowski@linaro.org; a=openpgp; fpr=9BD07E0E0C51F8D59677B7541B93437D3B41629B Simplify error handling (less gotos) over locks with guard(). Signed-off-by: Krzysztof Kozlowski --- drivers/clk/qcom/clk-spmi-pmic-div.c | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/drivers/clk/qcom/clk-spmi-pmic-div.c b/drivers/clk/qcom/clk-spmi-pmic-div.c index f394031eb0e520b1b59e863dfbda4312f4f8215b..41a0a4f3b4fb316827365a522079dcd99630c49f 100644 --- a/drivers/clk/qcom/clk-spmi-pmic-div.c +++ b/drivers/clk/qcom/clk-spmi-pmic-div.c @@ -3,6 +3,7 @@ */ #include +#include #include #include #include @@ -140,30 +141,26 @@ static int clk_spmi_pmic_div_set_rate(struct clk_hw *hw, unsigned long rate, { struct clkdiv *clkdiv = to_clkdiv(hw); unsigned int div_factor = div_to_div_factor(parent_rate / rate); - unsigned long flags; bool enabled; int ret; - spin_lock_irqsave(&clkdiv->lock, flags); + guard(spinlock_irqsave)(&clkdiv->lock); + enabled = is_spmi_pmic_clkdiv_enabled(clkdiv); if (enabled) { ret = spmi_pmic_clkdiv_set_enable_state(clkdiv, false); if (ret) - goto unlock; + return ret; } ret = regmap_update_bits(clkdiv->regmap, clkdiv->base + REG_DIV_CTL1, DIV_CTL1_DIV_FACTOR_MASK, div_factor); if (ret) - goto unlock; + return ret; if (enabled) ret = __spmi_pmic_clkdiv_set_enable_state(clkdiv, true, div_factor); - -unlock: - spin_unlock_irqrestore(&clkdiv->lock, flags); - return ret; }