Skip to content

Commit

Permalink
Revert "usb: add struct usb_hub_port to store port related members."
Browse files Browse the repository at this point in the history
This reverts commit f397d7c.

This series isn't quite ready for 3.5 just yet, so revert it and give
the author more time to get it correct.

Cc: Lan Tianyu <tianyu.lan@intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
  • Loading branch information
Greg Kroah-Hartman committed May 14, 2012
1 parent fa28618 commit 304f0b2
Showing 1 changed file with 13 additions and 16 deletions.
29 changes: 13 additions & 16 deletions drivers/usb/core/hub.c
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,6 @@
#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 @@ -85,7 +81,7 @@ struct usb_hub {
u8 indicator[USB_MAXCHILDREN];
struct delayed_work leds;
struct delayed_work init_work;
struct usb_hub_port *port_data;
void **port_owners;
};

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

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

usb_free_urb(hub->urb);
kfree(hdev->children);
kfree(hub->port_data);
kfree(hub->port_owners);
kfree(hub->descriptor);
kfree(hub->status);
kfree(hub->buffer);
Expand Down Expand Up @@ -1442,7 +1437,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_data[port1 - 1].port_owner);
*ppowner = &(hdev_to_hub(hdev)->port_owners[port1 - 1]);
return 0;
}

Expand Down Expand Up @@ -1477,14 +1472,16 @@ 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;

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

}

/* The caller must hold udev's lock */
Expand All @@ -1495,7 +1492,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_data[udev->portnum - 1].port_owner;
return !!hub->port_owners[udev->portnum - 1];
}


Expand Down

0 comments on commit 304f0b2

Please sign in to comment.