From a5a82418126ee6cadff69d9487c43edc1ccea097 Mon Sep 17 00:00:00 2001 From: Wai-Hong Tam Date: Wed, 15 Jul 2020 14:38:30 -0700 Subject: battery: Fix obtaining battery manufacture date * Fix the typo: should be SB_MANUFACTURE_DATE (manufacture without r) * Fix the register, i.e. SB_MANUFACTURE_DATE, not SB_SPECIFICATION_INFO * Fix the format parsing. The LSB of year is bit-9, not bit-8. BRANCH=None BUG=b:160784792 TEST=With the later CL, checked the manufacture date. Change-Id: I5b5f2bfefec4bbe700bb1ec0d9d6048123f4ad16 Signed-off-by: Wai-Hong Tam Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2300688 Reviewed-by: Douglas Anderson --- driver/battery/smart.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'driver/battery') diff --git a/driver/battery/smart.c b/driver/battery/smart.c index 96a1a3f824..91b9bcfd10 100644 --- a/driver/battery/smart.c +++ b/driver/battery/smart.c @@ -287,16 +287,16 @@ test_mockable int battery_manufacture_date(int *year, int *month, int *day) int rv; int ymd; - rv = sb_read(SB_SPECIFICATION_INFO, &ymd); + rv = sb_read(SB_MANUFACTURE_DATE, &ymd); if (rv) return rv; /* battery date format: - * ymd = day + month * 32 + (year - 1980) * 256 + * ymd = day + month * 32 + (year - 1980) * 512 */ - *year = (ymd >> 8) + 1980; - *month = (ymd & 0xff) / 32; - *day = (ymd & 0xff) % 32; + *year = (ymd >> 9) + 1980; + *month = (ymd >> 5) & 0xf; + *day = ymd & 0x1f; return EC_SUCCESS; } -- cgit v1.2.1