summaryrefslogtreecommitdiff
path: root/src/class
diff options
context:
space:
mode:
authorhathach <[email protected]>2019-02-22 01:31:13 +0700
committerhathach <[email protected]>2019-02-22 01:31:13 +0700
commitf2d76a39ebda89afeb74321942dbc651888a1231 (patch)
treeae3f6377c6145b6c320b4d102b48457d7eaa98c6 /src/class
parent6645be65f52e253e9650662fa042ea7fed6fe36d (diff)
mscd: send scsi status before invoke read10/write10/scsi complete callback
Diffstat (limited to 'src/class')
-rw-r--r--src/class/msc/msc.h2
-rw-r--r--src/class/msc/msc_device.c13
2 files changed, 9 insertions, 6 deletions
diff --git a/src/class/msc/msc.h b/src/class/msc/msc.h
index baa0641d0..15fcea572 100644
--- a/src/class/msc/msc.h
+++ b/src/class/msc/msc.h
@@ -284,8 +284,10 @@ typedef struct ATTR_PACKED
{
uint8_t data_len;
uint8_t medium_type;
+
uint8_t reserved : 7;
bool write_protected : 1;
+
uint8_t block_descriptor_len;
} scsi_mode_sense6_resp_t;
diff --git a/src/class/msc/msc_device.c b/src/class/msc/msc_device.c
index 9fbe48bd7..d8bb72216 100644
--- a/src/class/msc/msc_device.c
+++ b/src/class/msc/msc_device.c
@@ -525,6 +525,12 @@ bool mscd_xfer_cb(uint8_t rhport, uint8_t ep_addr, xfer_result_t event, uint32_t
}
else
{
+ // Move to default CMD stage when sending status
+ p_msc->stage = MSC_STAGE_CMD;
+
+ // Send SCSI Status
+ TU_ASSERT( dcd_edpt_xfer(rhport, p_msc->ep_in , (uint8_t*) &p_msc->csw, sizeof(msc_csw_t)) );
+
// Invoke complete callback if defined
if ( SCSI_CMD_READ_10 == p_cbw->command[0])
{
@@ -539,12 +545,7 @@ bool mscd_xfer_cb(uint8_t rhport, uint8_t ep_addr, xfer_result_t event, uint32_t
if ( tud_msc_scsi_complete_cb ) tud_msc_scsi_complete_cb(p_cbw->lun, p_cbw->command);
}
- // Move to default CMD stage after sending status
- p_msc->stage = MSC_STAGE_CMD;
-
- TU_ASSERT( dcd_edpt_xfer(rhport, p_msc->ep_in , (uint8_t*) &p_msc->csw, sizeof(msc_csw_t)) );
-
- //------------- Queue the next CBW -------------//
+ // Queue for the next CBW
TU_ASSERT( dcd_edpt_xfer(rhport, p_msc->ep_out, (uint8_t*) &p_msc->cbw, sizeof(msc_cbw_t)) );
}
}