Get rid of the redundant ATTR_NEVER_INLINE macro which translated to the same as...
[pub/USBasp.git] / Bootloaders / MassStorage / Lib / SCSI.c
index b23a5a0..3bb868c 100644 (file)
@@ -113,8 +113,12 @@ bool SCSI_DecodeSCSICommand(USB_ClassInfo_MS_Device_t* const MSInterfaceInfo)
                case SCSI_CMD_MODE_SENSE_6:
                        CommandSuccess = SCSI_Command_ModeSense_6(MSInterfaceInfo);
                        break;
-               case SCSI_CMD_SEND_DIAGNOSTIC:
                case SCSI_CMD_START_STOP_UNIT:
+#if !defined(NO_APP_START_ON_EJECT)
+                       /* If the user ejected the volume, signal bootloader exit at next opportunity. */
+                       RunBootloader = ((MSInterfaceInfo->State.CommandBlock.SCSICommandData[4] & 0x03) != 0x02);
+#endif
+               case SCSI_CMD_SEND_DIAGNOSTIC:
                case SCSI_CMD_TEST_UNIT_READY:
                case SCSI_CMD_PREVENT_ALLOW_MEDIUM_REMOVAL:
                case SCSI_CMD_VERIFY_10:
@@ -255,14 +259,12 @@ static bool SCSI_Command_ReadWrite_10(USB_ClassInfo_MS_Device_t* const MSInterfa
        }
 
        /* Determine if the packet is a READ (10) or WRITE (10) command, call appropriate function */
-       while (TotalBlocks--)
+       for (uint16_t i = 0; i < TotalBlocks; i++)
        {
                if (IsDataRead == DATA_READ)
-                 VirtualFAT_ReadBlock(BlockAddress);
+                 VirtualFAT_ReadBlock(BlockAddress + i);
                else
-                 VirtualFAT_WriteBlock(BlockAddress);
-
-               BlockAddress++;
+                 VirtualFAT_WriteBlock(BlockAddress + i);
        }
 
        /* Update the bytes transferred counter and succeed the command */