@@ -365,11 +365,14 @@ SYSCALL_DEFINE1(adjtimex_time32, struct old_timex32 __user *, utp)
365
365
}
366
366
#endif
367
367
368
- /*
369
- * Convert jiffies to milliseconds and back.
368
+ /**
369
+ * jiffies_to_msecs - Convert jiffies to milliseconds
370
+ * @j: jiffies value
370
371
*
371
372
* Avoid unnecessary multiplications/divisions in the
372
- * two most common HZ cases:
373
+ * two most common HZ cases.
374
+ *
375
+ * Return: milliseconds value
373
376
*/
374
377
unsigned int jiffies_to_msecs (const unsigned long j )
375
378
{
@@ -388,6 +391,12 @@ unsigned int jiffies_to_msecs(const unsigned long j)
388
391
}
389
392
EXPORT_SYMBOL (jiffies_to_msecs );
390
393
394
+ /**
395
+ * jiffies_to_usecs - Convert jiffies to microseconds
396
+ * @j: jiffies value
397
+ *
398
+ * Return: microseconds value
399
+ */
391
400
unsigned int jiffies_to_usecs (const unsigned long j )
392
401
{
393
402
/*
@@ -408,8 +417,15 @@ unsigned int jiffies_to_usecs(const unsigned long j)
408
417
}
409
418
EXPORT_SYMBOL (jiffies_to_usecs );
410
419
411
- /*
420
+ /**
412
421
* 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
+ *
413
429
* Converts Gregorian date to seconds since 1970-01-01 00:00:00.
414
430
* Assumes input in normal date format, i.e. 1980-12-31 23:59:59
415
431
* => year=1980, mon=12, day=31, hour=23, min=59, sec=59.
@@ -427,6 +443,8 @@ EXPORT_SYMBOL(jiffies_to_usecs);
427
443
*
428
444
* An encoding of midnight at the end of the day as 24:00:00 - ie. midnight
429
445
* tomorrow - (allowable under ISO 8601) is supported.
446
+ *
447
+ * Return: seconds since the epoch time for the given input date
430
448
*/
431
449
time64_t mktime64 (const unsigned int year0 , const unsigned int mon0 ,
432
450
const unsigned int day , const unsigned int hour ,
@@ -471,8 +489,7 @@ EXPORT_SYMBOL(ns_to_kernel_old_timeval);
471
489
* Set seconds and nanoseconds field of a timespec variable and
472
490
* normalize to the timespec storage format
473
491
*
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.
476
493
* For negative values only the tv_sec field is negative !
477
494
*/
478
495
void set_normalized_timespec64 (struct timespec64 * ts , time64_t sec , s64 nsec )
@@ -501,7 +518,7 @@ EXPORT_SYMBOL(set_normalized_timespec64);
501
518
* ns_to_timespec64 - Convert nanoseconds to timespec64
502
519
* @nsec: the nanoseconds value to be converted
503
520
*
504
- * Returns the timespec64 representation of the nsec parameter.
521
+ * Return: the timespec64 representation of the nsec parameter.
505
522
*/
506
523
struct timespec64 ns_to_timespec64 (s64 nsec )
507
524
{
@@ -548,6 +565,8 @@ EXPORT_SYMBOL(ns_to_timespec64);
548
565
* runtime.
549
566
* The _msecs_to_jiffies helpers are the HZ dependent conversion
550
567
* routines found in include/linux/jiffies.h
568
+ *
569
+ * Return: jiffies value
551
570
*/
552
571
unsigned long __msecs_to_jiffies (const unsigned int m )
553
572
{
@@ -560,6 +579,12 @@ unsigned long __msecs_to_jiffies(const unsigned int m)
560
579
}
561
580
EXPORT_SYMBOL (__msecs_to_jiffies );
562
581
582
+ /**
583
+ * __usecs_to_jiffies: - convert microseconds to jiffies
584
+ * @u: time in milliseconds
585
+ *
586
+ * Return: jiffies value
587
+ */
563
588
unsigned long __usecs_to_jiffies (const unsigned int u )
564
589
{
565
590
if (u > jiffies_to_usecs (MAX_JIFFY_OFFSET ))
@@ -568,7 +593,10 @@ unsigned long __usecs_to_jiffies(const unsigned int u)
568
593
}
569
594
EXPORT_SYMBOL (__usecs_to_jiffies );
570
595
571
- /*
596
+ /**
597
+ * timespec64_to_jiffies - convert a timespec64 value to jiffies
598
+ * @value: pointer to &struct timespec64
599
+ *
572
600
* The TICK_NSEC - 1 rounds up the value to the next resolution. Note
573
601
* that a remainder subtract here would not do the right thing as the
574
602
* resolution values don't fall on second boundaries. I.e. the line:
@@ -582,8 +610,9 @@ EXPORT_SYMBOL(__usecs_to_jiffies);
582
610
*
583
611
* The >> (NSEC_JIFFIE_SC - SEC_JIFFIE_SC) converts the scaled nsec
584
612
* value to a scaled second value.
613
+ *
614
+ * Return: jiffies value
585
615
*/
586
-
587
616
unsigned long
588
617
timespec64_to_jiffies (const struct timespec64 * value )
589
618
{
@@ -601,6 +630,11 @@ timespec64_to_jiffies(const struct timespec64 *value)
601
630
}
602
631
EXPORT_SYMBOL (timespec64_to_jiffies );
603
632
633
+ /**
634
+ * jiffies_to_timespec64 - convert jiffies value to &struct timespec64
635
+ * @jiffies: jiffies value
636
+ * @value: pointer to &struct timespec64
637
+ */
604
638
void
605
639
jiffies_to_timespec64 (const unsigned long jiffies , struct timespec64 * value )
606
640
{
@@ -618,6 +652,13 @@ EXPORT_SYMBOL(jiffies_to_timespec64);
618
652
/*
619
653
* Convert jiffies/jiffies_64 to clock_t and back.
620
654
*/
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
+ */
621
662
clock_t jiffies_to_clock_t (unsigned long x )
622
663
{
623
664
#if (TICK_NSEC % (NSEC_PER_SEC / USER_HZ )) == 0
@@ -632,6 +673,12 @@ clock_t jiffies_to_clock_t(unsigned long x)
632
673
}
633
674
EXPORT_SYMBOL (jiffies_to_clock_t );
634
675
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
+ */
635
682
unsigned long clock_t_to_jiffies (unsigned long x )
636
683
{
637
684
#if (HZ % USER_HZ )== 0
@@ -649,6 +696,12 @@ unsigned long clock_t_to_jiffies(unsigned long x)
649
696
}
650
697
EXPORT_SYMBOL (clock_t_to_jiffies );
651
698
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
+ */
652
705
u64 jiffies_64_to_clock_t (u64 x )
653
706
{
654
707
#if (TICK_NSEC % (NSEC_PER_SEC / USER_HZ )) == 0
@@ -671,6 +724,12 @@ u64 jiffies_64_to_clock_t(u64 x)
671
724
}
672
725
EXPORT_SYMBOL (jiffies_64_to_clock_t );
673
726
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
+ */
674
733
u64 nsec_to_clock_t (u64 x )
675
734
{
676
735
#if (NSEC_PER_SEC % USER_HZ ) == 0
@@ -687,6 +746,12 @@ u64 nsec_to_clock_t(u64 x)
687
746
#endif
688
747
}
689
748
749
+ /**
750
+ * jiffies64_to_nsecs - Convert jiffies64 to nanoseconds
751
+ * @j: jiffies64 value
752
+ *
753
+ * Return: nanoseconds value
754
+ */
690
755
u64 jiffies64_to_nsecs (u64 j )
691
756
{
692
757
#if !(NSEC_PER_SEC % HZ )
@@ -697,6 +762,12 @@ u64 jiffies64_to_nsecs(u64 j)
697
762
}
698
763
EXPORT_SYMBOL (jiffies64_to_nsecs );
699
764
765
+ /**
766
+ * jiffies64_to_msecs - Convert jiffies64 to milliseconds
767
+ * @j: jiffies64 value
768
+ *
769
+ * Return: milliseconds value
770
+ */
700
771
u64 jiffies64_to_msecs (const u64 j )
701
772
{
702
773
#if HZ <= MSEC_PER_SEC && !(MSEC_PER_SEC % HZ )
@@ -719,6 +790,8 @@ EXPORT_SYMBOL(jiffies64_to_msecs);
719
790
* note:
720
791
* NSEC_PER_SEC = 10^9 = (5^9 * 2^9) = (1953125 * 512)
721
792
* ULLONG_MAX ns = 18446744073.709551615 secs = about 584 years
793
+ *
794
+ * Return: nsecs converted to jiffies64 value
722
795
*/
723
796
u64 nsecs_to_jiffies64 (u64 n )
724
797
{
@@ -750,17 +823,25 @@ EXPORT_SYMBOL(nsecs_to_jiffies64);
750
823
* note:
751
824
* NSEC_PER_SEC = 10^9 = (5^9 * 2^9) = (1953125 * 512)
752
825
* ULLONG_MAX ns = 18446744073.709551615 secs = about 584 years
826
+ *
827
+ * Return: nsecs converted to jiffies value
753
828
*/
754
829
unsigned long nsecs_to_jiffies (u64 n )
755
830
{
756
831
return (unsigned long )nsecs_to_jiffies64 (n );
757
832
}
758
833
EXPORT_SYMBOL_GPL (nsecs_to_jiffies );
759
834
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
+ *
762
841
* It's assumed that both values are valid (>= 0).
763
842
* And, each timespec64 is in normalized form.
843
+ *
844
+ * Return: sum of @lhs + @rhs
764
845
*/
765
846
struct timespec64 timespec64_add_safe (const struct timespec64 lhs ,
766
847
const struct timespec64 rhs )
@@ -778,6 +859,15 @@ struct timespec64 timespec64_add_safe(const struct timespec64 lhs,
778
859
return res ;
779
860
}
780
861
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
+ */
781
871
int get_timespec64 (struct timespec64 * ts ,
782
872
const struct __kernel_timespec __user * uts )
783
873
{
@@ -801,6 +891,14 @@ int get_timespec64(struct timespec64 *ts,
801
891
}
802
892
EXPORT_SYMBOL_GPL (get_timespec64 );
803
893
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
+ */
804
902
int put_timespec64 (const struct timespec64 * ts ,
805
903
struct __kernel_timespec __user * uts )
806
904
{
@@ -839,6 +937,15 @@ static int __put_old_timespec32(const struct timespec64 *ts64,
839
937
return copy_to_user (cts , & ts , sizeof (ts )) ? - EFAULT : 0 ;
840
938
}
841
939
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
+ */
842
949
int get_old_timespec32 (struct timespec64 * ts , const void __user * uts )
843
950
{
844
951
if (COMPAT_USE_64BIT_TIME )
@@ -848,6 +955,16 @@ int get_old_timespec32(struct timespec64 *ts, const void __user *uts)
848
955
}
849
956
EXPORT_SYMBOL_GPL (get_old_timespec32 );
850
957
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
+ */
851
968
int put_old_timespec32 (const struct timespec64 * ts , void __user * uts )
852
969
{
853
970
if (COMPAT_USE_64BIT_TIME )
@@ -857,6 +974,13 @@ int put_old_timespec32(const struct timespec64 *ts, void __user *uts)
857
974
}
858
975
EXPORT_SYMBOL_GPL (put_old_timespec32 );
859
976
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
+ */
860
984
int get_itimerspec64 (struct itimerspec64 * it ,
861
985
const struct __kernel_itimerspec __user * uit )
862
986
{
@@ -872,6 +996,14 @@ int get_itimerspec64(struct itimerspec64 *it,
872
996
}
873
997
EXPORT_SYMBOL_GPL (get_itimerspec64 );
874
998
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
+ */
875
1007
int put_itimerspec64 (const struct itimerspec64 * it ,
876
1008
struct __kernel_itimerspec __user * uit )
877
1009
{
@@ -887,6 +1019,13 @@ int put_itimerspec64(const struct itimerspec64 *it,
887
1019
}
888
1020
EXPORT_SYMBOL_GPL (put_itimerspec64 );
889
1021
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
+ */
890
1029
int get_old_itimerspec32 (struct itimerspec64 * its ,
891
1030
const struct old_itimerspec32 __user * uits )
892
1031
{
@@ -898,6 +1037,14 @@ int get_old_itimerspec32(struct itimerspec64 *its,
898
1037
}
899
1038
EXPORT_SYMBOL_GPL (get_old_itimerspec32 );
900
1039
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
+ */
901
1048
int put_old_itimerspec32 (const struct itimerspec64 * its ,
902
1049
struct old_itimerspec32 __user * uits )
903
1050
{
0 commit comments