Remove the devsw magic from DEV_MODULE()

This commit is contained in:
Poul-Henning Kamp 1999-11-07 10:01:17 +00:00
parent 74d8e84034
commit d53dedee55
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=52965
7 changed files with 23 additions and 29 deletions

View File

@ -242,6 +242,16 @@ promtimeout(v)
promtimeouthandle = timeout(promtimeout, tp, polltime);
}
DEV_MODULE(prom, CDEV_MAJOR, NOMAJ, prom_cdevsw, 0, 0);
static int
prom_modevent(module_t mod, int type, void *data)
{
if (type == MOD_LOAD) {
cdevsw_add(&prom_cdevsw);
return(0);
}
return(EOPNOTSUPP);
}
DEV_MODULE(prom, prom_modevent, 0);
#endif /* _PMAP_MAY_USE_PROM_CONSOLE */

View File

@ -322,6 +322,7 @@ ccdattach()
bzero(ccd_softc, num * sizeof(struct ccd_softc));
bzero(ccddevs, num * sizeof(struct ccddevice));
cdevsw_add(&ccd_cdevsw);
/* XXX: is this necessary? */
for (i = 0; i < numccd; ++i)
ccddevs[i].ccd_dk = -1;
@ -351,7 +352,7 @@ ccd_modevent(mod, type, data)
return (error);
}
DEV_MODULE(ccd, CDEV_MAJOR, BDEV_MAJOR, ccd_cdevsw, ccd_modevent, NULL);
DEV_MODULE(ccd, ccd_modevent, NULL);
static int
ccdinit(ccd, cpaths, p)

View File

@ -743,6 +743,7 @@ vn_modevent(module_t mod, int type, void *data)
switch (type) {
case MOD_LOAD:
cdevsw_add(&vn_cdevsw);
break;
case MOD_UNLOAD:
@ -764,4 +765,4 @@ vn_modevent(module_t mod, int type, void *data)
return 0;
}
DEV_MODULE(vn, CDEV_MAJOR, BDEV_MAJOR, vn_cdevsw, vn_modevent, 0);
DEV_MODULE(vn, vn_modevent, 0);

View File

@ -322,6 +322,7 @@ ccdattach()
bzero(ccd_softc, num * sizeof(struct ccd_softc));
bzero(ccddevs, num * sizeof(struct ccddevice));
cdevsw_add(&ccd_cdevsw);
/* XXX: is this necessary? */
for (i = 0; i < numccd; ++i)
ccddevs[i].ccd_dk = -1;
@ -351,7 +352,7 @@ ccd_modevent(mod, type, data)
return (error);
}
DEV_MODULE(ccd, CDEV_MAJOR, BDEV_MAJOR, ccd_cdevsw, ccd_modevent, NULL);
DEV_MODULE(ccd, ccd_modevent, NULL);
static int
ccdinit(ccd, cpaths, p)

View File

@ -178,23 +178,6 @@ devsw_module_handler(module_t mod, int what, void* arg)
struct devsw_module_data* data = (struct devsw_module_data*) arg;
int error = 0;
switch (what) {
case MOD_LOAD:
error = cdevsw_add(data->cdevsw);
if (!error && data->chainevh)
error = data->chainevh(mod, what, data->chainarg);
return error;
case MOD_UNLOAD:
if (data->chainevh) {
error = data->chainevh(mod, what, data->chainarg);
if (error)
return error;
}
cdevsw_remove(data->cdevsw);
return error;
}
if (data->chainevh)
return data->chainevh(mod, what, data->chainarg);
else

View File

@ -243,13 +243,12 @@ struct module;
struct devsw_module_data {
int (*chainevh)(struct module *, int, void *); /* next handler */
void *chainarg; /* arg for next event handler */
struct cdevsw *cdevsw; /* device functions */
/* Do not initialize fields hereafter */
};
#define DEV_MODULE(name, cmaj, bmaj, devsw, evh, arg) \
#define DEV_MODULE(name, evh, arg) \
static struct devsw_module_data name##_devsw_mod = { \
evh, arg, &devsw \
evh, arg, \
}; \
\
static moduledata_t name##_mod = { \
@ -257,7 +256,7 @@ static moduledata_t name##_mod = { \
devsw_module_handler, \
&name##_devsw_mod \
}; \
DECLARE_MODULE(name, name##_mod, SI_SUB_DRIVERS, SI_ORDER_MIDDLE+cmaj*256+bmaj)
DECLARE_MODULE(name, name##_mod, SI_SUB_DRIVERS, SI_ORDER_MIDDLE)
int cdevsw_add __P((struct cdevsw *new));

View File

@ -243,13 +243,12 @@ struct module;
struct devsw_module_data {
int (*chainevh)(struct module *, int, void *); /* next handler */
void *chainarg; /* arg for next event handler */
struct cdevsw *cdevsw; /* device functions */
/* Do not initialize fields hereafter */
};
#define DEV_MODULE(name, cmaj, bmaj, devsw, evh, arg) \
#define DEV_MODULE(name, evh, arg) \
static struct devsw_module_data name##_devsw_mod = { \
evh, arg, &devsw \
evh, arg, \
}; \
\
static moduledata_t name##_mod = { \
@ -257,7 +256,7 @@ static moduledata_t name##_mod = { \
devsw_module_handler, \
&name##_devsw_mod \
}; \
DECLARE_MODULE(name, name##_mod, SI_SUB_DRIVERS, SI_ORDER_MIDDLE+cmaj*256+bmaj)
DECLARE_MODULE(name, name##_mod, SI_SUB_DRIVERS, SI_ORDER_MIDDLE)
int cdevsw_add __P((struct cdevsw *new));