From owner-freebsd-hackers@FreeBSD.ORG Sun Aug 24 12:02:57 2008 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id A46E41065671 for ; Sun, 24 Aug 2008 12:02:57 +0000 (UTC) (envelope-from ticso@cicely7.cicely.de) Received: from raven.bwct.de (raven.bwct.de [85.159.14.73]) by mx1.freebsd.org (Postfix) with ESMTP id F33158FC1C for ; Sun, 24 Aug 2008 12:02:56 +0000 (UTC) (envelope-from ticso@cicely7.cicely.de) Received: from cicely5.cicely.de ([10.1.1.7]) by raven.bwct.de (8.13.4/8.13.4) with ESMTP id m7OC2rU8079490 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Sun, 24 Aug 2008 14:02:54 +0200 (CEST) (envelope-from ticso@cicely7.cicely.de) Received: from cicely7.cicely.de (cicely7.cicely.de [10.1.1.9]) by cicely5.cicely.de (8.14.2/8.14.2) with ESMTP id m7OC2o3m084396 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Sun, 24 Aug 2008 14:02:50 +0200 (CEST) (envelope-from ticso@cicely7.cicely.de) Received: from cicely7.cicely.de (localhost [127.0.0.1]) by cicely7.cicely.de (8.14.2/8.14.2) with ESMTP id m7OC2oRn030732; Sun, 24 Aug 2008 14:02:50 +0200 (CEST) (envelope-from ticso@cicely7.cicely.de) Received: (from ticso@localhost) by cicely7.cicely.de (8.14.2/8.14.2/Submit) id m7OC2nX9030731; Sun, 24 Aug 2008 14:02:49 +0200 (CEST) (envelope-from ticso) Date: Sun, 24 Aug 2008 14:02:49 +0200 From: Bernd Walter To: Peter B Message-ID: <20080824120234.GM23672@cicely7.cicely.de> References: <200808222002.m7MK2fvo004486@brother.ludd.ltu.se> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <200808222002.m7MK2fvo004486@brother.ludd.ltu.se> X-Operating-System: FreeBSD cicely7.cicely.de 7.0-STABLE i386 User-Agent: Mutt/1.5.11 X-Spam-Status: No, score=-4.3 required=5.0 tests=ALL_TRUSTED=-1.8, AWL=0.079, BAYES_00=-2.599 autolearn=ham version=3.2.5 X-Spam-Checker-Version: SpamAssassin 3.2.5 (2008-06-10) on spamd.cicely.de Cc: freebsd-hackers@freebsd.org Subject: Re: usb match() function X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: ticso@cicely.de List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 24 Aug 2008 12:02:57 -0000 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 http://www.bwct.de Modbus/TCP Ethernet I/O Baugruppen, ARM basierte FreeBSD Rechner uvm.