diff options
-rw-r--r-- | firmware/drivers/rtc/rtc_s35390a.c | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/firmware/drivers/rtc/rtc_s35390a.c b/firmware/drivers/rtc/rtc_s35390a.c index 0b95431330..13027d31a2 100644 --- a/firmware/drivers/rtc/rtc_s35390a.c +++ b/firmware/drivers/rtc/rtc_s35390a.c | |||
@@ -61,7 +61,8 @@ void rtc_init(void) | |||
61 | int rtc_read_datetime(struct tm *tm) | 61 | int rtc_read_datetime(struct tm *tm) |
62 | { | 62 | { |
63 | unsigned char buf[7]; | 63 | unsigned char buf[7]; |
64 | int i, ret; | 64 | unsigned int i; |
65 | int ret; | ||
65 | 66 | ||
66 | ret = i2c_read(RTC_ADDR | (REALTIME_DATA1 << 1), -1, sizeof(buf), buf); | 67 | ret = i2c_read(RTC_ADDR | (REALTIME_DATA1 << 1), -1, sizeof(buf), buf); |
67 | reverse_bits(buf, sizeof(buf)); | 68 | reverse_bits(buf, sizeof(buf)); |
@@ -69,7 +70,7 @@ int rtc_read_datetime(struct tm *tm) | |||
69 | buf[4] &= 0x3f; /* mask out p.m. flag */ | 70 | buf[4] &= 0x3f; /* mask out p.m. flag */ |
70 | 71 | ||
71 | for (i = 0; i < sizeof(buf); i++) | 72 | for (i = 0; i < sizeof(buf); i++) |
72 | BCD2DEC(buf[i]); | 73 | buf[i] = BCD2DEC(buf[i]); |
73 | 74 | ||
74 | tm->tm_sec = buf[6]; | 75 | tm->tm_sec = buf[6]; |
75 | tm->tm_min = buf[5]; | 76 | tm->tm_min = buf[5]; |
@@ -85,7 +86,8 @@ int rtc_read_datetime(struct tm *tm) | |||
85 | int rtc_write_datetime(const struct tm *tm) | 86 | int rtc_write_datetime(const struct tm *tm) |
86 | { | 87 | { |
87 | unsigned char buf[7]; | 88 | unsigned char buf[7]; |
88 | int i, ret; | 89 | unsigned int i; |
90 | int ret; | ||
89 | 91 | ||
90 | buf[6] = tm->tm_sec; | 92 | buf[6] = tm->tm_sec; |
91 | buf[5] = tm->tm_min; | 93 | buf[5] = tm->tm_min; |
@@ -96,7 +98,7 @@ int rtc_write_datetime(const struct tm *tm) | |||
96 | buf[0] = tm->tm_year - 100; | 98 | buf[0] = tm->tm_year - 100; |
97 | 99 | ||
98 | for (i = 0; i < sizeof(buf); i++) | 100 | for (i = 0; i < sizeof(buf); i++) |
99 | DEC2BCD(buf[i]); | 101 | buf[i] = DEC2BCD(buf[i]); |
100 | 102 | ||
101 | reverse_bits(buf, sizeof(buf)); | 103 | reverse_bits(buf, sizeof(buf)); |
102 | ret = i2c_write(RTC_ADDR | (REALTIME_DATA1 << 1), -1, sizeof(buf), buf); | 104 | ret = i2c_write(RTC_ADDR | (REALTIME_DATA1 << 1), -1, sizeof(buf), buf); |