ChangeSet 1.823.3.17, 2002/11/14 11:25:38-08:00, [EMAIL PROTECTED]
[PATCH] usb_new_device() sets up dev->dev earlier
This mostly moves the initialization of some sysfs-related
fields earlier, so HCD code can access them during those
(initial error prone) parts of enumeration without oopsing.
The particular access I wanted was using <linux/driver.h>
debug utilities like dev_dbg(), dev_warn() and so on ... so
I also changed the name the "generic" driver gives itself
to be "usb" so those messages make more sense.
Also added comments about how usb_new_device() moves the
device through the other chapter 9 usb device states.
diff -Nru a/drivers/usb/core/usb.c b/drivers/usb/core/usb.c
--- a/drivers/usb/core/usb.c Thu Nov 14 14:12:12 2002
+++ b/drivers/usb/core/usb.c Thu Nov 14 14:12:12 2002
@@ -67,7 +67,7 @@
}
static struct device_driver usb_generic_driver = {
- .name = "generic",
+ .name = "usb",
.bus = &usb_bus_type,
.probe = generic_probe,
.remove = generic_remove,
@@ -941,6 +941,24 @@
int i;
int j;
+ /*
+ * Set the driver for the usb device to point to the "generic" driver.
+ * This prevents the main usb device from being sent to the usb bus
+ * probe function. Yes, it's a hack, but a nice one :)
+ *
+ * Do it asap, so more driver model stuff (like the device.h message
+ * utilities) can be used in hcd submit/unlink code paths.
+ */
+ usb_generic_driver.bus = &usb_bus_type;
+ dev->dev.parent = parent;
+ dev->dev.driver = &usb_generic_driver;
+ dev->dev.bus = &usb_bus_type;
+ if (dev->dev.bus_id[0] == 0)
+ sprintf (&dev->dev.bus_id[0], "%d-%s",
+ dev->bus->busnum, dev->devpath);
+
+ /* USB device state == default ... it's not usable yet */
+
/* USB 2.0 section 5.5.3 talks about ep0 maxpacket ...
* it's fixed size except for full speed devices.
*/
@@ -1002,6 +1020,8 @@
dev->epmaxpacketout[0] = dev->descriptor.bMaxPacketSize0;
}
+ /* USB device state == addressed ... still not usable */
+
err = usb_get_device_descriptor(dev);
if (err < (signed)sizeof(dev->descriptor)) {
if (err < 0)
@@ -1034,6 +1054,8 @@
return 1;
}
+ /* USB device state == configured ... tell the world! */
+
dbg("new device strings: Mfr=%d, Product=%d, SerialNumber=%d",
dev->descriptor.iManufacturer, dev->descriptor.iProduct,
dev->descriptor.iSerialNumber);
set_device_description (dev);
@@ -1043,23 +1065,10 @@
usb_show_string(dev, "SerialNumber", dev->descriptor.iSerialNumber);
#endif
- /*
- * Set the driver for the usb device to point to the "generic" driver.
- * This prevents the main usb device from being sent to the usb bus
- * probe function. Yes, it's a hack, but a nice one :)
- */
- usb_generic_driver.bus = &usb_bus_type;
- dev->dev.parent = parent;
- dev->dev.driver = &usb_generic_driver;
- dev->dev.bus = &usb_bus_type;
- if (dev->dev.bus_id[0] == 0)
- sprintf (&dev->dev.bus_id[0], "%d-%s",
- dev->bus->busnum, dev->devpath);
+ /* put into sysfs, with device and config specific files */
err = device_register (&dev->dev);
if (err)
return err;
-
- /* add the USB device specific driverfs files */
usb_create_driverfs_dev_files (dev);
/* Register all of the interfaces for this device with the driver core.
-------------------------------------------------------
This sf.net email is sponsored by: To learn the basics of securing
your web site with SSL, click here to get a FREE TRIAL of a Thawte
Server Certificate: http://www.gothawte.com/rd524.html
_______________________________________________
[EMAIL PROTECTED]
To unsubscribe, use the last form field at:
https://lists.sourceforge.net/lists/listinfo/linux-usb-devel