Skip to content

Commit 8467cfe

Browse files
elkabloarndb
authored andcommitted
firmware: turris-mox-rwtm: Fix checking return value of wait_for_completion_timeout()
The wait_for_completion_timeout() function returns 0 if timed out, and a positive value if completed. Fix the usage of this function. Fixes: 389711b ("firmware: Add Turris Mox rWTM firmware driver") Fixes: 2eab59c ("firmware: turris-mox-rwtm: fail probing when firmware does not support hwrng") Signed-off-by: Marek Behún <[email protected]> Reviewed-by: Ilpo Järvinen <[email protected]> Reviewed-by: Andy Shevchenko <[email protected]> Signed-off-by: Arnd Bergmann <[email protected]>
1 parent 0bafb17 commit 8467cfe

File tree

1 file changed

+6
-9
lines changed

1 file changed

+6
-9
lines changed

drivers/firmware/turris-mox-rwtm.c

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -202,9 +202,8 @@ static int mox_get_board_info(struct mox_rwtm *rwtm)
202202
if (ret < 0)
203203
return ret;
204204

205-
ret = wait_for_completion_timeout(&rwtm->cmd_done, HZ / 2);
206-
if (ret < 0)
207-
return ret;
205+
if (!wait_for_completion_timeout(&rwtm->cmd_done, HZ / 2))
206+
return -ETIMEDOUT;
208207

209208
ret = mox_get_status(MBOX_CMD_BOARD_INFO, reply->retval);
210209
if (ret == -ENODATA) {
@@ -238,9 +237,8 @@ static int mox_get_board_info(struct mox_rwtm *rwtm)
238237
if (ret < 0)
239238
return ret;
240239

241-
ret = wait_for_completion_timeout(&rwtm->cmd_done, HZ / 2);
242-
if (ret < 0)
243-
return ret;
240+
if (!wait_for_completion_timeout(&rwtm->cmd_done, HZ / 2))
241+
return -ETIMEDOUT;
244242

245243
ret = mox_get_status(MBOX_CMD_ECDSA_PUB_KEY, reply->retval);
246244
if (ret == -ENODATA) {
@@ -277,9 +275,8 @@ static int check_get_random_support(struct mox_rwtm *rwtm)
277275
if (ret < 0)
278276
return ret;
279277

280-
ret = wait_for_completion_timeout(&rwtm->cmd_done, HZ / 2);
281-
if (ret < 0)
282-
return ret;
278+
if (!wait_for_completion_timeout(&rwtm->cmd_done, HZ / 2))
279+
return -ETIMEDOUT;
283280

284281
return mox_get_status(MBOX_CMD_GET_RANDOM, rwtm->reply.retval);
285282
}

0 commit comments

Comments
 (0)