On Fri, Feb 15, 2002 at 09:59:13AM -0800, Greg KH wrote: > > Ok, in the whole "hub debounce problem" the problem where > usb_port_status is on the stack and passed to the host controller was > also brought up. Here's that patch split out of the debounce patch > against 2.5.5-pre1 thanks to Martin Diehl. > > Does anyone have any problems with this patch? > I'll also make up a 2.4.x based one, as it will be a bit different.
Here's the 2.4 version of the patch. Anyone have any problems with it? How about the time delay patch on top of this patch Martin? thanks, greg k-h diff -Nru a/drivers/usb/hub.c b/drivers/usb/hub.c --- a/drivers/usb/hub.c Mon Feb 18 22:09:26 2002 +++ b/drivers/usb/hub.c Mon Feb 18 22:09:26 2002 @@ -496,6 +496,29 @@ err("cannot disconnect hub %d", dev->devnum); } +static int usb_hub_port_status(struct usb_device *hub, int port, + u16 *status, u16 *change) +{ + struct usb_port_status *portsts; + int ret = -ENOMEM; + + portsts = kmalloc(sizeof(*portsts), GFP_KERNEL); + if (portsts) { + ret = usb_get_port_status(hub, port + 1, portsts); + if (ret < 0) + err("%s (%d) failed (err = %d)", __FUNCTION__, hub->devnum, +ret); + else { + *status = le16_to_cpu(portsts->wPortStatus); + *change = le16_to_cpu(portsts->wPortChange); + dbg("port %d, portstatus %x, change %x, %s", port + 1, + *status, *change, portspeed(*status)); + ret = 0; + } + kfree(portsts); + } + return ret; +} + #define HUB_RESET_TRIES 5 #define HUB_PROBE_TRIES 2 #define HUB_SHORT_RESET_TIME 10 @@ -507,25 +530,19 @@ struct usb_device *dev, unsigned int delay) { int delay_time, ret; - struct usb_port_status portsts; - unsigned short portchange, portstatus; + u16 portstatus; + u16 portchange; for (delay_time = 0; delay_time < HUB_RESET_TIMEOUT; delay_time += delay) { /* wait to give the device a chance to reset */ wait_ms(delay); /* read and decode port status */ - ret = usb_get_port_status(hub, port + 1, &portsts); + ret = usb_hub_port_status(hub, port, &portstatus, &portchange); if (ret < 0) { - err("get_port_status(%d) failed (err = %d)", port + 1, ret); return -1; } - portstatus = le16_to_cpu(portsts.wPortStatus); - portchange = le16_to_cpu(portsts.wPortChange); - dbg("port %d, portstatus %x, change %x, %s", port + 1, - portstatus, portchange, portspeed (portstatus)); - /* bomb out completely if something weird happened */ if ((portchange & USB_PORT_STAT_C_CONNECTION)) return -1; @@ -593,16 +610,13 @@ } static void usb_hub_port_connect_change(struct usb_device *hub, int port, - struct usb_port_status *portsts) + u16 portstatus, u16 portchange) { struct usb_device *dev; - unsigned short portstatus, portchange; unsigned int delay = HUB_SHORT_RESET_TIME; int i; char *portstr, *tempstr; - portstatus = le16_to_cpu(portsts->wPortStatus); - portchange = le16_to_cpu(portsts->wPortChange); dbg("port %d, portstatus %x, change %x, %s", port + 1, portstatus, portchange, portspeed (portstatus)); @@ -709,7 +723,10 @@ struct usb_device *dev; struct usb_hub *hub; struct usb_hub_status hubsts; - unsigned short hubstatus, hubchange; + u16 hubstatus; + u16 hubchange; + u16 portstatus; + u16 portchange; int i, ret; /* @@ -751,22 +768,15 @@ } for (i = 0; i < hub->descriptor->bNbrPorts; i++) { - struct usb_port_status portsts; - unsigned short portstatus, portchange; - - ret = usb_get_port_status(dev, i + 1, &portsts); + ret = usb_hub_port_status(dev, i, &portstatus, &portchange); if (ret < 0) { - err("get_port_status failed (err = %d)", ret); continue; } - portstatus = le16_to_cpu(portsts.wPortStatus); - portchange = le16_to_cpu(portsts.wPortChange); - if (portchange & USB_PORT_STAT_C_CONNECTION) { dbg("port %d connection change", i + 1); - usb_hub_port_connect_change(dev, i, &portsts); + usb_hub_port_connect_change(dev, i, portstatus, +portchange); } else if (portchange & USB_PORT_STAT_C_ENABLE) { dbg("port %d enable change, status %x", i + 1, portstatus); usb_clear_port_feature(dev, i + 1, USB_PORT_FEAT_C_ENABLE); @@ -780,7 +790,7 @@ (portstatus & USB_PORT_STAT_CONNECTION) && (dev->children[i])) { err("already running port %i disabled by hub (EMI?), re-enabling...", i + 1); - usb_hub_port_connect_change(dev, i, &portsts); + usb_hub_port_connect_change(dev, i, +portstatus, portchange); } } _______________________________________________ [EMAIL PROTECTED] To unsubscribe, use the last form field at: https://lists.sourceforge.net/lists/listinfo/linux-usb-devel