linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Richard Cochran <richardcochran@gmail.com>
To: linux-kernel@vger.kernel.org
Cc: linux-api@vger.kernel.org, Alan Cox <alan@lxorguk.ukuu.org.uk>,
	Arnd Bergmann <arnd@arndb.de>, Christoph Lameter <cl@linux.com>,
	John Stultz <johnstul@us.ibm.com>,
	Peter Zijlstra <peterz@infradead.org>,
	Thomas Gleixner <tglx@linutronix.de>
Subject: [PATCH RFC 7/8] clock device: convert timer_gettime
Date: Thu, 4 Nov 2010 20:30:26 +0100	[thread overview]
Message-ID: <b9498f9489d2fa947fcbad3e4828079347f7e283.1288897199.git.richard.cochran@omicron.at> (raw)
In-Reply-To: <cover.1288897198.git.richard.cochran@omicron.at>

This patch lets the timer_gettime system call use dynamic clock devices.

Signed-off-by: Richard Cochran <richard.cochran@omicron.at>
---
 include/linux/clockdevice.h |    2 ++
 kernel/posix-timers.c       |    9 ++++++++-
 kernel/time/clockdevice.c   |   15 +++++++++++++++
 3 files changed, 25 insertions(+), 1 deletions(-)

diff --git a/include/linux/clockdevice.h b/include/linux/clockdevice.h
index 592bd5e..b56debb 100644
--- a/include/linux/clockdevice.h
+++ b/include/linux/clockdevice.h
@@ -108,5 +108,7 @@ struct clock_device *clockid_to_clock_device(clockid_t id);
  */
 int clock_device_timer_create(struct clock_device *clk, struct k_itimer *kit);
 int clock_device_timer_delete(struct clock_device *clk, struct k_itimer *kit);
+void clock_device_timer_gettime(struct clock_device *clk, struct k_itimer *kit,
+				struct itimerspec *tsp);
 
 #endif
diff --git a/kernel/posix-timers.c b/kernel/posix-timers.c
index 5feb565..d00ff73 100644
--- a/kernel/posix-timers.c
+++ b/kernel/posix-timers.c
@@ -711,6 +711,7 @@ common_timer_get(struct k_itimer *timr, struct itimerspec *cur_setting)
 SYSCALL_DEFINE2(timer_gettime, timer_t, timer_id,
 		struct itimerspec __user *, setting)
 {
+	struct clock_device *clk_dev;
 	struct k_itimer *timr;
 	struct itimerspec cur_setting;
 	unsigned long flags;
@@ -719,7 +720,13 @@ SYSCALL_DEFINE2(timer_gettime, timer_t, timer_id,
 	if (!timr)
 		return -EINVAL;
 
-	CLOCK_DISPATCH(timr->it_clock, timer_get, (timr, &cur_setting));
+	clk_dev = clockid_to_clock_device(timr->it_clock);
+
+	if (clk_dev)
+		clock_device_timer_gettime(clk_dev, timr, &cur_setting);
+	else {
+		CLOCK_DISPATCH(timr->it_clock, timer_get, (timr, &cur_setting));
+	}
 
 	unlock_timer(timr, flags);
 
diff --git a/kernel/time/clockdevice.c b/kernel/time/clockdevice.c
index 27d13a4..0f6f913 100644
--- a/kernel/time/clockdevice.c
+++ b/kernel/time/clockdevice.c
@@ -299,3 +299,18 @@ int clock_device_timer_delete(struct clock_device *clk, struct k_itimer *kit)
 
 	return err;
 }
+
+void clock_device_timer_gettime(struct clock_device *clk, struct k_itimer *kit,
+				struct itimerspec *tsp)
+{
+	mutex_lock(&clk->mux);
+
+	if (clk->zombie)
+		goto out;
+	else if (!clk->ops->timer_gettime)
+		goto out;
+	else
+		clk->ops->timer_gettime(clk->priv, kit, tsp);
+out:
+	mutex_unlock(&clk->mux);
+}
-- 
1.7.0.4


  parent reply	other threads:[~2010-11-04 19:30 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-11-04 19:26 [PATCH RFC 0/8] Dynamic clock devices Richard Cochran
2010-11-04 19:28 ` [PATCH RFC 1/8] Introduce dynamic " Richard Cochran
2010-11-08  6:38   ` Arnd Bergmann
2010-12-04 14:55     ` Richard Cochran
2010-12-06 14:14       ` Arnd Bergmann
2010-11-04 19:28 ` [PATCH RFC 2/8] clock device: convert clock_gettime Richard Cochran
2010-11-08  6:56   ` Arnd Bergmann
2010-11-09 10:26     ` Richard Cochran
2010-11-09 12:47       ` Arnd Bergmann
2010-11-09 21:37     ` john stultz
2010-11-10 10:16       ` Arnd Bergmann
2010-11-08 23:37   ` john stultz
2010-11-09  8:23     ` Richard Cochran
2010-11-09 21:10       ` john stultz
2010-11-15  9:41         ` Richard Cochran
2010-11-04 19:28 ` [PATCH RFC 3/8] clock device: convert clock_getres Richard Cochran
2010-11-04 19:29 ` [PATCH RFC 4/8] clock device: convert clock_settime Richard Cochran
2010-11-04 19:29 ` [PATCH RFC 5/8] clock device: convert timer_create Richard Cochran
2010-11-04 19:30 ` [PATCH RFC 6/8] clock device: convert timer_delete Richard Cochran
2010-11-04 19:30 ` Richard Cochran [this message]
2010-11-04 19:30 ` [PATCH RFC 8/8] clock device: convert timer_settime Richard Cochran
2010-11-08 23:01 ` [PATCH RFC 0/8] Dynamic clock devices john stultz
2010-11-15  9:34   ` Richard Cochran
2010-11-15 10:01 ` Paul Mundt
2010-11-18 16:33   ` Richard Cochran

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=b9498f9489d2fa947fcbad3e4828079347f7e283.1288897199.git.richard.cochran@omicron.at \
    --to=richardcochran@gmail.com \
    --cc=alan@lxorguk.ukuu.org.uk \
    --cc=arnd@arndb.de \
    --cc=cl@linux.com \
    --cc=johnstul@us.ibm.com \
    --cc=linux-api@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=peterz@infradead.org \
    --cc=tglx@linutronix.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).