Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 303927
b: refs/heads/master
c: f397d7c
h: refs/heads/master
i:
  303925: 7e263c2
  303923: d3c798f
  303919: 82e5a34
v: v3
  • Loading branch information
Lan Tianyu authored and Greg Kroah-Hartman committed May 12, 2012
1 parent dafcc0e commit 55bcee3
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 14 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 54d3f8c63d6940966217b807972778fb17c3fa82
refs/heads/master: f397d7c4c5e8a1eb93f2ed15808a509318ccf1dd
29 changes: 16 additions & 13 deletions trunk/drivers/usb/core/hub.c
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,10 @@
#endif
#endif

struct usb_hub_port {
void *port_owner;
};

struct usb_hub {
struct device *intfdev; /* the "interface" device */
struct usb_device *hdev;
Expand Down Expand Up @@ -81,7 +85,7 @@ struct usb_hub {
u8 indicator[USB_MAXCHILDREN];
struct delayed_work leds;
struct delayed_work init_work;
void **port_owners;
struct usb_hub_port *port_data;
};

static inline int hub_is_superspeed(struct usb_device *hdev)
Expand Down Expand Up @@ -1049,8 +1053,9 @@ static int hub_configure(struct usb_hub *hub,

hdev->children = kzalloc(hdev->maxchild *
sizeof(struct usb_device *), GFP_KERNEL);
hub->port_owners = kzalloc(hdev->maxchild * sizeof(void *), GFP_KERNEL);
if (!hdev->children || !hub->port_owners) {
hub->port_data = kzalloc(hdev->maxchild * sizeof(struct usb_hub_port),
GFP_KERNEL);
if (!hub->port_data || !hdev->children) {
ret = -ENOMEM;
goto fail;
}
Expand Down Expand Up @@ -1305,7 +1310,7 @@ static void hub_disconnect(struct usb_interface *intf)

usb_free_urb(hub->urb);
kfree(hdev->children);
kfree(hub->port_owners);
kfree(hub->port_data);
kfree(hub->descriptor);
kfree(hub->status);
kfree(hub->buffer);
Expand Down Expand Up @@ -1437,7 +1442,7 @@ static int find_port_owner(struct usb_device *hdev, unsigned port1,
/* This assumes that devices not managed by the hub driver
* will always have maxchild equal to 0.
*/
*ppowner = &(hdev_to_hub(hdev)->port_owners[port1 - 1]);
*ppowner = &(hdev_to_hub(hdev)->port_data[port1 - 1].port_owner);
return 0;
}

Expand Down Expand Up @@ -1472,16 +1477,14 @@ int usb_hub_release_port(struct usb_device *hdev, unsigned port1, void *owner)

void usb_hub_release_all_ports(struct usb_device *hdev, void *owner)
{
struct usb_hub *hub = hdev_to_hub(hdev);
int n;
void **powner;

n = find_port_owner(hdev, 1, &powner);
if (n == 0) {
for (; n < hdev->maxchild; (++n, ++powner)) {
if (*powner == owner)
*powner = NULL;
}
for (n = 0; n < hdev->maxchild; n++) {
if (hub->port_data[n].port_owner == owner)
hub->port_data[n].port_owner = NULL;
}

}

/* The caller must hold udev's lock */
Expand All @@ -1492,7 +1495,7 @@ bool usb_device_is_owned(struct usb_device *udev)
if (udev->state == USB_STATE_NOTATTACHED || !udev->parent)
return false;
hub = hdev_to_hub(udev->parent);
return !!hub->port_owners[udev->portnum - 1];
return !!hub->port_data[udev->portnum - 1].port_owner;
}


Expand Down

0 comments on commit 55bcee3

Please sign in to comment.