From patchwork Mon Jun 1 11:57:06 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: 49309 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-la0-f69.google.com (mail-la0-f69.google.com [209.85.215.69]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 54E37218FC for ; Mon, 1 Jun 2015 11:57:48 +0000 (UTC) Received: by laboh3 with SMTP id oh3sf28828831lab.0 for ; Mon, 01 Jun 2015 04:57:46 -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=ZXtavx+7/RUSLHAN6uTT+IwS3CI3ZnNSt7n75QrAb9k=; b=JDWYx5MmY0pKMKvlFH+NMx3V5LnONiK1B7Bd1vYfD4IQaDGUOtbNCF5UwYSf5Cir1G jUJxSUzCb9HAr7blMqF3a7m9oxCBpDV950hiAXKyku5//ezACmRzUZ4jifadyHd0ULK+ ov8Big6Uh55eJxkDM89vd7UUqhk9pOHpSvc4QrTTp/3BLa+3bPJBHmq8nB4Aj7B7Dz0y WrqVEETY8AHNyQqTvBvrmWRNSTYkCrsqfY0WxF4A+U843R1hTAjqwcw5hf37mj+EkOQe u4HEhodhN5nONGNZpVP2mwmU6ElGyKAKpuooNaHhhLE6lXbczT5apFwNR4D0R3++vnzn eZZg== X-Gm-Message-State: ALoCoQmN221ezOtB95fWOTTiUsuo5iwvTeaRO2+HVUnsPlIMicgLYWJjluoIc77NprAYXQJA6vpz X-Received: by 10.152.19.161 with SMTP id g1mr14493055lae.8.1433159866863; Mon, 01 Jun 2015 04:57:46 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.120.227 with SMTP id lf3ls623050lab.93.gmail; Mon, 01 Jun 2015 04:57:46 -0700 (PDT) X-Received: by 10.112.156.231 with SMTP id wh7mr16427828lbb.118.1433159866691; Mon, 01 Jun 2015 04:57:46 -0700 (PDT) Received: from mail-la0-f46.google.com (mail-la0-f46.google.com. [209.85.215.46]) by mx.google.com with ESMTPS id ev1si12151935lbc.0.2015.06.01.04.57.46 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 01 Jun 2015 04:57:46 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.46 as permitted sender) client-ip=209.85.215.46; Received: by laei3 with SMTP id i3so11683053lae.3 for ; Mon, 01 Jun 2015 04:57:46 -0700 (PDT) X-Received: by 10.152.4.137 with SMTP id k9mr20402307lak.29.1433159866575; Mon, 01 Jun 2015 04:57:46 -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 hn6csp2258748lbb; Mon, 1 Jun 2015 04:57:45 -0700 (PDT) X-Received: by 10.70.35.201 with SMTP id k9mr39355918pdj.128.1433159864727; Mon, 01 Jun 2015 04:57:44 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id g2si21197019pdp.243.2015.06.01.04.57.43; Mon, 01 Jun 2015 04:57:44 -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 S1753084AbbFAL5h (ORCPT + 28 others); Mon, 1 Jun 2015 07:57:37 -0400 Received: from mail-pa0-f41.google.com ([209.85.220.41]:33428 "EHLO mail-pa0-f41.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752999AbbFAL5U (ORCPT ); Mon, 1 Jun 2015 07:57:20 -0400 Received: by padj3 with SMTP id j3so41990061pad.0 for ; Mon, 01 Jun 2015 04:57:20 -0700 (PDT) X-Received: by 10.70.47.138 with SMTP id d10mr39216465pdn.137.1433159840582; Mon, 01 Jun 2015 04:57:20 -0700 (PDT) Received: from baolinwangubtpc.spreadtrum.com ([175.111.195.49]) by mx.google.com with ESMTPSA id oa14sm4454769pdb.47.2015.06.01.04.57.18 (version=TLSv1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 01 Jun 2015 04:57:19 -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 12/25] posix-timers:Convert to the 64bit methods for the clock_settime syscall function Date: Mon, 1 Jun 2015 19:57:06 +0800 Message-Id: <1433159826-4998-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.46 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. 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 | 24 +++++++++++++++++++----- 2 files changed, 21 insertions(+), 5 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 9912745..06e2549 100644 --- a/kernel/time/posix-timers.c +++ b/kernel/time/posix-timers.c @@ -570,6 +570,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) { @@ -594,6 +606,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; } @@ -1082,22 +1096,22 @@ 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) { - struct timespec new_tp; + struct timespec64 new_tp; - if (copy_from_user(&new_tp, tp, sizeof (*tp))) + if (get_timespec(&new_tp, tp)) return -EFAULT; return __clock_settime(which_clock, &new_tp);