mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH 1/3] soc: qcom: pmic_glink_altmode: simplify locking with guard()
@ 2024-08-22 16:48 Krzysztof Kozlowski
  2024-08-22 16:48 ` [PATCH] soc: qcom: smem_state: fix missing of_node_put in error path Krzysztof Kozlowski
                   ` (3 more replies)
  0 siblings, 4 replies; 9+ messages in thread
From: Krzysztof Kozlowski @ 2024-08-22 16:48 UTC (permalink / raw)
  To: Bjorn Andersson, Konrad Dybcio, Andy Gross, linux-arm-msm, linux-kernel
  Cc: Krzysztof Kozlowski

Simplify error handling (less gotos) over locks with guard().

Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
---
 drivers/soc/qcom/pmic_glink_altmode.c | 11 +++++------
 1 file changed, 5 insertions(+), 6 deletions(-)

diff --git a/drivers/soc/qcom/pmic_glink_altmode.c b/drivers/soc/qcom/pmic_glink_altmode.c
index 463b1c528831..bd06ce161804 100644
--- a/drivers/soc/qcom/pmic_glink_altmode.c
+++ b/drivers/soc/qcom/pmic_glink_altmode.c
@@ -5,6 +5,7 @@
  */
 #include <linux/auxiliary_bus.h>
 #include <linux/bitfield.h>
+#include <linux/cleanup.h>
 #include <linux/module.h>
 #include <linux/of.h>
 #include <linux/of_device.h>
@@ -114,7 +115,7 @@ static int pmic_glink_altmode_request(struct pmic_glink_altmode *altmode, u32 cm
 	 * The USBC_CMD_WRITE_REQ ack doesn't identify the request, so wait for
 	 * one ack at a time.
 	 */
-	mutex_lock(&altmode->lock);
+	guard(mutex)(&altmode->lock);
 
 	req.hdr.owner = cpu_to_le32(altmode->owner_id);
 	req.hdr.type = cpu_to_le32(PMIC_GLINK_REQ_RESP);
@@ -125,18 +126,16 @@ static int pmic_glink_altmode_request(struct pmic_glink_altmode *altmode, u32 cm
 	ret = pmic_glink_send(altmode->client, &req, sizeof(req));
 	if (ret) {
 		dev_err(altmode->dev, "failed to send altmode request: %#x (%d)\n", cmd, ret);
-		goto out_unlock;
+		return ret;
 	}
 
 	left = wait_for_completion_timeout(&altmode->pan_ack, 5 * HZ);
 	if (!left) {
 		dev_err(altmode->dev, "timeout waiting for altmode request ack for: %#x\n", cmd);
-		ret = -ETIMEDOUT;
+		return -ETIMEDOUT;
 	}
 
-out_unlock:
-	mutex_unlock(&altmode->lock);
-	return ret;
+	return 0;
 }
 
 static void pmic_glink_altmode_enable_dp(struct pmic_glink_altmode *altmode,
-- 
2.43.0


^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2024-12-26 22:39 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-08-22 16:48 [PATCH 1/3] soc: qcom: pmic_glink_altmode: simplify locking with guard() Krzysztof Kozlowski
2024-08-22 16:48 ` [PATCH] soc: qcom: smem_state: fix missing of_node_put in error path Krzysztof Kozlowski
2024-08-22 16:52   ` Krzysztof Kozlowski
2024-10-07 14:26   ` (subset) " Bjorn Andersson
2024-12-26 18:26   ` Bjorn Andersson
2024-12-26 22:38   ` Bjorn Andersson
2024-08-22 16:48 ` [PATCH 2/3] soc: qcom: pbs: simplify locking with guard() Krzysztof Kozlowski
2024-08-22 16:48 ` [PATCH 3/3] soc: qcom: smem_state: " Krzysztof Kozlowski
2024-12-26 22:38 ` (subset) [PATCH 1/3] soc: qcom: pmic_glink_altmode: " Bjorn Andersson

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®