Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

time: add kernel-doc in time.c

Add kernel-doc for all APIs that do not already have it.

Signed-off-by: Randy Dunlap <rdunlap@infradead.org>
Cc: John Stultz <jstultz@google.com>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Stephen Boyd <sboyd@kernel.org>
Cc: Jonathan Corbet <corbet@lwn.net>
Cc: linux-doc@vger.kernel.org
Acked-by: John Stultz <jstultz@google.com>
Signed-off-by: Jonathan Corbet <corbet@lwn.net>
Link: https://lore.kernel.org/r/20230704052405.5089-3-rdunlap@infradead.org

authored by

Randy Dunlap and committed by
Jonathan Corbet
67b3f564 6d07a31f

+158 -11
+158 -11
kernel/time/time.c
··· 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 { ··· 391 388 } 392 389 EXPORT_SYMBOL(jiffies_to_msecs); 393 390 391 + /** 392 + * jiffies_to_usecs - Convert jiffies to microseconds 393 + * @j: jiffies value 394 + * 395 + * Return: microseconds value 396 + */ 394 397 unsigned int jiffies_to_usecs(const unsigned long j) 395 398 { 396 399 /* ··· 417 408 } 418 409 EXPORT_SYMBOL(jiffies_to_usecs); 419 410 420 - /* 411 + /** 421 412 * mktime64 - Converts date to seconds. 413 + * @year0: year to convert 414 + * @mon0: month to convert 415 + * @day: day to convert 416 + * @hour: hour to convert 417 + * @min: minute to convert 418 + * @sec: second to convert 419 + * 422 420 * Converts Gregorian date to seconds since 1970-01-01 00:00:00. 423 421 * Assumes input in normal date format, i.e. 1980-12-31 23:59:59 424 422 * => year=1980, mon=12, day=31, hour=23, min=59, sec=59. ··· 443 427 * 444 428 * An encoding of midnight at the end of the day as 24:00:00 - ie. midnight 445 429 * tomorrow - (allowable under ISO 8601) is supported. 430 + * 431 + * Return: seconds since the epoch time for the given input date 446 432 */ 447 433 time64_t mktime64(const unsigned int year0, const unsigned int mon0, 448 434 const unsigned int day, const unsigned int hour, ··· 489 471 * Set seconds and nanoseconds field of a timespec variable and 490 472 * normalize to the timespec storage format 491 473 * 492 - * Note: The tv_nsec part is always in the range of 493 - * 0 <= tv_nsec < NSEC_PER_SEC 474 + * Note: The tv_nsec part is always in the range of 0 <= tv_nsec < NSEC_PER_SEC. 494 475 * For negative values only the tv_sec field is negative ! 495 476 */ 496 477 void set_normalized_timespec64(struct timespec64 *ts, time64_t sec, s64 nsec) ··· 518 501 * ns_to_timespec64 - Convert nanoseconds to timespec64 519 502 * @nsec: the nanoseconds value to be converted 520 503 * 521 - * Returns the timespec64 representation of the nsec parameter. 504 + * Return: the timespec64 representation of the nsec parameter. 522 505 */ 523 506 struct timespec64 ns_to_timespec64(s64 nsec) 524 507 { ··· 565 548 * runtime. 566 549 * The _msecs_to_jiffies helpers are the HZ dependent conversion 567 550 * routines found in include/linux/jiffies.h 551 + * 552 + * Return: jiffies value 568 553 */ 569 554 unsigned long __msecs_to_jiffies(const unsigned int m) 570 555 { ··· 579 560 } 580 561 EXPORT_SYMBOL(__msecs_to_jiffies); 581 562 563 + /** 564 + * __usecs_to_jiffies: - convert microseconds to jiffies 565 + * @u: time in milliseconds 566 + * 567 + * Return: jiffies value 568 + */ 582 569 unsigned long __usecs_to_jiffies(const unsigned int u) 583 570 { 584 571 if (u > jiffies_to_usecs(MAX_JIFFY_OFFSET)) ··· 593 568 } 594 569 EXPORT_SYMBOL(__usecs_to_jiffies); 595 570 596 - /* 571 + /** 572 + * timespec64_to_jiffies - convert a timespec64 value to jiffies 573 + * @value: pointer to &struct timespec64 574 + * 597 575 * The TICK_NSEC - 1 rounds up the value to the next resolution. Note 598 576 * that a remainder subtract here would not do the right thing as the 599 577 * resolution values don't fall on second boundaries. I.e. the line: ··· 610 582 * 611 583 * The >> (NSEC_JIFFIE_SC - SEC_JIFFIE_SC) converts the scaled nsec 612 584 * value to a scaled second value. 585 + * 586 + * Return: jiffies value 613 587 */ 614 - 615 588 unsigned long 616 589 timespec64_to_jiffies(const struct timespec64 *value) 617 590 { ··· 630 601 } 631 602 EXPORT_SYMBOL(timespec64_to_jiffies); 632 603 604 + /** 605 + * jiffies_to_timespec64 - convert jiffies value to &struct timespec64 606 + * @jiffies: jiffies value 607 + * @value: pointer to &struct timespec64 608 + */ 633 609 void 634 610 jiffies_to_timespec64(const unsigned long jiffies, struct timespec64 *value) 635 611 { ··· 652 618 /* 653 619 * Convert jiffies/jiffies_64 to clock_t and back. 654 620 */ 621 + 622 + /** 623 + * jiffies_to_clock_t - Convert jiffies to clock_t 624 + * @x: jiffies value 625 + * 626 + * Return: jiffies converted to clock_t (CLOCKS_PER_SEC) 627 + */ 655 628 clock_t jiffies_to_clock_t(unsigned long x) 656 629 { 657 630 #if (TICK_NSEC % (NSEC_PER_SEC / USER_HZ)) == 0 ··· 673 632 } 674 633 EXPORT_SYMBOL(jiffies_to_clock_t); 675 634 635 + /** 636 + * clock_t_to_jiffies - Convert clock_t to jiffies 637 + * @x: clock_t value 638 + * 639 + * Return: clock_t value converted to jiffies 640 + */ 676 641 unsigned long clock_t_to_jiffies(unsigned long x) 677 642 { 678 643 #if (HZ % USER_HZ)==0 ··· 696 649 } 697 650 EXPORT_SYMBOL(clock_t_to_jiffies); 698 651 652 + /** 653 + * jiffies_64_to_clock_t - Convert jiffies_64 to clock_t 654 + * @x: jiffies_64 value 655 + * 656 + * Return: jiffies_64 value converted to 64-bit "clock_t" (CLOCKS_PER_SEC) 657 + */ 699 658 u64 jiffies_64_to_clock_t(u64 x) 700 659 { 701 660 #if (TICK_NSEC % (NSEC_PER_SEC / USER_HZ)) == 0 ··· 724 671 } 725 672 EXPORT_SYMBOL(jiffies_64_to_clock_t); 726 673 674 + /** 675 + * nsec_to_clock_t - Convert nsec value to clock_t 676 + * @x: nsec value 677 + * 678 + * Return: nsec value converted to 64-bit "clock_t" (CLOCKS_PER_SEC) 679 + */ 727 680 u64 nsec_to_clock_t(u64 x) 728 681 { 729 682 #if (NSEC_PER_SEC % USER_HZ) == 0 ··· 746 687 #endif 747 688 } 748 689 690 + /** 691 + * jiffies64_to_nsecs - Convert jiffies64 to nanoseconds 692 + * @j: jiffies64 value 693 + * 694 + * Return: nanoseconds value 695 + */ 749 696 u64 jiffies64_to_nsecs(u64 j) 750 697 { 751 698 #if !(NSEC_PER_SEC % HZ) ··· 762 697 } 763 698 EXPORT_SYMBOL(jiffies64_to_nsecs); 764 699 700 + /** 701 + * jiffies64_to_msecs - Convert jiffies64 to milliseconds 702 + * @j: jiffies64 value 703 + * 704 + * Return: milliseconds value 705 + */ 765 706 u64 jiffies64_to_msecs(const u64 j) 766 707 { 767 708 #if HZ <= MSEC_PER_SEC && !(MSEC_PER_SEC % HZ) ··· 790 719 * note: 791 720 * NSEC_PER_SEC = 10^9 = (5^9 * 2^9) = (1953125 * 512) 792 721 * ULLONG_MAX ns = 18446744073.709551615 secs = about 584 years 722 + * 723 + * Return: nsecs converted to jiffies64 value 793 724 */ 794 725 u64 nsecs_to_jiffies64(u64 n) 795 726 { ··· 823 750 * note: 824 751 * NSEC_PER_SEC = 10^9 = (5^9 * 2^9) = (1953125 * 512) 825 752 * ULLONG_MAX ns = 18446744073.709551615 secs = about 584 years 753 + * 754 + * Return: nsecs converted to jiffies value 826 755 */ 827 756 unsigned long nsecs_to_jiffies(u64 n) 828 757 { ··· 832 757 } 833 758 EXPORT_SYMBOL_GPL(nsecs_to_jiffies); 834 759 835 - /* 836 - * Add two timespec64 values and do a safety check for overflow. 760 + /** 761 + * timespec64_add_safe - Add two timespec64 values and do a safety check 762 + * for overflow. 763 + * @lhs: first (left) timespec64 to add 764 + * @rhs: second (right) timespec64 to add 765 + * 837 766 * It's assumed that both values are valid (>= 0). 838 767 * And, each timespec64 is in normalized form. 768 + * 769 + * Return: sum of @lhs + @rhs 839 770 */ 840 771 struct timespec64 timespec64_add_safe(const struct timespec64 lhs, 841 772 const struct timespec64 rhs) ··· 859 778 return res; 860 779 } 861 780 781 + /** 782 + * get_timespec64 - get user's time value into kernel space 783 + * @ts: destination &struct timespec64 784 + * @uts: user's time value as &struct __kernel_timespec 785 + * 786 + * Handles compat or 32-bit modes. 787 + * 788 + * Return: %0 on success or negative errno on error 789 + */ 862 790 int get_timespec64(struct timespec64 *ts, 863 791 const struct __kernel_timespec __user *uts) 864 792 { ··· 891 801 } 892 802 EXPORT_SYMBOL_GPL(get_timespec64); 893 803 804 + /** 805 + * put_timespec64 - convert timespec64 value to __kernel_timespec format and 806 + * copy the latter to userspace 807 + * @ts: input &struct timespec64 808 + * @uts: user's &struct __kernel_timespec 809 + * 810 + * Return: %0 on success or negative errno on error 811 + */ 894 812 int put_timespec64(const struct timespec64 *ts, 895 813 struct __kernel_timespec __user *uts) 896 814 { ··· 937 839 return copy_to_user(cts, &ts, sizeof(ts)) ? -EFAULT : 0; 938 840 } 939 841 842 + /** 843 + * get_old_timespec32 - get user's old-format time value into kernel space 844 + * @ts: destination &struct timespec64 845 + * @uts: user's old-format time value (&struct old_timespec32) 846 + * 847 + * Handles X86_X32_ABI compatibility conversion. 848 + * 849 + * Return: %0 on success or negative errno on error 850 + */ 940 851 int get_old_timespec32(struct timespec64 *ts, const void __user *uts) 941 852 { 942 853 if (COMPAT_USE_64BIT_TIME) ··· 955 848 } 956 849 EXPORT_SYMBOL_GPL(get_old_timespec32); 957 850 851 + /** 852 + * put_old_timespec32 - convert timespec64 value to &struct old_timespec32 and 853 + * copy the latter to userspace 854 + * @ts: input &struct timespec64 855 + * @uts: user's &struct old_timespec32 856 + * 857 + * Handles X86_X32_ABI compatibility conversion. 858 + * 859 + * Return: %0 on success or negative errno on error 860 + */ 958 861 int put_old_timespec32(const struct timespec64 *ts, void __user *uts) 959 862 { 960 863 if (COMPAT_USE_64BIT_TIME) ··· 974 857 } 975 858 EXPORT_SYMBOL_GPL(put_old_timespec32); 976 859 860 + /** 861 + * get_itimerspec64 - get user's &struct __kernel_itimerspec into kernel space 862 + * @it: destination &struct itimerspec64 863 + * @uit: user's &struct __kernel_itimerspec 864 + * 865 + * Return: %0 on success or negative errno on error 866 + */ 977 867 int get_itimerspec64(struct itimerspec64 *it, 978 868 const struct __kernel_itimerspec __user *uit) 979 869 { ··· 996 872 } 997 873 EXPORT_SYMBOL_GPL(get_itimerspec64); 998 874 875 + /** 876 + * put_itimerspec64 - convert &struct itimerspec64 to __kernel_itimerspec format 877 + * and copy the latter to userspace 878 + * @it: input &struct itimerspec64 879 + * @uit: user's &struct __kernel_itimerspec 880 + * 881 + * Return: %0 on success or negative errno on error 882 + */ 999 883 int put_itimerspec64(const struct itimerspec64 *it, 1000 884 struct __kernel_itimerspec __user *uit) 1001 885 { ··· 1019 887 } 1020 888 EXPORT_SYMBOL_GPL(put_itimerspec64); 1021 889 890 + /** 891 + * get_old_itimerspec32 - get user's &struct old_itimerspec32 into kernel space 892 + * @its: destination &struct itimerspec64 893 + * @uits: user's &struct old_itimerspec32 894 + * 895 + * Return: %0 on success or negative errno on error 896 + */ 1022 897 int get_old_itimerspec32(struct itimerspec64 *its, 1023 898 const struct old_itimerspec32 __user *uits) 1024 899 { ··· 1037 898 } 1038 899 EXPORT_SYMBOL_GPL(get_old_itimerspec32); 1039 900 901 + /** 902 + * put_old_itimerspec32 - convert &struct itimerspec64 to &struct 903 + * old_itimerspec32 and copy the latter to userspace 904 + * @its: input &struct itimerspec64 905 + * @uits: user's &struct old_itimerspec32 906 + * 907 + * Return: %0 on success or negative errno on error 908 + */ 1040 909 int put_old_itimerspec32(const struct itimerspec64 *its, 1041 910 struct old_itimerspec32 __user *uits) 1042 911 {