From 7147ed320b84515bec243f541948f7cb9edeca1e Mon Sep 17 00:00:00 2001 From: haad Date: Fri, 5 Jun 2009 19:21:02 +0000 Subject: [PATCH] Add work in support for compiling ccd and cgd drivers as a modules. I forgot to committ when I have written device module autoloading stuff. --- sys/dev/ccd.c | 39 +++++++++++++++++++++++++++++++++++++-- sys/dev/cgd.c | 39 +++++++++++++++++++++++++++++++++++++-- sys/modules/ccd/Makefile | 10 ++++++++++ sys/modules/cgd/Makefile | 10 ++++++++++ 4 files changed, 94 insertions(+), 4 deletions(-) create mode 100644 sys/modules/ccd/Makefile create mode 100644 sys/modules/cgd/Makefile diff --git a/sys/dev/ccd.c b/sys/dev/ccd.c index c7f817e04deb..ba43020f7a19 100644 --- a/sys/dev/ccd.c +++ b/sys/dev/ccd.c @@ -1,4 +1,4 @@ -/* $NetBSD: ccd.c,v 1.133 2009/04/04 08:29:39 ad Exp $ */ +/* $NetBSD: ccd.c,v 1.134 2009/06/05 19:21:02 haad Exp $ */ /*- * Copyright (c) 1996, 1997, 1998, 1999, 2007, 2009 The NetBSD Foundation, Inc. @@ -127,7 +127,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: ccd.c,v 1.133 2009/04/04 08:29:39 ad Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ccd.c,v 1.134 2009/06/05 19:21:02 haad Exp $"); #include #include @@ -1563,3 +1563,38 @@ printiinfo(struct ccdiinfo *ii) } } #endif + +#ifdef _MODULE + +#include + +MODULE(MODULE_CLASS_DRIVER, ccd, NULL); + +static int +ccd_modcmd(modcmd_t cmd, void *arg) +{ + int bmajor = -1, cmajor = -1, error = 0; + + switch (cmd) { + case MODULE_CMD_INIT: + ccdattach(4); + + return devsw_attach("ccd", &ccd_bdevsw, &bmajor, + &ccd_cdevsw, &cmajor); + break; + + case MODULE_CMD_FINI: + return devsw_detach(&ccd_bdevsw, &ccd_cdevsw); + break; + + case MODULE_CMD_STAT: + return ENOTTY; + + default: + return ENOTTY; + } + + return error; +} + +#endif diff --git a/sys/dev/cgd.c b/sys/dev/cgd.c index 8ece18f2afb2..b26bd647f4a4 100644 --- a/sys/dev/cgd.c +++ b/sys/dev/cgd.c @@ -1,4 +1,4 @@ -/* $NetBSD: cgd.c,v 1.57 2009/03/14 17:56:47 apb Exp $ */ +/* $NetBSD: cgd.c,v 1.58 2009/06/05 19:21:02 haad Exp $ */ /*- * Copyright (c) 2002 The NetBSD Foundation, Inc. @@ -30,7 +30,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: cgd.c,v 1.57 2009/03/14 17:56:47 apb Exp $"); +__KERNEL_RCSID(0, "$NetBSD: cgd.c,v 1.58 2009/06/05 19:21:02 haad Exp $"); #include #include @@ -845,3 +845,38 @@ hexprint(const char *start, void *buf, int len) printf("%02x", (unsigned char) *c++); } #endif + +#ifdef _MODULE + +#include + +MODULE(MODULE_CLASS_DRIVER, cgd, NULL); + +static int +cgd_modcmd(modcmd_t cmd, void *arg) +{ + int bmajor = -1, cmajor = -1, error = 0; + + switch (cmd) { + case MODULE_CMD_INIT: + cgdattach(4); + + return devsw_attach("cgd", &cgd_bdevsw, &bmajor, + &cgd_cdevsw, &cmajor); + break; + + case MODULE_CMD_FINI: + return devsw_detach(&cgd_bdevsw, &cgd_cdevsw); + break; + + case MODULE_CMD_STAT: + return ENOTTY; + + default: + return ENOTTY; + } + + return error; +} + +#endif diff --git a/sys/modules/ccd/Makefile b/sys/modules/ccd/Makefile new file mode 100644 index 000000000000..7b1b8f148d4c --- /dev/null +++ b/sys/modules/ccd/Makefile @@ -0,0 +1,10 @@ +# $NetBSD: Makefile,v 1.1 2009/06/05 19:21:03 haad Exp $ + +.include "../Makefile.inc" + +.PATH: ${S}/dev + +KMOD= ccd +SRCS= ccd.c + +.include diff --git a/sys/modules/cgd/Makefile b/sys/modules/cgd/Makefile new file mode 100644 index 000000000000..b85f27d02c34 --- /dev/null +++ b/sys/modules/cgd/Makefile @@ -0,0 +1,10 @@ +# $NetBSD: Makefile,v 1.1 2009/06/05 19:21:03 haad Exp $ + +.include "../Makefile.inc" + +.PATH: ${S}/dev + +KMOD= cgd +SRCS= cgd.c cgd_crypto.c + +.include