From patchwork Fri Jun 12 07:58:31 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "\(Exiting\) Baolin Wang" X-Patchwork-Id: 49802 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-wg0-f72.google.com (mail-wg0-f72.google.com [74.125.82.72]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 0D77F228DB for ; Fri, 12 Jun 2015 07:59:56 +0000 (UTC) Received: by wgez8 with SMTP id z8sf7456596wge.2 for ; Fri, 12 Jun 2015 00:59:55 -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:in-reply-to:references:in-reply-to:references :sender:precedence:list-id:x-original-sender :x-original-authentication-results:mailing-list:list-post:list-help :list-archive:list-unsubscribe; bh=CWBC9bPdbqnOVff3cDcRPL1rGS7jZ/EE9JzBo6vPsaw=; b=HrGKWTCy4zEGdqPuO89MJcoHzcg642GR2kro+NFvUG7Nzdh6PbGiMZHnDlPBrryWQR VrR02NDYr3Pa+e+PzdXre+I5Pu73knllOgzrj0j2/XBhQ0422e/PPvhvKFcEBorstVAX exrqpPOkkEQnpBbOC6aC8q7bsegGKPNOJUgNXxKuihhZrvqtbz5zw3WdQk3AQApMqSD/ BHRtaDnc5l7I286qHqYv19ngqacRj1pYsu8iPaYhd56Vtf2mXu130T15k3wJf9EzXUIe UJ5pkZ3UFMJDtaAWbaHDSnqJL/7+Slch69brlVgDqN2PQXFa5W1yU1HulD9rlGHubpZT d0iQ== X-Gm-Message-State: ALoCoQkHGTSe1tOtnVI+hTIIvDAgFuDWD+gmaLRAMeVVxQWSbnYQg1n/tmLp1vAE2d+sXkOVLGYZ X-Received: by 10.112.138.2 with SMTP id qm2mr12799569lbb.19.1434095995347; Fri, 12 Jun 2015 00:59:55 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.36.65 with SMTP id o1ls555632laj.108.gmail; Fri, 12 Jun 2015 00:59:55 -0700 (PDT) X-Received: by 10.152.37.37 with SMTP id v5mr13567539laj.11.1434095995162; Fri, 12 Jun 2015 00:59:55 -0700 (PDT) Received: from mail-lb0-f180.google.com (mail-lb0-f180.google.com. [209.85.217.180]) by mx.google.com with ESMTPS id ug12si2757566lac.47.2015.06.12.00.59.55 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 12 Jun 2015 00:59:55 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.180 as permitted sender) client-ip=209.85.217.180; Received: by lbcmx3 with SMTP id mx3so15511216lbc.1 for ; Fri, 12 Jun 2015 00:59:55 -0700 (PDT) X-Received: by 10.152.36.161 with SMTP id r1mr13863878laj.88.1434095994943; Fri, 12 Jun 2015 00:59:54 -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.108.230 with SMTP id hn6csp360805lbb; Fri, 12 Jun 2015 00:59:53 -0700 (PDT) X-Received: by 10.68.180.131 with SMTP id do3mr21176740pbc.42.1434095993134; Fri, 12 Jun 2015 00:59:53 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id qq9si4324976pbb.13.2015.06.12.00.59.52; Fri, 12 Jun 2015 00:59:53 -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 S1753571AbbFLH7r (ORCPT + 29 others); Fri, 12 Jun 2015 03:59:47 -0400 Received: from mail-pd0-f181.google.com ([209.85.192.181]:35995 "EHLO mail-pd0-f181.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750931AbbFLH7n (ORCPT ); Fri, 12 Jun 2015 03:59:43 -0400 Received: by pdjm12 with SMTP id m12so19741360pdj.3 for ; Fri, 12 Jun 2015 00:59:43 -0700 (PDT) X-Received: by 10.68.246.1 with SMTP id xs1mr21141676pbc.53.1434095983242; Fri, 12 Jun 2015 00:59:43 -0700 (PDT) Received: from baolinwangubtpc.spreadtrum.com ([175.111.195.49]) by mx.google.com with ESMTPSA id w3sm2776653pdw.22.2015.06.12.00.59.40 (version=TLSv1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 12 Jun 2015 00:59:42 -0700 (PDT) From: Baolin Wang To: arnd@arndb.de Cc: gregkh@linuxfoundation.org, linux-kernel@vger.kernel.org, baolin.wang@linaro.org, y2038@lists.linaro.org Subject: [PATCH v5 18/24] mmtimer: Convert to y2038 safe callbacks Date: Fri, 12 Jun 2015 15:58:31 +0800 Message-Id: <9ef52e40520523d9c3f5912f2125b8523ef5b361.1434079263.git.baolin.wang@linaro.org> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: References: In-Reply-To: References: Sender: linux-kernel-owner@vger.kernel.org Precedence: list List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: baolin.wang@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.180 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org 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: , The clock_getres()/clock_get()/clock_set()/timer_set()/timer_get() callbacks in struct k_clock are not year 2038 safe on 32bit systems, and it need convert to safe callbacks which use struct timespec64 or struct itimerspec64. Signed-off-by: Baolin Wang --- drivers/char/mmtimer.c | 36 +++++++++++++++++------------------- 1 file changed, 17 insertions(+), 19 deletions(-) diff --git a/drivers/char/mmtimer.c b/drivers/char/mmtimer.c index 3d6c067..213d0bb 100644 --- a/drivers/char/mmtimer.c +++ b/drivers/char/mmtimer.c @@ -478,18 +478,18 @@ static int sgi_clock_period; static struct timespec sgi_clock_offset; static int sgi_clock_period; -static int sgi_clock_get(clockid_t clockid, struct timespec *tp) +static int sgi_clock_get(clockid_t clockid, struct timespec64 *tp) { u64 nsec; nsec = rtc_time() * sgi_clock_period + sgi_clock_offset.tv_nsec; - *tp = ns_to_timespec(nsec); + *tp = ns_to_timespec64(nsec); tp->tv_sec += sgi_clock_offset.tv_sec; return 0; }; -static int sgi_clock_set(const clockid_t clockid, const struct timespec *tp) +static int sgi_clock_set(const clockid_t clockid, const struct timespec64 *tp) { u64 nsec; @@ -657,7 +657,7 @@ static int sgi_timer_del(struct k_itimer *timr) } /* Assumption: it_lock is already held with irq's disabled */ -static void sgi_timer_get(struct k_itimer *timr, struct itimerspec *cur_setting) +static void sgi_timer_get(struct k_itimer *timr, struct itimerspec64 *cur_setting) { if (timr->it.mmtimer.clock == TIMER_OFF) { @@ -668,14 +668,14 @@ static void sgi_timer_get(struct k_itimer *timr, struct itimerspec *cur_setting) return; } - cur_setting->it_interval = ns_to_timespec(timr->it.mmtimer.incr * sgi_clock_period); - cur_setting->it_value = ns_to_timespec((timr->it.mmtimer.expires - rtc_time()) * sgi_clock_period); + cur_setting->it_interval = ns_to_timespec64(timr->it.mmtimer.incr * sgi_clock_period); + cur_setting->it_value = ns_to_timespec64((timr->it.mmtimer.expires - rtc_time()) * sgi_clock_period); } static int sgi_timer_set(struct k_itimer *timr, int flags, - struct itimerspec * new_setting, - struct itimerspec * old_setting) + struct itimerspec64 *new_setting, + struct itimerspec64 *old_setting) { unsigned long when, period, irqflags; int err = 0; @@ -687,8 +687,8 @@ static int sgi_timer_set(struct k_itimer *timr, int flags, sgi_timer_get(timr, old_setting); sgi_timer_del(timr); - when = timespec_to_ns(&new_setting->it_value); - period = timespec_to_ns(&new_setting->it_interval); + when = timespec64_to_ns(&new_setting->it_value); + period = timespec64_to_ns(&new_setting->it_interval); if (when == 0) /* Clear timer */ @@ -699,11 +699,9 @@ static int sgi_timer_set(struct k_itimer *timr, int flags, return -ENOMEM; if (flags & TIMER_ABSTIME) { - struct timespec n; unsigned long now; - getnstimeofday(&n); - now = timespec_to_ns(&n); + now = ktime_get_real_ns(); if (when > now) when -= now; else @@ -765,7 +763,7 @@ static int sgi_timer_set(struct k_itimer *timr, int flags, return err; } -static int sgi_clock_getres(const clockid_t which_clock, struct timespec *tp) +static int sgi_clock_getres(const clockid_t which_clock, struct timespec64 *tp) { tp->tv_sec = 0; tp->tv_nsec = sgi_clock_period; @@ -773,13 +771,13 @@ static int sgi_clock_getres(const clockid_t which_clock, struct timespec *tp) } static struct k_clock sgi_clock = { - .clock_set = sgi_clock_set, - .clock_get = sgi_clock_get, - .clock_getres = sgi_clock_getres, + .clock_set64 = sgi_clock_set, + .clock_get64 = sgi_clock_get, + .clock_getres64 = sgi_clock_getres, .timer_create = sgi_timer_create, - .timer_set = sgi_timer_set, + .timer_set64 = sgi_timer_set, .timer_del = sgi_timer_del, - .timer_get = sgi_timer_get + .timer_get64 = sgi_timer_get }; /**