From patchwork Tue May 12 14:10:14 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: 48383 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-la0-f72.google.com (mail-la0-f72.google.com [209.85.215.72]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 9EB4C2121F for ; Tue, 12 May 2015 14:11:24 +0000 (UTC) Received: by laat2 with SMTP id t2sf2359558laa.2 for ; Tue, 12 May 2015 07:11:23 -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=DqyD+yvBfmjSOukFAwHolCdx1p/HBgpNmufHaoDBoFQ=; b=MCAm7SlDQMKrRUd6dhw0jxmIzAgCucUK+46gdDfesfp9NpMx6JiCPztjms8OsWVFF5 q+p3rmS9BnCw9VDi3bn9Zb1WrbU+l/VvO1S7bY26tjMU1SEypi7uRZ6V7+0VKsrop3vF UjPUIEctcmo+qxOw1F7VbdFGI2Zu0ppusVGLATOAAsucrly1+xpOw0XtPud5zklLGt+8 hXd50D+wJ2QTqhkGi5X19dxvKCc8GQ90Hw8Gr+Wvkyq6rLlY5pdkTzVZxKZ3A5gjsat9 VjTUMvVVKfk2YoVrM2DPz1La7oNmKzsYKFpYMOZ8RwvaA1SbqJ0J2kZc0Npi8f+n6V2a 0AcA== X-Gm-Message-State: ALoCoQlogM2zlx2cBVd4u18+uPsK6ATyQdZmSHgbQN4ypZYiAbSI5zUHTiXvkL0gJZyVRqKUzLX0 X-Received: by 10.112.203.168 with SMTP id kr8mr10782020lbc.10.1431439883393; Tue, 12 May 2015 07:11:23 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.36.7 with SMTP id m7ls39446laj.70.gmail; Tue, 12 May 2015 07:11:23 -0700 (PDT) X-Received: by 10.152.204.40 with SMTP id kv8mr12026890lac.113.1431439883225; Tue, 12 May 2015 07:11:23 -0700 (PDT) Received: from mail-la0-f42.google.com (mail-la0-f42.google.com. [209.85.215.42]) by mx.google.com with ESMTPS id rk9si10429104lbb.152.2015.05.12.07.11.23 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 12 May 2015 07:11:23 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.42 as permitted sender) client-ip=209.85.215.42; Received: by lagv1 with SMTP id v1so6822725lag.3 for ; Tue, 12 May 2015 07:11:23 -0700 (PDT) X-Received: by 10.152.29.161 with SMTP id l1mr11924732lah.76.1431439883075; Tue, 12 May 2015 07:11:23 -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 hn6csp2116426lbb; Tue, 12 May 2015 07:11:21 -0700 (PDT) X-Received: by 10.66.156.198 with SMTP id wg6mr28492675pab.126.1431439881117; Tue, 12 May 2015 07:11:21 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id ql2si22622385pbc.204.2015.05.12.07.11.00; Tue, 12 May 2015 07:11:21 -0700 (PDT) Received-SPF: none (google.com: linux-kernel-owner@vger.kernel.org does not designate permitted sender hosts) client-ip=209.132.180.67; Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933041AbbELOKY (ORCPT + 28 others); Tue, 12 May 2015 10:10:24 -0400 Received: from mail-pa0-f50.google.com ([209.85.220.50]:35148 "EHLO mail-pa0-f50.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932920AbbELOKW (ORCPT ); Tue, 12 May 2015 10:10:22 -0400 Received: by pabtp1 with SMTP id tp1so13435824pab.2 for ; Tue, 12 May 2015 07:10:21 -0700 (PDT) X-Received: by 10.66.154.111 with SMTP id vn15mr28099695pab.108.1431439821755; Tue, 12 May 2015 07:10:21 -0700 (PDT) Received: from baolinwangubtpc.spreadtrum.com ([175.111.195.49]) by mx.google.com with ESMTPSA id sl9sm16482353pac.41.2015.05.12.07.10.19 (version=TLSv1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 12 May 2015 07:10:21 -0700 (PDT) From: Baolin Wang To: tglx@linutronix.de Cc: arnd@arndb.de, linux-kernel@vger.kernel.org, baolin.wang@linaro.org, y2038@lists.linaro.org Subject: [PATCH v3 08/23] posix-timers:Convert to the 64bit methods for the timer_settime syscall function Date: Tue, 12 May 2015 22:10:14 +0800 Message-Id: <1431439814-28820-1-git-send-email-baolin.wang@linaro.org> X-Mailer: git-send-email 1.7.9.5 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.215.42 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: , This patch introduces the timer_set64 method with itimerspec64 type for k_clock structure, that makes it ready for the 2038 year. Convert to the 64bit method with itimerspec64 type for the timer_settime syscall function, and change the timer_settime syscall implementation according to the CONFIG_64BIT macro. Also add a default 64bit method for the timer_set64 pointer of k_clock structure, and it will be removed after all the drivers are converted to 64bit methods. Signed-off-by: Baolin Wang --- include/linux/posix-timers.h | 3 +++ kernel/time/posix-timers.c | 46 +++++++++++++++++++++++++++++++++++++----- 2 files changed, 44 insertions(+), 5 deletions(-) diff --git a/include/linux/posix-timers.h b/include/linux/posix-timers.h index e84436b..16c3364 100644 --- a/include/linux/posix-timers.h +++ b/include/linux/posix-timers.h @@ -109,6 +109,9 @@ struct k_clock { int (*timer_set) (struct k_itimer * timr, int flags, struct itimerspec * new_setting, struct itimerspec * old_setting); + int (*timer_set64) (struct k_itimer *timr, int flags, + struct itimerspec64 *new_setting, + struct itimerspec64 *old_setting); int (*timer_del) (struct k_itimer * timr); #define TIMER_RETRY 1 void (*timer_get) (struct k_itimer * timr, diff --git a/kernel/time/posix-timers.c b/kernel/time/posix-timers.c index d289846..e7b98f9 100644 --- a/kernel/time/posix-timers.c +++ b/kernel/time/posix-timers.c @@ -524,6 +524,23 @@ static void default_timer_get64(struct k_itimer *timr, *cur_setting64 = itimerspec_to_itimerspec64(&cur_setting); } +static int default_timer_set64(struct k_itimer *timr, int flags, + struct itimerspec64 *new_setting64, + struct itimerspec64 *old_setting64) +{ + struct k_clock *kc = clockid_to_kclock(timr->it_clock); + struct itimerspec new_setting, old_setting; + int ret; + + new_setting = itimerspec64_to_itimerspec(new_setting64); + old_setting = itimerspec64_to_itimerspec(old_setting64); + ret = kc->timer_set(timr, flags, &new_setting, &old_setting); + if (!ret && old_setting64) + *old_setting64 = itimerspec_to_itimerspec64(&old_setting); + + return ret; +} + void posix_timers_register_clock(const clockid_t clock_id, struct k_clock *new_clock) { @@ -546,6 +563,8 @@ void posix_timers_register_clock(const clockid_t clock_id, if (new_clock->timer_get && !new_clock->timer_get64) new_clock->timer_get64 = default_timer_get64; + if (new_clock->timer_set && !new_clock->timer_set64) + new_clock->timer_set64 = default_timer_set64; posix_clocks[clock_id] = *new_clock; } @@ -899,8 +918,8 @@ common_timer_set(struct k_itimer *timr, int flags, return 0; } -static int __timer_settime(timer_t timer_id, int flags, struct itimerspec *new_spec, - struct itimerspec *old_spec) +static int __timer_settime(timer_t timer_id, int flags, struct itimerspec64 *new_spec, + struct itimerspec64 *old_spec) { struct k_itimer *timr; int error = 0; @@ -913,10 +932,10 @@ retry: return -EINVAL; kc = clockid_to_kclock(timr->it_clock); - if (WARN_ON_ONCE(!kc || !kc->timer_set)) + if (WARN_ON_ONCE(!kc || !kc->timer_set64)) error = -EINVAL; else - error = kc->timer_set(timr, flags, new_spec, old_spec); + error = kc->timer_set64(timr, flags, new_spec, old_spec); unlock_timer(timr, flag); if (error == TIMER_RETRY) { @@ -932,9 +951,16 @@ SYSCALL_DEFINE4(timer_settime, timer_t, timer_id, int, flags, const struct itimerspec __user *, new_setting, struct itimerspec __user *, old_setting) { - struct itimerspec new_spec, old_spec; int error = 0; +#ifdef CONFIG_64BIT + struct itimerspec64 new_spec, old_spec; + struct itimerspec64 *rtn = old_setting ? &old_spec : NULL; +#else + struct itimerspec new_spec, old_spec; struct itimerspec *rtn = old_setting ? &old_spec : NULL; + struct itimerspec64 new_spec64; + struct itimerspec64 *rtn64; +#endif if (!new_setting) return -EINVAL; @@ -946,7 +972,17 @@ SYSCALL_DEFINE4(timer_settime, timer_t, timer_id, int, flags, !timespec_valid(&new_spec.it_value)) return -EINVAL; +#ifdef CONFIG_64BIT error = __timer_settime(timer_id, flags, &new_spec, rtn); +#else + new_spec64 = itimerspec_to_itimerspec64(&new_spec); + if (rtn) + *rtn64 = itimerspec_to_itimerspec64(rtn); + else + rtn64 = NULL; + + error = __timer_settime(timer_id, flags, &new_spec64, rtn64); +#endif if (old_setting && !error && copy_to_user(old_setting, &old_spec, sizeof (old_spec)))