From owner-freebsd-usb@FreeBSD.ORG Tue Jan 9 20:38:00 2007 Return-Path: X-Original-To: freebsd-usb@freebsd.org Delivered-To: freebsd-usb@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 3D21416A412 for ; Tue, 9 Jan 2007 20:38:00 +0000 (UTC) (envelope-from hselasky@c2i.net) Received: from swip.net (mailfe11.swip.net [212.247.155.65]) by mx1.freebsd.org (Postfix) with ESMTP id A84E713C44C for ; Tue, 9 Jan 2007 20:37:59 +0000 (UTC) (envelope-from hselasky@c2i.net) X-Cloudmark-Score: 0.000000 [] Received: from [193.217.102.48] (account mc467741@c2i.net HELO [10.0.0.249]) by mailfe11.swip.net (CommuniGate Pro SMTP 5.0.12) with ESMTPA id 209282001; Tue, 09 Jan 2007 21:37:47 +0100 From: Hans Petter Selasky To: freebsd-usb@freebsd.org Date: Tue, 9 Jan 2007 21:37:21 +0100 User-Agent: KMail/1.7 References: <20070109083450.A75138@xorpc.icir.org> In-Reply-To: <20070109083450.A75138@xorpc.icir.org> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200701092137.22421.hselasky@c2i.net> Cc: Luigi Rizzo Subject: Re: any way to detect usb detached from a device driver ? X-BeenThere: freebsd-usb@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: FreeBSD support for USB List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 09 Jan 2007 20:38:00 -0000 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