Date: 12 Aug 1999 15:51:02 +0200 From: Assar Westerlund <assar@sics.se> To: Poul-Henning Kamp <phk@critter.freebsd.dk> Cc: current@FreeBSD.ORG Subject: Re: DEV_MODULE doesn't support dynamic major numbers any longer? Message-ID: <5l7ln1umyh.fsf@assaris.sics.se> In-Reply-To: Poul-Henning Kamp's message of "Thu, 12 Aug 1999 11:10:53 %2B0200" References: <356.934449053@critter.freebsd.dk>
next in thread | previous in thread | raw e-mail | index | archive | help
[-- Attachment #1 --]
Poul-Henning Kamp <phk@critter.freebsd.dk> 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
[-- Attachment #2 --]
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));
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?5l7ln1umyh.fsf>
