All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] efi: rtc-efi: use correct EFI 'epoch'
@ 2015-06-08 11:27 ` Ard Biesheuvel
  0 siblings, 0 replies; 14+ messages in thread
From: Ard Biesheuvel @ 2015-06-08 11:27 UTC (permalink / raw)
  To: matt.fleming-ral2JQCrhuEAvxtiuMwx3w,
	linux-efi-u79uwXL29TY76Z2rM5mHXA
  Cc: roy.franz-QSEj5FYQhm4dnm+yROfE0A,
	leif.lindholm-QSEj5FYQhm4dnm+yROfE0A, Ard Biesheuvel,
	Alessandro Zummo, Alexandre Belloni,
	rtc-linux-/JYPxA39Uh5TLH3MbocFFw

The rtc-efi driver declares that the EFI 'epoch' is 1/1/1998, but
the UEFI spec does not define it at all. It does define a minimum
of 1900 for the 'Year' member of the EFI_TIME struct, so let's use
1900 as the minimum year and not 1998.

This prevents rtc_read_time() failures when the RTC that backs the
EFI time services is set to a date before 1998.

Cc: Alessandro Zummo <a.zummo-BfzFCNDTiLLj+vYz1yj4TQ@public.gmane.org>
Cc: Alexandre Belloni <alexandre.belloni-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8@public.gmane.org>
Cc: rtc-linux-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
Signed-off-by: Ard Biesheuvel <ard.biesheuvel-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
---
 drivers/rtc/rtc-efi.c | 13 +++++++------
 1 file changed, 7 insertions(+), 6 deletions(-)

diff --git a/drivers/rtc/rtc-efi.c b/drivers/rtc/rtc-efi.c
index cb989cd00b14..4a93b0bbf22c 100644
--- a/drivers/rtc/rtc-efi.c
+++ b/drivers/rtc/rtc-efi.c
@@ -25,9 +25,12 @@
 
 #define EFI_ISDST (EFI_TIME_ADJUST_DAYLIGHT|EFI_TIME_IN_DAYLIGHT)
 /*
- * EFI Epoch is 1/1/1998
+ * The UEFI spec does not literally define an epoch, but it does
+ * define EFI_TIME::Year as having a value between 1900 and 9999.
+ * (UEFI spec v2.5 paragraph 7.3)
+ * So let's use 1900 as the EFI epoch year.
  */
-#define EFI_RTC_EPOCH		1998
+#define EFI_RTC_EPOCH		1900
 
 /*
  * returns day of the year [0-365]
@@ -40,8 +43,6 @@ compute_yday(efi_time_t *eft)
 }
 /*
  * 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)
@@ -60,9 +61,9 @@ compute_wday(efi_time_t *eft)
 	ndays += compute_yday(eft);
 
 	/*
-	 * 4=1/1/1998 was a Thursday
+	 * 1=1/1/1900 was a Monday
 	 */
-	return (ndays + 4) % 7;
+	return (ndays + 1) % 7;
 }
 
 static void
-- 
1.9.1

^ permalink raw reply related	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2015-06-13 12:57 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-06-08 11:27 [PATCH] efi: rtc-efi: use correct EFI 'epoch' Ard Biesheuvel
2015-06-08 11:27 ` [rtc-linux] " Ard Biesheuvel
     [not found] ` <1433762834-17961-1-git-send-email-ard.biesheuvel-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
2015-06-08 19:26   ` James Bottomley
2015-06-08 19:26     ` [rtc-linux] " James Bottomley
     [not found]     ` <1433791592.2291.83.camel-d9PhHud1JfjCXq6kfMZ53/egYHeGw8Jk@public.gmane.org>
2015-06-08 20:15       ` Ard Biesheuvel
2015-06-08 20:15         ` [rtc-linux] " Ard Biesheuvel
     [not found]         ` <CAKv+Gu-e03H7nP5UOoSR++CkAt96qsVz1YaR4K8wRPhg7LpEqQ-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2015-06-08 20:27           ` James Bottomley
2015-06-08 20:27             ` [rtc-linux] " James Bottomley
     [not found]             ` <1433795250.2291.106.camel-d9PhHud1JfjCXq6kfMZ53/egYHeGw8Jk@public.gmane.org>
2015-06-08 21:27               ` Ard Biesheuvel
2015-06-08 21:27                 ` [rtc-linux] " Ard Biesheuvel
2015-06-09  9:15   ` [PATCH v2] " Ard Biesheuvel
2015-06-09  9:15     ` [rtc-linux] " Ard Biesheuvel
     [not found]     ` <1433841335-10453-1-git-send-email-ard.biesheuvel-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
2015-06-13 12:57       ` Alexandre Belloni
2015-06-13 12:57         ` [rtc-linux] " Alexandre Belloni

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.