]> git.proxmox.com Git - mirror_edk2.git/blobdiff - EdkModulePkg/Bus/Usb/UsbMassStorage/Dxe/UsbMassStorageHelper.c
Fix the build break by removing an unreferenced static function.
[mirror_edk2.git] / EdkModulePkg / Bus / Usb / UsbMassStorage / Dxe / UsbMassStorageHelper.c
index 3d6a6d977b2e983ec759cac351c87378b91d1516..eb7a8bb63a44373fce6505d2464135d3fea54f07 100644 (file)
@@ -1,18 +1,18 @@
 /*++\r
 \r
 /*++\r
 \r
-Copyright (c) 2006, Intel Corporation                                                         \r
-All rights reserved. This program and the accompanying materials                          \r
-are licensed and made available under the terms and conditions of the BSD License         \r
-which accompanies this distribution.  The full text of the license may be found at        \r
-http://opensource.org/licenses/bsd-license.php                                            \r
-                                                                                          \r
-THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
-WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+Copyright (c) 2006, Intel Corporation\r
+All rights reserved. This program and the accompanying materials\r
+are licensed and made available under the terms and conditions of the BSD License\r
+which accompanies this distribution.  The full text of the license may be found at\r
+http://opensource.org/licenses/bsd-license.php\r
+\r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
 \r
 Module Name:\r
 \r
   UsbMassStorageHelper.c\r
 \r
 Module Name:\r
 \r
   UsbMassStorageHelper.c\r
-    \r
+\r
 Abstract:\r
 \r
   Helper functions for USB Mass Storage Driver\r
 Abstract:\r
 \r
   Helper functions for USB Mass Storage Driver\r
@@ -59,12 +59,6 @@ IsMediaWriteProtected (
   IN  UINTN                 SenseCounts\r
   );\r
 \r
   IN  UINTN                 SenseCounts\r
   );\r
 \r
-STATIC\r
-BOOLEAN\r
-IsLogicalUnitCommunicationOverRun (\r
-  IN  REQUEST_SENSE_DATA    *SenseData,\r
-  IN  UINTN                 SenseCounts\r
-  );\r
 \r
 EFI_STATUS\r
 USBFloppyPacketCommand (\r
 \r
 EFI_STATUS\r
 USBFloppyPacketCommand (\r
@@ -80,19 +74,19 @@ USBFloppyPacketCommand (
 \r
   Routine Description:\r
     Sends Packet Command to USB Floppy Drive.\r
 \r
   Routine Description:\r
     Sends Packet Command to USB Floppy Drive.\r
-  \r
+\r
   Arguments:\r
     UsbFloppyDevice  -  The USB_FLOPPY_DEV instance.\r
     Command          -  A pointer to the command packet.\r
     CommandSize      -  Indicates the size of the command packet.\r
     DataBuffer       -  A pointer to the buffer for the data transfer\r
   Arguments:\r
     UsbFloppyDevice  -  The USB_FLOPPY_DEV instance.\r
     Command          -  A pointer to the command packet.\r
     CommandSize      -  Indicates the size of the command packet.\r
     DataBuffer       -  A pointer to the buffer for the data transfer\r
-                        after the command packet.              \r
+                        after the command packet.\r
     BufferLength     -  Indicates the size of the Data Buffer.\r
     Direction        -  Transfer Direction\r
     TimeOutInMilliSeconds - Timeout Value\r
     BufferLength     -  Indicates the size of the Data Buffer.\r
     Direction        -  Transfer Direction\r
     TimeOutInMilliSeconds - Timeout Value\r
-  Returns:  \r
+  Returns:\r
     EFI_SUCCESS  - Success\r
     EFI_SUCCESS  - Success\r
---*/    \r
+--*/\r
 {\r
   EFI_USB_ATAPI_PROTOCOL  *UsbAtapiInterface;\r
   EFI_STATUS              Status;\r
 {\r
   EFI_USB_ATAPI_PROTOCOL  *UsbAtapiInterface;\r
   EFI_STATUS              Status;\r
@@ -123,14 +117,14 @@ USBFloppyIdentify (
 \r
   Routine Description:\r
     Retrieves device information to tell the device type.\r
 \r
   Routine Description:\r
     Retrieves device information to tell the device type.\r
-  \r
+\r
   Arguments:\r
     UsbFloppyDevice    The USB_FLOPPY_DEV instance.\r
   Arguments:\r
     UsbFloppyDevice    The USB_FLOPPY_DEV instance.\r
-      \r
-  Returns:  \r
+\r
+  Returns:\r
     EFI_DEVICE_ERROR - Hardware error\r
     EFI_SUCCESS      - Success\r
     EFI_DEVICE_ERROR - Hardware error\r
     EFI_SUCCESS      - Success\r
---*/    \r
+--*/\r
 {\r
 \r
   EFI_STATUS        Status;\r
 {\r
 \r
   EFI_STATUS        Status;\r
@@ -144,7 +138,7 @@ USBFloppyIdentify (
   if (EFI_ERROR (Status)) {\r
     return EFI_DEVICE_ERROR;\r
   }\r
   if (EFI_ERROR (Status)) {\r
     return EFI_DEVICE_ERROR;\r
   }\r
-   \r
+\r
   //\r
   // Get media removable info from INQUIRY data.\r
   //\r
   //\r
   // Get media removable info from INQUIRY data.\r
   //\r
@@ -201,7 +195,7 @@ USBFloppyIdentify (
     gBS->FreePool (Idata);\r
     return EFI_DEVICE_ERROR;\r
   }\r
     gBS->FreePool (Idata);\r
     return EFI_DEVICE_ERROR;\r
   }\r
-  \r
+\r
   //\r
   // Get media information.\r
   //\r
   //\r
   // Get media information.\r
   //\r
@@ -221,22 +215,20 @@ USBFloppyInquiry (
 \r
   Routine Description:\r
     Send Inquiry Packet Command to device and retrieve Inquiry Data.\r
 \r
   Routine Description:\r
     Send Inquiry Packet Command to device and retrieve Inquiry Data.\r
-  \r
+\r
   Arguments:\r
     UsbFloppyDevice    The USB_FLOPPY_DEV instance.\r
   Arguments:\r
     UsbFloppyDevice    The USB_FLOPPY_DEV instance.\r
-    Idata              A pointer pointing to the address of \r
+    Idata              A pointer pointing to the address of\r
                        Inquiry Data.\r
                        Inquiry Data.\r
-      \r
-  Returns:  \r
+\r
+  Returns:\r
     EFI_DEVICE_ERROR - Hardware error\r
     EFI_SUCCESS      - Success\r
     EFI_DEVICE_ERROR - Hardware error\r
     EFI_SUCCESS      - Success\r
---*/      \r
+--*/\r
 {\r
   ATAPI_PACKET_COMMAND    Packet;\r
   EFI_STATUS              Status;\r
 {\r
   ATAPI_PACKET_COMMAND    Packet;\r
   EFI_STATUS              Status;\r
-  EFI_USB_ATAPI_PROTOCOL  *UsbAtapiInterface;\r
 \r
 \r
-  UsbAtapiInterface = UsbFloppyDevice->AtapiProtocol;\r
 \r
   //\r
   // prepare command packet for the Inquiry Packet Command.\r
 \r
   //\r
   // prepare command packet for the Inquiry Packet Command.\r
@@ -272,31 +264,31 @@ USBFloppyInquiry (
 \r
 EFI_STATUS\r
 USBFloppyRead10 (\r
 \r
 EFI_STATUS\r
 USBFloppyRead10 (\r
-  IN    USB_FLOPPY_DEV    *UsbFloppyDevice,\r
-  IN    VOID              *Buffer,\r
-  IN    EFI_LBA           Lba,\r
-  IN    UINTN             NumberOfBlocks\r
+  IN  USB_FLOPPY_DEV    *UsbFloppyDevice,\r
+  IN  VOID              *Buffer,\r
+  IN  EFI_LBA           Lba,\r
+  IN  UINTN             NumberOfBlocks\r
   )\r
 /*++\r
 \r
   Routine Description:\r
     Sends Read10 Packet Command to device to perform data transfer\r
     from device to host.\r
   )\r
 /*++\r
 \r
   Routine Description:\r
     Sends Read10 Packet Command to device to perform data transfer\r
     from device to host.\r
-  \r
+\r
   Arguments:\r
     UsbFloppyDevice -   The USB_FLOPPY_DEV instance.\r
   Arguments:\r
     UsbFloppyDevice -   The USB_FLOPPY_DEV instance.\r
-    Buffer          -   A pointer to the destination buffer for the data. \r
+    Buffer          -   A pointer to the destination buffer for the data.\r
                         The caller is responsible for either having implicit\r
                         or explicit ownership of the buffer.\r
                         The caller is responsible for either having implicit\r
                         or explicit ownership of the buffer.\r
-    Lba             -   The starting logical block address to read from \r
+    Lba             -   The starting logical block address to read from\r
                         on the device.\r
                         on the device.\r
-    NumberOfBlocks  -   Indicates the number of blocks that the read \r
+    NumberOfBlocks  -   Indicates the number of blocks that the read\r
                         operation requests.\r
                         operation requests.\r
-      \r
-  Returns:  \r
+\r
+  Returns:\r
     EFI_DEVICE_ERROR - Hardware error\r
     EFI_SUCCESS      - Success\r
     EFI_DEVICE_ERROR - Hardware error\r
     EFI_SUCCESS      - Success\r
---*/      \r
+--*/\r
 {\r
   ATAPI_PACKET_COMMAND    Packet;\r
   READ10_CMD              *Read10Packet;\r
 {\r
   ATAPI_PACKET_COMMAND    Packet;\r
   READ10_CMD              *Read10Packet;\r
@@ -309,10 +301,8 @@ USBFloppyRead10 (
   VOID                    *ptrBuffer;\r
   EFI_STATUS              Status;\r
   UINT16                  TimeOut;\r
   VOID                    *ptrBuffer;\r
   EFI_STATUS              Status;\r
   UINT16                  TimeOut;\r
-  EFI_USB_ATAPI_PROTOCOL  *UsbAtapiInterface;\r
-  UINTN                   SenseCounts;\r
+  UINT8                   Index;\r
 \r
 \r
-  UsbAtapiInterface = UsbFloppyDevice->AtapiProtocol;\r
 \r
   //\r
   // prepare command packet for the Inquiry Packet Command.\r
 \r
   //\r
   // prepare command packet for the Inquiry Packet Command.\r
@@ -333,78 +323,52 @@ USBFloppyRead10 (
     } else {\r
       SectorCount = MaxBlock;\r
     }\r
     } else {\r
       SectorCount = MaxBlock;\r
     }\r
-    //\r
-    // fill the Packet data structure\r
-    //\r
-    Read10Packet->opcode = READ_10;\r
 \r
 \r
-    //\r
-    // Lba0 ~ Lba3 specify the start logical block address of the data transfer.\r
-    // Lba0 is MSB, Lba3 is LSB\r
-    //\r
-    Read10Packet->Lba3  = (UINT8) (Lba32 & 0xff);\r
-    Read10Packet->Lba2  = (UINT8) (Lba32 >> 8);\r
-    Read10Packet->Lba1  = (UINT8) (Lba32 >> 16);\r
-    Read10Packet->Lba0  = (UINT8) (Lba32 >> 24);\r
+    for (Index = 0; Index < 3; Index ++) {\r
 \r
 \r
-    //\r
-    // TranLen0 ~ TranLen1 specify the transfer length in block unit.\r
-    // TranLen0 is MSB, TranLen is LSB\r
-    //\r
-    Read10Packet->TranLen1  = (UINT8) (SectorCount & 0xff);\r
-    Read10Packet->TranLen0  = (UINT8) (SectorCount >> 8);\r
+      //\r
+      // fill the Packet data structure\r
+      //\r
+      Read10Packet->opcode = READ_10;\r
+      //\r
+      // Lba0 ~ Lba3 specify the start logical block address of the data transfer.\r
+      // Lba0 is MSB, Lba3 is LSB\r
+      //\r
+      Read10Packet->Lba3  = (UINT8) (Lba32 & 0xff);\r
+      Read10Packet->Lba2  = (UINT8) (Lba32 >> 8);\r
+      Read10Packet->Lba1  = (UINT8) (Lba32 >> 16);\r
+      Read10Packet->Lba0  = (UINT8) (Lba32 >> 24);\r
 \r
 \r
-    ByteCount               = SectorCount * BlockSize;\r
+      //\r
+      // TranLen0 ~ TranLen1 specify the transfer length in block unit.\r
+      // TranLen0 is MSB, TranLen is LSB\r
+      //\r
+      Read10Packet->TranLen1  = (UINT8) (SectorCount & 0xff);\r
+      Read10Packet->TranLen0  = (UINT8) (SectorCount >> 8);\r
 \r
 \r
-    TimeOut                 = (UINT16) (SectorCount * USBFLPTIMEOUT);\r
+      ByteCount               = SectorCount * BlockSize;\r
 \r
 \r
-    Status = USBFloppyPacketCommand (\r
-              UsbFloppyDevice,\r
-              &Packet,\r
-              sizeof (ATAPI_PACKET_COMMAND),\r
-              (VOID *) ptrBuffer,\r
-              ByteCount,\r
-              EfiUsbDataIn,\r
-              TimeOut\r
-              );\r
-    if (EFI_ERROR (Status)) {\r
+      TimeOut                 = (UINT16) (SectorCount * USBFLPTIMEOUT);\r
 \r
 \r
-      Status = UsbFloppyRequestSense (UsbFloppyDevice, &SenseCounts);\r
-      if (!EFI_ERROR (Status)) {\r
-        if (IsLogicalUnitCommunicationOverRun (\r
-              UsbFloppyDevice->SenseData,\r
-              SenseCounts\r
-              )) {\r
-          Lba32           = (UINT32) Lba;\r
-          ptrBuffer       = Buffer;\r
-          BlocksRemaining = (UINT16) NumberOfBlocks;\r
-          MaxBlock        = (UINT16) (MaxBlock / 4);\r
-          if (MaxBlock < 1) {\r
-            MaxBlock = 1;\r
-          }\r
 \r
 \r
-          continue;\r
-        }\r
-      } else {\r
-        return EFI_DEVICE_ERROR;\r
-      }\r
-      //\r
-      // retry read10 command\r
-      //\r
       Status = USBFloppyPacketCommand (\r
       Status = USBFloppyPacketCommand (\r
-                UsbFloppyDevice,\r
-                &Packet,\r
-                sizeof (ATAPI_PACKET_COMMAND),\r
-                (VOID *) ptrBuffer,\r
-                ByteCount,\r
-                EfiUsbDataIn,\r
-                TimeOut\r
-                );\r
-      if (EFI_ERROR (Status)) {\r
-        return EFI_DEVICE_ERROR;\r
+                 UsbFloppyDevice,\r
+                 &Packet,\r
+                 sizeof (ATAPI_PACKET_COMMAND),\r
+                 (VOID *) ptrBuffer,\r
+                 ByteCount,\r
+                 EfiUsbDataIn,\r
+                 TimeOut\r
+                 );\r
+      if (!EFI_ERROR (Status)) {\r
+         break;\r
       }\r
     }\r
 \r
       }\r
     }\r
 \r
+    if (Index == 3) {\r
+      return EFI_DEVICE_ERROR;\r
+    }\r
+\r
     Lba32 += SectorCount;\r
     ptrBuffer       = (UINT8 *) ptrBuffer + SectorCount * BlockSize;\r
     BlocksRemaining = (UINT16) (BlocksRemaining - SectorCount);\r
     Lba32 += SectorCount;\r
     ptrBuffer       = (UINT8 *) ptrBuffer + SectorCount * BlockSize;\r
     BlocksRemaining = (UINT16) (BlocksRemaining - SectorCount);\r
@@ -413,6 +377,7 @@ USBFloppyRead10 (
   return Status;\r
 }\r
 \r
   return Status;\r
 }\r
 \r
+STATIC\r
 EFI_STATUS\r
 USBFloppyReadCapacity (\r
   IN  USB_FLOPPY_DEV    *UsbFloppyDevice\r
 EFI_STATUS\r
 USBFloppyReadCapacity (\r
   IN  USB_FLOPPY_DEV    *UsbFloppyDevice\r
@@ -420,23 +385,22 @@ USBFloppyReadCapacity (
 /*++\r
 \r
   Routine Description:\r
 /*++\r
 \r
   Routine Description:\r
-    Retrieves media capacity information via \r
+    Retrieves media capacity information via\r
     sending Read Capacity Packet Command.\r
     sending Read Capacity Packet Command.\r
-  \r
+\r
   Arguments:\r
     UsbFloppyDevice -   The USB_FLOPPY_DEV instance.\r
   Arguments:\r
     UsbFloppyDevice -   The USB_FLOPPY_DEV instance.\r
-      \r
-  Returns:  \r
+\r
+  Returns:\r
     EFI_DEVICE_ERROR - Hardware error\r
     EFI_SUCCESS      - Success\r
     EFI_DEVICE_ERROR - Hardware error\r
     EFI_SUCCESS      - Success\r
---*/        \r
-{ \r
+--*/\r
+{\r
   //\r
   // status returned by Read Capacity Packet Command\r
   //\r
   EFI_STATUS              Status;\r
   ATAPI_PACKET_COMMAND    Packet;\r
   //\r
   // status returned by Read Capacity Packet Command\r
   //\r
   EFI_STATUS              Status;\r
   ATAPI_PACKET_COMMAND    Packet;\r
-  EFI_USB_ATAPI_PROTOCOL  *UsbAtapiInterface;\r
 \r
   //\r
   // used for capacity data returned from Usb Floppy\r
 \r
   //\r
   // used for capacity data returned from Usb Floppy\r
@@ -445,7 +409,6 @@ USBFloppyReadCapacity (
 \r
   ZeroMem (&Data, sizeof (Data));\r
 \r
 \r
   ZeroMem (&Data, sizeof (Data));\r
 \r
-  UsbAtapiInterface = UsbFloppyDevice->AtapiProtocol;\r
 \r
   ZeroMem (&Packet, sizeof (ATAPI_PACKET_COMMAND));\r
   Packet.Inquiry.opcode = READ_CAPACITY;\r
 \r
   ZeroMem (&Packet, sizeof (ATAPI_PACKET_COMMAND));\r
   Packet.Inquiry.opcode = READ_CAPACITY;\r
@@ -483,23 +446,22 @@ USBFloppyReadFormatCapacity (
 /*++\r
 \r
   Routine Description:\r
 /*++\r
 \r
   Routine Description:\r
-    Retrieves media capacity information via sending Read Format \r
+    Retrieves media capacity information via sending Read Format\r
     Capacity Packet Command.\r
     Capacity Packet Command.\r
-  \r
+\r
   Arguments:\r
     UsbFloppyDevice  - The USB_FLOPPY_DEV instance.\r
   Arguments:\r
     UsbFloppyDevice  - The USB_FLOPPY_DEV instance.\r
-      \r
-  Returns:  \r
+\r
+  Returns:\r
     EFI_DEVICE_ERROR - Hardware error\r
     EFI_SUCCESS      - Success\r
     EFI_DEVICE_ERROR - Hardware error\r
     EFI_SUCCESS      - Success\r
---*/         \r
-{ \r
+--*/\r
+{\r
   //\r
   // status returned by Read Capacity Packet Command\r
   //\r
   EFI_STATUS                Status;\r
   ATAPI_PACKET_COMMAND      Packet;\r
   //\r
   // status returned by Read Capacity Packet Command\r
   //\r
   EFI_STATUS                Status;\r
   ATAPI_PACKET_COMMAND      Packet;\r
-  EFI_USB_ATAPI_PROTOCOL    *UsbAtapiInterface;\r
 \r
   //\r
   // used for capacity data returned from Usb Floppy\r
 \r
   //\r
   // used for capacity data returned from Usb Floppy\r
@@ -508,7 +470,6 @@ USBFloppyReadFormatCapacity (
 \r
   ZeroMem (&FormatData, sizeof (FormatData));\r
 \r
 \r
   ZeroMem (&FormatData, sizeof (FormatData));\r
 \r
-  UsbAtapiInterface = UsbFloppyDevice->AtapiProtocol;\r
 \r
   ZeroMem (&Packet, sizeof (ATAPI_PACKET_COMMAND));\r
   Packet.ReadFormatCapacity.opcode                = READ_FORMAT_CAPACITY;\r
 \r
   ZeroMem (&Packet, sizeof (ATAPI_PACKET_COMMAND));\r
   Packet.ReadFormatCapacity.opcode                = READ_FORMAT_CAPACITY;\r
@@ -537,7 +498,7 @@ USBFloppyReadFormatCapacity (
   } else {\r
 \r
     UsbFloppyDevice->BlkIo.Media->LastBlock = (FormatData.LastLba3 << 24) |\r
   } else {\r
 \r
     UsbFloppyDevice->BlkIo.Media->LastBlock = (FormatData.LastLba3 << 24) |\r
-                                              (FormatData.LastLba2 << 16) | \r
+                                              (FormatData.LastLba2 << 16) |\r
                                               (FormatData.LastLba1 << 8)  |\r
                                                FormatData.LastLba0;\r
 \r
                                               (FormatData.LastLba1 << 8)  |\r
                                                FormatData.LastLba0;\r
 \r
@@ -565,26 +526,24 @@ UsbFloppyRequestSense (
 /*++\r
 \r
   Routine Description:\r
 /*++\r
 \r
   Routine Description:\r
-    Retrieves Sense Data from device via \r
+    Retrieves Sense Data from device via\r
     sending Request Sense Packet Command.\r
     sending Request Sense Packet Command.\r
-  \r
+\r
   Arguments:\r
     UsbFloppyDevice - The USB_FLOPPY_DEV instance.\r
     SenseCounts     - A pointer to the number of Sense Data returned.\r
   Arguments:\r
     UsbFloppyDevice - The USB_FLOPPY_DEV instance.\r
     SenseCounts     - A pointer to the number of Sense Data returned.\r
-      \r
-  Returns:  \r
+\r
+  Returns:\r
     EFI_DEVICE_ERROR - Hardware error\r
     EFI_SUCCESS      - Success\r
     EFI_DEVICE_ERROR - Hardware error\r
     EFI_SUCCESS      - Success\r
---*/         \r
+--*/\r
 {\r
   EFI_STATUS              Status;\r
   REQUEST_SENSE_DATA      *Sense;\r
   UINT8                   *Ptr;\r
   BOOLEAN                 SenseReq;\r
   ATAPI_PACKET_COMMAND    Packet;\r
 {\r
   EFI_STATUS              Status;\r
   REQUEST_SENSE_DATA      *Sense;\r
   UINT8                   *Ptr;\r
   BOOLEAN                 SenseReq;\r
   ATAPI_PACKET_COMMAND    Packet;\r
-  EFI_USB_ATAPI_PROTOCOL  *UsbAtapiInterface;\r
 \r
 \r
-  UsbAtapiInterface = UsbFloppyDevice->AtapiProtocol;\r
 \r
   *SenseCounts      = 0;\r
 \r
 \r
   *SenseCounts      = 0;\r
 \r
@@ -598,7 +557,7 @@ UsbFloppyRequestSense (
   ZeroMem (&Packet, sizeof (ATAPI_PACKET_COMMAND));\r
   Packet.RequestSense.opcode            = REQUEST_SENSE;\r
   Packet.RequestSense.allocation_length = sizeof (REQUEST_SENSE_DATA);\r
   ZeroMem (&Packet, sizeof (ATAPI_PACKET_COMMAND));\r
   Packet.RequestSense.opcode            = REQUEST_SENSE;\r
   Packet.RequestSense.allocation_length = sizeof (REQUEST_SENSE_DATA);\r
-  \r
+\r
   //\r
   // initialize pointer\r
   //\r
   //\r
   // initialize pointer\r
   //\r
@@ -666,7 +625,7 @@ UsbFloppyRequestSense (
       //\r
       SenseReq = FALSE;\r
     }\r
       //\r
       SenseReq = FALSE;\r
     }\r
-  \r
+\r
     //\r
     // If the sense key numbers exceed Sense Data Buffer size,\r
     // just skip the loop and do not fetch the sense key in this function.\r
     //\r
     // If the sense key numbers exceed Sense Data Buffer size,\r
     // just skip the loop and do not fetch the sense key in this function.\r
@@ -687,25 +646,23 @@ UsbFloppyTestUnitReady (
 \r
   Routine Description:\r
     Sends Test Unit ReadyPacket Command to the device.\r
 \r
   Routine Description:\r
     Sends Test Unit ReadyPacket Command to the device.\r
-  \r
+\r
   Arguments:\r
     UsbFloppyDevice -  The USB_FLOPPY_DEV instance.\r
   Arguments:\r
     UsbFloppyDevice -  The USB_FLOPPY_DEV instance.\r
-      \r
-  Returns:  \r
+\r
+  Returns:\r
     EFI_DEVICE_ERROR - Hardware error\r
     EFI_SUCCESS      - Success\r
     EFI_DEVICE_ERROR - Hardware error\r
     EFI_SUCCESS      - Success\r
---*/  \r
-{ \r
-  ATAPI_PACKET_COMMAND      Packet; \r
+--*/\r
+{\r
+  ATAPI_PACKET_COMMAND      Packet;\r
   EFI_STATUS                Status;\r
   EFI_STATUS                Status;\r
-  EFI_USB_ATAPI_PROTOCOL    *UsbAtapiInterface;\r
   UINT32                    RetryIndex;\r
   UINT32                    MaximumRetryTimes;\r
   UINT32                    RetryIndex;\r
   UINT32                    MaximumRetryTimes;\r
-  \r
-  UsbAtapiInterface = UsbFloppyDevice->AtapiProtocol;\r
+\r
   MaximumRetryTimes = 2;\r
   //\r
   MaximumRetryTimes = 2;\r
   //\r
-  // fill command packet  \r
+  // fill command packet\r
   //\r
   ZeroMem (&Packet, sizeof (ATAPI_PACKET_COMMAND));\r
   Packet.TestUnitReady.opcode = TEST_UNIT_READY;\r
   //\r
   ZeroMem (&Packet, sizeof (ATAPI_PACKET_COMMAND));\r
   Packet.TestUnitReady.opcode = TEST_UNIT_READY;\r
@@ -737,31 +694,31 @@ UsbFloppyTestUnitReady (
 \r
 EFI_STATUS\r
 USBFloppyWrite10 (\r
 \r
 EFI_STATUS\r
 USBFloppyWrite10 (\r
-  IN    USB_FLOPPY_DEV    *UsbFloppyDevice,\r
-  IN    VOID              *Buffer,\r
-  IN    EFI_LBA           Lba,\r
-  IN    UINTN             NumberOfBlocks\r
+  IN  USB_FLOPPY_DEV    *UsbFloppyDevice,\r
+  IN  VOID              *Buffer,\r
+  IN  EFI_LBA           Lba,\r
+  IN  UINTN             NumberOfBlocks\r
   )\r
 /*++\r
 \r
   Routine Description:\r
     Sends Write10 Packet Command to device to perform data transfer\r
     from host to device.\r
   )\r
 /*++\r
 \r
   Routine Description:\r
     Sends Write10 Packet Command to device to perform data transfer\r
     from host to device.\r
-  \r
+\r
   Arguments:\r
     UsbFloppyDevice -   The USB_FLOPPY_DEV instance.\r
   Arguments:\r
     UsbFloppyDevice -   The USB_FLOPPY_DEV instance.\r
-    Buffer          -   A pointer to the source buffer for the data. \r
+    Buffer          -   A pointer to the source buffer for the data.\r
                         The caller is responsible for either having implicit\r
                         or explicit ownership of the buffer.\r
                         The caller is responsible for either having implicit\r
                         or explicit ownership of the buffer.\r
-    Lba             -   The starting logical block address to written to \r
+    Lba             -   The starting logical block address to written to\r
                         the device.\r
                         the device.\r
-    NumberOfBlocks  -   Indicates the number of blocks that the write \r
+    NumberOfBlocks  -   Indicates the number of blocks that the write\r
                         operation requests.\r
                         operation requests.\r
-      \r
-  Returns:  \r
+\r
+  Returns:\r
     EFI_DEVICE_ERROR - Hardware error\r
     EFI_SUCCESS      - Success\r
     EFI_DEVICE_ERROR - Hardware error\r
     EFI_SUCCESS      - Success\r
---*/      \r
+--*/\r
 {\r
   ATAPI_PACKET_COMMAND    Packet;\r
   READ10_CMD              *Write10Packet;\r
 {\r
   ATAPI_PACKET_COMMAND    Packet;\r
   READ10_CMD              *Write10Packet;\r
@@ -774,10 +731,8 @@ USBFloppyWrite10 (
   VOID                    *ptrBuffer;\r
   EFI_STATUS              Status;\r
   UINT16                  TimeOut;\r
   VOID                    *ptrBuffer;\r
   EFI_STATUS              Status;\r
   UINT16                  TimeOut;\r
-  EFI_USB_ATAPI_PROTOCOL  *UsbAtapiInterface;\r
-  UINTN                   SenseCounts;\r
+  UINT8                   Index;\r
 \r
 \r
-  UsbAtapiInterface = UsbFloppyDevice->AtapiProtocol;\r
 \r
   //\r
   // prepare command packet for the Write10 Packet Command.\r
 \r
   //\r
   // prepare command packet for the Write10 Packet Command.\r
@@ -795,82 +750,56 @@ USBFloppyWrite10 (
   while (BlocksRemaining > 0) {\r
 \r
     if (BlocksRemaining <= MaxBlock) {\r
   while (BlocksRemaining > 0) {\r
 \r
     if (BlocksRemaining <= MaxBlock) {\r
-\r
       SectorCount = BlocksRemaining;\r
     } else {\r
       SectorCount = BlocksRemaining;\r
     } else {\r
-\r
       SectorCount = MaxBlock;\r
     }\r
       SectorCount = MaxBlock;\r
     }\r
-    //\r
-    // fill the Packet data structure\r
-    //\r
-    Write10Packet->opcode = WRITE_10;\r
 \r
 \r
-    //\r
-    // Lba0 ~ Lba3 specify the start logical block address\r
-    // of the data transfer.\r
-    // Lba0 is MSB, Lba3 is LSB\r
-    //\r
-    Write10Packet->Lba3 = (UINT8) (Lba32 & 0xff);\r
-    Write10Packet->Lba2 = (UINT8) (Lba32 >> 8);\r
-    Write10Packet->Lba1 = (UINT8) (Lba32 >> 16);\r
-    Write10Packet->Lba0 = (UINT8) (Lba32 >> 24);\r
+    for (Index = 0; Index < 3; Index ++) {\r
+      //\r
+      // fill the Packet data structure\r
+      //\r
+      Write10Packet->opcode = WRITE_10;\r
 \r
 \r
-    //\r
-    // TranLen0 ~ TranLen1 specify the transfer length in block unit.\r
-    // TranLen0 is MSB, TranLen is LSB\r
-    //\r
-    Write10Packet->TranLen1 = (UINT8) (SectorCount & 0xff);\r
-    Write10Packet->TranLen0 = (UINT8) (SectorCount >> 8);\r
+      //\r
+      // Lba0 ~ Lba3 specify the start logical block address\r
+      // of the data transfer.\r
+      // Lba0 is MSB, Lba3 is LSB\r
+      //\r
+      Write10Packet->Lba3 = (UINT8) (Lba32 & 0xff);\r
+      Write10Packet->Lba2 = (UINT8) (Lba32 >> 8);\r
+      Write10Packet->Lba1 = (UINT8) (Lba32 >> 16);\r
+      Write10Packet->Lba0 = (UINT8) (Lba32 >> 24);\r
 \r
 \r
-    ByteCount               = SectorCount * BlockSize;\r
+      //\r
+      // TranLen0 ~ TranLen1 specify the transfer length in block unit.\r
+      // TranLen0 is MSB, TranLen is LSB\r
+      //\r
+      Write10Packet->TranLen1 = (UINT8) (SectorCount & 0xff);\r
+      Write10Packet->TranLen0 = (UINT8) (SectorCount >> 8);\r
 \r
 \r
-    TimeOut                 = (UINT16) (SectorCount * USBFLPTIMEOUT);\r
+      ByteCount               = SectorCount * BlockSize;\r
 \r
 \r
-    Status = USBFloppyPacketCommand (\r
-              UsbFloppyDevice,\r
-              &Packet,\r
-              sizeof (ATAPI_PACKET_COMMAND),\r
-              (VOID *) ptrBuffer,\r
-              ByteCount,\r
-              EfiUsbDataOut,\r
-              TimeOut\r
-              );\r
-    if (EFI_ERROR (Status)) {\r
-      Status = UsbFloppyRequestSense (UsbFloppyDevice, &SenseCounts);\r
-      if (!EFI_ERROR (Status)) {\r
-        if (IsLogicalUnitCommunicationOverRun (\r
-              UsbFloppyDevice->SenseData,\r
-              SenseCounts\r
-              )) {\r
-          Lba32           = (UINT32) Lba;\r
-          ptrBuffer       = Buffer;\r
-          BlocksRemaining = (UINT16) NumberOfBlocks;\r
-          MaxBlock        = (UINT16) (MaxBlock / 4);\r
-          if (MaxBlock < 1) {\r
-            MaxBlock = 1;\r
-          }\r
+      TimeOut                 = (UINT16) (SectorCount * USBFLPTIMEOUT);\r
 \r
 \r
-          continue;\r
-        }\r
-      }\r
-      //\r
-      // retry write10 command\r
-      //\r
       Status = USBFloppyPacketCommand (\r
       Status = USBFloppyPacketCommand (\r
-                UsbFloppyDevice,\r
-                &Packet,\r
-                sizeof (ATAPI_PACKET_COMMAND),\r
-                (VOID *) ptrBuffer,\r
-                ByteCount,\r
-                EfiUsbDataOut,\r
-                TimeOut\r
-                );\r
-      if (EFI_ERROR (Status)) {\r
-        return EFI_DEVICE_ERROR;\r
+                 UsbFloppyDevice,\r
+                 &Packet,\r
+                 sizeof (ATAPI_PACKET_COMMAND),\r
+                 (VOID *) ptrBuffer,\r
+                 ByteCount,\r
+                 EfiUsbDataOut,\r
+                 TimeOut\r
+                 );\r
+      if (!EFI_ERROR (Status)) {\r
+         break;\r
       }\r
     }\r
 \r
       }\r
     }\r
 \r
+    if (Index == 3) {\r
+      return EFI_DEVICE_ERROR;\r
+    }\r
+\r
     Lba32 += SectorCount;\r
     ptrBuffer       = (UINT8 *) ptrBuffer + SectorCount * BlockSize;\r
     BlocksRemaining = (UINT16) (BlocksRemaining - SectorCount);\r
     Lba32 += SectorCount;\r
     ptrBuffer       = (UINT8 *) ptrBuffer + SectorCount * BlockSize;\r
     BlocksRemaining = (UINT16) (BlocksRemaining - SectorCount);\r
@@ -888,16 +817,16 @@ UsbFloppyDetectMedia (
 \r
   Routine Description:\r
     Retrieves media information.\r
 \r
   Routine Description:\r
     Retrieves media information.\r
-  \r
+\r
   Arguments:\r
     UsbFloppyDevice  -  The USB_FLOPPY_DEV instance.\r
     MediaChange      -  Indicates whether media was changed.\r
   Arguments:\r
     UsbFloppyDevice  -  The USB_FLOPPY_DEV instance.\r
     MediaChange      -  Indicates whether media was changed.\r
-      \r
-  Returns:  \r
+\r
+  Returns:\r
     EFI_DEVICE_ERROR - Hardware error\r
     EFI_SUCCESS      - Success\r
     EFI_INVALID_PARAMETER - Parameter is error\r
     EFI_DEVICE_ERROR - Hardware error\r
     EFI_SUCCESS      - Success\r
     EFI_INVALID_PARAMETER - Parameter is error\r
---*/        \r
+--*/\r
 {\r
   EFI_STATUS          Status;\r
   EFI_STATUS          FloppyStatus;\r
 {\r
   EFI_STATUS          Status;\r
   EFI_STATUS          FloppyStatus;\r
@@ -910,13 +839,10 @@ UsbFloppyDetectMedia (
   UINTN               RetryTimes;\r
   UINTN               MaximumRetryTimes;\r
   BOOLEAN             NeedRetry;\r
   UINTN               RetryTimes;\r
   UINTN               MaximumRetryTimes;\r
   BOOLEAN             NeedRetry;\r
-\r
+  BOOLEAN             NeedReadCapacity;\r
   //\r
   // a flag used to determine whether need to perform Read Capacity command.\r
   //\r
   //\r
   // a flag used to determine whether need to perform Read Capacity command.\r
   //\r
-  BOOLEAN             NeedReadCapacity;\r
-\r
-  REQUEST_SENSE_DATA  *SensePtr;\r
 \r
   //\r
   // init\r
 \r
   //\r
   // init\r
@@ -937,8 +863,6 @@ UsbFloppyDetectMedia (
 \r
   if (!EFI_ERROR (Status)) {\r
 \r
 \r
   if (!EFI_ERROR (Status)) {\r
 \r
-    SensePtr = UsbFloppyDevice->SenseData;\r
-\r
     //\r
     // No Media\r
     //\r
     //\r
     // No Media\r
     //\r
@@ -955,14 +879,14 @@ UsbFloppyDetectMedia (
       if (IsMediaChange (UsbFloppyDevice->SenseData, SenseCounts)) {\r
         UsbFloppyDevice->BlkIo.Media->MediaId++;\r
       }\r
       if (IsMediaChange (UsbFloppyDevice->SenseData, SenseCounts)) {\r
         UsbFloppyDevice->BlkIo.Media->MediaId++;\r
       }\r
-        \r
+\r
       //\r
       // Media Write-protected\r
       //\r
       if (IsMediaWriteProtected (UsbFloppyDevice->SenseData, SenseCounts)) {\r
         UsbFloppyDevice->BlkIo.Media->ReadOnly = TRUE;\r
       }\r
       //\r
       // Media Write-protected\r
       //\r
       if (IsMediaWriteProtected (UsbFloppyDevice->SenseData, SenseCounts)) {\r
         UsbFloppyDevice->BlkIo.Media->ReadOnly = TRUE;\r
       }\r
-        \r
+\r
       //\r
       // Media Error\r
       //\r
       //\r
       // Media Error\r
       //\r
@@ -999,26 +923,26 @@ UsbFloppyDetectMedia (
         Status = USBFloppyReadCapacity (UsbFloppyDevice);\r
         break;\r
 \r
         Status = USBFloppyReadCapacity (UsbFloppyDevice);\r
         break;\r
 \r
-      case USBFLOPPY:\r
+      case USBFLOPPY2:\r
         UsbMassStorageModeSense (UsbFloppyDevice);\r
         Status = USBFloppyReadFormatCapacity (UsbFloppyDevice);\r
         if (EFI_ERROR (Status) || !UsbFloppyDevice->BlkMedia.MediaPresent) {\r
           //\r
           // retry the ReadCapacity command\r
           //\r
         UsbMassStorageModeSense (UsbFloppyDevice);\r
         Status = USBFloppyReadFormatCapacity (UsbFloppyDevice);\r
         if (EFI_ERROR (Status) || !UsbFloppyDevice->BlkMedia.MediaPresent) {\r
           //\r
           // retry the ReadCapacity command\r
           //\r
-          UsbFloppyDevice->DeviceType = USBFLOPPY2;\r
+          UsbFloppyDevice->DeviceType = USBFLOPPY;\r
           Status                      = EFI_DEVICE_ERROR;\r
         }\r
         break;\r
 \r
           Status                      = EFI_DEVICE_ERROR;\r
         }\r
         break;\r
 \r
-      case USBFLOPPY2:\r
+      case USBFLOPPY:\r
         UsbMassStorageModeSense (UsbFloppyDevice);\r
         Status = USBFloppyReadCapacity (UsbFloppyDevice);\r
         if (EFI_ERROR (Status)) {\r
           //\r
           // retry the ReadFormatCapacity command\r
           //\r
         UsbMassStorageModeSense (UsbFloppyDevice);\r
         Status = USBFloppyReadCapacity (UsbFloppyDevice);\r
         if (EFI_ERROR (Status)) {\r
           //\r
           // retry the ReadFormatCapacity command\r
           //\r
-          UsbFloppyDevice->DeviceType = USBFLOPPY;\r
+          UsbFloppyDevice->DeviceType = USBFLOPPY2;\r
         }\r
         //\r
         // force the BlockSize to be 0x200.\r
         }\r
         //\r
         // force the BlockSize to be 0x200.\r
@@ -1078,7 +1002,7 @@ UsbFloppyDetectMedia (
       }\r
 \r
       if (!IsDriveReady (UsbFloppyDevice->SenseData, SenseCounts, &NeedRetry)) {\r
       }\r
 \r
       if (!IsDriveReady (UsbFloppyDevice->SenseData, SenseCounts, &NeedRetry)) {\r
-          \r
+\r
         //\r
         // Drive not ready: if NeedRetry, then retry once more;\r
         // else return error\r
         //\r
         // Drive not ready: if NeedRetry, then retry once more;\r
         // else return error\r
@@ -1160,24 +1084,23 @@ UsbFloppyModeSense5APage5 (
 /*++\r
 \r
   Routine Description:\r
 /*++\r
 \r
   Routine Description:\r
-    Retrieves media capacity information via sending Read Format \r
+    Retrieves media capacity information via sending Read Format\r
     Capacity Packet Command.\r
     Capacity Packet Command.\r
-  \r
+\r
   Arguments:\r
     UsbFloppyDevice  - The USB_FLOPPY_DEV instance.\r
   Arguments:\r
     UsbFloppyDevice  - The USB_FLOPPY_DEV instance.\r
-      \r
-  Returns:  \r
+\r
+  Returns:\r
     EFI_DEVICE_ERROR - Hardware error\r
     EFI_SUCCESS      - Success\r
     EFI_DEVICE_ERROR - Hardware error\r
     EFI_SUCCESS      - Success\r
-    \r
---*/         \r
-{ \r
+\r
+--*/\r
+{\r
   //\r
   // status returned by Read Capacity Packet Command\r
   //\r
   EFI_STATUS                Status;\r
   ATAPI_PACKET_COMMAND      Packet;\r
   //\r
   // status returned by Read Capacity Packet Command\r
   //\r
   EFI_STATUS                Status;\r
   ATAPI_PACKET_COMMAND      Packet;\r
-  EFI_USB_ATAPI_PROTOCOL    *UsbAtapiInterface;\r
   UFI_MODE_PARAMETER_PAGE_5 ModePage5;\r
   EFI_LBA                   LastBlock;\r
   UINT32                    SectorsPerTrack;\r
   UFI_MODE_PARAMETER_PAGE_5 ModePage5;\r
   EFI_LBA                   LastBlock;\r
   UINT32                    SectorsPerTrack;\r
@@ -1185,7 +1108,6 @@ UsbFloppyModeSense5APage5 (
   UINT32                    NumberOfHeads;\r
   UINT32                    DataBytesPerSector;\r
 \r
   UINT32                    NumberOfHeads;\r
   UINT32                    DataBytesPerSector;\r
 \r
-  UsbAtapiInterface = UsbFloppyDevice->AtapiProtocol;\r
 \r
   ZeroMem (&ModePage5, sizeof (UFI_MODE_PARAMETER_PAGE_5));\r
 \r
 \r
   ZeroMem (&ModePage5, sizeof (UFI_MODE_PARAMETER_PAGE_5));\r
 \r
@@ -1246,27 +1168,25 @@ UsbFloppyModeSense5APage1C (
 /*++\r
 \r
   Routine Description:\r
 /*++\r
 \r
   Routine Description:\r
-    Retrieves media capacity information via sending Read Format \r
+    Retrieves media capacity information via sending Read Format\r
     Capacity Packet Command.\r
     Capacity Packet Command.\r
-  \r
+\r
   Arguments:\r
     UsbFloppyDevice  - The USB_FLOPPY_DEV instance.\r
   Arguments:\r
     UsbFloppyDevice  - The USB_FLOPPY_DEV instance.\r
-      \r
-  Returns:  \r
+\r
+  Returns:\r
     EFI_DEVICE_ERROR - Hardware error\r
     EFI_SUCCESS      - Success\r
     EFI_DEVICE_ERROR - Hardware error\r
     EFI_SUCCESS      - Success\r
-    \r
---*/         \r
-{ \r
+\r
+--*/\r
+{\r
   //\r
   // status returned by Read Capacity Packet Command\r
   //\r
   EFI_STATUS                  Status;\r
   ATAPI_PACKET_COMMAND        Packet;\r
   //\r
   // status returned by Read Capacity Packet Command\r
   //\r
   EFI_STATUS                  Status;\r
   ATAPI_PACKET_COMMAND        Packet;\r
-  EFI_USB_ATAPI_PROTOCOL      *UsbAtapiInterface;\r
   UFI_MODE_PARAMETER_PAGE_1C  ModePage1C;\r
 \r
   UFI_MODE_PARAMETER_PAGE_1C  ModePage1C;\r
 \r
-  UsbAtapiInterface = UsbFloppyDevice->AtapiProtocol;\r
 \r
   ZeroMem (&ModePage1C, sizeof (UFI_MODE_PARAMETER_PAGE_1C));\r
 \r
 \r
   ZeroMem (&ModePage1C, sizeof (UFI_MODE_PARAMETER_PAGE_1C));\r
 \r
@@ -1323,26 +1243,24 @@ UsbFloppyModeSense5APage3F (
   Routine Description:\r
     Retrieves mode sense information via sending Mode Sense\r
     Packet Command.\r
   Routine Description:\r
     Retrieves mode sense information via sending Mode Sense\r
     Packet Command.\r
-  \r
+\r
   Arguments:\r
     UsbFloppyDevice  - The USB_FLOPPY_DEV instance.\r
   Arguments:\r
     UsbFloppyDevice  - The USB_FLOPPY_DEV instance.\r
-      \r
-  Returns:  \r
+\r
+  Returns:\r
     EFI_DEVICE_ERROR - Hardware error\r
     EFI_SUCCESS      - Success\r
 \r
     EFI_DEVICE_ERROR - Hardware error\r
     EFI_SUCCESS      - Success\r
 \r
---*/         \r
-{ \r
+--*/\r
+{\r
   //\r
   // status returned by Read Capacity Packet Command\r
   //\r
   EFI_STATUS                Status;\r
   ATAPI_PACKET_COMMAND      Packet;\r
   //\r
   // status returned by Read Capacity Packet Command\r
   //\r
   EFI_STATUS                Status;\r
   ATAPI_PACKET_COMMAND      Packet;\r
-  EFI_USB_ATAPI_PROTOCOL    *UsbAtapiInterface;\r
   UFI_MODE_PARAMETER_HEADER Header;\r
   UINT32                    Size;\r
 \r
   UFI_MODE_PARAMETER_HEADER Header;\r
   UINT32                    Size;\r
 \r
-  UsbAtapiInterface = UsbFloppyDevice->AtapiProtocol;\r
 \r
   Size              = sizeof (UFI_MODE_PARAMETER_HEADER);\r
 \r
 \r
   Size              = sizeof (UFI_MODE_PARAMETER_HEADER);\r
 \r
@@ -1381,26 +1299,24 @@ UsbSCSIModeSense1APage3F (
   Routine Description:\r
     Retrieves mode sense information via sending Mode Sense\r
     Packet Command.\r
   Routine Description:\r
     Retrieves mode sense information via sending Mode Sense\r
     Packet Command.\r
-  \r
+\r
   Arguments:\r
     UsbFloppyDevice  - The USB_FLOPPY_DEV instance.\r
   Arguments:\r
     UsbFloppyDevice  - The USB_FLOPPY_DEV instance.\r
-      \r
-  Returns:  \r
+\r
+  Returns:\r
     EFI_DEVICE_ERROR - Hardware error\r
     EFI_SUCCESS      - Success\r
     EFI_DEVICE_ERROR - Hardware error\r
     EFI_SUCCESS      - Success\r
-    \r
---*/  \r
-{ \r
+\r
+--*/\r
+{\r
   //\r
   // status returned by Read Capacity Packet Command\r
   //\r
   EFI_STATUS                  Status;\r
   ATAPI_PACKET_COMMAND        Packet;\r
   //\r
   // status returned by Read Capacity Packet Command\r
   //\r
   EFI_STATUS                  Status;\r
   ATAPI_PACKET_COMMAND        Packet;\r
-  EFI_USB_ATAPI_PROTOCOL      *UsbAtapiInterface;\r
   SCSI_MODE_PARAMETER_HEADER6 Header;\r
   UINT32                      Size;\r
 \r
   SCSI_MODE_PARAMETER_HEADER6 Header;\r
   UINT32                      Size;\r
 \r
-  UsbAtapiInterface = UsbFloppyDevice->AtapiProtocol;\r
 \r
   Size              = sizeof (SCSI_MODE_PARAMETER_HEADER6);\r
 \r
 \r
   Size              = sizeof (SCSI_MODE_PARAMETER_HEADER6);\r
 \r
@@ -1450,7 +1366,7 @@ IsNoMedia (
 \r
   for (Index = 0; Index < SenseCounts; Index++) {\r
 \r
 \r
   for (Index = 0; Index < SenseCounts; Index++) {\r
 \r
-    if ((SensePtr->sense_key == SK_NOT_READY) && \r
+    if ((SensePtr->sense_key == SK_NOT_READY) &&\r
         (SensePtr->addnl_sense_code == ASC_NO_MEDIA)) {\r
 \r
       NoMedia = TRUE;\r
         (SensePtr->addnl_sense_code == ASC_NO_MEDIA)) {\r
 \r
       NoMedia = TRUE;\r
@@ -1479,7 +1395,7 @@ IsMediaError (
   for (Index = 0; Index < SenseCounts; Index++) {\r
 \r
     switch (SensePtr->sense_key) {\r
   for (Index = 0; Index < SenseCounts; Index++) {\r
 \r
     switch (SensePtr->sense_key) {\r
-      \r
+\r
     //\r
     // Medium error case\r
     //\r
     //\r
     // Medium error case\r
     //\r
@@ -1624,29 +1540,3 @@ IsMediaWriteProtected (
   return IsWriteProtected;\r
 }\r
 \r
   return IsWriteProtected;\r
 }\r
 \r
-BOOLEAN\r
-IsLogicalUnitCommunicationOverRun (\r
-  IN  REQUEST_SENSE_DATA    *SenseData,\r
-  IN  UINTN                 SenseCounts\r
-  )\r
-{\r
-  REQUEST_SENSE_DATA  *SensePtr;\r
-  UINTN               Index;\r
-  BOOLEAN             IsOverRun;\r
-\r
-  IsOverRun = FALSE;\r
-  SensePtr  = SenseData;\r
-\r
-  for (Index = 0; Index < SenseCounts; Index++) {\r
-\r
-    if ((SensePtr->sense_key == SK_NOT_READY) &&\r
-        (SensePtr->addnl_sense_code == ASC_LOGICAL_UNIT_STATUS) &&\r
-        (SensePtr->addnl_sense_code_qualifier == ASCQ_LOGICAL_UNIT_OVERRUN)) {\r
-      IsOverRun = TRUE;\r
-    }\r
-\r
-    SensePtr++;\r
-  }\r
-\r
-  return IsOverRun;\r
-}\r