From: Simon Glass <sjg@chromium.org>
Date: Tue, 6 Nov 2018 22:21:19 +0000 (-0700)
Subject: cros_ec: Add error logging on a few commands
X-Git-Tag: v2025.01-rc5-pxa1908~3271^2~18
X-Git-Url: http://git.dujemihanovic.xyz/%22http:/kyber.dk/phpMyBuilder/static/%7B%7B%20%28.OutputFormats.Get?a=commitdiff_plain;h=ac80652342dafa5356cd25959f1c45d003ba9dcf;p=u-boot.git

cros_ec: Add error logging on a few commands

Add some more logging to provide more information on failures.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

diff --git a/drivers/misc/cros_ec.c b/drivers/misc/cros_ec.c
index 4013f50d59..e0f3dfc98e 100644
--- a/drivers/misc/cros_ec.c
+++ b/drivers/misc/cros_ec.c
@@ -13,6 +13,8 @@
  * is not reset.
  */
 
+#define LOG_CATEGORY UCLASS_CROS_EC
+
 #include <common.h>
 #include <command.h>
 #include <dm.h>
@@ -365,10 +367,14 @@ int cros_ec_scan_keyboard(struct udevice *dev, struct mbkp_keyscan *scan)
 int cros_ec_read_id(struct udevice *dev, char *id, int maxlen)
 {
 	struct ec_response_get_version *r;
+	int ret;
 
-	if (ec_command_inptr(dev, EC_CMD_GET_VERSION, 0, NULL, 0,
-			(uint8_t **)&r, sizeof(*r)) != sizeof(*r))
+	ret = ec_command_inptr(dev, EC_CMD_GET_VERSION, 0, NULL, 0,
+			       (uint8_t **)&r, sizeof(*r));
+	if (ret != sizeof(*r)) {
+		log_err("Got rc %d, expected %d\n", ret, sizeof(*r));
 		return -1;
+	}
 
 	if (maxlen > (int)sizeof(r->version_string_ro))
 		maxlen = sizeof(r->version_string_ro);
@@ -381,6 +387,7 @@ int cros_ec_read_id(struct udevice *dev, char *id, int maxlen)
 		memcpy(id, r->version_string_rw, maxlen);
 		break;
 	default:
+		log_err("Invalid EC image %d\n", r->current_image);
 		return -1;
 	}