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

ipmi: kill off 'timespec' usage again

'struct timespec' is getting removed from the kernel. The usage in ipmi
was fixed before in commit 48862ea2ce86 ("ipmi: Update timespec usage
to timespec64"), but unfortunately it crept back in.

The busy looping code can better use ktime_t anyway, so use that
there to simplify the implementation.

Fixes: cbb19cb1eef0 ("ipmi_si: Convert timespec64 to timespec")
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Message-Id: <20191108203435.112759-5-arnd@arndb.de>
Signed-off-by: Corey Minyard <cminyard@mvista.com>

authored by

Arnd Bergmann and committed by
Corey Minyard
8d73b2ae 0d8633bf

+13 -27
+13 -27
drivers/char/ipmi/ipmi_si_intf.c
··· 265 265 #ifdef DEBUG_TIMING 266 266 void debug_timestamp(char *msg) 267 267 { 268 - struct timespec t; 268 + struct timespec64 t; 269 269 270 - ktime_get_ts(&t); 271 - pr_debug("**%s: %ld.%9.9ld\n", msg, (long) t.tv_sec, t.tv_nsec); 270 + ktime_get_ts64(&t); 271 + pr_debug("**%s: %lld.%9.9ld\n", msg, t.tv_sec, t.tv_nsec); 272 272 } 273 273 #else 274 274 #define debug_timestamp(x) ··· 935 935 } 936 936 937 937 /* 938 - * Use -1 in the nsec value of the busy waiting timespec to tell that 939 - * we are spinning in kipmid looking for something and not delaying 940 - * between checks 938 + * Use -1 as a special constant to tell that we are spinning in kipmid 939 + * looking for something and not delaying between checks 941 940 */ 942 - static inline void ipmi_si_set_not_busy(struct timespec *ts) 943 - { 944 - ts->tv_nsec = -1; 945 - } 946 - static inline int ipmi_si_is_busy(struct timespec *ts) 947 - { 948 - return ts->tv_nsec != -1; 949 - } 950 - 941 + #define IPMI_TIME_NOT_BUSY ns_to_ktime(-1ull) 951 942 static inline bool ipmi_thread_busy_wait(enum si_sm_result smi_result, 952 943 const struct smi_info *smi_info, 953 - struct timespec *busy_until) 944 + ktime_t *busy_until) 954 945 { 955 946 unsigned int max_busy_us = 0; 956 947 957 948 if (smi_info->si_num < num_max_busy_us) 958 949 max_busy_us = kipmid_max_busy_us[smi_info->si_num]; 959 950 if (max_busy_us == 0 || smi_result != SI_SM_CALL_WITH_DELAY) 960 - ipmi_si_set_not_busy(busy_until); 961 - else if (!ipmi_si_is_busy(busy_until)) { 962 - ktime_get_ts(busy_until); 963 - timespec_add_ns(busy_until, max_busy_us * NSEC_PER_USEC); 951 + *busy_until = IPMI_TIME_NOT_BUSY; 952 + else if (*busy_until == IPMI_TIME_NOT_BUSY) { 953 + *busy_until = ktime_get() + max_busy_us * NSEC_PER_USEC; 964 954 } else { 965 - struct timespec now; 966 - 967 - ktime_get_ts(&now); 968 - if (unlikely(timespec_compare(&now, busy_until) > 0)) { 969 - ipmi_si_set_not_busy(busy_until); 955 + if (unlikely(ktime_get() > *busy_until)) { 956 + *busy_until = IPMI_TIME_NOT_BUSY; 970 957 return false; 971 958 } 972 959 } ··· 975 988 struct smi_info *smi_info = data; 976 989 unsigned long flags; 977 990 enum si_sm_result smi_result; 978 - struct timespec busy_until = { 0, 0 }; 991 + ktime_t busy_until = IPMI_TIME_NOT_BUSY; 979 992 980 - ipmi_si_set_not_busy(&busy_until); 981 993 set_user_nice(current, MAX_NICE); 982 994 while (!kthread_should_stop()) { 983 995 int busy_wait;