From patchwork Mon Mar 25 20:08:13 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Stultz X-Patchwork-Id: 15628 Return-Path: X-Original-To: patchwork@peony.canonical.com Delivered-To: patchwork@peony.canonical.com Received: from fiordland.canonical.com (fiordland.canonical.com [91.189.94.145]) by peony.canonical.com (Postfix) with ESMTP id 478B723E66 for ; Mon, 25 Mar 2013 20:08:31 +0000 (UTC) Received: from mail-vb0-f53.google.com (mail-vb0-f53.google.com [209.85.212.53]) by fiordland.canonical.com (Postfix) with ESMTP id F3642A19564 for ; Mon, 25 Mar 2013 20:08:30 +0000 (UTC) Received: by mail-vb0-f53.google.com with SMTP id fq11so487473vbb.12 for ; Mon, 25 Mar 2013 13:08:30 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-received:x-forwarded-to:x-forwarded-for:delivered-to:x-received :received-spf:x-received:from:to:cc:subject:date:message-id:x-mailer :in-reply-to:references:x-gm-message-state; bh=Lpi8ImZEdu9m0eFxahbKUQSL3hOOWCNfgp0sKsSxgbg=; b=R7AqBc9dEmcDunmPNkboW8y2D8oOMzfv0/pY0GLHaDQUPiiV0z+41OKAygi0I2EXz7 glduRWi6bvXrohwSYJy/H4AVhI0SbPz4HzmO+6vNWbXqfkCSIqGxv76uRqIWdCnRnOOg mzrKYo9vxasdd1uKPwd4wRFIbseASkcJ5Hw4+uf49+3Ntk5V09wK8phxNCKVqJ82zGkB gsSqQxYrP5ZzfZs6/XaxN5+X5pHPomylx1GqF6Nf5ZNJbmsW7f3i1mL9i7LTXBGJ4bbK 77uzpFWyXGf7Z2rVvynJE+xrXYWwzhWHME8crZdcHhXjxhN2yTcAiHkvyIeJTu2RuGjV p41w== X-Received: by 10.220.106.14 with SMTP id v14mr964520vco.2.1364242110323; Mon, 25 Mar 2013 13:08:30 -0700 (PDT) X-Forwarded-To: linaro-patchwork@canonical.com X-Forwarded-For: patch@linaro.org linaro-patchwork@canonical.com Delivered-To: patches@linaro.org Received: by 10.59.4.204 with SMTP id cg12csp41754ved; Mon, 25 Mar 2013 13:08:29 -0700 (PDT) X-Received: by 10.68.221.36 with SMTP id qb4mr19563859pbc.66.1364242109458; Mon, 25 Mar 2013 13:08:29 -0700 (PDT) Received: from mail-pa0-f43.google.com (mail-pa0-f43.google.com [209.85.220.43]) by mx.google.com with ESMTPS id te10si15070846pab.154.2013.03.25.13.08.29 (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 25 Mar 2013 13:08:29 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.220.43 is neither permitted nor denied by best guess record for domain of john.stultz@linaro.org) client-ip=209.85.220.43; Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.220.43 is neither permitted nor denied by best guess record for domain of john.stultz@linaro.org) smtp.mail=john.stultz@linaro.org Received: by mail-pa0-f43.google.com with SMTP id hz11so43135pad.16 for ; Mon, 25 Mar 2013 13:08:29 -0700 (PDT) X-Received: by 10.68.184.33 with SMTP id er1mr19749820pbc.151.1364242108938; Mon, 25 Mar 2013 13:08:28 -0700 (PDT) Received: from localhost.localdomain (c-24-21-54-107.hsd1.or.comcast.net. [24.21.54.107]) by mx.google.com with ESMTPS id gn2sm14529074pbb.22.2013.03.25.13.08.27 (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 25 Mar 2013 13:08:28 -0700 (PDT) From: John Stultz To: lkml Cc: John Stultz , Thomas Gleixner , Richard Cochran , Prarit Bhargava Subject: [PATCH 3/8] ntp: Move timex validation to timekeeping do_adjtimex call. Date: Mon, 25 Mar 2013 13:08:13 -0700 Message-Id: <1364242098-5977-4-git-send-email-john.stultz@linaro.org> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1364242098-5977-1-git-send-email-john.stultz@linaro.org> References: <1364242098-5977-1-git-send-email-john.stultz@linaro.org> X-Gm-Message-State: ALoCoQnzrQMQx5gc1AMHvJ2pwv2cZJF4xnaOSqmZzQG553XW/vRrVX9OFY8TAIW1ajA9Jy0BftCL Move logic that does not need the ntp state to be done in the timekeeping do_adjtimex() call. Cc: Thomas Gleixner Cc: Richard Cochran Cc: Prarit Bhargava Signed-off-by: John Stultz --- kernel/time/ntp.c | 5 ----- kernel/time/ntp_internal.h | 1 + kernel/time/timekeeping.c | 7 +++++++ 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/kernel/time/ntp.c b/kernel/time/ntp.c index 8b10706..2dc60c6 100644 --- a/kernel/time/ntp.c +++ b/kernel/time/ntp.c @@ -668,11 +668,6 @@ int __do_adjtimex(struct timex *txc) u32 time_tai, orig_tai; int result; - /* Validate the data before disabling interrupts */ - result = ntp_validate_timex(txc); - if (result) - return result; - if (txc->modes & ADJ_SETOFFSET) { struct timespec delta; delta.tv_sec = txc->time.tv_sec; diff --git a/kernel/time/ntp_internal.h b/kernel/time/ntp_internal.h index fdee80c..a2a3976 100644 --- a/kernel/time/ntp_internal.h +++ b/kernel/time/ntp_internal.h @@ -6,6 +6,7 @@ extern void ntp_clear(void); /* Returns how long ticks are at present, in ns / 2^NTP_SCALE_SHIFT. */ extern u64 ntp_tick_length(void); extern int second_overflow(unsigned long secs); +extern int ntp_validate_timex(struct timex *); extern int __do_adjtimex(struct timex *); extern void __hardpps(const struct timespec *, const struct timespec *); #endif /* _LINUX_NTP_INTERNAL_H */ diff --git a/kernel/time/timekeeping.c b/kernel/time/timekeeping.c index a138ec2..f6c8a72 100644 --- a/kernel/time/timekeeping.c +++ b/kernel/time/timekeeping.c @@ -1618,6 +1618,13 @@ EXPORT_SYMBOL_GPL(ktime_get_monotonic_offset); */ int do_adjtimex(struct timex *txc) { + int ret; + + /* Validate the data before disabling interrupts */ + ret = ntp_validate_timex(txc); + if (ret) + return ret; + return __do_adjtimex(txc); }