Skip to content

Commit 95fee30

Browse files
krzkandersson
authored andcommitted
soc: qcom: pmic_glink_altmode: simplify locking with guard()
Simplify error handling (less gotos) over locks with guard(). Signed-off-by: Krzysztof Kozlowski <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Bjorn Andersson <[email protected]>
1 parent 2705bce commit 95fee30

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

drivers/soc/qcom/pmic_glink_altmode.c

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
*/
66
#include <linux/auxiliary_bus.h>
77
#include <linux/bitfield.h>
8+
#include <linux/cleanup.h>
89
#include <linux/module.h>
910
#include <linux/of.h>
1011
#include <linux/of_device.h>
@@ -114,7 +115,7 @@ static int pmic_glink_altmode_request(struct pmic_glink_altmode *altmode, u32 cm
114115
* The USBC_CMD_WRITE_REQ ack doesn't identify the request, so wait for
115116
* one ack at a time.
116117
*/
117-
mutex_lock(&altmode->lock);
118+
guard(mutex)(&altmode->lock);
118119

119120
req.hdr.owner = cpu_to_le32(altmode->owner_id);
120121
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
125126
ret = pmic_glink_send(altmode->client, &req, sizeof(req));
126127
if (ret) {
127128
dev_err(altmode->dev, "failed to send altmode request: %#x (%d)\n", cmd, ret);
128-
goto out_unlock;
129+
return ret;
129130
}
130131

131132
left = wait_for_completion_timeout(&altmode->pan_ack, 5 * HZ);
132133
if (!left) {
133134
dev_err(altmode->dev, "timeout waiting for altmode request ack for: %#x\n", cmd);
134-
ret = -ETIMEDOUT;
135+
return -ETIMEDOUT;
135136
}
136137

137-
out_unlock:
138-
mutex_unlock(&altmode->lock);
139-
return ret;
138+
return 0;
140139
}
141140

142141
static void pmic_glink_altmode_enable_dp(struct pmic_glink_altmode *altmode,

0 commit comments

Comments
 (0)