Re: DEV_MODULE doesn't support dynamic major numbers any longer?

1999-08-12 Thread Assar Westerlund

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)
 
 
+intalloc_bmaj __P((void));
+intalloc_cmaj __P((void));
 struct cdevsw *bdevsw __P((dev_t dev));
 intcdevsw_add __P((struct cdevsw *new));
 intcdevsw_remove __P((struct cdevsw *old));



Re: DEV_MODULE doesn't support dynamic major numbers any longer?

1999-08-12 Thread Poul-Henning Kamp

In message <[EMAIL PROTECTED]>, Assar Westerlund writes:

>It seems to be the case that the possibility of specifying a major
>number of NOMAJ in DEV_MODULE has vanished.

The cmaj and bmaj in DEV_MODULE are only used for ordering the drivers,
and otherwise with no significance.

You should store your majors in your cdevsw structure.

I don't particular like the concept of DEV_MODULE registrating
the cdevsw by magic.

>cdevsw_add() doesn't have any code for handling NOMAJ any longer.
>(The only mention I can find of NOMAJ in a -current kernel tree from
>19990811 are these:

>which makes me wonder how the promcons works...).

Fine, see above.

>Is this intentional that there isn't there any support for dynamically
>assigning major device numbers or is it an accident that I should go
>and rectify?

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.

--
Poul-Henning Kamp FreeBSD coreteam member
[EMAIL PROTECTED]   "Real hackers run -current on their laptop."
FreeBSD -- It will take a long time before progress goes too far!


To Unsubscribe: send mail to [EMAIL PROTECTED]
with "unsubscribe freebsd-current" in the body of the message



DEV_MODULE doesn't support dynamic major numbers any longer?

1999-08-11 Thread Assar Westerlund

It seems to be the case that the possibility of specifying a major
number of NOMAJ in DEV_MODULE has vanished.

cdevsw_add() doesn't have any code for handling NOMAJ any longer.
(The only mention I can find of NOMAJ in a -current kernel tree from
19990811 are these:

./alpha/alpha/promcons.c:284:DEV_MODULE(prom, CDEV_MAJOR, NOMAJ, prom_cdevsw, 0, 0);
./sys/param.h:128:#define   NOMAJ   256 /* non-existent device */

which makes me wonder how the promcons works...).

Is this intentional that there isn't there any support for dynamically
assigning major device numbers or is it an accident that I should go
and rectify?

/assar


To Unsubscribe: send mail to [EMAIL PROTECTED]
with "unsubscribe freebsd-current" in the body of the message