atom feed43 messages in org.freebsd.freebsd-archRe: Extending sys/dev/mii
FromSent OnAttachments
Stefan BethkeJan 4, 2012 8:03 am 
Adrian ChaddJan 4, 2012 9:07 am 
Marius StroblJan 4, 2012 1:59 pm 
Stefan BethkeJan 5, 2012 12:52 pm 
Stefan BethkeJan 6, 2012 4:56 am 
Stefan BethkeJan 6, 2012 5:02 am.diff
Marius StroblJan 6, 2012 10:27 am 
Stefan BethkeJan 6, 2012 12:35 pm 
Marius StroblJan 6, 2012 1:47 pm 
Stefan BethkeJan 6, 2012 1:52 pm 
Marius StroblJan 8, 2012 5:00 am 
Stefan BethkeJan 8, 2012 2:27 pm 
Adrian ChaddJan 10, 2012 5:18 pm 
Marius StroblJan 11, 2012 11:37 am 
Adrian ChaddJan 14, 2012 8:15 pm 
Warner LoshJan 14, 2012 9:13 pm 
Stefan BethkeJan 20, 2012 3:08 pm.patch
Warner LoshJan 20, 2012 5:43 pm 
Oleksandr TymoshenkoJan 20, 2012 8:12 pm 
Stefan BethkeJan 21, 2012 4:02 am 
Aleksandr RybalkoJan 21, 2012 5:12 am 
Oleksandr TymoshenkoJan 23, 2012 11:45 pm 
Aleksandr RybalkoJan 24, 2012 5:53 am 
Marius StroblJan 25, 2012 2:17 pm 
Warner LoshJan 25, 2012 2:28 pm 
Marius StroblJan 25, 2012 3:21 pm 
Hans Petter SelaskyJan 26, 2012 8:24 am 
Stefan BethkeJan 26, 2012 8:24 am 
Stefan BethkeJan 26, 2012 8:30 am 
Marius StroblJan 27, 2012 6:15 am 
Adrian ChaddFeb 10, 2012 9:22 pm 
Marius StroblFeb 11, 2012 3:17 am 
Aleksandr RybalkoFeb 11, 2012 4:45 am 
Adrian ChaddFeb 11, 2012 4:59 pm 
Warner LoshFeb 11, 2012 5:15 pm 
Adrian ChaddFeb 11, 2012 8:48 pm 
Warner LoshFeb 11, 2012 8:58 pm 
Juli MallettFeb 11, 2012 9:05 pm 
Adrian ChaddFeb 11, 2012 9:19 pm 
Aleksandr RybalkoFeb 12, 2012 9:51 am 
Aleksandr RybalkoFeb 12, 2012 10:04 am 
Juli MallettFeb 12, 2012 10:30 am 
Aleksandr RybalkoFeb 12, 2012 10:38 am 
Subject:Re: Extending sys/dev/mii
From:Oleksandr Tymoshenko (gon@bluezbox.com)
Date:Jan 23, 2012 11:45:01 pm
List:org.freebsd.freebsd-arch

On 2012-01-20, at 8:13 PM, Oleksandr Tymoshenko wrote:

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.

I tinkered a little bit with this idea and here is what I've come up with so
far:

http://people.freebsd.org/~gonzo/patches/horizontal-api.diff

this patch adds one more available declaration to .m files: APIMETHOD In addition to usual kobj method declaration one more function is generated. This function gets first device in devclass with the same name as declared interface and uses it as object for respective method call.

Also if there is at least one APIMETHOD in interface one more function called XXXX_available() is generated. It returns 1 if there is device of required
devclass.

Usage example: int maxpin;

printf("GPIO available: %d\n", gpio_available()); if (gpio_available()) { gpio_pin_max(&maxpin); printf("GPIO pins: %d\n", maxpin); }

Possible improvements: instead of using devclass for identifying kobj, create way for device to explicitly register/deregister as an API "provider".

Comments, ideas?_______________________________________________ free@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-arch To unsubscribe, send any mail to "free@freebsd.org"