From patchwork Wed Feb 15 09:30:02 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Christophe JAILLET X-Patchwork-Id: 57451 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp95548wrn; Wed, 15 Feb 2023 01:41:51 -0800 (PST) X-Google-Smtp-Source: AK7set8VctrwfBGlrQYD4ezwqMWs8jNteqkqUbj5HNKdHrbkzZa+Y0UeyhbSprYEDpSjFJSjyxqe X-Received: by 2002:a17:906:a409:b0:887:981:5f7c with SMTP id l9-20020a170906a40900b0088709815f7cmr1658482ejz.11.1676454111736; Wed, 15 Feb 2023 01:41:51 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1676454111; cv=none; d=google.com; s=arc-20160816; b=J6omY+aNpocMumir/DKVORubS46nxH6k6XemgNQPx9VHDu/CKcQnxRdXR1+pVBi9eA xwrUynkeuhQRDuEqHNjnvGV7r14pbhvvVXj4fyBaguwKCV5pPUaF1qxrua3QCuljI71m wtHB3loMpSw8kKU3FrKVv59UfcU78WYYibPHxszhgeUkibMOMLdbyFHk3SWmU1sFa95X kBxsL6x6N/9yZzAMtDcwanRmPn6fWG+JzgYpjRLoP532T+Lh4b7iRzYBriAxt2Fjn0MP zxXTFdCT2BElsGXr2bHWL7kp6u6tmC3rf+i2ydG3XHLnOXWEaWbdSOBCYXA9FTCstNJz dfjQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from; bh=vsHp+vpmovpbGRRzG7MbeJ9grTWEXGZ/IxYgXUd67Zg=; b=YCCMtNi11jD2rugq/PUYO3Uj+AVpUmhY6a6uDXXoJsToy+DyUzxqYor+cFKDgDh3zY VimThdy4vUyR+zJNtKbafQahAsEb32/gBOJ984xc8xdsQX6F+UCWVGfW+RiqklrjkzJR 6WJGBRojgkK74F/2tC2dtV+MKisc4kdJhzjJJmfdzmVUFC95BPcPZ8zqoMLud73yCO8Y 7wLD3JSCEZOLUHXLvBG4jgVoXAfpRPwJ8q98cGPu98SFfCRWcqCwKvPYFqdTqdeu8W7K bUfhejlY4NhOWt0NMNO2IVvLKjwzXd+RmylPuGZwHmH5i5IxBZDY3mX8WpRbB27Hul0D oz+w== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id y30-20020a170906519e00b008b1329ec185si4120106ejk.786.2023.02.15.01.41.26; Wed, 15 Feb 2023 01:41:51 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233909AbjBOJaI (ORCPT + 99 others); Wed, 15 Feb 2023 04:30:08 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41116 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233914AbjBOJaG (ORCPT ); Wed, 15 Feb 2023 04:30:06 -0500 Received: from smtp.smtpout.orange.fr (smtp-18.smtpout.orange.fr [80.12.242.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AA70E93F7 for ; Wed, 15 Feb 2023 01:30:05 -0800 (PST) Received: from pop-os.home ([86.243.2.178]) by smtp.orange.fr with ESMTPA id SE71pmycJOJaFSE71pRCYM; Wed, 15 Feb 2023 10:30:04 +0100 X-ME-Helo: pop-os.home X-ME-Auth: Y2hyaXN0b3BoZS5qYWlsbGV0QHdhbmFkb28uZnI= X-ME-Date: Wed, 15 Feb 2023 10:30:04 +0100 X-ME-IP: 86.243.2.178 From: Christophe JAILLET To: =?utf-8?q?Marek_Beh=C3=BAn?= , Arnd Bergmann Cc: linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org, Christophe JAILLET Subject: [PATCH v2] firmware: turris-mox-rwtm: Fix an error handling path in mox_get_board_info() Date: Wed, 15 Feb 2023 10:30:02 +0100 Message-Id: X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_PASS,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1757888577074484825?= X-GMAIL-MSGID: =?utf-8?q?1757889546598615646?= wait_for_completion_timeout() returns 0 if timed out, and positive (at least 1, or number of jiffies left till timeout) if completed. In case of timeout, return -ETIMEDOUT. Fixes: 389711b37493 ("firmware: Add Turris Mox rWTM firmware driver") Signed-off-by: Christophe JAILLET Reviewed-by: Marek BehĂșn --- Compile tested only. v2: - Fix some other wait_for_completion_timeout() calls --- drivers/firmware/turris-mox-rwtm.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/drivers/firmware/turris-mox-rwtm.c b/drivers/firmware/turris-mox-rwtm.c index 6ea5789a89e2..d6fc37ba897d 100644 --- a/drivers/firmware/turris-mox-rwtm.c +++ b/drivers/firmware/turris-mox-rwtm.c @@ -200,8 +200,8 @@ static int mox_get_board_info(struct mox_rwtm *rwtm) return ret; ret = wait_for_completion_timeout(&rwtm->cmd_done, HZ / 2); - if (ret < 0) - return ret; + if (ret == 0) + return -ETIMEDOUT; ret = mox_get_status(MBOX_CMD_BOARD_INFO, reply->retval); if (ret == -ENODATA) { @@ -236,8 +236,8 @@ static int mox_get_board_info(struct mox_rwtm *rwtm) return ret; ret = wait_for_completion_timeout(&rwtm->cmd_done, HZ / 2); - if (ret < 0) - return ret; + if (ret == 0) + return -ETIMEDOUT; ret = mox_get_status(MBOX_CMD_ECDSA_PUB_KEY, reply->retval); if (ret == -ENODATA) { @@ -275,8 +275,8 @@ static int check_get_random_support(struct mox_rwtm *rwtm) return ret; ret = wait_for_completion_timeout(&rwtm->cmd_done, HZ / 2); - if (ret < 0) - return ret; + if (ret == 0) + return -ETIMEDOUT; return mox_get_status(MBOX_CMD_GET_RANDOM, rwtm->reply.retval); }