fs: rename poll_select_set_timeout() to set_normalized_timeout()
Subsystems (5)
PATCH 1/1 fs: rename poll_select_set_timeout() to set_normalized_timeout()
From: yuan linyu <[email protected]>
addtional move it to include/linux/timekeeping.h.
reason to do this is poll_select_set_timeout() called by some functions which are not poll functions, and it's a pure time function, make it common.
Signed-off-by yuan linyu <[email protected]>
--- arch/alpha/kernel/osf_sys.c | 3 +-- fs/compat.c | 6 +++--- fs/select.c | 39 ++++++--------------------------------- include/linux/poll.h | 3 --- include/linux/timekeeping.h | 27 +++++++++++++++++++++++++++ net/socket.c | 2 +- 6 files changed, 38 insertions(+), 42 deletions(-)
arch/alpha/kernel/osf_sys.c +1 -2
@@ -27,7 +27,6 @@#include <linux/stat.h> #include <linux/mman.h> #include <linux/shm.h> -#include <linux/poll.h> #include <linux/file.h> #include <linux/types.h> #include <linux/ipc.h>
@@ -1114,7 +1113,7 @@ SYSCALL_DEFINE5(osf_select, int, n, fd_set __user *, inp, fd_set __user *, outp,if (sec <0 || usec <0 )return -EINVAL ; -if (poll_select_set_timeout (to, sec, usec *NSEC_PER_USEC )) +if (set_normalized_timeout (to, sec, usec *NSEC_PER_USEC ))return -EINVAL ; }
fs/compat.c +3 -3
@@ -1229,7 +1229,7 @@ COMPAT_SYSCALL_DEFINE5(select, int, n, compat_ulong_t __user *, inp,return -EFAULT ; to = &end_time; -if (poll_select_set_timeout (to, +if (set_normalized_timeout (to, tv.tv_sec + (tv.tv_usec /USEC_PER_SEC ), (tv.tv_usec %USEC_PER_SEC ) *NSEC_PER_USEC ))return -EINVAL ;
@@ -1275,7 +1275,7 @@ static long do_compat_pselect(int n, compat_ulong_t __user *inp,return -EFAULT ; to = &end_time; -if (poll_select_set_timeout (to, ts.tv_sec, ts.tv_nsec)) +if (set_normalized_timeout (to, ts.tv_sec, ts.tv_nsec))return -EINVAL ; }
@@ -1344,7 +1344,7 @@ COMPAT_SYSCALL_DEFINE5(ppoll, struct pollfd __user *, ufds,return -EFAULT ; to = &end_time; -if (poll_select_set_timeout (to, ts.tv_sec, ts.tv_nsec)) +if (set_normalized_timeout (to, ts.tv_sec, ts.tv_nsec))return -EINVAL ; }
fs/select.c +6 -33
@@ -259,34 +259,6 @@ int poll_schedule_timeout(struct poll_wqueues *pwq, int state, }EXPORT_SYMBOL (poll_schedule_timeout); -/** -* poll_select_set_timeout - helper function to setup the timeout value -* @to: pointer to timespec64 variable for the final timeout -* @sec: seconds (from user space) -* @nsec: nanoseconds (from user space) -* -* Note, we do not use a timespec for the user space value here, That -* way we can use the function for timeval and compat interfaces as well. -* -* Returns -EINVAL if sec/nsec are not normalized. Otherwise 0. -*/ -int poll_select_set_timeout (struct timespec64 *to,time64_t sec,long nsec) -{ -struct timespec64 ts = {.tv_sec = sec, .tv_nsec = nsec}; - -if (!timespec64_valid (&ts)) -return -EINVAL ; - -/* Optimize for the zero timeout value here */ -if (!sec && !nsec) { - to->tv_sec = to->tv_nsec =0 ; - }else { -ktime_get_ts64 (to); - *to =timespec64_add_safe (*to, ts); - } -return 0 ; -} -static int poll_select_copy_remaining (struct timespec64 *end_time,void __user *p,int timeval,int ret)
@@ -643,7 +615,7 @@ SYSCALL_DEFINE5(select, int, n, fd_set __user *, inp, fd_set __user *, outp,return -EFAULT ; to = &end_time; -if (poll_select_set_timeout (to, +if (set_normalized_timeout (to, tv.tv_sec + (tv.tv_usec /USEC_PER_SEC ), (tv.tv_usec %USEC_PER_SEC ) *NSEC_PER_USEC ))return -EINVAL ;
@@ -670,7 +642,7 @@ static long do_pselect(int n, fd_set __user *inp, fd_set __user *outp, ts64 =timespec_to_timespec64 (ts); to = &end_time; -if (poll_select_set_timeout (to, ts64.tv_sec, ts64.tv_nsec)) +if (set_normalized_timeout (to, ts64.tv_sec, ts64.tv_nsec))return -EINVAL ; }
@@ -976,8 +948,9 @@ SYSCALL_DEFINE3(poll, struct pollfd __user *, ufds, unsigned int, nfds,if (timeout_msecs >=0 ) { to = &end_time; -poll_select_set_timeout (to, timeout_msecs /MSEC_PER_SEC , -NSEC_PER_MSEC * (timeout_msecs %MSEC_PER_SEC )); +if (set_normalized_timeout (to, timeout_msecs /MSEC_PER_SEC , +NSEC_PER_MSEC * (timeout_msecs %MSEC_PER_SEC ))) +return -EINVAL ; } ret =do_sys_poll (ufds, nfds, to);
@@ -1016,7 +989,7 @@ SYSCALL_DEFINE5(ppoll, struct pollfd __user *, ufds, unsigned int, nfds,return -EFAULT ; to = &end_time; -if (poll_select_set_timeout (to, ts.tv_sec, ts.tv_nsec)) +if (set_normalized_timeout (to, ts.tv_sec, ts.tv_nsec))return -EINVAL ; }
include/linux/poll.h +0 -3
@@ -159,7 +159,4 @@ extern int do_sys_poll(struct pollfd __user * ufds, unsigned int nfds,extern int core_sys_select (int n,fd_set __user *inp,fd_set __user *outp,fd_set __user *exp,struct timespec64 *end_time); -extern int poll_select_set_timeout (struct timespec64 *to,time64_t sec, -long nsec); -#endif /* _LINUX_POLL_H */
include/linux/timekeeping.h +27 -0
@@ -352,5 +352,32 @@ extern void read_boot_clock64(struct timespec64 *ts);extern int update_persistent_clock (struct timespec now);extern int update_persistent_clock64 (struct timespec64 now); +/** +* set_normalized_timeout - helper function to setup the timeout value +* @to: pointer to timespec64 variable for the final timeout +* @sec: seconds (from user space) +* @nsec: nanoseconds (from user space) +* +* Note, we do not use a timespec for the user space value here, That +* way we can use the function for timeval and compat interfaces as well. +* +* Returns -EINVAL if sec/nsec are not normalized. Otherwise 0. +*/ +static inline int set_normalized_timeout (struct timespec64 *to,time64_t sec,long nsec) +{ +struct timespec64 ts = {.tv_sec = sec, .tv_nsec = nsec}; + +if (!timespec64_valid (&ts)) +return -EINVAL ; + +/* Optimize for the zero timeout value here */ +if (!sec && !nsec) { + to->tv_sec = to->tv_nsec =0 ; + }else { +ktime_get_ts64 (to); + *to =timespec64_add_safe (*to, ts); + } +return 0 ; +}#endif
net/socket.c +1 -1
@@ -2217,7 +2217,7 @@ int __sys_recvmmsg(int fd, struct mmsghdr __user *mmsg, unsigned int vlen,struct timespec64 timeout64;if (timeout && -poll_select_set_timeout (&end_time, timeout->tv_sec, +set_normalized_timeout (&end_time, timeout->tv_sec, timeout->tv_nsec))return -EINVAL ;
Signature · 1 line
2.7.4