Commit a4204ff0 authored by Dan Williams's avatar Dan Williams Committed by Greg Kroah-Hartman

usb: cleanup setting udev->removable from port_dev->connect_type

Once usb-acpi has set the port's connect type the usb_device's
->removable attribute can be set in the standard location
set_usb_port_removable().

This also changes behavior in the case where the firmware says that the
port connect type is unknown.  In that case just use the default setting
determined from the hub descriptor.

Note, we no longer pass udev->portnum to acpi_find_child_device() in the
root hub case since:
1/ the usb-core sets this to zero
2/ acpi always expects zero
...just pass zero.
Suggested-by: default avatarAlan Stern <stern@rowland.harvard.edu>
Acked-by: default avatarAlan Stern <stern@rowland.harvard.edu>
Signed-off-by: default avatarDan Williams <dan.j.williams@intel.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent d99f6b41
...@@ -2305,6 +2305,22 @@ static void set_usb_port_removable(struct usb_device *udev) ...@@ -2305,6 +2305,22 @@ static void set_usb_port_removable(struct usb_device *udev)
udev->removable = USB_DEVICE_REMOVABLE; udev->removable = USB_DEVICE_REMOVABLE;
else else
udev->removable = USB_DEVICE_FIXED; udev->removable = USB_DEVICE_FIXED;
/*
* Platform firmware may have populated an alternative value for
* removable. If the parent port has a known connect_type use
* that instead.
*/
switch (hub->ports[udev->portnum - 1]->connect_type) {
case USB_PORT_CONNECT_TYPE_HOT_PLUG:
udev->removable = USB_DEVICE_REMOVABLE;
break;
case USB_PORT_CONNECT_TYPE_HARD_WIRED:
udev->removable = USB_DEVICE_FIXED;
break;
default: /* use what was set above */
break;
}
} }
/** /**
...@@ -2374,11 +2390,7 @@ int usb_new_device(struct usb_device *udev) ...@@ -2374,11 +2390,7 @@ int usb_new_device(struct usb_device *udev)
device_enable_async_suspend(&udev->dev); device_enable_async_suspend(&udev->dev);
/* /* check whether the hub or firmware marks this port as non-removable */
* check whether the hub marks this port as non-removable. Do it
* now so that platform-specific data can override it in
* device_add()
*/
if (udev->parent) if (udev->parent)
set_usb_port_removable(udev); set_usb_port_removable(udev);
......
...@@ -136,8 +136,8 @@ static int usb_acpi_check_port_connect_type(struct usb_device *hdev, ...@@ -136,8 +136,8 @@ static int usb_acpi_check_port_connect_type(struct usb_device *hdev,
static struct acpi_device *usb_acpi_find_companion(struct device *dev) static struct acpi_device *usb_acpi_find_companion(struct device *dev)
{ {
int port1;
struct usb_device *udev; struct usb_device *udev;
struct acpi_device *adev;
acpi_handle *parent_handle; acpi_handle *parent_handle;
/* /*
...@@ -155,40 +155,18 @@ static struct acpi_device *usb_acpi_find_companion(struct device *dev) ...@@ -155,40 +155,18 @@ static struct acpi_device *usb_acpi_find_companion(struct device *dev)
*/ */
if (is_usb_device(dev)) { if (is_usb_device(dev)) {
udev = to_usb_device(dev); udev = to_usb_device(dev);
port1 = udev->portnum; if (udev->parent)
if (udev->parent) {
struct usb_hub *hub;
hub = usb_hub_to_struct_hub(udev->parent);
/*
* According usb port's connect type to set usb device's
* removability.
*/
switch (hub->ports[port1 - 1]->connect_type) {
case USB_PORT_CONNECT_TYPE_HOT_PLUG:
udev->removable = USB_DEVICE_REMOVABLE;
break;
case USB_PORT_CONNECT_TYPE_HARD_WIRED:
udev->removable = USB_DEVICE_FIXED;
break;
default:
udev->removable = USB_DEVICE_REMOVABLE_UNKNOWN;
break;
}
return NULL; return NULL;
}
/* root hub's parent is the usb hcd. */ /* root hub is only child (_ADR=0) under its parent, the HC */
return acpi_find_child_device(ACPI_COMPANION(dev->parent), adev = ACPI_COMPANION(dev->parent);
port1, false); return acpi_find_child_device(adev, 0, false);
} else if (is_usb_port(dev)) { } else if (is_usb_port(dev)) {
struct usb_port *port_dev = to_usb_port(dev); struct usb_port *port_dev = to_usb_port(dev);
struct acpi_device *adev = NULL; int port1 = port_dev->portnum;
/* Get the struct usb_device point of port's hub */ /* Get the struct usb_device point of port's hub */
udev = to_usb_device(dev->parent->parent); udev = to_usb_device(dev->parent->parent);
port1 = port_dev->portnum;
/* /*
* The root hub ports' parent is the root hub. The non-root-hub * The root hub ports' parent is the root hub. The non-root-hub
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment