From patchwork Fri Sep 12 21:22:22 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Stultz X-Patchwork-Id: 37366 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 AC83A20C7F for ; Fri, 12 Sep 2014 21:22:42 +0000 (UTC) Received: by mail-wi0-f199.google.com with SMTP id bs8sf665378wib.2 for ; Fri, 12 Sep 2014 14:22:41 -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:x-original-sender :x-original-authentication-results:precedence:mailing-list:list-id :list-post:list-help:list-archive:list-unsubscribe; bh=/9d8ViqGtnAS4RgpWDKHeGeGYoalVXXHGDIYYqWpOlc=; b=V0SR6olGcmnE452zCi3zfZ0AG1PGFfGbweiNfkl/VTAzzh8A0SPfQ78oUSfMw6op+b IdAzXgq+KF9nE6JsWaHZNF2bSnOA4iDbXCMp8nfnO3kTVImiPEtVgjV1ZWOjGYnXsqAP az7vBU2tOX4kba8E5hgqPh7d9TdeOsFbj3eeieKY4+g9EMOw8J+eeBLOMmiss6VBSP1f 3QKdkLhUPJ6mAEVuFCq8SMuG88DT6hd/I/jAEwG5BHhu9p50BwWih67bhh9jjqoum23v eK9ln/KwkHowRweYb3c2O0xboFJ4yecs7EUPZOfM5dIsMicRy2tyzi7kXtwpDIa64582 KNbQ== X-Gm-Message-State: ALoCoQmxc486OpgXs4lPg6KQ228YLhazWBVfa2nIisSHBVGAWYI+nf4YNeA9h5C+cNLbffklcGUr X-Received: by 10.180.37.211 with SMTP id a19mr1403601wik.6.1410556961905; Fri, 12 Sep 2014 14:22:41 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.26.132 with SMTP id l4ls197418lag.45.gmail; Fri, 12 Sep 2014 14:22:41 -0700 (PDT) X-Received: by 10.112.8.99 with SMTP id q3mr11180583lba.85.1410556961682; Fri, 12 Sep 2014 14:22:41 -0700 (PDT) Received: from mail-la0-f43.google.com (mail-la0-f43.google.com [209.85.215.43]) by mx.google.com with ESMTPS id q5si8340579lbb.112.2014.09.12.14.22.41 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 12 Sep 2014 14:22:41 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.43 as permitted sender) client-ip=209.85.215.43; Received: by mail-la0-f43.google.com with SMTP id gi9so1744197lab.2 for ; Fri, 12 Sep 2014 14:22:41 -0700 (PDT) X-Received: by 10.112.75.233 with SMTP id f9mr11206746lbw.102.1410556961584; Fri, 12 Sep 2014 14:22:41 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patches@linaro.org Received: by 10.112.141.42 with SMTP id rl10csp809193lbb; Fri, 12 Sep 2014 14:22:40 -0700 (PDT) X-Received: by 10.66.191.200 with SMTP id ha8mr15583583pac.107.1410556959731; Fri, 12 Sep 2014 14:22:39 -0700 (PDT) Received: from mail-pd0-f179.google.com (mail-pd0-f179.google.com [209.85.192.179]) by mx.google.com with ESMTPS id l2si10126416pdp.156.2014.09.12.14.22.39 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 12 Sep 2014 14:22:39 -0700 (PDT) Received-SPF: pass (google.com: domain of john.stultz@linaro.org designates 209.85.192.179 as permitted sender) client-ip=209.85.192.179; Received: by mail-pd0-f179.google.com with SMTP id g10so2027052pdj.38 for ; Fri, 12 Sep 2014 14:22:39 -0700 (PDT) X-Received: by 10.66.244.132 with SMTP id xg4mr12690652pac.64.1410556958903; Fri, 12 Sep 2014 14:22:38 -0700 (PDT) Received: from localhost.localdomain (c-67-170-153-23.hsd1.or.comcast.net. [67.170.153.23]) by mx.google.com with ESMTPSA id p6sm4225878pds.13.2014.09.12.14.22.37 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 12 Sep 2014 14:22:38 -0700 (PDT) From: John Stultz To: lkml Cc: Richard Larocque , stable@vger.kernel.org, Thomas Gleixner , Ingo Molnar , Richard Cochran , Prarit Bhargava , Sharvil Nanavati , John Stultz Subject: [PATCH 2/4] alarmtimer: Return relative times in timer_gettime Date: Fri, 12 Sep 2014 14:22:22 -0700 Message-Id: <1410556944-14944-3-git-send-email-john.stultz@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1410556944-14944-1-git-send-email-john.stultz@linaro.org> References: <1410556944-14944-1-git-send-email-john.stultz@linaro.org> X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: john.stultz@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.43 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Precedence: list Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org List-ID: X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , From: Richard Larocque Returns the time remaining for an alarm timer, rather than the time at which it is scheduled to expire. If the timer has already expired or it is not currently scheduled, the it_value's members are set to zero. This new behavior matches that of the other posix-timers and the POSIX specifications. This is a change in user-visible behavior, and may break existing applications. Hopefully, few users rely on the old incorrect behavior. Cc: stable@vger.kernel.org Cc: Thomas Gleixner Cc: Ingo Molnar Cc: Richard Cochran Cc: Prarit Bhargava Cc: Sharvil Nanavati Signed-off-by: Richard Larocque [jstultz: minor style tweak] Signed-off-by: John Stultz --- kernel/time/alarmtimer.c | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/kernel/time/alarmtimer.c b/kernel/time/alarmtimer.c index 4aec4a4..b4bce62 100644 --- a/kernel/time/alarmtimer.c +++ b/kernel/time/alarmtimer.c @@ -541,18 +541,22 @@ static int alarm_timer_create(struct k_itimer *new_timer) * @new_timer: k_itimer pointer * @cur_setting: itimerspec data to fill * - * Copies the itimerspec data out from the k_itimer + * Copies out the current itimerspec data */ static void alarm_timer_get(struct k_itimer *timr, struct itimerspec *cur_setting) { - memset(cur_setting, 0, sizeof(struct itimerspec)); + ktime_t relative_expiry_time = + alarm_expires_remaining(&(timr->it.alarm.alarmtimer)); - cur_setting->it_interval = - ktime_to_timespec(timr->it.alarm.interval); - cur_setting->it_value = - ktime_to_timespec(timr->it.alarm.alarmtimer.node.expires); - return; + if (ktime_to_ns(relative_expiry_time) > 0) { + cur_setting->it_value = ktime_to_timespec(relative_expiry_time); + } else { + cur_setting->it_value.tv_sec = 0; + cur_setting->it_value.tv_nsec = 0; + } + + cur_setting->it_interval = ktime_to_timespec(timr->it.alarm.interval); } /**