Author: janderwald
Date: Tue Dec 4 19:20:12 2012
New Revision: 57799
URL:
http://svn.reactos.org/svn/reactos?rev=57799&view=rev
Log:
[USBHUB]
- Handle devices which provide indicate a serial number but not provide one
- Fixes device installation initialization for F5D8053 N Wireless USB Adapter
Modified:
trunk/reactos/drivers/usb/usbhub/fdo.c
Modified: trunk/reactos/drivers/usb/usbhub/fdo.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/usb/usbhub/fdo.c?r…
==============================================================================
--- trunk/reactos/drivers/usb/usbhub/fdo.c [iso-8859-1] (original)
+++ trunk/reactos/drivers/usb/usbhub/fdo.c [iso-8859-1] Tue Dec 4 19:20:12 2012
@@ -1022,54 +1022,49 @@
0,
(PVOID*)&SerialBuffer,
&UsbChildExtension->usInstanceId.Length);
- if (!NT_SUCCESS(Status))
- {
- DPRINT1("USBHUB: GetUsbStringDescriptor failed with status %x\n",
Status);
+ if (NT_SUCCESS(Status))
+ {
+ // construct instance id buffer
+ Index = swprintf(Buffer, L"%04d&%s",
HubDeviceExtension->InstanceCount, SerialBuffer) + 1;
+ UsbChildExtension->usInstanceId.Buffer =
(LPWSTR)ExAllocatePool(NonPagedPool, Index * sizeof(WCHAR));
+ if (UsbChildExtension->usInstanceId.Buffer == NULL)
+ {
+ DPRINT1("Error: failed to allocate %lu bytes\n", Index *
sizeof(WCHAR));
+ return STATUS_INSUFFICIENT_RESOURCES;
+ }
+
+ //
+ // copy instance id
+ //
+ RtlCopyMemory(UsbChildExtension->usInstanceId.Buffer, Buffer, Index *
sizeof(WCHAR));
+ UsbChildExtension->usInstanceId.Length =
UsbChildExtension->usInstanceId.MaximumLength = Index * sizeof(WCHAR);
+ ExFreePool(SerialBuffer);
+
+ DPRINT("Usb InstanceId %wZ InstanceCount %x\n",
&UsbChildExtension->usInstanceId, HubDeviceExtension->InstanceCount);
return Status;
}
-
- // construct instance id buffer
- Index = swprintf(Buffer, L"%04d&%s",
HubDeviceExtension->InstanceCount, SerialBuffer) + 1;
- UsbChildExtension->usInstanceId.Buffer = (LPWSTR)ExAllocatePool(NonPagedPool,
Index * sizeof(WCHAR));
- if (UsbChildExtension->usInstanceId.Buffer == NULL)
- {
- DPRINT1("Error: failed to allocate %lu bytes\n", Index *
sizeof(WCHAR));
- Status = STATUS_INSUFFICIENT_RESOURCES;
- return Status;
- }
-
- //
- // copy instance id
- //
- RtlCopyMemory(UsbChildExtension->usInstanceId.Buffer, Buffer, Index *
sizeof(WCHAR));
- UsbChildExtension->usInstanceId.Length =
UsbChildExtension->usInstanceId.MaximumLength = Index * sizeof(WCHAR);
- ExFreePool(SerialBuffer);
-
- DPRINT("Usb InstanceId %wZ InstanceCount %x\n",
&UsbChildExtension->usInstanceId, HubDeviceExtension->InstanceCount);
- }
- else
- {
- //
- // the device did not provide a serial number, lets create a pseudo instance id
- //
- Index = swprintf(Buffer, L"%04d&%04d",
HubDeviceExtension->InstanceCount, UsbChildExtension->PortNumber) + 1;
- UsbChildExtension->usInstanceId.Buffer = (LPWSTR)ExAllocatePool(NonPagedPool,
Index * sizeof(WCHAR));
- if (UsbChildExtension->usInstanceId.Buffer == NULL)
- {
- DPRINT1("Error: failed to allocate %lu bytes\n", Index *
sizeof(WCHAR));
- Status = STATUS_INSUFFICIENT_RESOURCES;
- return Status;
- }
-
- //
- // copy instance id
- //
- RtlCopyMemory(UsbChildExtension->usInstanceId.Buffer, Buffer, Index *
sizeof(WCHAR));
- UsbChildExtension->usInstanceId.Length =
UsbChildExtension->usInstanceId.MaximumLength = Index * sizeof(WCHAR);
-
- DPRINT("usDeviceId %wZ\n", &UsbChildExtension->usInstanceId);
- }
-
+ }
+
+ //
+ // the device did not provide a serial number, or failed to retrieve the serial
number
+ // lets create a pseudo instance id
+ //
+ Index = swprintf(Buffer, L"%04d&%04d",
HubDeviceExtension->InstanceCount, UsbChildExtension->PortNumber) + 1;
+ UsbChildExtension->usInstanceId.Buffer = (LPWSTR)ExAllocatePool(NonPagedPool,
Index * sizeof(WCHAR));
+ if (UsbChildExtension->usInstanceId.Buffer == NULL)
+ {
+ DPRINT1("Error: failed to allocate %lu bytes\n", Index *
sizeof(WCHAR));
+ Status = STATUS_INSUFFICIENT_RESOURCES;
+ return Status;
+ }
+
+ //
+ // copy instance id
+ //
+ RtlCopyMemory(UsbChildExtension->usInstanceId.Buffer, Buffer, Index *
sizeof(WCHAR));
+ UsbChildExtension->usInstanceId.Length =
UsbChildExtension->usInstanceId.MaximumLength = Index * sizeof(WCHAR);
+
+ DPRINT("usDeviceId %wZ\n", &UsbChildExtension->usInstanceId);
return STATUS_SUCCESS;
}