]> git.proxmox.com Git - mirror_edk2.git/blobdiff - OptionRomPkg/Bus/Usb/UsbNetworking/Ax88772b/DriverBinding.c
OptionRomPkg: Ax88772b: Fixing register access issue in Apple Eth Adapter
[mirror_edk2.git] / OptionRomPkg / Bus / Usb / UsbNetworking / Ax88772b / DriverBinding.c
index d64bc739c1aea53f4078dbc26e5c2ef6178546de..bf05c742176c7a48e6fecd7c2d8be0c5d7eddf52 100644 (file)
@@ -124,6 +124,8 @@ DriverStart (
        UINTN                                                   LengthInBytes;\r
        EFI_DEVICE_PATH_PROTOCOL        *ParentDevicePath = NULL;\r
        MAC_ADDR_DEVICE_PATH            MacDeviceNode;\r
+        EFI_USB_DEVICE_DESCRIPTOR       Device;\r
+        UINT32                          Index;\r
 \r
   //\r
        //  Allocate the device structure\r
@@ -178,6 +180,41 @@ DriverStart (
                  goto EXIT;\r
   }\r
 \r
+  Status = pNicDevice->pUsbIo->UsbGetDeviceDescriptor ( pNicDevice->pUsbIo, &Device );\r
+  if (EFI_ERROR ( Status )) {\r
+     gBS->CloseProtocol (\r
+               Controller,\r
+               &gEfiUsbIoProtocolGuid,\r
+               pThis->DriverBindingHandle,\r
+               Controller\r
+               );\r
+     gBS->FreePool ( pNicDevice );\r
+              goto EXIT;\r
+  } else {\r
+      //\r
+      //  Validate the adapter\r
+      //\r
+      for (Index = 0; ASIX_DONGLES[Index].VendorId != 0; Index++) {\r
+          if (ASIX_DONGLES[Index].VendorId == Device.IdVendor &&\r
+              ASIX_DONGLES[Index].ProductId == Device.IdProduct) {\r
+                break;\r
+          }\r
+      }\r
+\r
+      if (ASIX_DONGLES[Index].VendorId == 0) {\r
+         gBS->CloseProtocol (\r
+                   Controller,\r
+                   &gEfiUsbIoProtocolGuid,\r
+                   pThis->DriverBindingHandle,\r
+                   Controller\r
+                   );\r
+          gBS->FreePool ( pNicDevice );\r
+                   goto EXIT;\r
+      }\r
+\r
+      pNicDevice->Flags = ASIX_DONGLES[Index].Flags;\r
+  }\r
+\r
        //\r
   // Set Device Path\r
   //                   \r