Poul-Henning Kamp <[EMAIL PROTECTED]> writes: > The cmaj and bmaj in DEV_MODULE are only used for ordering the drivers, > and otherwise with no significance. Yeah, I realized that later. > The previous code was a hack and inflicted problems. The right > solution, (until DEVFS of course) is to add two new functions: > alloc_cmaj() and alloc_bmaj() and use those. Like the following code? And should they be used by cdevsw_add when d_maj and d_bmaj are some magical value such as -1? /assar
Index: kern/kern_conf.c =================================================================== RCS file: /src/fbsd-repository/src/sys/kern/kern_conf.c,v retrieving revision 1.55 diff -u -w -u -w -r1.55 kern_conf.c --- kern_conf.c 1999/08/08 18:42:47 1.55 +++ kern_conf.c 1999/08/12 13:24:04 @@ -88,6 +88,36 @@ } /* + * Return an unused cdev major or -1 if there are none free. + */ + +int +alloc_cmaj (void) +{ + int i; + + for (i = cdevsw_ALLOCSTART; i < NUMCDEVSW; ++i) + if (cdevsw[i] == NULL) + return i; + return -1; +} + +/* + * Return an unused bdev major or -1 if there are none free. + */ + +int +alloc_bmaj (void) +{ + int i; + + for (i = cdevsw_ALLOCSTART; i < NUMCDEVSW; ++i) + if (bmaj2cmaj[i] == 254) + return i; + return -1; +} + +/* * Add a cdevsw entry */ Index: sys/conf.h =================================================================== RCS file: /src/fbsd-repository/src/sys/sys/conf.h,v retrieving revision 1.69 diff -u -w -u -w -r1.69 conf.h --- conf.h 1999/08/09 18:45:20 1.69 +++ conf.h 1999/08/12 13:21:23 @@ -248,6 +248,8 @@ DECLARE_MODULE(name, name##_mod, SI_SUB_DRIVERS, SI_ORDER_MIDDLE+cmaj*256+bmaj) +int alloc_bmaj __P((void)); +int alloc_cmaj __P((void)); struct cdevsw *bdevsw __P((dev_t dev)); int cdevsw_add __P((struct cdevsw *new)); int cdevsw_remove __P((struct cdevsw *old));