Accessing driver members

Warner Losh imp at bsdimp.com
Wed Dec 21 09:13:24 PST 2005


> I would like to know what's the better way to access to a device member form
> kernelspace. For example, I can use  a ioctl from userspace but, since the
> functions are all static I can't access nicely from kernel space (and using
> ioctl(2) in the kernel is not a great idea...).

You have one device driver that wants to access another device
driver's private parts?

If so, there are only a few ways to deal with this:

(1) Make the drivers friends.  Let one driver know about the private
    parts of the other driver and provide secret public functions for
    that other driver to use (you can firewall the information leak by
    using modules and MODULE_DEPEND).  This is simple, but scales
    poorly and is thought by many to be ugly.

(2) Use a kobj interface for the two devices to talk to one another.
    This tends to be a better interface in that it is more flexible.
    I use this when I have one module that measures something in the
    kernel controlling a different module based on those
    measurements to meet a soft real-time specification (and also to
    give a level of overkill that made management happy given their
    flawed knowledge about how certain things worked).

Warner


More information about the freebsd-drivers mailing list