From cc17ee2ece085d7d746bcd8fa9be19170855aaac Mon Sep 17 00:00:00 2001 From: pgoyette Date: Sun, 27 Jan 2019 02:08:33 +0000 Subject: Merge the [pgoyette-compat] branch --- sys/dev/clockctl.c | 100 ++++++++--------------------------------------------- 1 file changed, 14 insertions(+), 86 deletions(-) (limited to 'sys/dev/clockctl.c') diff --git a/sys/dev/clockctl.c b/sys/dev/clockctl.c index 0cf726e717b..bb8cc1e924d 100644 --- a/sys/dev/clockctl.c +++ b/sys/dev/clockctl.c @@ -1,4 +1,4 @@ -/* $NetBSD: clockctl.c,v 1.35 2016/11/21 03:53:59 rin Exp $ */ +/* $NetBSD: clockctl.c,v 1.36 2019/01/27 02:08:41 pgoyette Exp $ */ /*- * Copyright (c) 2001 The NetBSD Foundation, Inc. @@ -31,7 +31,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: clockctl.c,v 1.35 2016/11/21 03:53:59 rin Exp $"); +__KERNEL_RCSID(0, "$NetBSD: clockctl.c,v 1.36 2019/01/27 02:08:41 pgoyette Exp $"); #ifdef _KERNEL_OPT #include "opt_ntp.h" @@ -46,18 +46,16 @@ __KERNEL_RCSID(0, "$NetBSD: clockctl.c,v 1.35 2016/11/21 03:53:59 rin Exp $"); #include #include #include -#ifdef NTP #include -#endif /* NTP */ #include #include #include +#include #include -#ifdef COMPAT_50 #include #include -#endif + kmutex_t clockctl_mtx; int clockctl_refcnt; @@ -245,101 +243,31 @@ clockctlioctl( error = clock_settime1(l->l_proc, args->clock_id, &ts, false); break; } -#ifdef NTP case CLOCKCTL_NTP_ADJTIME: { struct clockctl_ntp_adjtime *args = data; struct timex ntv; + if (vec_ntp_timestatus == NULL) { + error = ENOTTY; + break; + } error = copyin(args->tp, &ntv, sizeof(ntv)); if (error) return (error); - ntp_adjtime1(&ntv); + (*vec_ntp_adjtime1)(&ntv); error = copyout(&ntv, args->tp, sizeof(ntv)); if (error == 0) - args->retval = ntp_timestatus(); - break; - } -#endif /* NTP */ - default: -#ifdef COMPAT_50 - error = compat50_clockctlioctl(dev, cmd, data, flags, l); -#else - error = ENOTTY; -#endif - } - - return (error); -} - -#ifdef COMPAT_50 -int -compat50_clockctlioctl(dev_t dev, u_long cmd, void *data, int flags, - struct lwp *l) -{ - int error = 0; - const struct cdevsw *cd = cdevsw_lookup(dev); - - if (cd == NULL || cd->d_ioctl == NULL) - return ENXIO; - - switch (cmd) { - case CLOCKCTL_OSETTIMEOFDAY: { - struct timeval50 tv50; - struct timeval tv; - struct clockctl50_settimeofday *args = data; - - error = copyin(args->tv, &tv50, sizeof(tv50)); - if (error) - return (error); - timeval50_to_timeval(&tv50, &tv); - error = settimeofday1(&tv, false, args->tzp, l, false); - break; - } - case CLOCKCTL_OADJTIME: { - struct timeval atv, oldatv; - struct timeval50 atv50; - struct clockctl50_adjtime *args = data; - - if (args->delta) { - error = copyin(args->delta, &atv50, sizeof(atv50)); - if (error) - return (error); - timeval50_to_timeval(&atv50, &atv); - } - adjtime1(args->delta ? &atv : NULL, - args->olddelta ? &oldatv : NULL, l->l_proc); - if (args->olddelta) { - timeval_to_timeval50(&oldatv, &atv50); - error = copyout(&atv50, args->olddelta, sizeof(atv50)); - } - break; - } - case CLOCKCTL_OCLOCK_SETTIME: { - struct timespec50 tp50; - struct timespec tp; - struct clockctl50_clock_settime *args = data; - - error = copyin(args->tp, &tp50, sizeof(tp50)); - if (error) - return (error); - timespec50_to_timespec(&tp50, &tp); - error = clock_settime1(l->l_proc, args->clock_id, &tp, true); + args->retval = (*vec_ntp_timestatus)(); break; } -#ifdef NTP - case CLOCKCTL_ONTP_ADJTIME: { - /* The ioctl number changed but the data did not change. */ - error = (cd->d_ioctl)(dev, CLOCKCTL_NTP_ADJTIME, - data, flags, l); - break; - } -#endif default: - error = ENOTTY; + MODULE_CALL_HOOK(clockctl_ioctl_50_hook, + (dev, cmd, data, flags, l), enosys(), error); + if (error == ENOSYS) + error = ENOTTY; } return (error); } -#endif -- cgit