Report correctly USB device class and subclass when the device reports only one interface and the class is not defined in the device descriptor
Modified: trunk/reactos/drivers/usb/usbhub/fdo.c

Modified: trunk/reactos/drivers/usb/usbhub/fdo.c
--- trunk/reactos/drivers/usb/usbhub/fdo.c	2005-09-23 08:55:33 UTC (rev 18005)
+++ trunk/reactos/drivers/usb/usbhub/fdo.c	2005-09-23 09:02:16 UTC (rev 18006)
@@ -110,13 +110,11 @@
 		if (!NT_SUCCESS(Status))
 			goto ByeBye;
 		
-		DPRINT1("child #%lu: USB\\Vid_%04x&Pid_%04x&Rev_%04x (class %x:%x)\n",
+		DPRINT1("child #%lu: USB\\Vid_%04x&Pid_%04x&Rev_%04x\n",
 			i,
 			PdoExtension->dev->descriptor.idVendor,
 			PdoExtension->dev->descriptor.idProduct,
-			PdoExtension->dev->descriptor.bcdDevice,
-			PdoExtension->dev->descriptor.bDeviceClass,
-			PdoExtension->dev->descriptor.bDeviceSubClass);
+			PdoExtension->dev->descriptor.bcdDevice);
 		sprintf(Buffer[0], "USB\\Vid_%04x&Pid_%04x&Rev_%04x",
 			PdoExtension->dev->descriptor.idVendor,
 			PdoExtension->dev->descriptor.idProduct,
@@ -139,15 +137,33 @@
 		if (PdoExtension->dev->actconfig->desc.bNumInterfaces == 1)
 		{
 			/* Single-interface USB device */
-			sprintf(Buffer[0], "USB\\Class_%02x&SubClass_%02x&Prot_%02x",
-				PdoExtension->dev->descriptor.bDeviceClass,
-				PdoExtension->dev->descriptor.bDeviceSubClass,
-				PdoExtension->dev->descriptor.bDeviceProtocol);
-			sprintf(Buffer[1], "USB\\Class_%02x&SubClass_%02x",
-				PdoExtension->dev->descriptor.bDeviceClass,
-				PdoExtension->dev->descriptor.bDeviceSubClass);
-			sprintf(Buffer[2], "USB\\Class_%02x",
-				PdoExtension->dev->descriptor.bDeviceClass);
+			if (PdoExtension->dev->descriptor.bDeviceClass != 0)
+			{
+				/* Use these values for device class/sub class/protocol */
+				sprintf(Buffer[0], "USB\\Class_%02x&SubClass_%02x&Prot_%02x",
+					PdoExtension->dev->descriptor.bDeviceClass,
+					PdoExtension->dev->descriptor.bDeviceSubClass,
+					PdoExtension->dev->descriptor.bDeviceProtocol);
+				sprintf(Buffer[1], "USB\\Class_%02x&SubClass_%02x",
+					PdoExtension->dev->descriptor.bDeviceClass,
+					PdoExtension->dev->descriptor.bDeviceSubClass);
+				sprintf(Buffer[2], "USB\\Class_%02x",
+					PdoExtension->dev->descriptor.bDeviceClass);
+			}
+			else
+			{
+				/* Use values specified in the interface descriptor */
+				struct usb_host_interface *itf = PdoExtension->dev->actconfig->interface->altsetting;
+				sprintf(Buffer[0], "USB\\Class_%02x&SubClass_%02x&Prot_%02x",
+					itf->desc.bInterfaceClass,
+					itf->desc.bInterfaceSubClass,
+					itf->desc.bInterfaceProtocol);
+				sprintf(Buffer[1], "USB\\Class_%02x&SubClass_%02x",
+					itf->desc.bInterfaceClass,
+					itf->desc.bInterfaceSubClass);
+				sprintf(Buffer[2], "USB\\Class_%02x",
+					itf->desc.bInterfaceClass);
+			}
 			Status = UsbhubInitMultiSzString(
 				&PdoExtension->CompatibleIds,
 				Buffer[0], Buffer[1], Buffer[2], NULL);