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

[PATCH] Allow reading CMOS day of week register

Someone wanted access to this usually unused (and unused by Linux) value
for the day of week. Existing kernels have the field in the struct but
return 0 always. This updates the kernel to fill in the field. The usual
case of 'not set' conveniently is 0.

Signed-off-by: Alan Cox <alan@redhat.com>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>

authored by

Alan Cox and committed by
Linus Torvalds
b7599587 e56d5ae3

+9 -5
+9 -5
drivers/char/rtc.c
··· 46 46 * 1.11a Daniele Bellucci: Audit create_proc_read_entry in rtc_init 47 47 * 1.12 Venkatesh Pallipadi: Hooks for emulating rtc on HPET base-timer 48 48 * CONFIG_HPET_EMULATE_RTC 49 - * 49 + * 1.12ac Alan Cox: Allow read access to the day of week register 50 50 */ 51 51 52 - #define RTC_VERSION "1.12" 52 + #define RTC_VERSION "1.12ac" 53 53 54 54 #define RTC_IO_EXTENT 0x8 55 55 ··· 1250 1250 1251 1251 /* 1252 1252 * Only the values that we read from the RTC are set. We leave 1253 - * tm_wday, tm_yday and tm_isdst untouched. Even though the 1254 - * RTC has RTC_DAY_OF_WEEK, we ignore it, as it is only updated 1255 - * by the RTC when initially set to a non-zero value. 1253 + * tm_wday, tm_yday and tm_isdst untouched. Note that while the 1254 + * RTC has RTC_DAY_OF_WEEK, we should usually ignore it, as it is 1255 + * only updated by the RTC when initially set to a non-zero value. 1256 1256 */ 1257 1257 spin_lock_irq(&rtc_lock); 1258 1258 rtc_tm->tm_sec = CMOS_READ(RTC_SECONDS); ··· 1261 1261 rtc_tm->tm_mday = CMOS_READ(RTC_DAY_OF_MONTH); 1262 1262 rtc_tm->tm_mon = CMOS_READ(RTC_MONTH); 1263 1263 rtc_tm->tm_year = CMOS_READ(RTC_YEAR); 1264 + /* Only set from 2.6.16 onwards */ 1265 + rtc_tm->tm_wday = CMOS_READ(RTC_DAY_OF_WEEK); 1266 + 1264 1267 #ifdef CONFIG_MACH_DECSTATION 1265 1268 real_year = CMOS_READ(RTC_DEC_YEAR); 1266 1269 #endif ··· 1278 1275 BCD_TO_BIN(rtc_tm->tm_mday); 1279 1276 BCD_TO_BIN(rtc_tm->tm_mon); 1280 1277 BCD_TO_BIN(rtc_tm->tm_year); 1278 + BCD_TO_BIN(rtc_tm->tm_wday); 1281 1279 } 1282 1280 1283 1281 #ifdef CONFIG_MACH_DECSTATION