Skip to content

Commit 088c588

Browse files
Wolfram Sanggregkh
authored andcommitted
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 <[email protected]> Signed-off-by: Srinivas Kandagatla <[email protected]> Reviewed-by: Bjorn Andersson <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent 9c6fd5f commit 088c588

File tree

1 file changed

+16
-13
lines changed

1 file changed

+16
-13
lines changed

drivers/slimbus/qcom-ngd-ctrl.c

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -788,7 +788,8 @@ static int qcom_slim_ngd_xfer_msg(struct slim_controller *sctrl,
788788
struct qcom_slim_ngd_ctrl *ctrl = dev_get_drvdata(sctrl->dev);
789789
DECLARE_COMPLETION_ONSTACK(tx_sent);
790790
DECLARE_COMPLETION_ONSTACK(done);
791-
int ret, timeout, i;
791+
int ret, i;
792+
unsigned long time_left;
792793
u8 wbuf[SLIM_MSGQ_BUF_LEN];
793794
u8 rbuf[SLIM_MSGQ_BUF_LEN];
794795
u32 *pbuf;
@@ -890,17 +891,17 @@ static int qcom_slim_ngd_xfer_msg(struct slim_controller *sctrl,
890891
return ret;
891892
}
892893

893-
timeout = wait_for_completion_timeout(&tx_sent, HZ);
894-
if (!timeout) {
894+
time_left = wait_for_completion_timeout(&tx_sent, HZ);
895+
if (!time_left) {
895896
dev_err(sctrl->dev, "TX timed out:MC:0x%x,mt:0x%x", txn->mc,
896897
txn->mt);
897898
mutex_unlock(&ctrl->tx_lock);
898899
return -ETIMEDOUT;
899900
}
900901

901902
if (usr_msg) {
902-
timeout = wait_for_completion_timeout(&done, HZ);
903-
if (!timeout) {
903+
time_left = wait_for_completion_timeout(&done, HZ);
904+
if (!time_left) {
904905
dev_err(sctrl->dev, "TX timed out:MC:0x%x,mt:0x%x",
905906
txn->mc, txn->mt);
906907
mutex_unlock(&ctrl->tx_lock);
@@ -916,7 +917,8 @@ static int qcom_slim_ngd_xfer_msg_sync(struct slim_controller *ctrl,
916917
struct slim_msg_txn *txn)
917918
{
918919
DECLARE_COMPLETION_ONSTACK(done);
919-
int ret, timeout;
920+
int ret;
921+
unsigned long time_left;
920922

921923
ret = pm_runtime_get_sync(ctrl->dev);
922924
if (ret < 0)
@@ -928,8 +930,8 @@ static int qcom_slim_ngd_xfer_msg_sync(struct slim_controller *ctrl,
928930
if (ret)
929931
goto pm_put;
930932

931-
timeout = wait_for_completion_timeout(&done, HZ);
932-
if (!timeout) {
933+
time_left = wait_for_completion_timeout(&done, HZ);
934+
if (!time_left) {
933935
dev_err(ctrl->dev, "TX timed out:MC:0x%x,mt:0x%x", txn->mc,
934936
txn->mt);
935937
ret = -ETIMEDOUT;
@@ -1168,11 +1170,12 @@ static int qcom_slim_ngd_power_up(struct qcom_slim_ngd_ctrl *ctrl)
11681170
enum qcom_slim_ngd_state cur_state = ctrl->state;
11691171
struct qcom_slim_ngd *ngd = ctrl->ngd;
11701172
u32 laddr, rx_msgq;
1171-
int timeout, ret = 0;
1173+
int ret = 0;
1174+
unsigned long time_left;
11721175

11731176
if (ctrl->state == QCOM_SLIM_NGD_CTRL_DOWN) {
1174-
timeout = wait_for_completion_timeout(&ctrl->qmi.qmi_comp, HZ);
1175-
if (!timeout)
1177+
time_left = wait_for_completion_timeout(&ctrl->qmi.qmi_comp, HZ);
1178+
if (!time_left)
11761179
return -EREMOTEIO;
11771180
}
11781181

@@ -1217,8 +1220,8 @@ static int qcom_slim_ngd_power_up(struct qcom_slim_ngd_ctrl *ctrl)
12171220
ngd->base + NGD_RX_MSGQ_CFG);
12181221
qcom_slim_ngd_setup(ctrl);
12191222

1220-
timeout = wait_for_completion_timeout(&ctrl->reconf, HZ);
1221-
if (!timeout) {
1223+
time_left = wait_for_completion_timeout(&ctrl->reconf, HZ);
1224+
if (!time_left) {
12221225
dev_err(ctrl->dev, "capability exchange timed-out\n");
12231226
return -ETIMEDOUT;
12241227
}

0 commit comments

Comments
 (0)