From owner-freebsd-acpi@FreeBSD.ORG Tue Jul 31 20:08:43 2012 Return-Path: Delivered-To: freebsd-acpi@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id C8B8C1065670; Tue, 31 Jul 2012 20:08:43 +0000 (UTC) (envelope-from hselasky@c2i.net) Received: from swip.net (mailfe03.c2i.net [212.247.154.66]) by mx1.freebsd.org (Postfix) with ESMTP id 292F08FC1B; Tue, 31 Jul 2012 20:08:42 +0000 (UTC) X-T2-Spam-Status: No, hits=-0.2 required=5.0 tests=ALL_TRUSTED, BAYES_50 Received: from [176.74.212.201] (account mc467741@c2i.net HELO laptop015.hselasky.homeunix.org) by mailfe03.swip.net (CommuniGate Pro SMTP 5.4.4) with ESMTPA id 136265463; Tue, 31 Jul 2012 22:08:36 +0200 From: Hans Petter Selasky To: freebsd-acpi@freebsd.org Date: Tue, 31 Jul 2012 22:08:55 +0200 User-Agent: KMail/1.13.7 (FreeBSD/9.0-STABLE; KDE/4.7.4; amd64; ; ) References: <201207310319.q6V3JC6a014526@sana.init-main.com> In-Reply-To: <201207310319.q6V3JC6a014526@sana.init-main.com> X-Face: 'mmZ:T{)),Oru^0c+/}w'`gU1$ubmG?lp!=R4Wy\ELYo2)@'UZ24N@d2+AyewRX}mAm; Yp |U[@, _z/([?1bCfM{_"B<.J>mICJCHAzzGHI{y7{%JVz%R~yJHIji`y>Y}k1C4TfysrsUI -%GU9V5]iUZF&nRn9mJ'?&>O MIME-Version: 1.0 Content-Type: Text/Plain; charset="iso-8859-15" Content-Transfer-Encoding: 7bit Message-Id: <201207312208.55871.hselasky@c2i.net> Cc: freebsd-usb@freebsd.org Subject: Re: USB ACPI namespace mapping. X-BeenThere: freebsd-acpi@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: ACPI and power management development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 31 Jul 2012 20:08:43 -0000 On Tuesday 31 July 2012 05:19:12 Takanori Watanabe wrote: > I'm trying to map USB devices and hub into acpi handle, > and I want ideas to cope with a problem. > > The problem is that there is no easy way to get port number from > child usb device in hub device. > usb_attach_arg structure have one, but invalidate after probe and attach. > > And, furthermore, which device_t instance should I register to acpi > device handle to cope with ACPI docking station framework. > > The code I wrote is as follows. > Hi, In userspace there is: man libusb20_dev_get_parent_port Most of the information you need is supplied via either devd, or an IOCTL request on the ugen device: #define USB_DEVICEINFO _IOWR('U', 4, struct usb_device_info) ... uint8_t udi_hubaddr; /* parent HUB address */ uint8_t udi_hubindex; /* parent HUB device index */ uint8_t udi_hubport; /* parent HUB port */ ... Check how the DEVICEINFO IOCTL is implemented and you will see how the current port numbers are computed. Important: Don't forget that the USB stack is multithreaded! And that you need to lock resources before accessing them! Do you need more info than this? --HPS