Matt DeVillier has uploaded this change for review.

View Change

ec/chromeec: fix LPC read/write for MEC devices

Commit 8cf8aa2 [ec/google/chromeec: Use common MEC interface]
changed the return mechanism for the checksum on reads/writes
for MEC devices, but incorrectly handled the passed-in csum
parameter by not dereferencing. This led to the returned csum
value always being zero, which causes all EC commands with non-
NULL data_in to fail with a checksum error.

Fix this by storing the returned checksum in a temp variable,
and only assigning to csum when the pointer isn't NULL;

Test: build/boot google/chell, verify EC hello command succeeds,
keyboard backlight turned on at boot.

Change-Id: I7122c3fdc5a19f87f12975ee448728cf29948436
Signed-off-by: Matt DeVillier <matt.devillier@gmail.com>
---
M src/ec/google/chromeec/ec_lpc.c
1 file changed, 6 insertions(+), 2 deletions(-)

git pull ssh://review.coreboot.org:29418/coreboot refs/changes/44/30444/1
diff --git a/src/ec/google/chromeec/ec_lpc.c b/src/ec/google/chromeec/ec_lpc.c
index c8665c9..61005d3 100644
--- a/src/ec/google/chromeec/ec_lpc.c
+++ b/src/ec/google/chromeec/ec_lpc.c
@@ -41,9 +41,11 @@
#if IS_ENABLED(CONFIG_EC_GOOGLE_CHROMEEC_MEC)
/* Access desired range though EMI interface */
if (port >= MEC_EMI_RANGE_START && port <= MEC_EMI_RANGE_END) {
- csum += mec_io_bytes(MEC_IO_READ, MEC_EMI_BASE,
+ u8 ret = mec_io_bytes(MEC_IO_READ, MEC_EMI_BASE,
port - MEC_EMI_RANGE_START,
dest, length);
+ if (csum)
+ *csum += ret;
return;
}
#endif
@@ -78,9 +80,11 @@
#if IS_ENABLED(CONFIG_EC_GOOGLE_CHROMEEC_MEC)
/* Access desired range though EMI interface */
if (port >= MEC_EMI_RANGE_START && port <= MEC_EMI_RANGE_END) {
- csum += mec_io_bytes(MEC_IO_WRITE, MEC_EMI_BASE,
+ u8 ret = mec_io_bytes(MEC_IO_WRITE, MEC_EMI_BASE,
port - MEC_EMI_RANGE_START,
msg, length);
+ if (csum)
+ *csum += ret;
return;
}
#endif

To view, visit change 30444. To unsubscribe, or for help writing mail filters, visit settings.

Gerrit-Project: coreboot
Gerrit-Branch: master
Gerrit-Change-Id: I7122c3fdc5a19f87f12975ee448728cf29948436
Gerrit-Change-Number: 30444
Gerrit-PatchSet: 1
Gerrit-Owner: Matt DeVillier <matt.devillier@gmail.com>
Gerrit-MessageType: newchange