From patchwork Mon Mar 8 15:37:00 2021 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: 12122773 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-17.2 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2C42BC433E0 for ; Mon, 8 Mar 2021 15:39:15 +0000 (UTC) Received: from desiato.infradead.org (desiato.infradead.org [90.155.92.199]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id C20C865208 for ; Mon, 8 Mar 2021 15:39:14 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org C20C865208 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=desiato.20200630; h=Sender:Content-Transfer-Encoding :Content-Type:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:Message-Id:Date:Subject:Cc:To:From: Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender :Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References:List-Owner; bh=3WvemEpqLVfO6K27YfXEca/ijPAJEqXyVQSoF3q5jNA=; b=cT/OX9IT2TKVXzVBZ9Gp7dXV8d kMLNq+gVcbqMV0Vv+AGM7tKWNhoEzKBZOI6nofjTvSCc8xkAi7Zhx/UXQS1Y3SaRAen7Bzw1kKyyp ZFNvSfksyV8+7YpsUT10YLPdcQr6iWUkSttrAtawnhVpIpkPAtFsMwSVz6xUmbRtg35Ck1aTbf74V fuKHzxox/qTEfv/dUFoVl2aDo08bZevW5si6aymZEJmq86thNS6WCh4kfP241dZMDvc58UTSw0Do2 H3GxawpmzgN7aw30aN9OZ8XlGqjjktXUTMyyyXHaMBEnfz4VTRWXLRoOUeOiMj2K/5n2Ne4T+xNGs O+/Bsdww==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1lJHww-000erE-1d; Mon, 08 Mar 2021 15:37:38 +0000 Received: from mail.kernel.org ([198.145.29.99]) by desiato.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lJHwr-000enw-Pd for linux-arm-kernel@lists.infradead.org; Mon, 08 Mar 2021 15:37:35 +0000 Received: by mail.kernel.org (Postfix) with ESMTPSA id EEC2C65208; Mon, 8 Mar 2021 15:37:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1615217850; bh=uxCp6IN5xTdKQhaP3mh22hDmJsBIoNGm5ZELPunoPH8=; h=From:To:Cc:Subject:Date:From; b=ema9w1jQkA2YIY4TsGwK7r16RdZUYOeE24bUjXU/vASrKw5Yh4Zn6e35G3miA6XdC MmiFDsH8RiyRV82zUZu2TuFyERphOLKJTYWFvvBrpKq9XKcmKvYi8Kj4OmIhwmCjXs s9ZP41L447I5fZgwEQv5zxb4c1Q9wg6yCDuRFPrYFrCW+iF7o9ShxGwt5BCHImhohm miZw2sx+zdyf2rCQSqRlvyGbQ5+QL12YplFfJ5H/0FGG/FX/BH8apDNBEtHaHKiAtz /VpCRkOWczDABvnIMEtm4U7+GxjExjFGJcBT/L9qL916WDuHYUEQ9PU7lzJ7QCDsjT A1PVHfHDwvjyA== From: =?utf-8?q?Marek_Beh=C3=BAn?= To: Gregory CLEMENT Cc: linux-arm-kernel@lists.infradead.org, pali@kernel.org, =?utf-8?q?Marek_B?= =?utf-8?q?eh=C3=BAn?= Subject: [PATCH mvebu + mvebu/dt64 1/4] firmware: turris-mox-rwtm: fix reply status decoding function Date: Mon, 8 Mar 2021 16:37:00 +0100 Message-Id: <20210308153703.23097-1-kabel@kernel.org> X-Mailer: git-send-email 2.26.2 MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210308_153734_158960_9FC2399C X-CRM114-Status: GOOD ( 11.07 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org The status decoding function mox_get_status() currently contains a dead code path: if the error status is not MBOX_STS_SUCCESS, it always returns -EIO, so the comparison to MBOX_STS_FAIL is never executed and we don't get the actual error code sent by the firmware. Fix this. Signed-off-by: Marek BehĂșn Fixes: 389711b37493 ("firmware: Add Turris Mox rWTM firmware driver") --- drivers/firmware/turris-mox-rwtm.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/drivers/firmware/turris-mox-rwtm.c b/drivers/firmware/turris-mox-rwtm.c index 50bb2a6d6ccf..54b98642ee1b 100644 --- a/drivers/firmware/turris-mox-rwtm.c +++ b/drivers/firmware/turris-mox-rwtm.c @@ -147,11 +147,14 @@ MOX_ATTR_RO(pubkey, "%s\n", pubkey); static int mox_get_status(enum mbox_cmd cmd, u32 retval) { - if (MBOX_STS_CMD(retval) != cmd || - MBOX_STS_ERROR(retval) != MBOX_STS_SUCCESS) + if (MBOX_STS_CMD(retval) != cmd) return -EIO; else if (MBOX_STS_ERROR(retval) == MBOX_STS_FAIL) return -(int)MBOX_STS_VALUE(retval); + else if (MBOX_STS_ERROR(retval) == MBOX_STS_BADCMD) + return -ENOSYS; + else if (MBOX_STS_ERROR(retval) != MBOX_STS_SUCCESS) + return -EIO; else return MBOX_STS_VALUE(retval); }