Skip to content

Commit 82ab754

Browse files
krzkvinodkoul
authored andcommitted
soundwire: qcom: Use guard to avoid mixing cleanup and goto
qcom_swrm_stream_alloc_ports() already uses cleanup.h but also has goto. Such combination is error-prone and discouraged: "... and that the "goto" statement can jump between scopes, the expectation is that usage of "goto" and cleanup helpers is never mixed in the same function." Actually simplify the code with a guard which allows to fix the discouraged style by removing the goto. Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@oss.qualcomm.com> Reviewed-by: Konrad Dybcio <konrad.dybcio@oss.qualcomm.com> Reviewed-by: Srinivas Kandagatla <srinivas.kandagatla@oss.qualcomm.com> Link: https://patch.msgid.link/20251201102627.146182-2-krzysztof.kozlowski@oss.qualcomm.com Signed-off-by: Vinod Koul <vkoul@kernel.org>
1 parent f87e557 commit 82ab754

1 file changed

Lines changed: 5 additions & 7 deletions

File tree

drivers/soundwire/qcom.c

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1228,7 +1228,7 @@ static int qcom_swrm_stream_alloc_ports(struct qcom_swrm_ctrl *ctrl,
12281228
struct sdw_port_runtime *p_rt;
12291229
struct sdw_slave *slave;
12301230
unsigned long *port_mask;
1231-
int maxport, pn, nports = 0, ret = 0;
1231+
int maxport, pn, nports = 0;
12321232
unsigned int m_port;
12331233
struct sdw_port_config *pconfig __free(kfree) = kcalloc(ctrl->nports,
12341234
sizeof(*pconfig), GFP_KERNEL);
@@ -1246,7 +1246,8 @@ static int qcom_swrm_stream_alloc_ports(struct qcom_swrm_ctrl *ctrl,
12461246
sconfig.type = stream->type;
12471247
sconfig.bps = 1;
12481248

1249-
mutex_lock(&ctrl->port_lock);
1249+
guard(mutex)(&ctrl->port_lock);
1250+
12501251
list_for_each_entry(m_rt, &stream->master_list, stream_node) {
12511252
/*
12521253
* For streams with multiple masters:
@@ -1272,8 +1273,7 @@ static int qcom_swrm_stream_alloc_ports(struct qcom_swrm_ctrl *ctrl,
12721273

12731274
if (pn > maxport) {
12741275
dev_err(ctrl->dev, "All ports busy\n");
1275-
ret = -EBUSY;
1276-
goto out;
1276+
return -EBUSY;
12771277
}
12781278
set_bit(pn, port_mask);
12791279
pconfig[nports].num = pn;
@@ -1285,10 +1285,8 @@ static int qcom_swrm_stream_alloc_ports(struct qcom_swrm_ctrl *ctrl,
12851285

12861286
sdw_stream_add_master(&ctrl->bus, &sconfig, pconfig,
12871287
nports, stream);
1288-
out:
1289-
mutex_unlock(&ctrl->port_lock);
12901288

1291-
return ret;
1289+
return 0;
12921290
}
12931291

12941292
static int qcom_swrm_hw_params(struct snd_pcm_substream *substream,

0 commit comments

Comments
 (0)