Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

rtc-m48t59: fix setting of a year on m48t08 and m48t02 rtcs

Fix setting of a year in m48t08 and m48t02 clocks.
They do not have century bits and setting them
causes the year to overflow (bit 0x80 set).

Problem found by Robert Reif on Sun Sparcstation 20.

Signed-off-by: Krzysztof Helt <krzysztof.h1@wp.pl>
Signed-off-by: David S. Miller <davem@davemloft.net>

authored by

Krzysztof Helt and committed by
David S. Miller
d875a4b0 3baca76f

+1 -1
+1 -1
drivers/rtc/rtc-m48t59.c
··· 126 126 M48T59_WRITE((BIN2BCD(tm->tm_mon + 1) & 0x1F), M48T59_MONTH); 127 127 M48T59_WRITE(BIN2BCD(tm->tm_year % 100), M48T59_YEAR); 128 128 129 - if (tm->tm_year/100) 129 + if (pdata->type == M48T59RTC_TYPE_M48T59 && (tm->tm_year / 100)) 130 130 val = (M48T59_WDAY_CEB | M48T59_WDAY_CB); 131 131 val |= (BIN2BCD(tm->tm_wday) & 0x07); 132 132 M48T59_WRITE(val, M48T59_WDAY);