From owner-freebsd-usb@FreeBSD.ORG Thu Aug 16 12:26:50 2007 Return-Path: Delivered-To: freebsd-usb@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id C30FE16A421 for ; Thu, 16 Aug 2007 12:26:50 +0000 (UTC) (envelope-from avg@icyb.net.ua) Received: from gateway.cybervisiontech.com.ua (gateway.cybervisiontech.com.ua [88.81.251.18]) by mx1.freebsd.org (Postfix) with ESMTP id 7EECF13C46A for ; Thu, 16 Aug 2007 12:26:48 +0000 (UTC) (envelope-from avg@icyb.net.ua) Received: from localhost (hq.cybervisiontech.com [127.0.0.1]) by gateway.cybervisiontech.com.ua (Postfix) with ESMTP id 58A9CED5442; Thu, 16 Aug 2007 15:26:45 +0300 (EEST) X-Virus-Scanned: amavisd-new at cybervisiontech.com Received: from gateway.cybervisiontech.com.ua ([127.0.0.1]) by localhost (hq.cybervisiontech.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id w-iugxC1bQCI; Thu, 16 Aug 2007 15:26:41 +0300 (EEST) Received: from [10.2.1.87] (rein.cybervisiontech.com.ua [10.2.1.87]) by gateway.cybervisiontech.com.ua (Postfix) with ESMTP id 4CAFCED543D; Thu, 16 Aug 2007 15:26:41 +0300 (EEST) Message-ID: <46C44280.6010908@icyb.net.ua> Date: Thu, 16 Aug 2007 15:26:40 +0300 From: Andriy Gapon User-Agent: Thunderbird 2.0.0.6 (X11/20070803) MIME-Version: 1.0 To: Hans Petter Selasky References: <46C2D04A.30409@icyb.net.ua> <200708151741.47907.hselasky@c2i.net> In-Reply-To: <200708151741.47907.hselasky@c2i.net> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Cc: freebsd-usb@freebsd.org Subject: Re: usbd_set_config_no vs. usbd_set_config_index 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: Thu, 16 Aug 2007 12:26:50 -0000 on 15/08/2007 18:41 Hans Petter Selasky said the following: > On Wednesday 15 August 2007, Andriy Gapon wrote: >> I am curious about a difference between usbd_set_config_no and >> usbd_set_config_index. My reason is such: I am trying to use >> palm/uppc-kmod to talk to my pocket pc device via usb. When I used the >> port in its original shape it gave me the following error each time I >> plugged the device: >> kernel: ucom0: failed to set configuration, err=STALLED >> kernel: device_attach: ucom0 attach returned 6 >> >> Then, to mimic some other driver I simply changed >> usbd_set_config_index() to usbd_set_config_no() in the code, and voila: >> kernel: ucom0: ASUS ASUS Windows Mobile Device, rev >> 2.00/0.00, addr 3 (rt) >> >> I am now trying to get synce to actually work. >> But I am really curious what my change really did, and I am totally >> ignorant about our usb code. >> BTW: >> FreeBSD 6.2-RELEASE-p3 amd64 >> >> Thank you in advance for my education. > > Hi, > > usbd_set_config_no will search for a matching bConfiguration value. > > usbd_set_config_index will set the configuration by physical index: 0, 1, > 2 ... > Thank you! Is it safe to assume that *_no is "more robust" than "*_index" and in drivers for general classes of devices it should be preferred ? And _index should only be used in very specific cases where we are sure of what we are doing ? Or am I talking nonsense ? It is curious to compare the following: $ glimpse -l usbd_set_config_no /usr/src/sys/dev/usb/usb_subr.h /usr/src/sys/dev/usb/if_zyd.c /usr/src/sys/dev/usb/uscanner.c /usr/src/sys/dev/usb/if_ural.c /usr/src/sys/dev/usb/if_kue.c /usr/src/sys/dev/usb/if_aue.c /usr/src/sys/dev/usb/ugen.c /usr/src/sys/dev/usb/if_axe.c /usr/src/sys/dev/usb/if_udav.c /usr/src/sys/dev/usb/if_rue.c /usr/src/sys/dev/usb/usb_subr.c /usr/src/sys/dev/usb/if_cue.c /usr/src/sys/dev/usb/usbdi_util.h /usr/src/sys/netgraph/bluetooth/drivers/ubtbcmfw/ubtbcmfw.c $ glimpse -l usbd_set_config_index /usr/src/sys/dev/usb/usb_subr.h /usr/src/sys/dev/usb/ugensa.c /usr/src/sys/dev/usb/umoscom.c /usr/src/sys/dev/usb/ugen.c /usr/src/sys/dev/usb/uplcom.c /usr/src/sys/dev/usb/umct.c /usr/src/sys/dev/usb/uvisor.c /usr/src/sys/dev/usb/uvscom.c /usr/src/sys/dev/usb/usb_subr.c /usr/src/sys/dev/usb/uhub.c /usr/src/sys/dev/usb/uftdi.c /usr/src/sys/dev/usb/usbdi_util.h /usr/src/sys/dev/usb/ubsa.c /usr/src/sys/dev/usb/ucycom.c -- Andriy Gapon