[coreboot-gerrit] New patch to review for coreboot: 46578c8 drivers/pc80/mc146818rtc: Fix checksum range test
Kyösti Mälkki (kyosti.malkki@gmail.com)
gerrit at coreboot.org
Sat Feb 7 08:09:38 CET 2015
Kyösti Mälkki (kyosti.malkki at gmail.com) just uploaded a new patch set to gerrit, which you can find at http://review.coreboot.org/8383
-gerrit
commit 46578c8c5b63dd5485f69bdcc8076cfdf8c220e3
Author: Kyösti Mälkki <kyosti.malkki at gmail.com>
Date: Sat Feb 7 09:13:02 2015 +0200
drivers/pc80/mc146818rtc: Fix checksum range test
When writing multiple bytes, only the last address was tested
if it was in LB_CKS_RANGE.
Change-Id: I34c0484e9758ef88e7005d0599f6055dc4f4fc59
Signed-off-by: Kyösti Mälkki <kyosti.malkki at gmail.com>
---
src/drivers/pc80/mc146818rtc.c | 19 +++++++++++--------
1 file changed, 11 insertions(+), 8 deletions(-)
diff --git a/src/drivers/pc80/mc146818rtc.c b/src/drivers/pc80/mc146818rtc.c
index b18f22f..030980a 100644
--- a/src/drivers/pc80/mc146818rtc.c
+++ b/src/drivers/pc80/mc146818rtc.c
@@ -243,11 +243,19 @@ static enum cb_err set_cmos_value(unsigned long bit, unsigned long length,
unsigned long byte,byte_bit;
unsigned long i;
unsigned char uchar, mask;
- unsigned int chksum_update_needed = 0;
+ unsigned int chksum_update_needed = 1;
ret = vret;
byte = bit / 8; /* find the byte where the data starts */
byte_bit = bit % 8; /* find the bit where the data starts */
+
+ if (length == 0)
+ return CB_SUCCESS;
+
+ /* Check if write stays outside of LB_CKS_RANGE. */
+ if ((byte + (length-1)/8 < LB_CKS_RANGE_START) || (byte > LB_CKS_RANGE_END))
+ chksum_update_needed = 0;
+
if (length <= 8) { /* one byte or less */
mask = (1 << length) - 1;
mask <<= byte_bit;
@@ -256,23 +264,18 @@ static enum cb_err set_cmos_value(unsigned long bit, unsigned long length,
uchar &= ~mask;
uchar |= (ret[0] << byte_bit);
cmos_write(uchar, byte);
- if (byte >= LB_CKS_RANGE_START && byte <= LB_CKS_RANGE_END)
- chksum_update_needed = 1;
} else { /* more that one byte so transfer the whole bytes */
if (byte_bit || length % 8)
return CB_ERR_ARG;
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) {
+ if (chksum_update_needed)
cmos_set_checksum(LB_CKS_RANGE_START, LB_CKS_RANGE_END,
LB_CKS_LOC);
- }
+
return CB_SUCCESS;
}
More information about the coreboot-gerrit
mailing list