From owner-freebsd-current Thu Aug 12 6:51:56 1999 Delivered-To: freebsd-current@freebsd.org Received: from assaris.sics.se (assaris.sics.se [193.10.66.108]) by hub.freebsd.org (Postfix) with ESMTP id 60FF914FAB for ; Thu, 12 Aug 1999 06:51:20 -0700 (PDT) (envelope-from assar@sics.se) Received: (from assar@localhost) by assaris.sics.se (8.9.3/8.7.3) id PAA01477; Thu, 12 Aug 1999 15:51:04 +0200 (CEST) To: Poul-Henning Kamp Cc: current@FreeBSD.ORG Subject: Re: DEV_MODULE doesn't support dynamic major numbers any longer? References: <356.934449053@critter.freebsd.dk> Mime-Version: 1.0 (generated by tm-edit 7.68) Content-Type: multipart/mixed; boundary="Multipart_Thu_Aug_12_15:51:01_1999-1" Content-Transfer-Encoding: 7bit From: Assar Westerlund Date: 12 Aug 1999 15:51:02 +0200 In-Reply-To: Poul-Henning Kamp's message of "Thu, 12 Aug 1999 11:10:53 +0200" Message-ID: <5l7ln1umyh.fsf@assaris.sics.se> Lines: 83 X-Mailer: Gnus v5.5/Emacs 19.34 Sender: owner-freebsd-current@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG --Multipart_Thu_Aug_12_15:51:01_1999-1 Content-Type: text/plain; charset=US-ASCII Poul-Henning Kamp 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 --Multipart_Thu_Aug_12_15:51:01_1999-1 Content-Type: text/plain; charset=US-ASCII 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)); --Multipart_Thu_Aug_12_15:51:01_1999-1-- To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-current" in the body of the message