Module Name: src
Committed By: pgoyette
Date: Sun Jun 11 22:14:55 UTC 2017
Modified Files:
src/sys/dev/wscons: wsbell.c
Log Message:
Add module infrastructure for wsbell(4)
To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/sys/dev/wscons/wsbell.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/wscons/wsbell.c
diff -u src/sys/dev/wscons/wsbell.c:1.1 src/sys/dev/wscons/wsbell.c:1.2
--- src/sys/dev/wscons/wsbell.c:1.1 Sun Jun 11 03:55:56 2017
+++ src/sys/dev/wscons/wsbell.c Sun Jun 11 22:14:55 2017
@@ -1,4 +1,4 @@
-/* $NetBSD: wsbell.c,v 1.1 2017/06/11 03:55:56 nat Exp $ */
+/* $NetBSD: wsbell.c,v 1.2 2017/06/11 22:14:55 pgoyette Exp $ */
/*-
* Copyright (c) 2017 Nathanial Sloss <[email protected]>
@@ -107,10 +107,11 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: wsbell.c,v 1.1 2017/06/11 03:55:56 nat Exp $");
+__KERNEL_RCSID(0, "$NetBSD: wsbell.c,v 1.2 2017/06/11 22:14:55 pgoyette Exp $");
-#include "wsdisplay.h"
+#if defined(_KERNEL_OPT)
#include "wsmux.h"
+#endif
#include <sys/param.h>
#include <sys/conf.h>
@@ -130,6 +131,7 @@ __KERNEL_RCSID(0, "$NetBSD: wsbell.c,v 1
#include <sys/vnode.h>
#include <sys/callout.h>
#include <sys/malloc.h>
+#include <sys/module.h>
#include <dev/wscons/wsconsio.h>
#include <dev/wscons/wsbellvar.h>
@@ -138,6 +140,8 @@ __KERNEL_RCSID(0, "$NetBSD: wsbell.c,v 1
#include <dev/spkrio.h>
+#include "ioconf.h"
+
#if defined(WSMUX_DEBUG) && NWSMUX > 0
#define DPRINTF(x) if (wsmuxdebug) printf x
#define DPRINTFN(n,x) if (wsmuxdebug > (n)) printf x
@@ -461,3 +465,50 @@ wsbell_mux_close(struct wsevsrc *me)
return (0);
}
#endif /* NWSMUX > 0 */
+
+MODULE(MODULE_CLASS_DRIVER, wsbell, "spkr");
+
+#ifdef _MODULE
+int wsbell_bmajor = -1, wsbell_cmajor = -1;
+
+#include "ioconf.c"
+#endif
+
+static int
+wsbell_modcmd(modcmd_t cmd, void *arg)
+{
+ int error = 0;
+
+ switch (cmd) {
+ case MODULE_CMD_INIT:
+#ifdef _MODULE
+ error = devsw_attach("wsbell", NULL, &wsbell_bmajor,
+ &wsbell_cdevsw, &wsbell_cmajor);
+ if (error)
+ break;
+
+ error = config_init_component(cfdriver_ioconf_wsbell,
+ cfattach_ioconf_wsbell, cfdata_ioconf_wsbell);
+ if (error)
+ devsw_detach(NULL, &wsbell_cdevsw);
+#endif
+ break;
+
+ case MODULE_CMD_FINI:
+#ifdef _MODULE
+ devsw_detach(NULL, &wsbell_cdevsw);
+ error = config_fini_component(cfdriver_ioconf_wsbell,
+ cfattach_ioconf_wsbell, cfdata_ioconf_wsbell);
+ if (error)
+ devsw_attach("wsbell", NULL, &wsbell_bmajor,
+ &wsbell_cdevsw, &wsbell_cmajor);
+#endif
+ break;
+
+ default:
+ error = ENOTTY;
+ break;
+ }
+
+ return error;
+}