From: Lan Tianyu <tianyu.lan@intel.com>
To: lenb@kernel.org, gregkh@linuxfoundation.org
Cc: Lan Tianyu <tianyu.lan@intel.com>,
linux-acpi@vger.kernel.org, mjg@redhat.com,
linux-usb@vger.kernel.org, sarah.a.sharp@intel.com
Subject: [RFC PATCH 3/4] usb/acpi: add the support of usb hub ports' acpi binding without attached devices.
Date: Mon, 19 Mar 2012 22:33:45 +0800 [thread overview]
Message-ID: <1332167626-5806-3-git-send-email-tianyu.lan@intel.com> (raw)
In-Reply-To: <1332167626-5806-1-git-send-email-tianyu.lan@intel.com>
The usb port is a device in the acpi table but it's not in the linux
usb subsystem. USB hub port doesn't have struct device. So the acpi
glue framework only can cover the usb port connected with usb device
and store the acpi handle to struct device.archdata.acpi_handle. This
patch gets the hub port's acpi_handle and store it in the port's platform_data
to resolve no attached device no binding problem. The acpi method "_UPC"
and "_PLD" can be accessed without attached device.
Signed-off-by: Lan Tianyu <tianyu.lan@intel.com>
---
drivers/usb/core/hub.c | 1 +
drivers/usb/core/usb-acpi.c | 38 +++++++++++++++++++++++++++++++++++++-
drivers/usb/core/usb.h | 4 ++++
3 files changed, 42 insertions(+), 1 deletions(-)
diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c
index af391cb..90877f0 100644
--- a/drivers/usb/core/hub.c
+++ b/drivers/usb/core/hub.c
@@ -1238,6 +1238,7 @@ static int hub_configure(struct usb_hub *hub,
hub->indicator [0] = INDICATOR_CYCLE;
hub_activate(hub, HUB_INIT);
+ usb_acpi_bind_hub_ports(hdev, hub->descriptor->bNbrPorts);
return 0;
fail:
diff --git a/drivers/usb/core/usb-acpi.c b/drivers/usb/core/usb-acpi.c
index e49373a..6ecff04 100644
--- a/drivers/usb/core/usb-acpi.c
+++ b/drivers/usb/core/usb-acpi.c
@@ -82,7 +82,16 @@ static int usb_acpi_find_device(struct device *dev, acpi_handle *handle)
if (!parent_handle)
return -ENODEV;
- *handle = acpi_get_child(parent_handle, udev->portnum);
+ /**
+ * The root hub's acpi handle is got from acpi method.
+ * Other device's acpi handle can be got from the usb hub
+ * port's platform_data.
+ */
+ if (!udev->parent)
+ *handle = acpi_get_child(parent_handle, udev->portnum);
+ else
+ usb_get_hub_port_platform_data(udev->parent, udev->portnum,
+ (unsigned long *)handle);
if (!*handle)
return -ENODEV;
@@ -105,6 +114,33 @@ static struct acpi_bus_type usb_acpi_bus = {
.find_device = usb_acpi_find_device,
};
+int usb_acpi_bind_hub_ports(struct usb_device *hdev, int portnum)
+{
+ acpi_handle hub_handle = NULL;
+ acpi_handle port_handle = NULL;
+ struct device *dev = &hdev->dev;
+ int i;
+
+ hub_handle = DEVICE_ACPI_HANDLE(dev);
+ if (!hub_handle)
+ return -ENODEV;
+
+ /**
+ * The usb hub port is not a device in the usb subsystem but it is a device
+ * in the acpi table. Store it's acpi handle in the platform data of usb
+ * hub port.
+ */
+ for (i = 1; i < portnum; i++) {
+ port_handle = acpi_get_child(hub_handle, i);
+ if (!port_handle)
+ continue;
+ if (usb_set_hub_port_platform_data(hdev, i,
+ (unsigned long)port_handle) < 0)
+ return -ENODEV;
+ }
+ return 0;
+}
+
int usb_acpi_register(void)
{
return register_acpi_bus_type(&usb_acpi_bus);
diff --git a/drivers/usb/core/usb.h b/drivers/usb/core/usb.h
index 3e70565..b780246 100644
--- a/drivers/usb/core/usb.h
+++ b/drivers/usb/core/usb.h
@@ -162,7 +162,11 @@ extern int usb_set_hub_port_platform_data(struct usb_device *udev,
#ifdef CONFIG_ACPI
extern int usb_acpi_register(void);
extern void usb_acpi_unregister(void);
+extern int usb_acpi_bind_hub_ports(struct usb_device *hdev,
+ int portnum);
#else
static inline int usb_acpi_register(void) { return 0; };
static inline void usb_acpi_unregister(void) { };
+static inline int usb_acpi_bind_hub_ports(struct usb_device *hdev,
+ int portnum) { return 0; };
#endif
--
1.7.6.rc2.8.g28eb
next prev parent reply other threads:[~2012-03-19 14:36 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-03-19 14:33 [RFC PATCH 1/4] usb: add struct usb_hub_port to store port related members Lan Tianyu
[not found] ` <1332167626-5806-1-git-send-email-tianyu.lan-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
2012-03-19 14:33 ` [RFC PATCH 2/4] usb: add platform_data in the struct usb_hub_port Lan Tianyu
2012-03-19 16:07 ` Alan Stern
2012-03-19 14:33 ` Lan Tianyu [this message]
2012-03-19 16:10 ` [RFC PATCH 3/4] usb/acpi: add the support of usb hub ports' acpi binding without attached devices Alan Stern
2012-03-19 14:33 ` [RFC PATCH 4/4] usb/acpi: add usb check for the connect type of usb port Lan Tianyu
2012-03-19 16:13 ` Alan Stern
2012-03-19 16:04 ` [RFC PATCH 1/4] usb: add struct usb_hub_port to store port related members Alan Stern
2012-03-20 6:16 ` Lan Tianyu
2012-03-20 14:04 ` Alan Stern
2012-03-21 8:53 ` Lan Tianyu
[not found] ` <4F699725.3080404-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
2012-03-21 14:38 ` Alan Stern
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1332167626-5806-3-git-send-email-tianyu.lan@intel.com \
--to=tianyu.lan@intel.com \
--cc=gregkh@linuxfoundation.org \
--cc=lenb@kernel.org \
--cc=linux-acpi@vger.kernel.org \
--cc=linux-usb@vger.kernel.org \
--cc=mjg@redhat.com \
--cc=sarah.a.sharp@intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox