From patchwork Thu May 20 11:35:17 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Pali_Roh=C3=A1r?= X-Patchwork-Id: 12269749 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.4 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,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 4B8F8C433ED for ; Thu, 20 May 2021 11:39:11 +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 C5F7B6101D for ; Thu, 20 May 2021 11:39:10 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org C5F7B6101D 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:References:In-Reply-To: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:List-Owner; bh=jepVzk2IhtqAdmAtU3ANjx/a6FrVeIH04krYwx1Dtcc=; b=jdr0h2uP9Cq/oSbtCf/fSTubYz hkCtIfC04Y2Ci77m+N77Bz/21+kbZmGbmFWFpCNfYXdVhIhm707/N/eVhy37qCv5CX9kCXH2F0/ha yuA4PljnoHmJzKCzT2BZSXDRfNzkpelFMi9/VtpGDzcBsEVLGx7bsWBsJv6svTIKeKbeldYuylv0S mCwBa1y3R0V0dtR8Jeqp4lBzojIrrT4oCKunvkxwLek7b8IAu1Py/LKUQvFM2SgIwthfJA+9ujLKl CAD9ovonoW21qFdzxrCynqPGQjZHxYhulGeMmzWwqPaD0PXJpvUIyIQZNJ0nv3G1o7GG1k5qfUKSI gGMoB0TQ==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1ljgyQ-000Vxn-KR; Thu, 20 May 2021 11:36:18 +0000 Received: from bombadil.infradead.org ([2607:7c80:54:e::133]) by desiato.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1ljgxk-000Vki-9S for linux-arm-kernel@desiato.infradead.org; Thu, 20 May 2021 11:35:38 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20210309; h=Content-Transfer-Encoding: Content-Type:MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc: To:From:Sender:Reply-To:Content-ID:Content-Description; bh=B601oesid6iXgjgdZKcDVkgX/QErjrE1s13BpnPil3E=; b=zgrxXMLFCeMFcI7jHqLibAYUhe lhl8zKMJYOw2nl3bv+gB9AaT5caERdx8UAlNZajdCsYjEbZbGc4ziSF0otPASkV6dISguJfwL4IX+ fvTrU63QkTPlRdhx1WkVfS0LeSbUCnHtxkpEVdl+Z0/xqGtsfLaLZVMLk6Bwv1s4xfF5PJKHZv4zz P+7t/cXdy+//Y2LzFsIsumHglUQjOK2/LtJ43QPFLlYnkVmo/ygjfktnlKoYQSaU5eIJOGgUreAbA ePT9gQbFspW0rgg8bqiRJaQ93Ip9kKHApVWHyEkKeAAFzhpj/UU8qBBbLya1aMwJ+lWTTTmEiF514 sWrIUH1Q==; Received: from mail.kernel.org ([198.145.29.99]) by bombadil.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1ljgxh-00GFun-1d for linux-arm-kernel@lists.infradead.org; Thu, 20 May 2021 11:35:34 +0000 Received: by mail.kernel.org (Postfix) with ESMTPSA id 5A6A6611AB; Thu, 20 May 2021 11:35:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1621510532; bh=X3jopxsX61QS+or7ehscRsDEihXrE0LQ/xHPv2/OfAY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=kI1SIb7omMxdoGjWjB4B5Kty8kDjP2oWTMDvEjcj+fOeUHuES5d1b8flMxJoMPkQu ELh2Afz1ugedNnCe9UqQIQvpoYfDYXCseC7ujLiPh5gqOszMwwzF3uYuKbgQ4hUYT6 7AX3h9AYLvi4lHV3IhCNFzHguwgnekTGSaFhUc27FQXIjSxW3XvsZaOjxY13rAZxvr lQdWsgavCwvSvhT3W3ZGZ0qErfdCBAhrLnJRWGRYr886+nB+opva/9kgANkquoK9fp rh5ToZbt72QyDNcdh5vlTCl4ai19UY+QXw73CEI8wDVyOPgoGpHZYfzpyRPkZ3mg8o csBa5GMpSaGbA== Received: by pali.im (Postfix) id 787CC9D7; Thu, 20 May 2021 13:35:30 +0200 (CEST) From: =?utf-8?q?Pali_Roh=C3=A1r?= To: Gregory CLEMENT , Andrew Lunn Cc: =?utf-8?q?Marek_Beh=C3=BAn?= , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH v4 mvebu 1/4] firmware: turris-mox-rwtm: fix reply status decoding function Date: Thu, 20 May 2021 13:35:17 +0200 Message-Id: <20210520113520.32240-2-pali@kernel.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20210520113520.32240-1-pali@kernel.org> References: <20210308153703.23097-1-kabel@kernel.org> <20210520113520.32240-1-pali@kernel.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210520_043533_131561_90F155EE X-CRM114-Status: GOOD ( 11.75 ) 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 From: Marek Behún The status decoding function mox_get_status() currently contains an incorrect check: 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 Reviewed-by: Pali Rohár Reviewed-by: Andrew Lunn 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 62f0d1a5dd32..f85acdb3130c 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); }