From patchwork Fri Jun 12 07:48:23 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: 49792 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-wi0-f199.google.com (mail-wi0-f199.google.com [209.85.212.199]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 3301E228DB for ; Fri, 12 Jun 2015 07:50:21 +0000 (UTC) Received: by wifx6 with SMTP id x6sf2687535wif.1 for ; Fri, 12 Jun 2015 00:50:20 -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=L0m66h+B1zEXZin4mHwtcyOCNprgx7UIyoETY2Q+KtM=; b=Z3Y92lcetyFJQPCrgu9coyITq7k5enZ9PacNHlwd4PwUZVK8XohffZTvC9L/eKls9c Fzuf6Ywol2mdv/bcd1jZQPUfe88AQdJf6o2rKTMY/KGv7idVX/ZoXfTKKUntmBYSPS+O fGa6ZWyXfemi6yND0POf8n/xAFbQ1NudbHgkCsPIDrj3qyry8zwmpJDepNPKEi5ZWFGw o7I/O+FNF4ryUNO8zi96RxyfuPvWIFWbm7ahhgxgn4zszJpQXSMMjnkplaUE/uINxUaz mSm0t/XdCB6dYXCch7tnJoRwn4ODM0i3z/1Fn/r+v4F4Lzf/aw/n2F6Q9dU2F4HAiidk kWDA== X-Gm-Message-State: ALoCoQm7m2qe0ZextrPGAlOju8/4Y8lOrE/a+4GGH+Q/ZXoLQuWK/hBsGsqUH9C4amiGPV80cz4L X-Received: by 10.112.122.13 with SMTP id lo13mr12829452lbb.5.1434095420477; Fri, 12 Jun 2015 00:50:20 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.45.99 with SMTP id l3ls555749lam.4.gmail; Fri, 12 Jun 2015 00:50:20 -0700 (PDT) X-Received: by 10.112.201.74 with SMTP id jy10mr13783824lbc.94.1434095420294; Fri, 12 Jun 2015 00:50:20 -0700 (PDT) Received: from mail-lb0-f174.google.com (mail-lb0-f174.google.com. [209.85.217.174]) by mx.google.com with ESMTPS id bx11si2714209lbb.141.2015.06.12.00.50.20 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 12 Jun 2015 00:50:20 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.174 as permitted sender) client-ip=209.85.217.174; Received: by lbbqq2 with SMTP id qq2so15346865lbb.3 for ; Fri, 12 Jun 2015 00:50:20 -0700 (PDT) X-Received: by 10.112.182.4 with SMTP id ea4mr14084762lbc.35.1434095420174; Fri, 12 Jun 2015 00:50:20 -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 hn6csp355997lbb; Fri, 12 Jun 2015 00:50:19 -0700 (PDT) X-Received: by 10.70.38.10 with SMTP id c10mr21073335pdk.72.1434095418456; Fri, 12 Jun 2015 00:50:18 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id fc2si4264675pab.110.2015.06.12.00.50.17; Fri, 12 Jun 2015 00:50:18 -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 S1754059AbbFLHuJ (ORCPT + 29 others); Fri, 12 Jun 2015 03:50:09 -0400 Received: from mail-pa0-f50.google.com ([209.85.220.50]:36602 "EHLO mail-pa0-f50.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753578AbbFLHuE (ORCPT ); Fri, 12 Jun 2015 03:50:04 -0400 Received: by pabqy3 with SMTP id qy3so18120661pab.3 for ; Fri, 12 Jun 2015 00:50:03 -0700 (PDT) X-Received: by 10.70.43.169 with SMTP id x9mr20897252pdl.52.1434095403707; Fri, 12 Jun 2015 00:50:03 -0700 (PDT) Received: from baolinwangubtpc.spreadtrum.com ([175.111.195.49]) by mx.google.com with ESMTPSA id yv6sm2734372pac.29.2015.06.12.00.50.01 (version=TLSv1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 12 Jun 2015 00:50:03 -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 v5 08/24] posix-timers: Factor out the guts of 'timer_settime' for reusing Date: Fri, 12 Jun 2015 15:48:23 +0800 Message-Id: <2644cc39311ba0a5d2328710a40e8f0a8d5ebd1e.1434079263.git.baolin.wang@linaro.org> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <647dcc7ede88d9d95a6f9a2878487d46c233fb2a.1434079262.git.baolin.wang@linaro.org> References: <647dcc7ede88d9d95a6f9a2878487d46c233fb2a.1434079262.git.baolin.wang@linaro.org> 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.174 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: , In order to reuse the very same logic for the year 2038 safe syscalls which we need to introduce for 32bit system, factor out the guts of the 'timer_settime' syscall. Signed-off-by: Baolin Wang --- kernel/time/posix-timers.c | 41 ++++++++++++++++++++++++++--------------- 1 file changed, 26 insertions(+), 15 deletions(-) diff --git a/kernel/time/posix-timers.c b/kernel/time/posix-timers.c index 70b5550..2f1c26f 100644 --- a/kernel/time/posix-timers.c +++ b/kernel/time/posix-timers.c @@ -927,27 +927,18 @@ common_timer_set(struct k_itimer *timr, int flags, return 0; } -/* Set a POSIX.1b interval timer */ -SYSCALL_DEFINE4(timer_settime, timer_t, timer_id, int, flags, - const struct itimerspec __user *, new_setting, - struct itimerspec __user *, old_setting) +static int __timer_settime(timer_t timer_id, int flags, struct itimerspec *new_spec, + struct itimerspec *old_spec) { struct k_itimer *timr; - struct itimerspec new_spec, old_spec; int error = 0; unsigned long flag; - struct itimerspec *rtn = old_setting ? &old_spec : NULL; struct k_clock *kc; - if (!new_setting) + if (!timespec_valid(&new_spec->it_interval) || + !timespec_valid(&new_spec->it_value)) return -EINVAL; - if (copy_from_user(&new_spec, new_setting, sizeof (new_spec))) - return -EFAULT; - - if (!timespec_valid(&new_spec.it_interval) || - !timespec_valid(&new_spec.it_value)) - return -EINVAL; retry: timr = lock_timer(timer_id, &flag); if (!timr) @@ -957,14 +948,34 @@ retry: if (WARN_ON_ONCE(!kc || !kc->timer_set)) error = -EINVAL; else - error = kc->timer_set(timr, flags, &new_spec, rtn); + error = kc->timer_set(timr, flags, new_spec, old_spec); unlock_timer(timr, flag); if (error == TIMER_RETRY) { - rtn = NULL; // We already got the old time... + old_spec = NULL; // We already got the old time... goto retry; } + return error; +} + +/* Set a POSIX.1b interval timer */ +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; + struct itimerspec *rtn = old_setting ? &old_spec : NULL; + + if (!new_setting) + return -EINVAL; + + if (copy_from_user(&new_spec, new_setting, sizeof (new_spec))) + 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))) error = -EFAULT;