diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2015-06-25 18:55:33 -0700 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2015-06-25 18:55:33 -0700 |
commit | c13c81006314ad76c2b31824960a900385601b8b (patch) | |
tree | 749f71b07f252960775c42bd1141d21cb35a768d /drivers/rtc/rtc-efi.c | |
parent | 24867481b8c0a3bc3ab53b634e3cc03680ac3ac6 (diff) | |
parent | 3783055ef4cf096910f670f9a1a32e32db08559b (diff) |
Merge tag 'rtc-v4.2-1' of git://git.kernel.org/pub/scm/linux/kernel/git/abelloni/linux
Pull RTC updates from Alexandre Belloni:
"Core:
- Coding style and whitespace fixes (interface, Makefile and Kconfig)
- New rtc_tm_sub() helper
- New CONFIG_RTC_SYSTOHC_DEVICE option
- Removed rtc_set_mmss()
New drivers:
- Mediatek MT6397
- Cortina Gemini
Drivers:
- Year 2106 fixes for isl1208, pcf8563 and sunxi
- update author email for at32ap700x and efi
- ds1307: alarm fix
- efi: use correct EFI 'epoch'
- hym8563: make irq optional
- imxdi: cleanups and better handling of the security/tamper monitoring
- snvs: fix wakealarm
- Compilation fixes or warning removal for gemini, mt6397, palmas, pfc8563
- Trivial cleanups for ab8500, ds1216, ds1286, ds1672, ep93xx,
hid-sensor-time, max6900, max8998, max77686, max77802, mc13xxx, mv,
mxc, s3c, spear, v3020
- Kconfig fixes for stmp3xxx and xgene"
* tag 'rtc-v4.2-1' of git://git.kernel.org/pub/scm/linux/kernel/git/abelloni/linux: (48 commits)
rtc: remove useless I2C dependencies
rtc: whitespace fixes
rtc: Properly sort Makefile
MAINTAINERS: Add RTC subsystem repository
rtc: pfc8563: fix uninitialized variable warning
rtc: ds1307: Enable the mcp794xx alarm after programming time
rtc: hym8563: make the irq optional
rtc: gemini: fix cocci warnings
rtc: mv: correct 24 hour error message
rtc: mv: use BIT()
rtc: efi: use correct EFI 'epoch'
rtc: interface: Remove rtc_set_mmss()
sparc: time: Replace update_persistent_clock() with CONFIG_RTC_SYSTOHC
rtc: NTP: Add CONFIG_RTC_SYSTOHC_DEVICE for NTP synchronization
rtc: sunxi: Replace deprecated rtc_tm_to_time()
rtc: isl1208: Replace deprecated rtc_tm_to_time()
rtc: Introduce rtc_tm_sub() helper function
rtc: pcf8563: Replace deprecated rtc_time_to_tm() and rtc_tm_to_time()
rtc: palmas: Initialise bb_charging flag before using it
rtc: simplify use of devm_ioremap_resource
...
Diffstat (limited to 'drivers/rtc/rtc-efi.c')
-rw-r--r-- | drivers/rtc/rtc-efi.c | 43 |
1 files changed, 16 insertions, 27 deletions
diff --git a/drivers/rtc/rtc-efi.c b/drivers/rtc/rtc-efi.c index cb989cd00b14..3806961b4348 100644 --- a/drivers/rtc/rtc-efi.c +++ b/drivers/rtc/rtc-efi.c @@ -3,7 +3,7 @@ * * Copyright (C) 2009 Hewlett-Packard Development Company, L.P. * - * Author: dann frazier <dannf@hp.com> + * Author: dann frazier <dannf@dannf.org> * Based on efirtc.c by Stephane Eranian * * This program is free software; you can redistribute it and/or modify it @@ -24,10 +24,6 @@ #include <linux/efi.h> #define EFI_ISDST (EFI_TIME_ADJUST_DAYLIGHT|EFI_TIME_IN_DAYLIGHT) -/* - * EFI Epoch is 1/1/1998 - */ -#define EFI_RTC_EPOCH 1998 /* * returns day of the year [0-365] @@ -38,31 +34,24 @@ compute_yday(efi_time_t *eft) /* efi_time_t.month is in the [1-12] so, we need -1 */ return rtc_year_days(eft->day, eft->month - 1, eft->year); } + /* * returns day of the week [0-6] 0=Sunday - * - * Don't try to provide a year that's before 1998, please ! */ static int -compute_wday(efi_time_t *eft) +compute_wday(efi_time_t *eft, int yday) { - int y; - int ndays = 0; - - if (eft->year < EFI_RTC_EPOCH) { - pr_err("EFI year < " __stringify(EFI_RTC_EPOCH) ", invalid date\n"); - return -1; - } - - for (y = EFI_RTC_EPOCH; y < eft->year; y++) - ndays += 365 + (is_leap_year(y) ? 1 : 0); - - ndays += compute_yday(eft); + int ndays = eft->year * (365 % 7) + + (eft->year - 1) / 4 + - (eft->year - 1) / 100 + + (eft->year - 1) / 400 + + yday; /* - * 4=1/1/1998 was a Thursday + * 1/1/0000 may or may not have been a Sunday (if it ever existed at + * all) but assuming it was makes this calculation work correctly. */ - return (ndays + 4) % 7; + return ndays % 7; } static void @@ -103,16 +92,16 @@ convert_from_efi_time(efi_time_t *eft, struct rtc_time *wtime) if (!eft->month || eft->month > 12) return false; wtime->tm_mon = eft->month - 1; - wtime->tm_year = eft->year - 1900; - /* day of the week [0-6], Sunday=0 */ - wtime->tm_wday = compute_wday(eft); - if (wtime->tm_wday < 0) + if (eft->year < 1900 || eft->year > 9999) return false; + wtime->tm_year = eft->year - 1900; /* day in the year [1-365]*/ wtime->tm_yday = compute_yday(eft); + /* day of the week [0-6], Sunday=0 */ + wtime->tm_wday = compute_wday(eft, wtime->tm_yday); switch (eft->daylight & EFI_ISDST) { case EFI_ISDST: @@ -233,7 +222,7 @@ static struct platform_driver efi_rtc_driver = { module_platform_driver_probe(efi_rtc_driver, efi_rtc_probe); MODULE_ALIAS("platform:rtc-efi"); -MODULE_AUTHOR("dann frazier <dannf@hp.com>"); +MODULE_AUTHOR("dann frazier <dannf@dannf.org>"); MODULE_LICENSE("GPL"); MODULE_DESCRIPTION("EFI RTC driver"); MODULE_ALIAS("platform:rtc-efi"); |