Extending sys/dev/mii

Oleksandr Tymoshenko gonzo at freebsd.org
Sat Jan 21 04:34:40 UTC 2012


On 20/01/2012 5:43 PM, Warner Losh wrote:
>
> On Jan 20, 2012, at 5:08 PM, Stefan Bethke wrote:
>> The second problem is that there's currently no way to express a dependency between two devices other than a parent-child relationship.   I would be interested to learn why this appears to be so uncommon that I could not find any discussion of such a feature.  Has it really never before come up?
>
> Sure there is: you can do it by name.  I wrote a driver that attached to the ISA bus, but also needed to talk to the ppbus that was attached to the printer.  My solution was to have a post-attach name-lookup so that it could then call methods on the other driver's device_t.  I wonder why we can't do that here?

     I've been thinking about it recently in regard to GPIO subsystem.
And the same issue appeared during OMAP code import: there are at least
two subsystems that are used by the rest of the drivers. Ben's suggested
following solution: define kobj interface if_SUBSYTEM.m and then
provide API call in form:

     int omap_prcm_clk_enable(clk_ident_t clk)
     {
         device_t prcm_dev;

         prcm_dev = devclass_get_device(devclass_find("omap_prcm"), 0);
         if (prcm_dev == NULL) {
             printf("Error: failed to get the PRCM device\n");
             return (EINVAL);
         }

         return OMAP_PRCM_CLK_ENABLE(prcm_dev, clk);
     }

So it might make sense to create some kind of upper-level API for
defining this kind of subsystems' APIs since every implementation
would duplicate a lot of code: look for instance of specific
devclass, check if it exists. Not sure how to do it at the moment
though.


More information about the freebsd-arch mailing list