[PATCH] cros_ec: Fix an error code is cros_ec_get_sku_id()

Dan Carpenter dan.carpenter at linaro.org
Wed Jul 26 08:58:34 CEST 2023


The ec_command_inptr() function returns negative error codes or
the number of bytes that it was able to read.  The cros_ec_get_sku_id()
function should return negative error codes.  Right now it returns
positive error codes or negative byte counts.

Signed-off-by: Dan Carpenter <dan.carpenter at linaro.org>
---
 drivers/misc/cros_ec.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/drivers/misc/cros_ec.c b/drivers/misc/cros_ec.c
index 621d1752176a..9c1e6a5e3e70 100644
--- a/drivers/misc/cros_ec.c
+++ b/drivers/misc/cros_ec.c
@@ -1100,8 +1100,11 @@ int cros_ec_get_sku_id(struct udevice *dev)
 
 	ret = ec_command_inptr(dev, EC_CMD_GET_SKU_ID, 0, NULL, 0,
 			       (uint8_t **)&r, sizeof(*r));
-	if (ret != sizeof(*r))
-		return -ret;
+	if (ret != sizeof(*r)) {
+		if (ret >= 0)
+			ret = -EIO;
+		return ret;
+	}
 
 	return r->sku_id;
 }
-- 
2.39.2



More information about the U-Boot mailing list