usb match() function

Bernd Walter ticso at cicely7.cicely.de
Sun Aug 24 12:02:57 UTC 2008


On Fri, Aug 22, 2008 at 10:02:41PM +0200, Peter B wrote:
> 
> Within the usb drivers (/usr/src/sys/dev/usb/u*.c) there's an matching routine
> where the 'uaa->iface' is supposed to be assigned before the routine is called.
> 
> However for a new device or class this doesn't seem to work. Instead 'uaa'
> is set like for an generic device (two interfaces, no "default" in my case).
> 
> So how is one supposed to make the kernel fill in 'uaa->iface' ..?

Your function is potentially getting called multiple times.
First all drivers (except ugen) are asked for the whole device and if all
refuses it splits the device into the interfaces and asks every driver
again - if no driver claims at least a single interface ugen is asked for
the whole device.
So you have to refuse the whole device and wait for the interface run.
If there's no interface run then another driver already claimed it or
your device has no interfaces defined.

> Code excerpt (v7.x):
>   static int
>   *_match(device_t self)
>   {
>         struct usb_attach_arg *uaa = device_get_ivars(self);
>         usb_interface_descriptor_t *id;
> 
>         DPRINTFN(10,("*_match\n"));
>         if (uaa->iface == NULL)
>                 return (UMATCH_NONE);
> 

-- 
B.Walter <bernd at bwct.de> http://www.bwct.de
Modbus/TCP Ethernet I/O Baugruppen, ARM basierte FreeBSD Rechner uvm.


More information about the freebsd-hackers mailing list