From patchwork Tue May 12 14:11:24 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: 48384 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-la0-f71.google.com (mail-la0-f71.google.com [209.85.215.71]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 7B1B62121F for ; Tue, 12 May 2015 14:12:12 +0000 (UTC) Received: by layy10 with SMTP id y10sf2385792lay.0 for ; Tue, 12 May 2015 07:12:11 -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=3uiKFLMogrRjJ34y2nTfRRJG65XcFZ89GfbZ1/1jWig=; b=gOtfPFcvoa6SnZfVZmvbLZ9shhV1QNTwzh0iYUftjPq64WbIifwphLRWSuffnXW2Mv nbdQ0/FgVynKvUSWrclZeUlvs3N7VlWE+9t5Z+eloK9t2snWY6UJIi1ZGm6b4qIv4Hsv TnWGM1XKIe8HAgtq/D8g9+NNR+/4W4PyLJi5Wt9NSwG77xdosxKLcPSNCO0jMRu+IBn7 XkP5fgHGwoWVpIgqSnxp0qi5S29PYM13reRhNPcLzOdMsETx5iRPZz1GSEgq+JSbjO12 aIWnN6exhDlHC0T0584HA4PDDaQfNdS1ZzZ8R7IvsABR1SrxYDXbhMBn1yUsAQX7XOGs xIig== X-Gm-Message-State: ALoCoQnLLuIv72Ph9LKCukVdYyE8QlxGgmp2ZvATiwzjtGIomBXDU9/cvCwfJiru+671TBMtOhlp X-Received: by 10.194.47.179 with SMTP id e19mr10804987wjn.4.1431439931426; Tue, 12 May 2015 07:12:11 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.45.71 with SMTP id k7ls40724lam.99.gmail; Tue, 12 May 2015 07:12:11 -0700 (PDT) X-Received: by 10.112.13.6 with SMTP id d6mr12020884lbc.117.1431439931241; Tue, 12 May 2015 07:12:11 -0700 (PDT) Received: from mail-lb0-f181.google.com (mail-lb0-f181.google.com. [209.85.217.181]) by mx.google.com with ESMTPS id ku3si10451529lbb.54.2015.05.12.07.12.11 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 12 May 2015 07:12:11 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.181 as permitted sender) client-ip=209.85.217.181; Received: by lbbzk7 with SMTP id zk7so6974700lbb.0 for ; Tue, 12 May 2015 07:12:11 -0700 (PDT) X-Received: by 10.152.36.2 with SMTP id m2mr12034991laj.72.1431439931142; Tue, 12 May 2015 07:12:11 -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 hn6csp2116896lbb; Tue, 12 May 2015 07:12:10 -0700 (PDT) X-Received: by 10.70.119.36 with SMTP id kr4mr29111064pdb.39.1431439929209; Tue, 12 May 2015 07:12:09 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id fe6si22750859pdb.84.2015.05.12.07.11.39; Tue, 12 May 2015 07:12:09 -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 S933061AbbELOLf (ORCPT + 28 others); Tue, 12 May 2015 10:11:35 -0400 Received: from mail-pd0-f169.google.com ([209.85.192.169]:33562 "EHLO mail-pd0-f169.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932920AbbELOLc (ORCPT ); Tue, 12 May 2015 10:11:32 -0400 Received: by pdbnk13 with SMTP id nk13so13977548pdb.0 for ; Tue, 12 May 2015 07:11:31 -0700 (PDT) X-Received: by 10.66.119.239 with SMTP id kx15mr29059014pab.156.1431439891703; Tue, 12 May 2015 07:11:31 -0700 (PDT) Received: from baolinwangubtpc.spreadtrum.com ([175.111.195.49]) by mx.google.com with ESMTPSA id bc14sm16443509pac.6.2015.05.12.07.11.29 (version=TLSv1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 12 May 2015 07:11:31 -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 10/23] posix-timers:Convert to the 64bit methods for the clock_settime syscall function Date: Tue, 12 May 2015 22:11:24 +0800 Message-Id: <1431439884-2375-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.217.181 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 clock_set64 method with timespec64 type for k_clock structure, that makes it ready for the 2038 year. Convert to the 64bit method with timespec64 type for the clock_settime syscall function, and change the clock_settime syscall implementation according to the CONFIG_64BIT macro. Also add a default 64bit method for the clock_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 | 2 ++ kernel/time/posix-timers.c | 30 +++++++++++++++++++++++++++--- 2 files changed, 29 insertions(+), 3 deletions(-) diff --git a/include/linux/posix-timers.h b/include/linux/posix-timers.h index 16c3364..2b19ec8 100644 --- a/include/linux/posix-timers.h +++ b/include/linux/posix-timers.h @@ -100,6 +100,8 @@ struct k_clock { int (*clock_getres) (const clockid_t which_clock, struct timespec *tp); int (*clock_set) (const clockid_t which_clock, const struct timespec *tp); + int (*clock_set64) (const clockid_t which_clock, + const struct timespec64 *tp); int (*clock_get) (const clockid_t which_clock, struct timespec * tp); int (*clock_adj) (const clockid_t which_clock, struct timex *tx); int (*timer_create) (struct k_itimer *timer); diff --git a/kernel/time/posix-timers.c b/kernel/time/posix-timers.c index a986a61..b8fae69 100644 --- a/kernel/time/posix-timers.c +++ b/kernel/time/posix-timers.c @@ -541,6 +541,18 @@ static int default_timer_set64(struct k_itimer *timr, int flags, return ret; } +static int default_clock_set64(const clockid_t which_clock, + const struct timespec64 *tp64) +{ + struct k_clock *kc = clockid_to_kclock(which_clock); + struct timespec tp; + int ret; + + tp = timespec64_to_timespec(*tp64); + ret = kc->clock_set(which_clock, &tp); + return ret; +} + void posix_timers_register_clock(const clockid_t clock_id, struct k_clock *new_clock) { @@ -565,6 +577,8 @@ void posix_timers_register_clock(const clockid_t clock_id, new_clock->timer_get64 = default_timer_get64; if (new_clock->timer_set && !new_clock->timer_set64) new_clock->timer_set64 = default_timer_set64; + if (new_clock->clock_set && !new_clock->clock_set64) + new_clock->clock_set64 = default_clock_set64; posix_clocks[clock_id] = *new_clock; } @@ -1078,25 +1092,35 @@ void exit_itimers(struct signal_struct *sig) } } -static int __clock_settime(clockid_t which_clock, struct timespec *ts) +static int __clock_settime(clockid_t which_clock, struct timespec64 *ts) { struct k_clock *kc = clockid_to_kclock(which_clock); - if (!kc || !kc->clock_set) + if (!kc || !kc->clock_set64) return -EINVAL; - return kc->clock_set(which_clock, ts); + return kc->clock_set64(which_clock, ts); } SYSCALL_DEFINE2(clock_settime, const clockid_t, which_clock, const struct timespec __user *, tp) { +#ifdef CONFIG_64BIT + struct timespec64 new_tp; +#else struct timespec new_tp; + struct timespec64 new_tp64; +#endif if (copy_from_user(&new_tp, tp, sizeof (*tp))) return -EFAULT; +#ifdef CONFIG_64BIT return __clock_settime(which_clock, &new_tp); +#else + new_tp64 = timespec_to_timespec64(new_tp); + return __clock_settime(which_clock, &new_tp64); +#endif } SYSCALL_DEFINE2(clock_gettime, const clockid_t, which_clock,