aboutsummaryrefslogtreecommitdiff
path: root/drivers/misc
diff options
context:
space:
mode:
authorSimon Glass <sjg@chromium.org>2020-11-09 07:14:43 -0700
committerSimon Glass <sjg@chromium.org>2020-11-14 15:23:41 -0700
commitd237e9c7c00d131d808761d0fe7f44768598c074 (patch)
tree697e7b27d357c91d9b4d8601395e24a2b18f58ad /drivers/misc
parentfcbec650e6216fdba0ffe6fc017a34ceed0c86cb (diff)
downloadu-boot-d237e9c7c00d131d808761d0fe7f44768598c074.zip
u-boot-d237e9c7c00d131d808761d0fe7f44768598c074.tar.gz
u-boot-d237e9c7c00d131d808761d0fe7f44768598c074.tar.bz2
cros_ec: Correct collection of EC hash
The EC now requires that the offset field be set correctly when checking on hash status. Update the code to handle this. Use the same message struct in both functions to reduce stack space. Signed-off-by: Simon Glass <sjg@chromium.org>
Diffstat (limited to 'drivers/misc')
-rw-r--r--drivers/misc/cros_ec.c16
1 files changed, 10 insertions, 6 deletions
diff --git a/drivers/misc/cros_ec.c b/drivers/misc/cros_ec.c
index c367490..1b22f18 100644
--- a/drivers/misc/cros_ec.c
+++ b/drivers/misc/cros_ec.c
@@ -495,18 +495,18 @@ int cros_ec_read_current_image(struct udevice *dev,
}
static int cros_ec_wait_on_hash_done(struct udevice *dev,
+ struct ec_params_vboot_hash *p,
struct ec_response_vboot_hash *hash)
{
- struct ec_params_vboot_hash p;
ulong start;
start = get_timer(0);
while (hash->status == EC_VBOOT_HASH_STATUS_BUSY) {
mdelay(50); /* Insert some reasonable delay */
- p.cmd = EC_VBOOT_HASH_GET;
- if (ec_command(dev, EC_CMD_VBOOT_HASH, 0, &p, sizeof(p),
- hash, sizeof(*hash)) < 0)
+ p->cmd = EC_VBOOT_HASH_GET;
+ if (ec_command(dev, EC_CMD_VBOOT_HASH, 0, p, sizeof(*p), hash,
+ sizeof(*hash)) < 0)
return -1;
if (get_timer(start) > CROS_EC_CMD_HASH_TIMEOUT_MS) {
@@ -530,7 +530,7 @@ int cros_ec_read_hash(struct udevice *dev, uint hash_offset,
return -1;
/* If the EC is busy calculating the hash, fidget until it's done. */
- rv = cros_ec_wait_on_hash_done(dev, hash);
+ rv = cros_ec_wait_on_hash_done(dev, &p, hash);
if (rv)
return rv;
@@ -553,9 +553,13 @@ int cros_ec_read_hash(struct udevice *dev, uint hash_offset,
hash, sizeof(*hash)) < 0)
return -1;
- rv = cros_ec_wait_on_hash_done(dev, hash);
+ rv = cros_ec_wait_on_hash_done(dev, &p, hash);
if (rv)
return rv;
+ if (hash->status != EC_VBOOT_HASH_STATUS_DONE) {
+ log_err("Hash did not complete, status=%d\n", hash->status);
+ return -EIO;
+ }
debug("%s: hash done\n", __func__);