diff --git a/include/nuttx/clock.h b/include/nuttx/clock.h index 71718f45064..5ac210c8392 100644 --- a/include/nuttx/clock.h +++ b/include/nuttx/clock.h @@ -817,19 +817,6 @@ void perf_convert(clock_t elapsed, FAR struct timespec *ts); unsigned long perf_getfreq(void); -/**************************************************************************** - * Name: nxclock_settime - * - * Description: - * Clock Functions based on POSIX APIs - * - * CLOCK_REALTIME - POSIX demands this to be present. This is the wall - * time clock. - * - ****************************************************************************/ - -int nxclock_settime(clockid_t clock_id, FAR const struct timespec *tp); - /**************************************************************************** * Name: nxclock_gettime * diff --git a/sched/clock/clock_settime.c b/sched/clock/clock_settime.c index a448e809ea1..cfe749f1f7f 100644 --- a/sched/clock/clock_settime.c +++ b/sched/clock/clock_settime.c @@ -98,50 +98,6 @@ static void nxclock_set_realtime(FAR const struct timespec *tp) * Public Functions ****************************************************************************/ -/**************************************************************************** - * Name: nxclock_settime - * - * Description: - * Clock Functions based on POSIX APIs - * - * CLOCK_REALTIME - POSIX demands this to be present. This is the wall - * time clock. - * - ****************************************************************************/ - -int nxclock_settime(clockid_t clock_id, FAR const struct timespec *tp) -{ - int ret = -EINVAL; - - if (tp == NULL || tp->tv_nsec < 0 || tp->tv_nsec >= 1000000000) - { - return ret; - } - - if (clock_id == CLOCK_REALTIME) - { - nxclock_set_realtime(tp); - return 0; - } -#ifdef CONFIG_PTP_CLOCK - else if ((clock_id & CLOCK_MASK) == CLOCK_FD) - { - FAR struct file *filep; - - ret = ptp_clockid_to_filep(clock_id, &filep); - if (ret < 0) - { - return ret; - } - - ret = file_ioctl(filep, PTP_CLOCK_SETTIME, tp); - fs_putfilep(filep); - } -#endif - - return ret; -} - /**************************************************************************** * Name: clock_settime * @@ -155,9 +111,30 @@ int nxclock_settime(clockid_t clock_id, FAR const struct timespec *tp) int clock_settime(clockid_t clock_id, FAR const struct timespec *tp) { - int ret; + int ret = -EINVAL; + + if (tp != NULL && tp->tv_nsec >= 0 && tp->tv_nsec < 1000000000) + { + if (clock_id == CLOCK_REALTIME) + { + nxclock_set_realtime(tp); + ret = 0; + } +#ifdef CONFIG_PTP_CLOCK + else if ((clock_id & CLOCK_MASK) == CLOCK_FD) + { + FAR struct file *filep; + + ret = ptp_clockid_to_filep(clock_id, &filep); + if (ret >= 0) + { + ret = file_ioctl(filep, PTP_CLOCK_SETTIME, tp); + fs_putfilep(filep); + } + } +#endif + } - ret = nxclock_settime(clock_id, tp); if (ret < 0) { set_errno(-ret);