Commit e34e6025 authored by Marek Behún's avatar Marek Behún Committed by Gregory CLEMENT

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: default avatarMarek Behún <kabel@kernel.org>
Reviewed-by: default avatarPali Rohár <pali@kernel.org>
Reviewed-by: default avatarAndrew Lunn <andrew@lunn.ch>
Fixes: 389711b3 ("firmware: Add Turris Mox rWTM firmware driver")
Signed-off-by: default avatarGregory CLEMENT <gregory.clement@bootlin.com>
parent 6efb943b
......@@ -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);
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment