diff options
author | Benoît Thébaudeau <benoit@wsystem.com> | 2016-07-21 06:41:29 -0400 |
---|---|---|
committer | Alexandre Belloni <alexandre.belloni@free-electrons.com> | 2016-07-28 03:59:37 -0400 |
commit | a1e98e09704ad247bff3c0de1bef6a73dc88b6d0 (patch) | |
tree | 48f18d457aeffe90c1332d9d0592151b7b51b2b6 | |
parent | 96acb25c50e77355673b89765b96bd764abf487d (diff) |
rtc: rv8803: Fix read day of week
The Weekday register is encoded as 2^tm_wday, with tm_wday in 0..6, so
using tm_wday = ffs(reg) to fill tm_wday from the register value is
wrong because this gives the expected value + 1. This could be fixed as
tm_wday = ffs(reg) - 1, but tm_wday = ilog2(reg) works as well and is
more direct.
Signed-off-by: Benoît Thébaudeau <benoit@wsystem.com>
Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
-rw-r--r-- | drivers/rtc/rtc-rv8803.c | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/drivers/rtc/rtc-rv8803.c b/drivers/rtc/rtc-rv8803.c index e740c8351659..aa1d6b67a9ee 100644 --- a/drivers/rtc/rtc-rv8803.c +++ b/drivers/rtc/rtc-rv8803.c | |||
@@ -13,6 +13,7 @@ | |||
13 | 13 | ||
14 | #include <linux/bcd.h> | 14 | #include <linux/bcd.h> |
15 | #include <linux/bitops.h> | 15 | #include <linux/bitops.h> |
16 | #include <linux/log2.h> | ||
16 | #include <linux/i2c.h> | 17 | #include <linux/i2c.h> |
17 | #include <linux/interrupt.h> | 18 | #include <linux/interrupt.h> |
18 | #include <linux/kernel.h> | 19 | #include <linux/kernel.h> |
@@ -145,7 +146,7 @@ static int rv8803_get_time(struct device *dev, struct rtc_time *tm) | |||
145 | tm->tm_sec = bcd2bin(date[RV8803_SEC] & 0x7f); | 146 | tm->tm_sec = bcd2bin(date[RV8803_SEC] & 0x7f); |
146 | tm->tm_min = bcd2bin(date[RV8803_MIN] & 0x7f); | 147 | tm->tm_min = bcd2bin(date[RV8803_MIN] & 0x7f); |
147 | tm->tm_hour = bcd2bin(date[RV8803_HOUR] & 0x3f); | 148 | tm->tm_hour = bcd2bin(date[RV8803_HOUR] & 0x3f); |
148 | tm->tm_wday = ffs(date[RV8803_WEEK] & 0x7f); | 149 | tm->tm_wday = ilog2(date[RV8803_WEEK] & 0x7f); |
149 | tm->tm_mday = bcd2bin(date[RV8803_DAY] & 0x3f); | 150 | tm->tm_mday = bcd2bin(date[RV8803_DAY] & 0x3f); |
150 | tm->tm_mon = bcd2bin(date[RV8803_MONTH] & 0x1f) - 1; | 151 | tm->tm_mon = bcd2bin(date[RV8803_MONTH] & 0x1f) - 1; |
151 | tm->tm_year = bcd2bin(date[RV8803_YEAR]) + 100; | 152 | tm->tm_year = bcd2bin(date[RV8803_YEAR]) + 100; |