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.

- Dave
--- ./drivers/usb-dist/core/usb.c       Mon Nov 11 06:37:46 2002
+++ ./drivers/usb/core/usb.c    Tue Nov 12 08:17:29 2002
@@ -68,5 +70,5 @@
 
 static struct device_driver usb_generic_driver = {
-       .name = "generic",
+       .name = "usb",
        .bus = &usb_bus_type,
        .probe = generic_probe,
@@ -950,4 +952,22 @@
        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.
@@ -1011,4 +1031,6 @@
        }
 
+       /* USB device state == addressed ... still not usable */
+
        err = usb_get_device_descriptor(dev);
        if (err < (signed)sizeof(dev->descriptor)) {
@@ -1043,4 +1065,6 @@
        }
 
+       /* 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);
@@ -1052,21 +1076,8 @@
 #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);
 

Reply via email to