@@ -365,11 +365,14 @@ SYSCALL_DEFINE1(adjtimex_time32, struct old_timex32 __user *, utp)
365365}
366366#endif
367367
368- /*
369- * Convert jiffies to milliseconds and back.
368+ /**
369+ * jiffies_to_msecs - Convert jiffies to milliseconds
370+ * @j: jiffies value
370371 *
371372 * Avoid unnecessary multiplications/divisions in the
372- * two most common HZ cases:
373+ * two most common HZ cases.
374+ *
375+ * Return: milliseconds value
373376 */
374377unsigned int jiffies_to_msecs (const unsigned long j )
375378{
@@ -388,6 +391,12 @@ unsigned int jiffies_to_msecs(const unsigned long j)
388391}
389392EXPORT_SYMBOL (jiffies_to_msecs );
390393
394+ /**
395+ * jiffies_to_usecs - Convert jiffies to microseconds
396+ * @j: jiffies value
397+ *
398+ * Return: microseconds value
399+ */
391400unsigned int jiffies_to_usecs (const unsigned long j )
392401{
393402 /*
@@ -408,8 +417,15 @@ unsigned int jiffies_to_usecs(const unsigned long j)
408417}
409418EXPORT_SYMBOL (jiffies_to_usecs );
410419
411- /*
420+ /**
412421 * mktime64 - Converts date to seconds.
422+ * @year0: year to convert
423+ * @mon0: month to convert
424+ * @day: day to convert
425+ * @hour: hour to convert
426+ * @min: minute to convert
427+ * @sec: second to convert
428+ *
413429 * Converts Gregorian date to seconds since 1970-01-01 00:00:00.
414430 * Assumes input in normal date format, i.e. 1980-12-31 23:59:59
415431 * => year=1980, mon=12, day=31, hour=23, min=59, sec=59.
@@ -427,6 +443,8 @@ EXPORT_SYMBOL(jiffies_to_usecs);
427443 *
428444 * An encoding of midnight at the end of the day as 24:00:00 - ie. midnight
429445 * tomorrow - (allowable under ISO 8601) is supported.
446+ *
447+ * Return: seconds since the epoch time for the given input date
430448 */
431449time64_t mktime64 (const unsigned int year0 , const unsigned int mon0 ,
432450 const unsigned int day , const unsigned int hour ,
@@ -471,8 +489,7 @@ EXPORT_SYMBOL(ns_to_kernel_old_timeval);
471489 * Set seconds and nanoseconds field of a timespec variable and
472490 * normalize to the timespec storage format
473491 *
474- * Note: The tv_nsec part is always in the range of
475- * 0 <= tv_nsec < NSEC_PER_SEC
492+ * Note: The tv_nsec part is always in the range of 0 <= tv_nsec < NSEC_PER_SEC.
476493 * For negative values only the tv_sec field is negative !
477494 */
478495void set_normalized_timespec64 (struct timespec64 * ts , time64_t sec , s64 nsec )
@@ -501,7 +518,7 @@ EXPORT_SYMBOL(set_normalized_timespec64);
501518 * ns_to_timespec64 - Convert nanoseconds to timespec64
502519 * @nsec: the nanoseconds value to be converted
503520 *
504- * Returns the timespec64 representation of the nsec parameter.
521+ * Return: the timespec64 representation of the nsec parameter.
505522 */
506523struct timespec64 ns_to_timespec64 (s64 nsec )
507524{
@@ -548,6 +565,8 @@ EXPORT_SYMBOL(ns_to_timespec64);
548565 * runtime.
549566 * The _msecs_to_jiffies helpers are the HZ dependent conversion
550567 * routines found in include/linux/jiffies.h
568+ *
569+ * Return: jiffies value
551570 */
552571unsigned long __msecs_to_jiffies (const unsigned int m )
553572{
@@ -560,6 +579,12 @@ unsigned long __msecs_to_jiffies(const unsigned int m)
560579}
561580EXPORT_SYMBOL (__msecs_to_jiffies );
562581
582+ /**
583+ * __usecs_to_jiffies: - convert microseconds to jiffies
584+ * @u: time in milliseconds
585+ *
586+ * Return: jiffies value
587+ */
563588unsigned long __usecs_to_jiffies (const unsigned int u )
564589{
565590 if (u > jiffies_to_usecs (MAX_JIFFY_OFFSET ))
@@ -568,7 +593,10 @@ unsigned long __usecs_to_jiffies(const unsigned int u)
568593}
569594EXPORT_SYMBOL (__usecs_to_jiffies );
570595
571- /*
596+ /**
597+ * timespec64_to_jiffies - convert a timespec64 value to jiffies
598+ * @value: pointer to &struct timespec64
599+ *
572600 * The TICK_NSEC - 1 rounds up the value to the next resolution. Note
573601 * that a remainder subtract here would not do the right thing as the
574602 * resolution values don't fall on second boundaries. I.e. the line:
@@ -582,8 +610,9 @@ EXPORT_SYMBOL(__usecs_to_jiffies);
582610 *
583611 * The >> (NSEC_JIFFIE_SC - SEC_JIFFIE_SC) converts the scaled nsec
584612 * value to a scaled second value.
613+ *
614+ * Return: jiffies value
585615 */
586-
587616unsigned long
588617timespec64_to_jiffies (const struct timespec64 * value )
589618{
@@ -601,6 +630,11 @@ timespec64_to_jiffies(const struct timespec64 *value)
601630}
602631EXPORT_SYMBOL (timespec64_to_jiffies );
603632
633+ /**
634+ * jiffies_to_timespec64 - convert jiffies value to &struct timespec64
635+ * @jiffies: jiffies value
636+ * @value: pointer to &struct timespec64
637+ */
604638void
605639jiffies_to_timespec64 (const unsigned long jiffies , struct timespec64 * value )
606640{
@@ -618,6 +652,13 @@ EXPORT_SYMBOL(jiffies_to_timespec64);
618652/*
619653 * Convert jiffies/jiffies_64 to clock_t and back.
620654 */
655+
656+ /**
657+ * jiffies_to_clock_t - Convert jiffies to clock_t
658+ * @x: jiffies value
659+ *
660+ * Return: jiffies converted to clock_t (CLOCKS_PER_SEC)
661+ */
621662clock_t jiffies_to_clock_t (unsigned long x )
622663{
623664#if (TICK_NSEC % (NSEC_PER_SEC / USER_HZ )) == 0
@@ -632,6 +673,12 @@ clock_t jiffies_to_clock_t(unsigned long x)
632673}
633674EXPORT_SYMBOL (jiffies_to_clock_t );
634675
676+ /**
677+ * clock_t_to_jiffies - Convert clock_t to jiffies
678+ * @x: clock_t value
679+ *
680+ * Return: clock_t value converted to jiffies
681+ */
635682unsigned long clock_t_to_jiffies (unsigned long x )
636683{
637684#if (HZ % USER_HZ )== 0
@@ -649,6 +696,12 @@ unsigned long clock_t_to_jiffies(unsigned long x)
649696}
650697EXPORT_SYMBOL (clock_t_to_jiffies );
651698
699+ /**
700+ * jiffies_64_to_clock_t - Convert jiffies_64 to clock_t
701+ * @x: jiffies_64 value
702+ *
703+ * Return: jiffies_64 value converted to 64-bit "clock_t" (CLOCKS_PER_SEC)
704+ */
652705u64 jiffies_64_to_clock_t (u64 x )
653706{
654707#if (TICK_NSEC % (NSEC_PER_SEC / USER_HZ )) == 0
@@ -671,6 +724,12 @@ u64 jiffies_64_to_clock_t(u64 x)
671724}
672725EXPORT_SYMBOL (jiffies_64_to_clock_t );
673726
727+ /**
728+ * nsec_to_clock_t - Convert nsec value to clock_t
729+ * @x: nsec value
730+ *
731+ * Return: nsec value converted to 64-bit "clock_t" (CLOCKS_PER_SEC)
732+ */
674733u64 nsec_to_clock_t (u64 x )
675734{
676735#if (NSEC_PER_SEC % USER_HZ ) == 0
@@ -687,6 +746,12 @@ u64 nsec_to_clock_t(u64 x)
687746#endif
688747}
689748
749+ /**
750+ * jiffies64_to_nsecs - Convert jiffies64 to nanoseconds
751+ * @j: jiffies64 value
752+ *
753+ * Return: nanoseconds value
754+ */
690755u64 jiffies64_to_nsecs (u64 j )
691756{
692757#if !(NSEC_PER_SEC % HZ )
@@ -697,6 +762,12 @@ u64 jiffies64_to_nsecs(u64 j)
697762}
698763EXPORT_SYMBOL (jiffies64_to_nsecs );
699764
765+ /**
766+ * jiffies64_to_msecs - Convert jiffies64 to milliseconds
767+ * @j: jiffies64 value
768+ *
769+ * Return: milliseconds value
770+ */
700771u64 jiffies64_to_msecs (const u64 j )
701772{
702773#if HZ <= MSEC_PER_SEC && !(MSEC_PER_SEC % HZ )
@@ -719,6 +790,8 @@ EXPORT_SYMBOL(jiffies64_to_msecs);
719790 * note:
720791 * NSEC_PER_SEC = 10^9 = (5^9 * 2^9) = (1953125 * 512)
721792 * ULLONG_MAX ns = 18446744073.709551615 secs = about 584 years
793+ *
794+ * Return: nsecs converted to jiffies64 value
722795 */
723796u64 nsecs_to_jiffies64 (u64 n )
724797{
@@ -750,17 +823,25 @@ EXPORT_SYMBOL(nsecs_to_jiffies64);
750823 * note:
751824 * NSEC_PER_SEC = 10^9 = (5^9 * 2^9) = (1953125 * 512)
752825 * ULLONG_MAX ns = 18446744073.709551615 secs = about 584 years
826+ *
827+ * Return: nsecs converted to jiffies value
753828 */
754829unsigned long nsecs_to_jiffies (u64 n )
755830{
756831 return (unsigned long )nsecs_to_jiffies64 (n );
757832}
758833EXPORT_SYMBOL_GPL (nsecs_to_jiffies );
759834
760- /*
761- * Add two timespec64 values and do a safety check for overflow.
835+ /**
836+ * timespec64_add_safe - Add two timespec64 values and do a safety check
837+ * for overflow.
838+ * @lhs: first (left) timespec64 to add
839+ * @rhs: second (right) timespec64 to add
840+ *
762841 * It's assumed that both values are valid (>= 0).
763842 * And, each timespec64 is in normalized form.
843+ *
844+ * Return: sum of @lhs + @rhs
764845 */
765846struct timespec64 timespec64_add_safe (const struct timespec64 lhs ,
766847 const struct timespec64 rhs )
@@ -778,6 +859,15 @@ struct timespec64 timespec64_add_safe(const struct timespec64 lhs,
778859 return res ;
779860}
780861
862+ /**
863+ * get_timespec64 - get user's time value into kernel space
864+ * @ts: destination &struct timespec64
865+ * @uts: user's time value as &struct __kernel_timespec
866+ *
867+ * Handles compat or 32-bit modes.
868+ *
869+ * Return: %0 on success or negative errno on error
870+ */
781871int get_timespec64 (struct timespec64 * ts ,
782872 const struct __kernel_timespec __user * uts )
783873{
@@ -801,6 +891,14 @@ int get_timespec64(struct timespec64 *ts,
801891}
802892EXPORT_SYMBOL_GPL (get_timespec64 );
803893
894+ /**
895+ * put_timespec64 - convert timespec64 value to __kernel_timespec format and
896+ * copy the latter to userspace
897+ * @ts: input &struct timespec64
898+ * @uts: user's &struct __kernel_timespec
899+ *
900+ * Return: %0 on success or negative errno on error
901+ */
804902int put_timespec64 (const struct timespec64 * ts ,
805903 struct __kernel_timespec __user * uts )
806904{
@@ -839,6 +937,15 @@ static int __put_old_timespec32(const struct timespec64 *ts64,
839937 return copy_to_user (cts , & ts , sizeof (ts )) ? - EFAULT : 0 ;
840938}
841939
940+ /**
941+ * get_old_timespec32 - get user's old-format time value into kernel space
942+ * @ts: destination &struct timespec64
943+ * @uts: user's old-format time value (&struct old_timespec32)
944+ *
945+ * Handles X86_X32_ABI compatibility conversion.
946+ *
947+ * Return: %0 on success or negative errno on error
948+ */
842949int get_old_timespec32 (struct timespec64 * ts , const void __user * uts )
843950{
844951 if (COMPAT_USE_64BIT_TIME )
@@ -848,6 +955,16 @@ int get_old_timespec32(struct timespec64 *ts, const void __user *uts)
848955}
849956EXPORT_SYMBOL_GPL (get_old_timespec32 );
850957
958+ /**
959+ * put_old_timespec32 - convert timespec64 value to &struct old_timespec32 and
960+ * copy the latter to userspace
961+ * @ts: input &struct timespec64
962+ * @uts: user's &struct old_timespec32
963+ *
964+ * Handles X86_X32_ABI compatibility conversion.
965+ *
966+ * Return: %0 on success or negative errno on error
967+ */
851968int put_old_timespec32 (const struct timespec64 * ts , void __user * uts )
852969{
853970 if (COMPAT_USE_64BIT_TIME )
@@ -857,6 +974,13 @@ int put_old_timespec32(const struct timespec64 *ts, void __user *uts)
857974}
858975EXPORT_SYMBOL_GPL (put_old_timespec32 );
859976
977+ /**
978+ * get_itimerspec64 - get user's &struct __kernel_itimerspec into kernel space
979+ * @it: destination &struct itimerspec64
980+ * @uit: user's &struct __kernel_itimerspec
981+ *
982+ * Return: %0 on success or negative errno on error
983+ */
860984int get_itimerspec64 (struct itimerspec64 * it ,
861985 const struct __kernel_itimerspec __user * uit )
862986{
@@ -872,6 +996,14 @@ int get_itimerspec64(struct itimerspec64 *it,
872996}
873997EXPORT_SYMBOL_GPL (get_itimerspec64 );
874998
999+ /**
1000+ * put_itimerspec64 - convert &struct itimerspec64 to __kernel_itimerspec format
1001+ * and copy the latter to userspace
1002+ * @it: input &struct itimerspec64
1003+ * @uit: user's &struct __kernel_itimerspec
1004+ *
1005+ * Return: %0 on success or negative errno on error
1006+ */
8751007int put_itimerspec64 (const struct itimerspec64 * it ,
8761008 struct __kernel_itimerspec __user * uit )
8771009{
@@ -887,6 +1019,13 @@ int put_itimerspec64(const struct itimerspec64 *it,
8871019}
8881020EXPORT_SYMBOL_GPL (put_itimerspec64 );
8891021
1022+ /**
1023+ * get_old_itimerspec32 - get user's &struct old_itimerspec32 into kernel space
1024+ * @its: destination &struct itimerspec64
1025+ * @uits: user's &struct old_itimerspec32
1026+ *
1027+ * Return: %0 on success or negative errno on error
1028+ */
8901029int get_old_itimerspec32 (struct itimerspec64 * its ,
8911030 const struct old_itimerspec32 __user * uits )
8921031{
@@ -898,6 +1037,14 @@ int get_old_itimerspec32(struct itimerspec64 *its,
8981037}
8991038EXPORT_SYMBOL_GPL (get_old_itimerspec32 );
9001039
1040+ /**
1041+ * put_old_itimerspec32 - convert &struct itimerspec64 to &struct
1042+ * old_itimerspec32 and copy the latter to userspace
1043+ * @its: input &struct itimerspec64
1044+ * @uits: user's &struct old_itimerspec32
1045+ *
1046+ * Return: %0 on success or negative errno on error
1047+ */
9011048int put_old_itimerspec32 (const struct itimerspec64 * its ,
9021049 struct old_itimerspec32 __user * uits )
9031050{
0 commit comments