summaryrefslogtreecommitdiff
path: root/src/drivers
diff options
context:
space:
mode:
authorStefan Reinauer <stefan.reinauer@coreboot.org>2016-05-04 16:16:47 -0700
committerMartin Roth <martinroth@google.com>2016-05-06 19:03:41 +0200
commit24850ccf9b4597a1269ac3409814219108fadf33 (patch)
tree0bb99d2b9d20650571ee91b5c79e425696e68537 /src/drivers
parentd5a6eb44ca68954416a238c2825ac01f511ecd9a (diff)
rtc: Do checksum check for all bytes
Due to missing braces (that went undetected because of the indentation), I584189d9fcf7c9b831d9c020ee7ed59bb5ae08e8 CMOS: add set_option() only takes the last changed byte into regard when determining whether the checksum needs to be updated. This bug went undetected for 5 years. Change-Id: I47cedc801a60959386dfdcda3a13b8e3162a7ecb Signed-off-by: Stefan Reinauer <stefan.reinauer@coreboot.org> Reviewed-on: https://review.coreboot.org/14616 Tested-by: build bot (Jenkins) Reviewed-by: Paul Menzel <paulepanter@users.sourceforge.net> Reviewed-by: Martin Roth <martinroth@google.com>
Diffstat (limited to 'src/drivers')
-rw-r--r--src/drivers/pc80/rtc/mc146818rtc.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/src/drivers/pc80/rtc/mc146818rtc.c b/src/drivers/pc80/rtc/mc146818rtc.c
index 35dad3256a..5fb9cf695b 100644
--- a/src/drivers/pc80/rtc/mc146818rtc.c
+++ b/src/drivers/pc80/rtc/mc146818rtc.c
@@ -198,7 +198,7 @@ static enum cb_err get_cmos_value(unsigned long bit, unsigned long length,
uchar >>= byte_bit; /* shift the bits to byte align */
/* clear unspecified bits */
ret[0] = uchar & ((1 << length) - 1);
- } else { /* more that one byte so transfer the whole bytes */
+ } else { /* more than one byte so transfer the whole bytes */
for (i = 0; length; i++, length -= 8, byte++) {
/* load the byte */
ret[i] = cmos_read(byte);
@@ -284,11 +284,12 @@ static enum cb_err set_cmos_value(unsigned long bit, unsigned long length,
if (byte_bit || length % 8)
return CB_ERR_ARG;
- for (i = 0; length; i++, length -= 8, byte++)
+ for (i = 0; length; i++, length -= 8, byte++) {
cmos_write(ret[i], byte);
if (byte >= LB_CKS_RANGE_START &&
byte <= LB_CKS_RANGE_END)
chksum_update_needed = 1;
+ }
}
if (chksum_update_needed) {