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

slimbus: qcom-ngd-ctrl: use 'time_left' variable with wait_for_completion_timeout()

There is a confusing pattern in the kernel to use a variable named 'timeout' to
store the result of wait_for_completion_timeout() causing patterns like:

timeout = wait_for_completion_timeout(...)
if (!timeout) return -ETIMEDOUT;

with all kinds of permutations. Use 'time_left' as a variable to make the code
self explaining.

Fix to the proper variable type 'unsigned long' while here.

Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
Reviewed-by: Bjorn Andersson <quic_bjorande@quicinc.com>
Link: https://lore.kernel.org/r/20240902141004.70048-4-srinivas.kandagatla@linaro.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

authored by

Wolfram Sang and committed by
Greg Kroah-Hartman
088c588f 9c6fd5fc

+16 -13
+16 -13
drivers/slimbus/qcom-ngd-ctrl.c
··· 788 788 struct qcom_slim_ngd_ctrl *ctrl = dev_get_drvdata(sctrl->dev); 789 789 DECLARE_COMPLETION_ONSTACK(tx_sent); 790 790 DECLARE_COMPLETION_ONSTACK(done); 791 - int ret, timeout, i; 791 + int ret, i; 792 + unsigned long time_left; 792 793 u8 wbuf[SLIM_MSGQ_BUF_LEN]; 793 794 u8 rbuf[SLIM_MSGQ_BUF_LEN]; 794 795 u32 *pbuf; ··· 891 890 return ret; 892 891 } 893 892 894 - timeout = wait_for_completion_timeout(&tx_sent, HZ); 895 - if (!timeout) { 893 + time_left = wait_for_completion_timeout(&tx_sent, HZ); 894 + if (!time_left) { 896 895 dev_err(sctrl->dev, "TX timed out:MC:0x%x,mt:0x%x", txn->mc, 897 896 txn->mt); 898 897 mutex_unlock(&ctrl->tx_lock); ··· 900 899 } 901 900 902 901 if (usr_msg) { 903 - timeout = wait_for_completion_timeout(&done, HZ); 904 - if (!timeout) { 902 + time_left = wait_for_completion_timeout(&done, HZ); 903 + if (!time_left) { 905 904 dev_err(sctrl->dev, "TX timed out:MC:0x%x,mt:0x%x", 906 905 txn->mc, txn->mt); 907 906 mutex_unlock(&ctrl->tx_lock); ··· 917 916 struct slim_msg_txn *txn) 918 917 { 919 918 DECLARE_COMPLETION_ONSTACK(done); 920 - int ret, timeout; 919 + int ret; 920 + unsigned long time_left; 921 921 922 922 ret = pm_runtime_get_sync(ctrl->dev); 923 923 if (ret < 0) ··· 930 928 if (ret) 931 929 goto pm_put; 932 930 933 - timeout = wait_for_completion_timeout(&done, HZ); 934 - if (!timeout) { 931 + time_left = wait_for_completion_timeout(&done, HZ); 932 + if (!time_left) { 935 933 dev_err(ctrl->dev, "TX timed out:MC:0x%x,mt:0x%x", txn->mc, 936 934 txn->mt); 937 935 ret = -ETIMEDOUT; ··· 1170 1168 enum qcom_slim_ngd_state cur_state = ctrl->state; 1171 1169 struct qcom_slim_ngd *ngd = ctrl->ngd; 1172 1170 u32 laddr, rx_msgq; 1173 - int timeout, ret = 0; 1171 + int ret = 0; 1172 + unsigned long time_left; 1174 1173 1175 1174 if (ctrl->state == QCOM_SLIM_NGD_CTRL_DOWN) { 1176 - timeout = wait_for_completion_timeout(&ctrl->qmi.qmi_comp, HZ); 1177 - if (!timeout) 1175 + time_left = wait_for_completion_timeout(&ctrl->qmi.qmi_comp, HZ); 1176 + if (!time_left) 1178 1177 return -EREMOTEIO; 1179 1178 } 1180 1179 ··· 1220 1217 ngd->base + NGD_RX_MSGQ_CFG); 1221 1218 qcom_slim_ngd_setup(ctrl); 1222 1219 1223 - timeout = wait_for_completion_timeout(&ctrl->reconf, HZ); 1224 - if (!timeout) { 1220 + time_left = wait_for_completion_timeout(&ctrl->reconf, HZ); 1221 + if (!time_left) { 1225 1222 dev_err(ctrl->dev, "capability exchange timed-out\n"); 1226 1223 return -ETIMEDOUT; 1227 1224 }