From patchwork Mon Jun 1 11:56:29 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: 49307 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 DF70B218FC for ; Mon, 1 Jun 2015 11:57:18 +0000 (UTC) Received: by labpg10 with SMTP id pg10sf2985166lab.2 for ; Mon, 01 Jun 2015 04:57:17 -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=lS7BBa6f+6DXTbSe1D1W1w4LPNlMu7NtLFdLq1KIOTY=; b=jo60hsdFNpiyyTS2BSIVynMdE0sTcFeeZj72pqaU6k1bNz6k8SHIG3ZGMoiB4KahKl dCrHEIiHK2S1Ud7IWogYRkMW48VxZ5GYR+YbYNCF0WakuwQ5mz3mKzpshI/Mu6g/EyPF jLaDrLDXYJ7f/iKiKPoCfD1yIlffQW3dDLZdR0FHahtlZOjKqxapYdZxylsDG3ui8AzM ec3Gym2aTiEq+klrIq+tPp/FG+GcK3styfJb2Tl4uxWno858MtFAANNg8mo7v7CHdJ2l bqMF8lmg7di0/LH0D/E0mb7eO6mMGDBMe8G/9BrKIN6uJPPo4ooFwxXMQLP7qe2CMmMW TO8g== X-Gm-Message-State: ALoCoQmGm8UTkUG6+33AiSmUSLDX5NDW1+dtvesrqbdUgGhww4tdvjC8m8WcpVgBAmnxCLpp15Vj X-Received: by 10.194.58.164 with SMTP id s4mr4139793wjq.3.1433159837361; Mon, 01 Jun 2015 04:57:17 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.120.105 with SMTP id lb9ls623477lab.10.gmail; Mon, 01 Jun 2015 04:57:17 -0700 (PDT) X-Received: by 10.152.30.4 with SMTP id o4mr19917555lah.74.1433159837172; Mon, 01 Jun 2015 04:57:17 -0700 (PDT) Received: from mail-lb0-f172.google.com (mail-lb0-f172.google.com. [209.85.217.172]) by mx.google.com with ESMTPS id lc8si3495082lac.24.2015.06.01.04.57.17 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 01 Jun 2015 04:57:17 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.172 as permitted sender) client-ip=209.85.217.172; Received: by lbcmx3 with SMTP id mx3so82662297lbc.1 for ; Mon, 01 Jun 2015 04:57:17 -0700 (PDT) X-Received: by 10.152.7.7 with SMTP id f7mr20954012laa.106.1433159836948; Mon, 01 Jun 2015 04:57:16 -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 hn6csp2258492lbb; Mon, 1 Jun 2015 04:57:15 -0700 (PDT) X-Received: by 10.68.252.233 with SMTP id zv9mr2397853pbc.109.1433159835039; Mon, 01 Jun 2015 04:57:15 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id fj8si21263860pdb.93.2015.06.01.04.57.11; Mon, 01 Jun 2015 04:57:15 -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 S1752920AbbFAL5F (ORCPT + 28 others); Mon, 1 Jun 2015 07:57:05 -0400 Received: from mail-pa0-f42.google.com ([209.85.220.42]:36169 "EHLO mail-pa0-f42.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752755AbbFAL4p (ORCPT ); Mon, 1 Jun 2015 07:56:45 -0400 Received: by pacux9 with SMTP id ux9so67550588pac.3 for ; Mon, 01 Jun 2015 04:56:44 -0700 (PDT) X-Received: by 10.70.103.132 with SMTP id fw4mr39265421pdb.5.1433159804120; Mon, 01 Jun 2015 04:56:44 -0700 (PDT) Received: from baolinwangubtpc.spreadtrum.com ([175.111.195.49]) by mx.google.com with ESMTPSA id ry2sm14015392pbb.83.2015.06.01.04.56.41 (version=TLSv1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 01 Jun 2015 04:56:43 -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 v4 10/25] posix-timers:Convert to the 64bit methods for the timer_settime syscall function Date: Mon, 1 Jun 2015 19:56:29 +0800 Message-Id: <1433159789-4926-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.172 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. 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 | 39 +++++++++++++++++++++++++++++---------- 2 files changed, 32 insertions(+), 10 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 99ccb3c..c034a53 100644 --- a/kernel/time/posix-timers.c +++ b/kernel/time/posix-timers.c @@ -553,6 +553,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; + struct itimerspec *rtn = old_setting64 ? &old_setting : NULL; + int ret; + + new_setting = itimerspec64_to_itimerspec(new_setting64); + ret = kc->timer_set(timr, flags, &new_setting, rtn); + 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) { @@ -575,6 +592,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; } @@ -920,16 +939,16 @@ 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; unsigned long flag; struct k_clock *kc; - if (!timespec_valid(&new_spec->it_interval) || - !timespec_valid(&new_spec->it_value)) + if (!timespec64_valid(&new_spec->it_interval) || + !timespec64_valid(&new_spec->it_value)) return -EINVAL; retry: @@ -938,10 +957,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) { @@ -957,20 +976,20 @@ 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; + struct itimerspec64 new_spec, old_spec; int error = 0; - struct itimerspec *rtn = old_setting ? &old_spec : NULL; + struct itimerspec64 *rtn = old_setting ? &old_spec : NULL; if (!new_setting) return -EINVAL; - if (copy_from_user(&new_spec, new_setting, sizeof (new_spec))) + if (get_itimerspec(&new_spec, new_setting)) return -EFAULT; error = __timer_settime(timer_id, flags, &new_spec, rtn); if (old_setting && !error && - copy_to_user(old_setting, &old_spec, sizeof (old_spec))) + put_itimerspec(&old_spec, old_setting)) error = -EFAULT; return error;