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.
This commit is contained in:
haad 2009-06-05 19:21:02 +00:00
parent b0b09eac89
commit 7147ed320b
4 changed files with 94 additions and 4 deletions

View File

@ -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 <sys/cdefs.h>
__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 <sys/param.h>
#include <sys/systm.h>
@ -1563,3 +1563,38 @@ printiinfo(struct ccdiinfo *ii)
}
}
#endif
#ifdef _MODULE
#include <sys/module.h>
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

View File

@ -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 <sys/cdefs.h>
__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 <sys/types.h>
#include <sys/param.h>
@ -845,3 +845,38 @@ hexprint(const char *start, void *buf, int len)
printf("%02x", (unsigned char) *c++);
}
#endif
#ifdef _MODULE
#include <sys/module.h>
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

10
sys/modules/ccd/Makefile Normal file
View File

@ -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 <bsd.kmodule.mk>

10
sys/modules/cgd/Makefile Normal file
View File

@ -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 <bsd.kmodule.mk>