[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Device Drivers



On Sun, 13 May 2001, liam wrote:

> How close are Linux Device Drivers to openBSD device drivers?

Not close at all, thankfully. My limited experience with Linux drivers has
been enough to horrify me. Magic values and duplicate code all over the
place. For example, in a Linux driver, you'll often see 0xd3c0 instead of
a nice DRIVER_FOO_REGISTER constant that actually gives the value meaning.
I've also noticed that a lot of MII handling and such will be put right
into the individual Ethernet drivers, instead of being split up into a
nice sys/dev/mii hierarchy like in Open/Net/FreeBSD.

But perhaps the worst thing about following a Linux driver is a lack of
commit history or audit trail. A lot of Linux source has history in the
leading comments of the file, but this is rarely complete, spotty at
best. I once tried to figure out when feature X was added to the Tulip
driver in Linux and nearly jumped out my window before giving up.

I'm sure (I hope?) such malpractices are not advocated by this book, and
you might actually get some ideas about basic driver writing fundamentals
from it. But the kernel API's used to implement these ideas are of course
completely different.

---
Aaron Campbell (aaron@monkey.org || aaron@openbsd.org)
http://www.monkey.org/~aaron