Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys Add support for building pud as module. Do it in a same ...



details:   https://anonhg.NetBSD.org/src/rev/8cc9f6c1e077
branches:  trunk
changeset: 761474:8cc9f6c1e077
user:      haad <haad%NetBSD.org@localhost>
date:      Fri Jan 28 23:54:28 2011 +0000

description:
Add support for building pud as module. Do it in a same way how putter is
done.

diffstat:

 sys/dev/pud/pud.c        |  30 ++++++++++++++++++++++++++++--
 sys/modules/pud/Makefile |  10 ++++++++++
 2 files changed, 38 insertions(+), 2 deletions(-)

diffs (66 lines):

diff -r f9038840af5c -r 8cc9f6c1e077 sys/dev/pud/pud.c
--- a/sys/dev/pud/pud.c Fri Jan 28 22:15:35 2011 +0000
+++ b/sys/dev/pud/pud.c Fri Jan 28 23:54:28 2011 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: pud.c,v 1.8 2009/03/18 10:22:41 cegger Exp $   */
+/*     $NetBSD: pud.c,v 1.9 2011/01/28 23:54:28 haad Exp $     */
 
 /*
  * Copyright (c) 2007  Antti Kantee.  All Rights Reserved.
@@ -29,11 +29,12 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: pud.c,v 1.8 2009/03/18 10:22:41 cegger Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pud.c,v 1.9 2011/01/28 23:54:28 haad Exp $");
 
 #include <sys/param.h>
 #include <sys/conf.h>
 #include <sys/kmem.h>
+#include <sys/module.h>
 #include <sys/poll.h>
 #include <sys/queue.h>
 
@@ -381,3 +382,28 @@
        }
        mutex_init(&pud_mtx, MUTEX_DEFAULT, IPL_NONE);
 }
+
+MODULE(MODULE_CLASS_DRIVER, pud, putter);
+
+static int
+pud_modcmd(modcmd_t cmd, void *arg)
+{
+       #ifdef _MODULE
+       devmajor_t bmajor = NODEVMAJOR, cmajor = NODEVMAJOR;
+
+       switch (cmd) {
+       case MODULE_CMD_INIT:
+               pudattach();
+               return devsw_attach("pud", NULL, &bmajor,
+                   &pud_cdevsw, &cmajor);
+       case MODULE_CMD_FINI:
+               return ENOTTY; /* XXX: puddetach */
+       default:
+               return ENOTTY;
+       }
+       #else
+       if (cmd == MODULE_CMD_INIT)
+               return 0;
+       return ENOTTY;
+       #endif
+}
diff -r f9038840af5c -r 8cc9f6c1e077 sys/modules/pud/Makefile
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/sys/modules/pud/Makefile  Fri Jan 28 23:54:28 2011 +0000
@@ -0,0 +1,10 @@
+# $NetBSD: Makefile,v 1.1 2011/01/28 23:54:28 haad Exp $
+
+.include "../Makefile.inc"
+
+.PATH: ${S}/dev/pud
+
+KMOD=  pud
+SRCS=  pud.c pud_dev.c
+
+.include <bsd.kmodule.mk>



Home | Main Index | Thread Index | Old Index