From owner-freebsd-usb@FreeBSD.ORG Thu Apr 30 12:42:12 2009 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 1C396106564A for ; Thu, 30 Apr 2009 12:42:12 +0000 (UTC) (envelope-from hselasky@c2i.net) Received: from swip.net (mailfe12.swipnet.se [212.247.155.97]) by mx1.freebsd.org (Postfix) with ESMTP id 7CB3A8FC12 for ; Thu, 30 Apr 2009 12:42:11 +0000 (UTC) (envelope-from hselasky@c2i.net) X-Cloudmark-Score: 0.000000 [] X-Cloudmark-Analysis: v=1.0 c=1 a=MXw7gxVQKqGXY79tIT8aFQ==:17 a=L9CR0MtUK664j7V6LHMA:9 a=DQcfRvILXqVzv-iH2Cr4Z7HFVTAA:4 a=N1DfUnNy2_waTfcz:21 a=28fObjYVIF7KoU-N:21 Received: from [62.113.132.61] (account mc467741@c2i.net HELO laptop) by mailfe12.swip.net (CommuniGate Pro SMTP 5.2.13) with ESMTPA id 1061651522; Thu, 30 Apr 2009 14:42:09 +0200 From: Hans Petter Selasky To: Milan Obuch Date: Thu, 30 Apr 2009 14:44:31 +0200 User-Agent: KMail/1.9.7 References: <200904301221.44674.freebsd-usb@dino.sk> <200904301258.37784.hselasky@c2i.net> <200904301412.38313.freebsd-usb@dino.sk> In-Reply-To: <200904301412.38313.freebsd-usb@dino.sk> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200904301444.32024.hselasky@c2i.net> Cc: freebsd-usb@freebsd.org Subject: Re: u3g serial device name query 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, 30 Apr 2009 12:42:12 -0000 On Thursday 30 April 2009, Milan Obuch wrote: > On Thursday 30 April 2009 12:58:36 Hans Petter Selasky wrote: > > On Thursday 30 April 2009, Milan Obuch wrote: > > > Hi, > > > > > > I have HUAWEI 3g usb modem. It works with u3g from current. There is > > > however one thing I did not get working yet. > > > > > > When device attaches, it is added into tree as u3gN, devd event is > > > sent. It is easily matched with 'device-name "u3g[0-9]"' clause in > > > devd.conf. I can start ppp automatically and it works well, given no > > > other USB serial device is present. > > > > > > If another USB serial device such as uplcom is present, u3g serial > > > ports does not have the same name. I found no way to relate serial > > > device name to this event and looking in source I see no place where it > > > is created. I would like to put a devctl notify call there. This way I > > > could start ppp with correct device name even if there is some other > > > USB serial device. > > > > > > Could someone point me in the right direction? > > > > USB serial devices have their own unit management. There is however a way > > to override the unit number through the "usb2_com_tty_name" callback, > > which requires some code changes to the u3g driver. > > > > All USB modems and serial adapters end up with the same naming > > prefix: /dev/cuaU%d.%d, so the assigned numbers must be serialised. > > > > What we could do is to have a separate naming prefix for 3G modems, and > > use the device_get_unit() for unit number. > > > > See: src/sys/dev/usb/serial and usb_serial.c > > I looked over usb2_com_attach_tty function in usb_serial.c, and somewhere > after call to tty_makedev (where a DPRINT is too) I could put a devctl > call. > > All I need for it would be device name. In /var/log/message file I see a > line telling 'u3g0 : Found 2 ports' just after usb2_com_attach_tty function > is called. If you could tell me how I can get 'u3g0' name via sc argument > in usb2_com_attach_tty function, I can solve this with no other change. > You have to cast the parent softc pointer back into "struct u3g_softc", which is stored in the ucom softc. In the u3g_softc you should find sc_dev, which you can use "device_get_nameunit()" on. You can do this in the "usb2_com_tty_name" callback function. --HPS