Skip to content

Commit e34e602

Browse files
elkablogclement
authored andcommitted
firmware: turris-mox-rwtm: fix reply status decoding function
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 <kabel@kernel.org> Reviewed-by: Pali Rohár <pali@kernel.org> Reviewed-by: Andrew Lunn <andrew@lunn.ch> Fixes: 389711b ("firmware: Add Turris Mox rWTM firmware driver") Signed-off-by: Gregory CLEMENT <gregory.clement@bootlin.com>
1 parent 6efb943 commit e34e602

1 file changed

Lines changed: 5 additions & 2 deletions

File tree

‎drivers/firmware/turris-mox-rwtm.c‎

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -147,11 +147,14 @@ MOX_ATTR_RO(pubkey, "%s\n", pubkey);
147147

148148
static int mox_get_status(enum mbox_cmd cmd, u32 retval)
149149
{
150-
if (MBOX_STS_CMD(retval) != cmd ||
151-
MBOX_STS_ERROR(retval) != MBOX_STS_SUCCESS)
150+
if (MBOX_STS_CMD(retval) != cmd)
152151
return -EIO;
153152
else if (MBOX_STS_ERROR(retval) == MBOX_STS_FAIL)
154153
return -(int)MBOX_STS_VALUE(retval);
154+
else if (MBOX_STS_ERROR(retval) == MBOX_STS_BADCMD)
155+
return -ENOSYS;
156+
else if (MBOX_STS_ERROR(retval) != MBOX_STS_SUCCESS)
157+
return -EIO;
155158
else
156159
return MBOX_STS_VALUE(retval);
157160
}

0 commit comments

Comments
 (0)