Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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>

authored by

Krzysztof Kozlowski and committed by
Vinod Koul
82ab754d f87e5575

+5 -7
+5 -7
drivers/soundwire/qcom.c
··· 1228 1228 struct sdw_port_runtime *p_rt; 1229 1229 struct sdw_slave *slave; 1230 1230 unsigned long *port_mask; 1231 - int maxport, pn, nports = 0, ret = 0; 1231 + int maxport, pn, nports = 0; 1232 1232 unsigned int m_port; 1233 1233 struct sdw_port_config *pconfig __free(kfree) = kcalloc(ctrl->nports, 1234 1234 sizeof(*pconfig), GFP_KERNEL); ··· 1246 1246 sconfig.type = stream->type; 1247 1247 sconfig.bps = 1; 1248 1248 1249 - mutex_lock(&ctrl->port_lock); 1249 + guard(mutex)(&ctrl->port_lock); 1250 + 1250 1251 list_for_each_entry(m_rt, &stream->master_list, stream_node) { 1251 1252 /* 1252 1253 * For streams with multiple masters: ··· 1273 1272 1274 1273 if (pn > maxport) { 1275 1274 dev_err(ctrl->dev, "All ports busy\n"); 1276 - ret = -EBUSY; 1277 - goto out; 1275 + return -EBUSY; 1278 1276 } 1279 1277 set_bit(pn, port_mask); 1280 1278 pconfig[nports].num = pn; ··· 1285 1285 1286 1286 sdw_stream_add_master(&ctrl->bus, &sconfig, pconfig, 1287 1287 nports, stream); 1288 - out: 1289 - mutex_unlock(&ctrl->port_lock); 1290 1288 1291 - return ret; 1289 + return 0; 1292 1290 } 1293 1291 1294 1292 static int qcom_swrm_hw_params(struct snd_pcm_substream *substream,