diff options
| author | hathach <[email protected]> | 2019-07-24 16:19:12 +0700 |
|---|---|---|
| committer | hathach <[email protected]> | 2019-07-24 16:19:12 +0700 |
| commit | 1ee9ef4f2b7c6acfab6c398a4f57ca22036958f7 (patch) | |
| tree | c2274ed466fb8d7b284d08f58f418eba9a4864be /src/class | |
| parent | b041b23ba3b6d3e8127ab19899219eeaf4b15fbb (diff) | |
change tud_msc_start_stop_cb() to return void -> bool
Diffstat (limited to 'src/class')
| -rw-r--r-- | src/class/msc/msc_device.c | 13 | ||||
| -rw-r--r-- | src/class/msc/msc_device.h | 2 |
2 files changed, 11 insertions, 4 deletions
diff --git a/src/class/msc/msc_device.c b/src/class/msc/msc_device.c index 5681e4f07..1e651459e 100644 --- a/src/class/msc/msc_device.c +++ b/src/class/msc/msc_device.c @@ -200,7 +200,7 @@ int32_t proc_builtin_scsi(uint8_t lun, uint8_t const scsi_cmd[16], uint8_t* buff resplen = 0;
if ( !tud_msc_test_unit_ready_cb(lun) )
{
- // not ready response with Failed status and sense key = not ready
+ // Failed status response
resplen = - 1;
// If sense key is not set by callback, default to Logical Unit Not Ready, Cause Not Reportable
@@ -214,7 +214,14 @@ int32_t proc_builtin_scsi(uint8_t lun, uint8_t const scsi_cmd[16], uint8_t* buff if (tud_msc_start_stop_cb)
{
scsi_start_stop_unit_t const * start_stop = (scsi_start_stop_unit_t const *) scsi_cmd;
- tud_msc_start_stop_cb(lun, start_stop->power_condition, start_stop->start, start_stop->load_eject);
+ if ( !tud_msc_start_stop_cb(lun, start_stop->power_condition, start_stop->start, start_stop->load_eject) )
+ {
+ // Failed status response
+ resplen = - 1;
+
+ // If sense key is not set by callback, default to Logical Unit Not Ready, Cause Not Reportable
+ if ( _mscd_itf.sense_key == 0 ) tud_msc_set_sense(lun, SCSI_SENSE_NOT_READY, 0x04, 0x00);
+ }
}
break;
@@ -417,7 +424,7 @@ bool mscd_xfer_cb(uint8_t rhport, uint8_t ep_addr, xfer_result_t event, uint32_t // failed but senskey is not set: default to Illegal Request
if ( p_msc->sense_key == 0 ) tud_msc_set_sense(p_cbw->lun, SCSI_SENSE_ILLEGAL_REQUEST, 0x20, 0x00);
- /// Stall bulk In if needed
+ // Stall bulk In if needed
if (p_cbw->total_bytes) usbd_edpt_stall(rhport, p_msc->ep_in);
}
else
diff --git a/src/class/msc/msc_device.h b/src/class/msc/msc_device.h index 03a4afadb..c07008c55 100644 --- a/src/class/msc/msc_device.h +++ b/src/class/msc/msc_device.h @@ -131,7 +131,7 @@ TU_ATTR_WEAK uint8_t tud_msc_get_maxlun_cb(void); // Invoked when received Start Stop Unit command
// - Start = 0 : stopped power mode, if load_eject = 1 : unload disk storage
// - Start = 1 : active mode, if load_eject = 1 : load disk storage
-TU_ATTR_WEAK void tud_msc_start_stop_cb(uint8_t lun, uint8_t power_condition, bool start, bool load_eject);
+TU_ATTR_WEAK bool tud_msc_start_stop_cb(uint8_t lun, uint8_t power_condition, bool start, bool load_eject);
// Invoked when Read10 command is complete
TU_ATTR_WEAK void tud_msc_read10_complete_cb(uint8_t lun);
|
