From patchwork Mon Jun 17 14:45:17 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Marek_Beh=C3=BAn?= X-Patchwork-Id: 13700859 X-Patchwork-Delegate: arnd@arndb.de Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 51C92C27C79 for ; Mon, 17 Jun 2024 14:45:43 +0000 (UTC) Received: by smtp.kernel.org (Postfix) id 1CBF2C2BD10; Mon, 17 Jun 2024 14:45:43 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0A9FEC4AF48; Mon, 17 Jun 2024 14:45:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1718635543; bh=sc7EudhJ+/Cu2fPeZrbVPk1U0HTdb44HVHOPZKReBEY=; h=From:List-Id:To:Cc:Subject:Date:In-Reply-To:References:From; b=Hj7K4hAZRyyA71WWIYuIWcvPbouXk5LJ1Ao4pqw3FalKxdlf5BsmKD3JLckyxGrDX Wtykcq6z2S2TYX7osZevo6kej9z2aZq2ZaPzt+BFfcmtwnOpF806IcBUqI5RUs8X5h xm4asUIjeiBGmGQIGr8FYy+hIBI7AgKnxTyqD5NhQdJiBU7M4Q7QS21LAQ7I0yjqZK xcbaYuPs6ifEax0M9SgbEdkPHvFSe59Q+72MAXF1a6eaGfL3OVCA/m4RlqoahzcyRn lSGeUhfBrROeCt+0L0hc+sKYBhPQ/Q8JIHXu5ab1S8mWKdO0X+Cc7EBH0X6GLJkPRl XCNU36b0zCOFA== From: =?utf-8?q?Marek_Beh=C3=BAn?= List-Id: To: Gregory CLEMENT , Andrew Lunn , Arnd Bergmann , soc@kernel.org, arm@kernel.org, Andy Shevchenko , Hans de Goede , =?utf-8?q?Ilpo_J=C3=A4rvinen?= Cc: =?utf-8?q?Marek_Beh=C3=BAn?= Subject: [PATCH v3 02/17] firmware: turris-mox-rwtm: Fix checking return value of wait_for_completion_timeout() Date: Mon, 17 Jun 2024 16:45:17 +0200 Message-ID: <20240617144532.17385-3-kabel@kernel.org> X-Mailer: git-send-email 2.44.2 In-Reply-To: <20240617144532.17385-1-kabel@kernel.org> References: <20240617144532.17385-1-kabel@kernel.org> MIME-Version: 1.0 The wait_for_completion_timeout() function returns 0 if timed out, and a positive value if completed. Fix the usage of this function. Fixes: 389711b37493 ("firmware: Add Turris Mox rWTM firmware driver") Fixes: 2eab59cf0d20 ("firmware: turris-mox-rwtm: fail probing when firmware does not support hwrng") Signed-off-by: Marek Behún Reviewed-by: Ilpo Järvinen --- drivers/firmware/turris-mox-rwtm.c | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/drivers/firmware/turris-mox-rwtm.c b/drivers/firmware/turris-mox-rwtm.c index f1f9160c4195..3f4758e03c81 100644 --- a/drivers/firmware/turris-mox-rwtm.c +++ b/drivers/firmware/turris-mox-rwtm.c @@ -202,9 +202,8 @@ static int mox_get_board_info(struct mox_rwtm *rwtm) if (ret < 0) return ret; - ret = wait_for_completion_timeout(&rwtm->cmd_done, HZ / 2); - if (ret < 0) - return ret; + if (!wait_for_completion_timeout(&rwtm->cmd_done, HZ / 2)) + return -ETIMEDOUT; ret = mox_get_status(MBOX_CMD_BOARD_INFO, reply->retval); if (ret == -ENODATA) { @@ -238,9 +237,8 @@ static int mox_get_board_info(struct mox_rwtm *rwtm) if (ret < 0) return ret; - ret = wait_for_completion_timeout(&rwtm->cmd_done, HZ / 2); - if (ret < 0) - return ret; + if (!wait_for_completion_timeout(&rwtm->cmd_done, HZ / 2)) + return -ETIMEDOUT; ret = mox_get_status(MBOX_CMD_ECDSA_PUB_KEY, reply->retval); if (ret == -ENODATA) { @@ -277,9 +275,8 @@ static int check_get_random_support(struct mox_rwtm *rwtm) if (ret < 0) return ret; - ret = wait_for_completion_timeout(&rwtm->cmd_done, HZ / 2); - if (ret < 0) - return ret; + if (!wait_for_completion_timeout(&rwtm->cmd_done, HZ / 2)) + return -ETIMEDOUT; return mox_get_status(MBOX_CMD_GET_RANDOM, rwtm->reply.retval); }