Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 3 Jan 1997 20:33:59 +1100
From:      Bruce Evans <bde@zeta.org.au>
To:        brawley@communica.com.au, freebsd-bugs@FreeBSD.ORG
Subject:   Re: LKMs and character special devices
Message-ID:  <199701030933.UAA26540@godzilla.zeta.org.au>

next in thread | raw e-mail | index | archive | help
>After spending quite some time (too much time) on trying to port
>a package to FreeBSD 2.2, I noticed something.
>
>In the file /usr/src/sys/kern/kern_lkm.c where it does some of the
>initializing of the LKMs,  noticed that there is code to add a block
>special device through a LKM, but not a character special device.
>Case statement begins at line 688 (or there abouts) in function
>_lkm_dev().
>
>Theres just a break in the case statment for the case of LM_DT_CHAR.
>
>Meaning, for someone to write a LKM that adds a character special
>device to the system, must add the entery into the cdevsw list themselves.

I think it's the bdev case that's broken.  Drivers should add entries to
the devswitches themselves in all cases.  In 2.2., non-lkm drivers have to
do this, so doing it differently for the lkm case just requires more code.
Most drivers do it in a poor way using SYSINIT().  This also requires more
code and gives worse results than adding the entries at the appropriate
time (several drivers have active devswitch entries although their probe
has failed, and open routines that can't handle being called when the
driver hasn't been attached).

>The next querk I found was in /usr/include/sys/lkm.h.
>
>The MOD_DEV macro seems to be wrong in defining _module (rather, it
>tryes to define name ## _module, then when you try to use the
>DISPATCH macro, the compiler errs with "_module symbol not found".

Apparently the static module object was once always named _module.
This only worked when there was only one MOD_DEV() invocation per file.
But wcd has two, because lkm doesn't support both cdevs and bdevs in
the same module, so someone hacked MOD_DEV() to make the object depend
on the module name (and several modules to define _module :-().

Dropping support for initializing devswitches in _lkm_dev() should
make supporting cdevs and bdevs in the same module a non-problem.
Does the wcd module actually work?  It doesn't seem to initialize
the devswitches explicitly, so I guess only its block devices work.

Bruce



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199701030933.UAA26540>