RE: Question about file I/O in device driver kernel module

Jeremy Fitzhardinge (jeremy@goop.org)
Wed, 06 Oct 1999 16:26:01 -0700 (PDT)


On 02-Jan-70 Mark Hall wrote:
> Or, is it considered
> "very bad form" to open a file from the kernel while initializing a module?

Yes, pretty much. Apart from things like /sbin/init, the kernel doesn't have
any pathnames hard-coded into it.

I can think of two reasonable approaches:
1. build the microcode into the driver itself. Since its pretty small, this
shouldn't be a big deal, and its what other drivers do. You could even make it
a separate module which is loaded when necessary, and can be regenerated from a
new microcode release by a script without having to recompile the whole driver.
2. If the microcode is going to chnage often, you could add an ioctl for
inserting the microcode, which an accompanying user-mode program to read it
from disk and pass it to the ioctl.

> Oh, and also, since I'll need a device file (/dev/slhdmx0), and I plan to
> release this driver, how can I find out about getting a static major/minor
> device number, or does one exist where this type of device should fit?

See Documentation/devices.txt

> An additional question that just came to mind, I have a section of
> initialization right after the card's microcode loads that I have to sleep
> for
> 50 microseconds. Is it considered unacceptable to use udelay(50) for this at
> module load time

Should be OK, but what are the real requirements? Do you need to sleep for at
least 50us, or exactly 50us?

Hope this helps,
J

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.tux.org/lkml/