summaryrefslogtreecommitdiff
path: root/sys/dev
diff options
context:
space:
mode:
authorpgoyette <pgoyette@NetBSD.org>2016-01-05 09:37:11 +0000
committerpgoyette <pgoyette@NetBSD.org>2016-01-05 09:37:11 +0000
commit1ff667afe4a0bd614369e8a603a024b5ed991dad (patch)
treef31960c52cf43b7920b36ae0dd544357b19f44d1 /sys/dev
parente6be45e3bbb349211c117f2ebe9837fc23c30fdb (diff)
Although not recommended, it is possible to include filemon(4) as a
built-in module. If we do this, don't try to call devsw_attach() as our device structures will already have been included via ioconf.[ch]. This avoids calling the init routine twice (once for CLASS_DRIVER and then later for CLASS_ANY), which in turn avoids trying to initialize an already initialized lock.
Diffstat (limited to 'sys/dev')
-rw-r--r--sys/dev/filemon/filemon.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/sys/dev/filemon/filemon.c b/sys/dev/filemon/filemon.c
index fe87d6e1e2e..1fe8d0fb442 100644
--- a/sys/dev/filemon/filemon.c
+++ b/sys/dev/filemon/filemon.c
@@ -1,4 +1,4 @@
-/* $NetBSD: filemon.c,v 1.22 2015/11/25 07:34:49 pgoyette Exp $ */
+/* $NetBSD: filemon.c,v 1.23 2016/01/05 09:37:11 pgoyette Exp $ */
/*
* Copyright (c) 2010, Juniper Networks, Inc.
*
@@ -25,7 +25,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: filemon.c,v 1.22 2015/11/25 07:34:49 pgoyette Exp $");
+__KERNEL_RCSID(0, "$NetBSD: filemon.c,v 1.23 2016/01/05 09:37:11 pgoyette Exp $");
#include <sys/param.h>
#include <sys/kernel.h>
@@ -391,8 +391,10 @@ static int
filemon_modcmd(modcmd_t cmd, void *data)
{
int error = 0;
+#ifdef _MODULE
int bmajor = -1;
int cmajor = -1;
+#endif
switch (cmd) {
case MODULE_CMD_INIT:
@@ -401,15 +403,19 @@ filemon_modcmd(modcmd_t cmd, void *data)
#endif
error = filemon_load(data);
+#ifdef _MODULE
if (!error)
error = devsw_attach("filemon", NULL, &bmajor,
&filemon_cdevsw, &cmajor);
+#endif
break;
case MODULE_CMD_FINI:
error = filemon_unload();
+#ifdef _MODULE
if (!error)
error = devsw_detach(NULL, &filemon_cdevsw);
+#endif
break;
case MODULE_CMD_STAT: