From patchwork Wed Aug 29 07:54:58 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joakim Tjernlund X-Patchwork-Id: 963260 Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [203.11.71.2]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 420dQR04GTz9s1x for ; Wed, 29 Aug 2018 18:02:39 +1000 (AEST) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=infinera.com Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 420dQQ4mGpzF2ZL for ; Wed, 29 Aug 2018 18:02:38 +1000 (AEST) Authentication-Results: lists.ozlabs.org; dmarc=fail (p=none dis=none) header.from=infinera.com X-Original-To: linuxppc-dev@lists.ozlabs.org Delivered-To: linuxppc-dev@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; spf=permerror (mailfrom) smtp.mailfrom=infinera.com (client-ip=31.15.61.139; helo=smtp.transmode.se; envelope-from=joakim.tjernlund@infinera.com; receiver=) Authentication-Results: lists.ozlabs.org; dmarc=fail (p=none dis=none) header.from=infinera.com X-Greylist: delayed 329 seconds by postgrey-1.36 at bilbo; Wed, 29 Aug 2018 18:00:41 AEST Received: from smtp.transmode.se (smtp.transmode.se [31.15.61.139]) by lists.ozlabs.org (Postfix) with ESMTP id 420dN9424zzF13F for ; Wed, 29 Aug 2018 18:00:41 +1000 (AEST) Received: from gentoo-jocke.infinera.com (gentoo-jocke.infinera.com [10.210.72.200]) by smtp.transmode.se (Postfix) with ESMTP id C9712118A71A; Wed, 29 Aug 2018 09:55:03 +0200 (CEST) Received: from gentoo-jocke.infinera.com (gentoo-jocke.infinera.com [127.0.0.1]) by gentoo-jocke.infinera.com (8.14.9/8.14.9) with ESMTP id w7T7t3Df010219; Wed, 29 Aug 2018 09:55:03 +0200 Received: (from jocke@localhost) by gentoo-jocke.infinera.com (8.14.9/8.14.9/Submit) id w7T7t3pe010218; Wed, 29 Aug 2018 09:55:03 +0200 From: Joakim Tjernlund To: linuxppc-dev@lists.ozlabs.org Subject: [PATCH] powerpc/time: Calculate proper wday Date: Wed, 29 Aug 2018 09:54:58 +0200 Message-Id: <20180829075458.10145-1-joakim.tjernlund@infinera.com> X-Mailer: git-send-email 2.16.4 X-BeenThere: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.27 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: linuxppc-dev-bounces+patchwork-incoming=ozlabs.org@lists.ozlabs.org Sender: "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 --- 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);