diff options
| author | pgoyette <pgoyette@NetBSD.org> | 2019-01-27 02:08:33 +0000 |
|---|---|---|
| committer | pgoyette <pgoyette@NetBSD.org> | 2019-01-27 02:08:33 +0000 |
| commit | cc17ee2ece085d7d746bcd8fa9be19170855aaac (patch) | |
| tree | 5be40613f405cb081b2c44410b1506781927f8e3 /sys/dev/clockctl.c | |
| parent | 10dd4cc92542aa04b0e59469a484a48e4c3cdd24 (diff) | |
Merge the [pgoyette-compat] branch
Diffstat (limited to 'sys/dev/clockctl.c')
| -rw-r--r-- | sys/dev/clockctl.c | 100 |
1 files changed, 14 insertions, 86 deletions
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 <sys/cdefs.h> -__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 <sys/device.h> #include <sys/time.h> #include <sys/conf.h> -#ifdef NTP #include <sys/timex.h> -#endif /* NTP */ #include <sys/kauth.h> #include <sys/module.h> #include <sys/mutex.h> +#include <sys/compat_stub.h> #include <sys/clockctl.h> -#ifdef COMPAT_50 #include <compat/sys/clockctl.h> #include <compat/sys/time_types.h> -#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 |
