change tud_msc_start_stop_cb() to return void -> bool

This commit is contained in:
hathach 2019-07-24 16:19:12 +07:00
parent b041b23ba3
commit 1ee9ef4f2b
5 changed files with 20 additions and 7 deletions

View File

@ -155,7 +155,7 @@ void tud_msc_capacity_cb(uint8_t lun, uint32_t* block_count, uint16_t* block_siz
// Invoked when received Start Stop Unit command // Invoked when received Start Stop Unit command
// - Start = 0 : stopped power mode, if load_eject = 1 : unload disk storage // - Start = 0 : stopped power mode, if load_eject = 1 : unload disk storage
// - Start = 1 : active mode, if load_eject = 1 : load disk storage // - Start = 1 : active mode, if load_eject = 1 : load disk storage
void tud_msc_start_stop_cb(uint8_t lun, uint8_t power_condition, bool start, bool load_eject) bool tud_msc_start_stop_cb(uint8_t lun, uint8_t power_condition, bool start, bool load_eject)
{ {
(void) lun; (void) lun;
(void) power_condition; (void) power_condition;
@ -170,6 +170,8 @@ void tud_msc_start_stop_cb(uint8_t lun, uint8_t power_condition, bool start, boo
// unload disk storage // unload disk storage
} }
} }
return true;
} }
// Callback invoked when received READ10 command. // Callback invoked when received READ10 command.

View File

@ -155,7 +155,7 @@ void tud_msc_capacity_cb(uint8_t lun, uint32_t* block_count, uint16_t* block_siz
// Invoked when received Start Stop Unit command // Invoked when received Start Stop Unit command
// - Start = 0 : stopped power mode, if load_eject = 1 : unload disk storage // - Start = 0 : stopped power mode, if load_eject = 1 : unload disk storage
// - Start = 1 : active mode, if load_eject = 1 : load disk storage // - Start = 1 : active mode, if load_eject = 1 : load disk storage
void tud_msc_start_stop_cb(uint8_t lun, uint8_t power_condition, bool start, bool load_eject) bool tud_msc_start_stop_cb(uint8_t lun, uint8_t power_condition, bool start, bool load_eject)
{ {
(void) lun; (void) lun;
(void) power_condition; (void) power_condition;
@ -170,6 +170,8 @@ void tud_msc_start_stop_cb(uint8_t lun, uint8_t power_condition, bool start, boo
// unload disk storage // unload disk storage
} }
} }
return true;
} }
// Callback invoked when received READ10 command. // Callback invoked when received READ10 command.

View File

@ -247,7 +247,7 @@ void tud_msc_capacity_cb(uint8_t lun, uint32_t* block_count, uint16_t* block_siz
// Invoked when received Start Stop Unit command // Invoked when received Start Stop Unit command
// - Start = 0 : stopped power mode, if load_eject = 1 : unload disk storage // - Start = 0 : stopped power mode, if load_eject = 1 : unload disk storage
// - Start = 1 : active mode, if load_eject = 1 : load disk storage // - Start = 1 : active mode, if load_eject = 1 : load disk storage
void tud_msc_start_stop_cb(uint8_t lun, uint8_t power_condition, bool start, bool load_eject) bool tud_msc_start_stop_cb(uint8_t lun, uint8_t power_condition, bool start, bool load_eject)
{ {
(void) lun; (void) lun;
(void) power_condition; (void) power_condition;
@ -262,6 +262,8 @@ void tud_msc_start_stop_cb(uint8_t lun, uint8_t power_condition, bool start, boo
// unload disk storage // unload disk storage
} }
} }
return true;
} }
// Callback invoked when received READ10 command. // Callback invoked when received READ10 command.

View File

@ -200,7 +200,7 @@ int32_t proc_builtin_scsi(uint8_t lun, uint8_t const scsi_cmd[16], uint8_t* buff
resplen = 0; resplen = 0;
if ( !tud_msc_test_unit_ready_cb(lun) ) if ( !tud_msc_test_unit_ready_cb(lun) )
{ {
// not ready response with Failed status and sense key = not ready // Failed status response
resplen = - 1; resplen = - 1;
// If sense key is not set by callback, default to Logical Unit Not Ready, Cause Not Reportable // 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) if (tud_msc_start_stop_cb)
{ {
scsi_start_stop_unit_t const * start_stop = (scsi_start_stop_unit_t const *) scsi_cmd; 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; 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 // 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); 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); if (p_cbw->total_bytes) usbd_edpt_stall(rhport, p_msc->ep_in);
} }
else else

View File

@ -131,7 +131,7 @@ TU_ATTR_WEAK uint8_t tud_msc_get_maxlun_cb(void);
// Invoked when received Start Stop Unit command // Invoked when received Start Stop Unit command
// - Start = 0 : stopped power mode, if load_eject = 1 : unload disk storage // - Start = 0 : stopped power mode, if load_eject = 1 : unload disk storage
// - Start = 1 : active mode, if load_eject = 1 : load 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 // Invoked when Read10 command is complete
TU_ATTR_WEAK void tud_msc_read10_complete_cb(uint8_t lun); TU_ATTR_WEAK void tud_msc_read10_complete_cb(uint8_t lun);