diff options
Diffstat (limited to 'drivers/usb/core/port.c')
-rw-r--r-- | drivers/usb/core/port.c | 40 |
1 files changed, 38 insertions, 2 deletions
diff --git a/drivers/usb/core/port.c b/drivers/usb/core/port.c index d288dfe..280433d 100644 --- a/drivers/usb/core/port.c +++ b/drivers/usb/core/port.c @@ -77,10 +77,36 @@ static int usb_port_runtime_resume(struct device *dev) struct usb_port *port_dev = to_usb_port(dev); struct usb_device *hdev = to_usb_device(dev->parent->parent); struct usb_interface *intf = to_usb_interface(dev->parent); + struct usb_hub *hub = usb_hub_to_struct_hub(hdev); + int port1 = port_dev->portnum; int retval; + if (!hub) + return -EINVAL; + usb_autopm_get_interface(intf); - retval = usb_hub_set_port_power(hdev, port_dev->portnum, true); + set_bit(port1, hub->busy_bits); + + retval = usb_hub_set_port_power(hdev, port1, true); + if (port_dev->child && !retval) { + /* + * Wait for usb hub port to be reconnected in order to make + * the resume procedure successful. + */ + retval = hub_port_debounce_be_connected(hub, port1); + if (retval < 0) { + dev_dbg(&port_dev->dev, "can't get reconnection after setting port power on, status %d\n", + retval); + goto out; + } + usb_clear_port_feature(hdev, port1, USB_PORT_FEAT_C_ENABLE); + + /* Set return value to 0 if debounce successful */ + retval = 0; + } + +out: + clear_bit(port1, hub->busy_bits); usb_autopm_put_interface(intf); return retval; } @@ -90,14 +116,23 @@ static int usb_port_runtime_suspend(struct device *dev) struct usb_port *port_dev = to_usb_port(dev); struct usb_device *hdev = to_usb_device(dev->parent->parent); struct usb_interface *intf = to_usb_interface(dev->parent); + struct usb_hub *hub = usb_hub_to_struct_hub(hdev); + int port1 = port_dev->portnum; int retval; + if (!hub) + return -EINVAL; + if (dev_pm_qos_flags(&port_dev->dev, PM_QOS_FLAG_NO_POWER_OFF) == PM_QOS_FLAGS_ALL) return -EAGAIN; usb_autopm_get_interface(intf); - retval = usb_hub_set_port_power(hdev, port_dev->portnum, false); + set_bit(port1, hub->busy_bits); + retval = usb_hub_set_port_power(hdev, port1, false); + usb_clear_port_feature(hdev, port1, USB_PORT_FEAT_C_CONNECTION); + usb_clear_port_feature(hdev, port1, USB_PORT_FEAT_C_ENABLE); + clear_bit(port1, hub->busy_bits); usb_autopm_put_interface(intf); return retval; } @@ -130,6 +165,7 @@ int usb_hub_create_port_device(struct usb_hub *hub, int port1) hub->ports[port1 - 1] = port_dev; port_dev->portnum = port1; + port_dev->power_is_on = true; port_dev->dev.parent = hub->intfdev; port_dev->dev.groups = port_dev_group; port_dev->dev.type = &usb_port_device_type; |