Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 289428
b: refs/heads/master
c: d35e70d
h: refs/heads/master
v: v3
  • Loading branch information
Matthew Garrett authored and Greg Kroah-Hartman committed Feb 9, 2012
1 parent fedd7ed commit 8ae77ce
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 1 deletion.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 0846e7e9856c0928223447d9349a877202a63f24
refs/heads/master: d35e70d50a0641ebc1502fd343bef9b4011ada27
40 changes: 40 additions & 0 deletions trunk/drivers/usb/core/hub.c
Original file line number Diff line number Diff line change
Expand Up @@ -1838,6 +1838,37 @@ static int usb_enumerate_device(struct usb_device *udev)
return err;
}

static void set_usb_port_removable(struct usb_device *udev)
{
struct usb_device *hdev = udev->parent;
struct usb_hub *hub;
u8 port = udev->portnum;
u16 wHubCharacteristics;
bool removable = true;

if (!hdev)
return;

hub = hdev_to_hub(udev->parent);

wHubCharacteristics = le16_to_cpu(hub->descriptor->wHubCharacteristics);

if (!(wHubCharacteristics & HUB_CHAR_COMPOUND))
return;

if (hub_is_superspeed(hdev)) {
if (hub->descriptor->u.ss.DeviceRemovable & (1 << port))
removable = false;
} else {
if (hub->descriptor->u.hs.DeviceRemovable[port / 8] & (1 << (port % 8)))
removable = false;
}

if (removable)
udev->removable = USB_DEVICE_REMOVABLE;
else
udev->removable = USB_DEVICE_FIXED;
}

/**
* usb_new_device - perform initial device setup (usbcore-internal)
Expand Down Expand Up @@ -1896,6 +1927,15 @@ int usb_new_device(struct usb_device *udev)
announce_device(udev);

device_enable_async_suspend(&udev->dev);

/*
* 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)
set_usb_port_removable(udev);

/* Register the device. The device driver is responsible
* for configuring the device and invoking the add-device
* notifier chain (used by usbfs and possibly others).
Expand Down

0 comments on commit 8ae77ce

Please sign in to comment.