lkml.org 
[lkml]   [2015]   [Apr]   [5]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH 3/3] time: update msecs_to_jiffies doc and move to kernel-doc format
Date
update the documentation of msecs_to_jiffies and move to kernel-doc format

Signed-off-by: Nicholas Mc Guire <hofrat@osadl.org>
---

Patch was compile with x86_64_defconfig

Patch is against 4.0-rc6 (localversion-next is -next-20150402)

include/linux/jiffies.h | 23 +++++++++++++++++++++++
kernel/time/time.c | 19 ++++++++++---------
2 files changed, 33 insertions(+), 9 deletions(-)

diff --git a/include/linux/jiffies.h b/include/linux/jiffies.h
index dcd8ba5..a75158e 100644
--- a/include/linux/jiffies.h
+++ b/include/linux/jiffies.h
@@ -290,6 +290,29 @@ static inline u64 jiffies_to_nsecs(const unsigned long j)
}

extern unsigned long __msecs_to_jiffies(const unsigned int m);
+
+/**
+ * msecs_to_jiffies: - convert milliseconds to jiffies
+ * @m: time in millisecons
+ *
+ * conversion is done as follows:
+ *
+ * - negative values mean 'infinite timeout' (MAX_JIFFY_OFFSET)
+ *
+ * - 'too large' values [that would result in larger than
+ * MAX_JIFFY_OFFSET values] mean 'infinite timeout' too.
+ *
+ * - all other values are converted to jiffies by either multiplying
+ * the input value by a factor or dividing it with a factor and
+ * handling any 32-bit overflows.
+ * for the details see __msecs_to_jiffies()
+ *
+ * msecs_to_jiffies() checks for the passed in value being a constant
+ * via __builtin_constant_p() allowing gcc to eliminate most of the
+ * code, __msecs_to_jiffies() is called if the value passed does not
+ * allow constant folding and the actual conversion must be done at
+ * runtime.
+ */
static inline unsigned long msecs_to_jiffies(const unsigned int m)
{
/*
diff --git a/kernel/time/time.c b/kernel/time/time.c
index 3797540..5d97610 100644
--- a/kernel/time/time.c
+++ b/kernel/time/time.c
@@ -483,22 +483,23 @@ struct timespec64 ns_to_timespec64(const s64 nsec)
}
EXPORT_SYMBOL(ns_to_timespec64);
#endif
-/*
- * When we convert to jiffies then we interpret incoming values
- * the following way:
+
+/**
+ * __msecs_to_jiffies: - convert milliseconds to jiffies
+ * @m: time in millisecons
*
- * - negative values mean 'infinite timeout' (MAX_JIFFY_OFFSET)
- * negative values are handled in msecs_to_jiffies in
- * include/linux/jiffies.h
+ * conversion is done as follows:
*
* - 'too large' values [that would result in larger than
* MAX_JIFFY_OFFSET values] mean 'infinite timeout' too.
*
* - all other values are converted to jiffies by either multiplying
- * the input value by a factor or dividing it with a factor
- *
- * We must also be careful about 32-bit overflows.
+ * the input value by a factor or dividing it with a factor and
+ * handling any 32-bit overflows.
*
+ * __msecs_to_jiffies() is called if the value passed to
+ * msecs_to_jiffies() does not allow constant folding and the actual
+ * conversion must be done at runtime.
*/
unsigned long __msecs_to_jiffies(const unsigned int m)
{
--
1.7.10.4


\
 
 \ /
  Last update: 2015-04-05 10:01    [W:0.050 / U:0.676 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site