any way to detect usb detached from a device driver ?

Hans Petter Selasky hselasky at c2i.net
Tue Jan 9 20:38:00 UTC 2007


On Tuesday 09 January 2007 17:34, Luigi Rizzo wrote:
> [sorry for the repost, not sure it went through]
>
> On Tue, Jan 09, 2007 at 08:16:29AM -0800, Luigi Rizzo wrote:
> I am modifying a kernel device driver for webcams
> (see http://info.iet.unipi.it/~luigi/FreeBSD/usb-cameras.html)
> packing together various projects around, and i was wondering
> how to handle the situation of a device being
> detached while in use.

If you look at the my USB driver for FreeBSD, 
http://www.turbocat.net/~hselasky/usb4bsd , there has been created a new 
device system, usb_cdev, with that goal in mind that you should not have to 
worry about detaching devices, hence this is somewhat complicated:

http://www.turbocat.net/~hselasky/isdn4bsd/sources/src/sys/dev/usb/usb_cdev.c

For example, have a look a the new URIO driver:

http://www.turbocat.net/~hselasky/isdn4bsd/sources/src/sys/dev/usb/urio.c

>
> Right now the code (from ports/multimedia/pwcbsd) detects
> that the device is in use while the driver-specific USB_DETACH
> routine is called, however then it goes on without doing
> anything.

Very bad!

>
> In another driver in the dree (urio.c) i see the driver
> calls usb_detach_wait() to wait up to 60s for the
> drivers to complete. However that function is not documented
> and used a bit inconsistently in the rest of /sys/dev/usb
>

--HPS


More information about the freebsd-usb mailing list