From patchwork Tue Jul 21 00:45:49 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Xunlei Pang X-Patchwork-Id: 51293 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-lb0-f197.google.com (mail-lb0-f197.google.com [209.85.217.197]) by patches.linaro.org (Postfix) with ESMTPS id E292320323 for ; Tue, 21 Jul 2015 01:17:53 +0000 (UTC) Received: by lbbvz8 with SMTP id vz8sf43414942lbb.2 for ; Mon, 20 Jul 2015 18:17:52 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:delivered-to:from:to:cc:subject :date:message-id:sender:precedence:list-id:x-original-sender :x-original-authentication-results:mailing-list:list-post:list-help :list-archive:list-unsubscribe; bh=z/Avrz1/fH6Hr/Qpetsss36vSZZfY39jXHR4vWo7Mdo=; b=H2fo2GTl7ZW/EhpLGpz381dGWtTpYfoM6/yDRhrmhOEOJW/yXLmUX80HhbsDGnI4it flBMNubzkHv1+9ju6/1tsJ2+AeSQ0KSYX8/WfnFGIbDCfDad96PjXM3hpyMHaW8ZFVrz +Cpz/9rN0Js80QqlT4sobl323JoIzmyjs43d2R/7xyGO79+FnT4TWiX6MpwYF8xa9DEH QT89EOR4WPMY7/R6q7xGpLnKAnsQMP3pYWoC108dc8QUyC3l/wXSegYNZkiodLqLvfbk SoQyPf233BSWS7xVmHE8d3Xw4WNBDgWzVCcLGHX3WVbpIbAfxo4O97xoTv2woXHzQ4JK ckoA== X-Gm-Message-State: ALoCoQmjnlDR4TVKL2wK9rT93jV8Y4wOAu/22ZLciWbp8kiyEO6h0JvpEEwMzpUzzRuqWAChmjyj X-Received: by 10.180.35.162 with SMTP id i2mr7686892wij.6.1437441472520; Mon, 20 Jul 2015 18:17:52 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.20.10 with SMTP id j10ls848337lae.6.gmail; Mon, 20 Jul 2015 18:17:52 -0700 (PDT) X-Received: by 10.112.185.100 with SMTP id fb4mr30413407lbc.79.1437441472164; Mon, 20 Jul 2015 18:17:52 -0700 (PDT) Received: from mail-lb0-x230.google.com (mail-lb0-x230.google.com. [2a00:1450:4010:c04::230]) by mx.google.com with ESMTPS id ll10si19405174lac.26.2015.07.20.18.17.52 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 20 Jul 2015 18:17:52 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 2a00:1450:4010:c04::230 as permitted sender) client-ip=2a00:1450:4010:c04::230; Received: by lbbqi7 with SMTP id qi7so25330385lbb.3 for ; Mon, 20 Jul 2015 18:17:52 -0700 (PDT) X-Received: by 10.112.166.106 with SMTP id zf10mr30142364lbb.36.1437441471969; Mon, 20 Jul 2015 18:17:51 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.112.7.198 with SMTP id l6csp1107048lba; Mon, 20 Jul 2015 18:17:50 -0700 (PDT) X-Received: by 10.66.55.3 with SMTP id n3mr65404715pap.58.1437441470088; Mon, 20 Jul 2015 18:17:50 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id bq3si19498126pdb.3.2015.07.20.18.17.49; Mon, 20 Jul 2015 18:17:50 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757559AbbGUBRr (ORCPT + 28 others); Mon, 20 Jul 2015 21:17:47 -0400 Received: from m50-111.126.com ([123.125.50.111]:44251 "EHLO m50-111.126.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1757218AbbGUBRq (ORCPT ); Mon, 20 Jul 2015 21:17:46 -0400 X-Greylist: delayed 1802 seconds by postgrey-1.27 at vger.kernel.org; Mon, 20 Jul 2015 21:17:45 EDT Received: from localhost.localdomain (unknown [210.21.223.3]) by smtp5 (Coremail) with SMTP id jtKowADHCSRylq1VD1bVAA--.4214S3; Tue, 21 Jul 2015 08:46:53 +0800 (CST) From: Xunlei Pang To: linux-kernel@vger.kernel.org Cc: Thomas Gleixner , David Howells , Koichi Yasutake , linux-am33-list@redhat.com, Xunlei Pang , John Stultz , Arnd Bergmann Subject: [PATCH] mn10300: time: Provide 64-bit persistent clock time Date: Tue, 21 Jul 2015 08:45:49 +0800 Message-Id: <1437439549-1012-1-git-send-email-xlpang@126.com> X-Mailer: git-send-email 1.9.1 X-CM-TRANSID: jtKowADHCSRylq1VD1bVAA--.4214S3 X-Coremail-Antispam: 1Uf129KBjvJXoWxCr13KrWkZrWUWr1rtryrWFg_yoW5ArWkp3 yIy3Z8tw4Uta13uF92ywnru34agwn0qFW2qa4fta4Fyw1DtrnrGFy0y3y2vr9FgFyfXa1j 9a1xJFnIvw18ZwUanT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDUYxBIdaVFxhVjvjDU0xZFpf9x07jqGQhUUUUU= X-Originating-IP: [210.21.223.3] X-CM-SenderInfo: p0ost0bj6rjloofrz/1tbi7x4+v1Uwy82HKwAAs- Sender: linux-kernel-owner@vger.kernel.org Precedence: list List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Original-Sender: xlpang@126.com X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 2a00:1450:4010:c04::230 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org; dkim=neutral (body hash did not verify) header.i=@126.com; dmarc=fail (p=NONE dis=NONE) header.from=126.com Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , From: Xunlei Pang As part of addressing the "y2038 problem" for in-kernel uses, convert update_persistent_clock() to update_persistent_clock64(), read_persistent_clock() to read_persistent_clock64() using timespec64 for MN10300. Add the common weak version of update_persistent_clock() to make the compiler happy, since we don't have any update_persistent_clock() defined for MN10300 after converting it to update_persistent_clock64(). Cc: John Stultz Cc: Arnd Bergmann Signed-off-by: Xunlei Pang --- arch/mn10300/kernel/rtc.c | 13 ++++++------- kernel/time/ntp.c | 5 +++++ 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/arch/mn10300/kernel/rtc.c b/arch/mn10300/kernel/rtc.c index 48d7058..038ae16 100644 --- a/arch/mn10300/kernel/rtc.c +++ b/arch/mn10300/kernel/rtc.c @@ -23,19 +23,19 @@ EXPORT_SYMBOL(rtc_lock); /* * Read the current RTC time */ -void read_persistent_clock(struct timespec *ts) +void read_persistent_clock64(struct timespec64 *ts) { struct rtc_time tm; get_rtc_time(&tm); ts->tv_nsec = 0; - ts->tv_sec = mktime(tm.tm_year, tm.tm_mon, tm.tm_mday, + ts->tv_sec = mktime64(tm.tm_year, tm.tm_mon, tm.tm_mday, tm.tm_hour, tm.tm_min, tm.tm_sec); /* if rtc is way off in the past, set something reasonable */ if (ts->tv_sec < 0) - ts->tv_sec = mktime(2009, 1, 1, 12, 0, 0); + ts->tv_sec = mktime64(2009, 1, 1, 12, 0, 0); } /* @@ -48,7 +48,7 @@ void read_persistent_clock(struct timespec *ts) * BUG: This routine does not handle hour overflow properly; it just * sets the minutes. Usually you'll only notice that after reboot! */ -static int set_rtc_mmss(unsigned long nowtime) +static int set_rtc_mmss(time64_t nowtime) { unsigned char save_control, save_freq_select; int retval = 0; @@ -74,8 +74,7 @@ static int set_rtc_mmss(unsigned long nowtime) * messing with unknown time zones but requires your * RTC not to be off by more than 15 minutes */ - real_seconds = nowtime % 60; - real_minutes = nowtime / 60; + real_minutes = div_s64_rem(nowtime, 60, &real_seconds); if (((abs(real_minutes - cmos_minutes) + 15) / 30) & 1) /* correct for half hour time zone */ real_minutes += 30; @@ -109,7 +108,7 @@ static int set_rtc_mmss(unsigned long nowtime) return retval; } -int update_persistent_clock(struct timespec now) +int update_persistent_clock64(struct timespec64 now) { return set_rtc_mmss(now.tv_sec); } diff --git a/kernel/time/ntp.c b/kernel/time/ntp.c index fb4d98c..df68cb8 100644 --- a/kernel/time/ntp.c +++ b/kernel/time/ntp.c @@ -487,6 +487,11 @@ out: } #ifdef CONFIG_GENERIC_CMOS_UPDATE +int __weak update_persistent_clock(struct timespec now) +{ + return -ENODEV; +} + int __weak update_persistent_clock64(struct timespec64 now64) { struct timespec now;