On Tuesday 28 April 2015 16:05:53 Baolin Wang wrote:
This patch introduces the timespec64_to_jiffies() and jiffies_to_timespec64() functions, that implement the conversion between cputime and timespec64.
Signed-off-by: Baolin Wang baolin.wang@linaro.org
include/linux/jiffies.h | 3 +++ kernel/time/time.c | 23 +++++++++++++++++++---- 2 files changed, 22 insertions(+), 4 deletions(-)
diff --git a/include/linux/jiffies.h b/include/linux/jiffies.h index c367cbd..dbaa4ee 100644 --- a/include/linux/jiffies.h +++ b/include/linux/jiffies.h @@ -293,6 +293,9 @@ extern unsigned long usecs_to_jiffies(const unsigned int u); extern unsigned long timespec_to_jiffies(const struct timespec *value); extern void jiffies_to_timespec(const unsigned long jiffies, struct timespec *value); +extern unsigned long timespec64_to_jiffies(const struct timespec64 *value); +extern void jiffies_to_timespec64(const unsigned long jiffies,
struct timespec64 *value);
extern unsigned long timeval_to_jiffies(const struct timeval *value); extern void jiffies_to_timeval(const unsigned long jiffies, struct timeval *value); diff --git a/kernel/time/time.c b/kernel/time/time.c index fe65e7d..b711f54 100644 --- a/kernel/time/time.c +++ b/kernel/time/time.c @@ -593,17 +593,16 @@ __timespec_to_jiffies(unsigned long sec, long nsec) (NSEC_JIFFIE_SC - SEC_JIFFIE_SC))) >> SEC_JIFFIE_SC; } +EXPORT_SYMBOL(__timespec_to_jiffies);
__timespec_to_jiffies is still marked as 'static', so it should not be exported.
unsigned long -timespec_to_jiffies(const struct timespec *value) +timespec64_to_jiffies(const struct timespec64 *value) { return __timespec_to_jiffies(value->tv_sec, value->tv_nsec); } -EXPORT_SYMBOL(timespec_to_jiffies);
Whereas the timespec64_to_jiffies should probably be exported, because it is now an official interface.
+unsigned long +timespec_to_jiffies(const struct timespec *value) +{
- return __timespec_to_jiffies(value->tv_sec, value->tv_nsec);
+}
This is also missing an EXPORT_SYMBOL now.
+void +jiffies_to_timespec(const unsigned long jiffies, struct timespec *value) +{
- struct timespec64 *ts;
- *ts = timespec_to_timespec64(*value);
- jiffies_to_timespec64(jiffies, ts);
+} EXPORT_SYMBOL(jiffies_to_timespec);
I would probably again put timespec_to_jiffies and jiffies_to_timespec into the header file as static inline functions, which implies that you then have to declare and export __timespec_to_jiffies.
Arnd