2006-10-21 12:57:30

by Martin Peschke

[permalink] [raw]
Subject: [Patch 1/5] I/O statistics through request queues: timeval_to_us()

The next patch requires a timeval-to-microseconds conversion.
Introducing a helper function (and fixing a comment).

Signed-off-by: Martin Peschke <[email protected]>
---

time.h | 14 +++++++++++++-
1 files changed, 13 insertions(+), 1 deletion(-)

diff -urp a/include/linux/time.h b/include/linux/time.h
--- a/include/linux/time.h 2006-10-03 16:25:53.000000000 +0200
+++ b/include/linux/time.h 2006-10-06 21:36:08.000000000 +0200
@@ -133,8 +133,20 @@ static inline s64 timespec_to_ns(const s
}

/**
+ * timeval_to_us - Convert timeval to microseconds
+ * @tv: pointer to the timeval variable to be converted
+ *
+ * Returns the scalar nanosecond representation of the timeval
+ * parameter.
+ */
+static inline s64 timeval_to_us(const struct timeval *tv)
+{
+ return ((s64) tv->tv_sec * USEC_PER_SEC) + tv->tv_usec;
+}
+
+/**
* timeval_to_ns - Convert timeval to nanoseconds
- * @ts: pointer to the timeval variable to be converted
+ * @tv: pointer to the timeval variable to be converted
*
* Returns the scalar nanosecond representation of the timeval
* parameter.