/* Returns -EINVAL if sec/nsec are not normalized. Otherwise 0.  */
int poll_select_set_timeout(struct timespec *to, long sec, long nsec)
/* Returns -EINVAL if sec/nsec are not normalized. Otherwise 0.  */
int poll_select_set_timeout(struct timespec *to, long sec, long nsec)
{
	struct timespec ts = {.tv_sec = sec, .tv_nsec = nsec};
	if (!timespec_valid(&ts))
		return -EINVAL;
	if (!sec && !nsec) {
		to->tv_sec = to->tv_nsec = 0;
	} else {
		ktime_get_ts(to);
		*to = timespec_add_safe(*to, ts);
	}
	return 0;
}