Module Name: src Committed By: christos Date: Wed Jan 6 18:06:38 UTC 2016
Modified Files: src/sys/dev: clockctl.c Log Message: Simplify and fix the unload to destroy the mutex. To reproduce, configure a kernel with LOCKDEBUG make clockctl a module: /etc/rc.d/ntpd stop modunload clockctl /etc/rc.d/ntpd start boom. To generate a diff of this commit: cvs rdiff -u -r1.33 -r1.34 src/sys/dev/clockctl.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/sys/dev/clockctl.c diff -u src/sys/dev/clockctl.c:1.33 src/sys/dev/clockctl.c:1.34 --- src/sys/dev/clockctl.c:1.33 Sun Dec 6 22:25:57 2015 +++ src/sys/dev/clockctl.c Wed Jan 6 13:06:38 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: clockctl.c,v 1.33 2015/12/07 03:25:57 pgoyette Exp $ */ +/* $NetBSD: clockctl.c,v 1.34 2016/01/06 18:06:38 christos Exp $ */ /*- * Copyright (c) 2001 The NetBSD Foundation, Inc. @@ -31,7 +31,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: clockctl.c,v 1.33 2015/12/07 03:25:57 pgoyette Exp $"); +__KERNEL_RCSID(0, "$NetBSD: clockctl.c,v 1.34 2016/01/06 18:06:38 christos Exp $"); #ifdef _KERNEL_OPT #include "opt_ntp.h" @@ -52,7 +52,6 @@ __KERNEL_RCSID(0, "$NetBSD: clockctl.c,v #include <sys/kauth.h> #include <sys/module.h> #include <sys/mutex.h> -#include <sys/once.h> #include <sys/clockctl.h> #ifdef COMPAT_50 @@ -63,8 +62,6 @@ __KERNEL_RCSID(0, "$NetBSD: clockctl.c,v kmutex_t clockctl_mtx; int clockctl_refcnt; -ONCE_DECL(clockctl_once); - #include "ioconf.h" dev_type_ioctl(clockctlioctl); @@ -151,15 +148,6 @@ clockctlclose(dev_t dev, int flag, int m return 0; } -int -clockctl_init(void) -{ - - mutex_init(&clockctl_mtx, MUTEX_DEFAULT, IPL_NONE); - clockctl_refcnt = 0; - return 0; -} - MODULE(MODULE_CLASS_DRIVER, clockctl, NULL); int @@ -174,7 +162,7 @@ clockctl_modcmd(modcmd_t cmd, void *data switch (cmd) { case MODULE_CMD_INIT: - RUN_ONCE(&clockctl_once, clockctl_init); + mutex_init(&clockctl_mtx, MUTEX_DEFAULT, IPL_NONE); clockctl_listener = kauth_listen_scope(KAUTH_SCOPE_SYSTEM, clockctl_listener_cb, NULL); @@ -200,9 +188,10 @@ clockctl_modcmd(modcmd_t cmd, void *data #endif mutex_exit(&clockctl_mtx); - if (error == 0) + if (error == 0) { kauth_unlisten_scope(clockctl_listener); - + mutex_destroy(&clockctl_mtx); + } break; default: