+
+#undef NEW_INIT_SEQ
+#ifdef NEW_INIT_SEQ
+ /* this is a Windows scheme of initialization sequence, with double
+ * reset of the device. Some equipment is said to work only with such
+ * init sequence; this patch is based on the work by Alan Stern:
+ * http://sourceforge.net/mailarchive/forum.php?thread_id=5729457&forum_id=5398
+ */
+ int j;
+ struct usb_device_descriptor *desc;
+ int port = -1;
+ struct usb_device *parent = dev->parent;
+ unsigned short portstatus;
+
+ /* send 64-byte GET-DEVICE-DESCRIPTOR request. Since the descriptor is
+ * only 18 bytes long, this will terminate with a short packet. But if
+ * the maxpacket size is 8 or 16 the device may be waiting to transmit
+ * some more. */
+
+ desc = (struct usb_device_descriptor *)tmpbuf;
+ desc->bMaxPacketSize0 = 0;
+ for (j = 0; j < 3; ++j) {
+ err = usb_get_descriptor(dev, USB_DT_DEVICE, 0, desc, 64);
+ if (err < 0) {
+ USB_PRINTF("usb_new_device: 64 byte descr\n");
+ break;
+ }
+ }
+ dev->descriptor.bMaxPacketSize0 = desc->bMaxPacketSize0;
+
+ /* find the port number we're at */
+ if (parent) {
+
+ for (j = 0; j < parent->maxchild; j++) {
+ if (parent->children[j] == dev) {
+ port = j;
+ break;
+ }
+ }
+ if (port < 0) {
+ printf("usb_new_device: cannot locate device's port..\n");
+ return 1;
+ }
+
+ /* reset the port for the second time */
+ err = hub_port_reset(dev->parent, port, &portstatus);
+ if (err < 0) {
+ printf("\n Couldn't reset port %i\n", port);
+ return 1;
+ }
+ }
+#else
+ /* and this is the old and known way of initializing devices */