[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[MiNT] [PATCH] Fix USB devices connected handling
Please Alan commit this patch.
Thank you!
Commit message:
Fix for when an USB device initialization fails, the USB device struct
data for others connected devices is messed up.
Index: sys/usb/src.km/usb.c
===================================================================
RCS file: /mint/freemint/sys/usb/src.km/usb.c,v
retrieving revision 1.7
diff -u -8 -r1.7 usb.c
--- sys/usb/src.km/usb.c 11 Feb 2014 22:39:35 -0000 1.7
+++ sys/usb/src.km/usb.c 18 Feb 2014 11:20:14 -0000
@@ -881,17 +881,16 @@
/*
* Free the newly created device node.
* Called in error cases where configuring a newly attached
* device fails for some reason.
*/
void usb_free_device(long dev_index)
{
DEBUG(("Freeing device node: %ld\n", dev_index));
- dev_index--;
memset(&usb_dev[dev_index], 0, sizeof(struct usb_device));
usb_dev[dev_index].devnum = -1;
}
/*
* By the time we get here, the device has gotten a new device ID
* and is in the default state. We need to identify the thing and
@@ -952,16 +951,17 @@
/* Default to 64 byte max packet size */
dev->maxpacketsize = PACKET_SIZE_64;
dev->epmaxpacketin[0] = 64;
dev->epmaxpacketout[0] = 64;
err = usb_get_descriptor(dev, USB_DT_DEVICE, 0, desc, 64);
if (err < 0) {
DEBUG(("usb_new_device: usb_get_descriptor() failed"));
+ dev->devnum = addr;
return 1;
}
dev->descriptor.bMaxPacketSize0 = desc->bMaxPacketSize0;
/*
* Fetch the device class, driver can use this info
* to differentiate between HUB and DEVICE.
*/