linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] powerpc/time: Calculate proper wday
@ 2018-08-29  7:54 Joakim Tjernlund
       [not found] ` <CA+7wUsxbYGAuwE--AukCCYA8H4CQj1tv31nAOv256u9tkDENKg@mail.gmail.com>
  0 siblings, 1 reply; 2+ messages in thread
From: Joakim Tjernlund @ 2018-08-29  7:54 UTC (permalink / raw)
  To: linuxppc-dev

to_tm() hardcodes wday to -1 as "No-one uses the day of the week".
But recently rtc driver ds1307 does care and tries to correct wday.

Add wday calculation(stolen from rtc_time64_to_tm) to to_tm() to please ds1307.

Signed-off-by: Joakim Tjernlund <joakim.tjernlund@infinera.com>
---
 arch/powerpc/kernel/time.c | 8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)

diff --git a/arch/powerpc/kernel/time.c b/arch/powerpc/kernel/time.c
index fe6f3a285455..f4a09ee01944 100644
--- a/arch/powerpc/kernel/time.c
+++ b/arch/powerpc/kernel/time.c
@@ -1160,6 +1160,9 @@ void to_tm(int tim, struct rtc_time * tm)
 	day = tim / SECDAY;
 	hms = tim % SECDAY;
 
+	/* day of the week, 1970-01-01 was a Thursday */
+	tm->tm_wday = (day + 4) % 7;
+
 	/* Hours, minutes, seconds are easy */
 	tm->tm_hour = hms / 3600;
 	tm->tm_min = (hms % 3600) / 60;
@@ -1180,11 +1183,6 @@ void to_tm(int tim, struct rtc_time * tm)
 
 	/* Days are what is left over (+1) from all that. */
 	tm->tm_mday = day + 1;
-
-	/*
-	 * No-one uses the day of the week.
-	 */
-	tm->tm_wday = -1;
 }
 EXPORT_SYMBOL(to_tm);
 
-- 
2.16.4

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

end of thread, other threads:[~2018-09-18  8:27 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-08-29  7:54 [PATCH] powerpc/time: Calculate proper wday Joakim Tjernlund
     [not found] ` <CA+7wUsxbYGAuwE--AukCCYA8H4CQj1tv31nAOv256u9tkDENKg@mail.gmail.com>
2018-09-18  8:27   ` Joakim Tjernlund

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).