All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 01/05] clocksource: add read2() callback and warning
@ 2008-12-10 15:12 Magnus Damm
  2008-12-10 15:29 ` Thomas Gleixner
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: Magnus Damm @ 2008-12-10 15:12 UTC (permalink / raw)
  To: linux-sh

From: Magnus Damm <damm@igel.co.jp>

Add a read2() callback for clocksources and warn if not in place.
This callback is passing a pointer to struct clocksource which makes
it easy to share the same callback for multiple clocksource instances.

The function clocksource_read() is modified to prefer read2() over
read() if initialized, and a warning is emitted at registration
time if read() is still in use. The jiffy clocksource is updated.

Signed-off-by: Magnus Damm <damm@igel.co.jp>
---

 include/linux/clocksource.h |    4 +++-
 kernel/time/clocksource.c   |    6 ++++++
 kernel/time/jiffies.c       |    4 ++--
 3 files changed, 11 insertions(+), 3 deletions(-)

--- 0001/include/linux/clocksource.h
+++ work/include/linux/clocksource.h	2008-12-10 23:06:00.000000000 +0900
@@ -43,6 +43,7 @@ struct clocksource;
  *				The ideal clocksource. A must-use where
  *				available.
  * @read:		returns a cycle value
+ * @read2:		returns a cycle value, passes clocksource as argument
  * @mask:		bitmask for two's complement
  *			subtraction of non 64 bit counters
  * @mult:		cycle to nanosecond multiplier (adjusted by NTP)
@@ -62,6 +63,7 @@ struct clocksource {
 	struct list_head list;
 	int rating;
 	cycle_t (*read)(void);
+	cycle_t (*read2)(struct clocksource *cs);
 	cycle_t mask;
 	u32 mult;
 	u32 mult_orig;
@@ -170,7 +172,7 @@ static inline u32 clocksource_hz2mult(u3
  */
 static inline cycle_t clocksource_read(struct clocksource *cs)
 {
-	return cs->read();
+	return cs->read2 ? cs->read2(cs) : cs->read();
 }
 
 /**
--- 0001/kernel/time/clocksource.c
+++ work/kernel/time/clocksource.c	2008-12-10 23:44:38.000000000 +0900
@@ -325,6 +325,12 @@ int clocksource_register(struct clocksou
 	unsigned long flags;
 	int ret;
 
+	/* warn to make sure people convert their code to read2() */
+	if (c->read)
+		printk(KERN_INFO
+			"warning: clocksource `%s' should be updated "
+			"to use read2()\n", c->name);
+
 	/* save mult_orig on registration */
 	c->mult_orig = c->mult;
 
--- 0001/kernel/time/jiffies.c
+++ work/kernel/time/jiffies.c	2008-12-10 23:44:38.000000000 +0900
@@ -50,7 +50,7 @@
  */
 #define JIFFIES_SHIFT	8
 
-static cycle_t jiffies_read(void)
+static cycle_t jiffies_read(struct clocksource *cs)
 {
 	return (cycle_t) jiffies;
 }
@@ -58,7 +58,7 @@ static cycle_t jiffies_read(void)
 struct clocksource clocksource_jiffies = {
 	.name		= "jiffies",
 	.rating		= 1, /* lowest valid rating*/
-	.read		= jiffies_read,
+	.read2		= jiffies_read,
 	.mask		= 0xffffffff, /*32bits*/
 	.mult		= NSEC_PER_JIFFY << JIFFIES_SHIFT, /* details above */
 	.mult_orig	= NSEC_PER_JIFFY << JIFFIES_SHIFT,

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2008-12-11  0:59 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-12-10 15:12 [PATCH 01/05] clocksource: add read2() callback and warning Magnus Damm
2008-12-10 15:29 ` Thomas Gleixner
2008-12-10 20:38 ` john stultz
2008-12-10 20:47 ` Thomas Gleixner
2008-12-11  0:59 ` Paul Mundt

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.