Fixed Mass Storage Host Class driver and Low Level demo not clearing the error condit...
authorDean Camera <dean@fourwalledcubicle.com>
Fri, 4 Dec 2009 09:08:48 +0000 (09:08 +0000)
committerDean Camera <dean@fourwalledcubicle.com>
Fri, 4 Dec 2009 09:08:48 +0000 (09:08 +0000)
Demos/Host/LowLevel/MassStorageHost/Lib/MassStoreCommands.c
LUFA/Drivers/USB/Class/Host/MassStorage.c
LUFA/Drivers/USB/Class/Host/MassStorage.h
LUFA/ManPages/ChangeLog.txt

index ff01dc0..edd1425 100644 (file)
@@ -287,13 +287,17 @@ uint8_t MassStore_MassStorageReset(void)
 /** Issues a Mass Storage class specific request to determine the index of the highest numbered Logical\r
  *  Unit in the attached device.\r
  *\r
+ *  \note Some devices do not support this request, and will STALL it when issued. To get around this,\r
+ *        on unsupported devices the max LUN index will be reported as zero and no error will be returned\r
+ *        if the device STALLs the request.\r
+ *\r
  *  \param[out] MaxLUNIndex  Pointer to the location that the maximum LUN index value should be stored\r
  *\r
  *  \return A value from the USB_Host_SendControlErrorCodes_t enum, or MASS_STORE_SCSI_COMMAND_FAILED if the SCSI command fails\r
  */\r
 uint8_t MassStore_GetMaxLUN(uint8_t* const MaxLUNIndex)\r
 {\r
-       uint8_t ErrorCode;\r
+       uint8_t ErrorCode = HOST_SENDCONTROL_Successful;\r
 \r
        USB_ControlRequest = (USB_Request_Header_t)\r
                {\r
@@ -313,7 +317,10 @@ uint8_t MassStore_GetMaxLUN(uint8_t* const MaxLUNIndex)
                Pipe_ClearStall();\r
        \r
                /* Some faulty Mass Storage devices don't implement the GET_MAX_LUN request, so assume a single LUN */\r
-               *MaxLUNIndex = 0;       \r
+               *MaxLUNIndex = 0;\r
+               \r
+               /* Clear the error, and pretend the request executed correctly if the device STALLed it */\r
+               ErrorCode = HOST_SENDCONTROL_Successful;\r
        }\r
        \r
        return ErrorCode;\r
index 75b8ef4..ca07175 100644 (file)
@@ -305,7 +305,7 @@ uint8_t MS_Host_ResetMSInterface(USB_ClassInfo_MS_Host_t* const MSInterfaceInfo)
 \r
 uint8_t MS_Host_GetMaxLUN(USB_ClassInfo_MS_Host_t* const MSInterfaceInfo, uint8_t* const MaxLUNIndex)\r
 {\r
-       uint8_t ErrorCode;\r
+       uint8_t ErrorCode = HOST_SENDCONTROL_Successful;\r
 \r
        USB_ControlRequest = (USB_Request_Header_t)\r
                {\r
@@ -319,7 +319,10 @@ uint8_t MS_Host_GetMaxLUN(USB_ClassInfo_MS_Host_t* const MSInterfaceInfo, uint8_
        Pipe_SelectPipe(PIPE_CONTROLPIPE);\r
 \r
        if ((ErrorCode = USB_Host_SendControlRequest(MaxLUNIndex)) != HOST_SENDCONTROL_Successful)\r
-         *MaxLUNIndex = 0;\r
+       {\r
+               *MaxLUNIndex = 0;\r
+               ErrorCode = HOST_SENDCONTROL_Successful;\r
+       }\r
        \r
        return ErrorCode;\r
 }\r
index fc3bc66..584172f 100644 (file)
                         *  UNit, a logical drive) in the device. This value can then be used in the other functions of the Mass Storage\r
                         *  Host mode Class driver to address a specific LUN within the device.\r
                         *\r
+                        *  \note Some devices do not support this request, and will STALL it when issued. To get around this,\r
+                        *        on unsupported devices the max LUN index will be reported as zero and no error will be returned\r
+                        *        if the device STALLs the request.\r
+                        *\r
                         *  \param[in,out] MSInterfaceInfo  Pointer to a structure containing a MS Class host configuration and state\r
                         *  \param[out] MaxLUNIndex  Pointer to a location where the highest LUN index value should be stored\r
                         *\r
index d3d80bf..6294674 100644 (file)
@@ -49,6 +49,8 @@
   *  - Fixed CDCHost failing on devices with bidirectional endpoints\r
   *  - Fixed USB driver failing to define the PLL prescaler mask for the ATMEGA8U2 and ATMEGA16U2\r
   *  - Fixed HID Parser not distributing the Usage Min and Usage Max values across an array of report items\r
+  *  - Fixed Mass Storage Host Class driver and Low Level demo not clearing the error condition if an attached device returns a\r
+  *    STALL to a GET MAX LUN request (thanks to Martin Luxen)\r
   *\r
   *  \section Sec_ChangeLog091122 Version 091122\r
   *\r