diff options
author | Rasmus Villemoes <rasmus.villemoes@prevas.dk> | 2020-05-01 15:24:50 +0200 |
---|---|---|
committer | Tom Rini <trini@konsulko.com> | 2020-05-01 11:34:01 -0400 |
commit | b8a42e0fcb94b335e0661ff4d2366ee3edf7f883 (patch) | |
tree | 7ecd559e6240cc5a5024575c8b97d625c26e4aba /drivers/rtc | |
parent | 54be09cd8f6e66f59144f9e5861b0252ed441d89 (diff) | |
download | u-boot-b8a42e0fcb94b335e0661ff4d2366ee3edf7f883.zip u-boot-b8a42e0fcb94b335e0661ff4d2366ee3edf7f883.tar.gz u-boot-b8a42e0fcb94b335e0661ff4d2366ee3edf7f883.tar.bz2 |
rtc: pcf2127: don't add/subtract 1 to tm_mon
As noted in rtc_def.h, the tm_mon field in struct rtc_time is 1-12,
unlike in struct tm where it is 0-11. Currently, running "date" prints
the wrong
Date: 2020-04-01 (Friday) Time: 13:05:30
and setting the RTC via the date command is also broken.
Signed-off-by: Rasmus Villemoes <rasmus.villemoes@prevas.dk>
Diffstat (limited to 'drivers/rtc')
-rw-r--r-- | drivers/rtc/pcf2127.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/drivers/rtc/pcf2127.c b/drivers/rtc/pcf2127.c index f695350..b34ed63 100644 --- a/drivers/rtc/pcf2127.c +++ b/drivers/rtc/pcf2127.c @@ -56,7 +56,7 @@ static int pcf2127_rtc_set(struct udevice *dev, const struct rtc_time *tm) buf[i++] = tm->tm_wday & 0x07; /* month, 1 - 12 */ - buf[i++] = bin2bcd(tm->tm_mon + 1); + buf[i++] = bin2bcd(tm->tm_mon); /* year */ buf[i++] = bin2bcd(tm->tm_year % 100); @@ -83,7 +83,7 @@ static int pcf2127_rtc_get(struct udevice *dev, struct rtc_time *tm) tm->tm_min = bcd2bin(buf[PCF2127_REG_MN] & 0x7F); tm->tm_hour = bcd2bin(buf[PCF2127_REG_HR] & 0x3F); tm->tm_mday = bcd2bin(buf[PCF2127_REG_DM] & 0x3F); - tm->tm_mon = bcd2bin(buf[PCF2127_REG_MO] & 0x1F) - 1; + tm->tm_mon = bcd2bin(buf[PCF2127_REG_MO] & 0x1F); tm->tm_year = bcd2bin(buf[PCF2127_REG_YR]) + 1900; if (tm->tm_year < 1970) tm->tm_year += 100; /* assume we are in 1970...2069 */ |