+/**
+ * timespec_to_timeval - convert a timespec to a timeval.
+ * @ts: a timespec.
+ *
+ * Example:
+ * struct timeval tv;
+ *
+ * tv = timespec_to_timeval(time_now());
+ */
+static inline struct timeval timespec_to_timeval(struct timespec ts)
+{
+ struct timeval tv;
+ tv.tv_sec = ts.tv_sec;
+ tv.tv_usec = ts.tv_nsec / 1000;
+ return tv;
+}
+
+/**
+ * timeval_to_timespec - convert a timeval to a timespec.
+ * @tv: a timeval.
+ *
+ * Example:
+ * struct timeval tv = { 0, 500 };
+ * struct timespec ts;
+ *
+ * ts = timeval_to_timespec(tv);
+ */
+static inline struct timespec timeval_to_timespec(struct timeval tv)
+{
+ struct timespec ts;
+ ts.tv_sec = tv.tv_sec;
+ ts.tv_nsec = tv.tv_usec * 1000;
+ return ts;
+}