clean up device msc

This commit is contained in:
hathach 2018-07-25 22:51:43 +07:00
parent 93db46292a
commit 226a4f8816
3 changed files with 26 additions and 24 deletions

View File

@ -49,8 +49,10 @@
scsi_sense_fixed_data_t mscd_sense_data = scsi_sense_fixed_data_t mscd_sense_data =
{ {
.response_code = 0x70, .response_code = 0x70,
.valid = 1,
.sense_key = 0, // no errors .sense_key = 0, // no errors
.additional_sense_len = sizeof(scsi_sense_fixed_data_t) - 8 .add_sense_len = sizeof(scsi_sense_fixed_data_t) - 8
}; };
static scsi_mode_parameters_t const msc_dev_mode_para = static scsi_mode_parameters_t const msc_dev_mode_para =
@ -106,11 +108,11 @@ int32_t tud_msc_scsi_cb (uint8_t lun, uint8_t const scsi_cmd[16], void* buffer,
len = 0; len = 0;
break; break;
case SCSI_CMD_START_STOP_UNIT: // case SCSI_CMD_START_STOP_UNIT:
// Host try to eject/safe remove/powerof us. We could safely disconnect with disk storage, or go into lower power // // Host try to eject/safe remove/powerof us. We could safely disconnect with disk storage, or go into lower power
// scsi_start_stop_unit_t const * cmd_start_stop = (scsi_start_stop_unit_t const *) scsi_cmd // // scsi_start_stop_unit_t const * cmd_start_stop = (scsi_start_stop_unit_t const *) scsi_cmd
len = 0; // len = 0;
break; // break;
default: default:
// negative is error -> Data stage is STALL, status = failed // negative is error -> Data stage is STALL, status = failed
@ -135,8 +137,8 @@ int32_t tud_msc_scsi_cb (uint8_t lun, uint8_t const scsi_cmd[16], void* buffer,
if ( SCSI_CMD_REQUEST_SENSE != scsi_cmd[0] ) if ( SCSI_CMD_REQUEST_SENSE != scsi_cmd[0] )
{ {
mscd_sense_data.sense_key = SCSI_SENSEKEY_NONE; mscd_sense_data.sense_key = SCSI_SENSEKEY_NONE;
mscd_sense_data.additional_sense_code = 0; mscd_sense_data.add_sense_code = 0;
mscd_sense_data.additional_sense_qualifier = 0; mscd_sense_data.add_sense_qualifier = 0;
} }
return len; return len;

View File

@ -67,7 +67,7 @@ static scsi_sense_fixed_data_t mscd_sense_data =
{ {
.response_code = 0x70, .response_code = 0x70,
.sense_key = 0, // no errors .sense_key = 0, // no errors
.additional_sense_len = sizeof(scsi_sense_fixed_data_t) - 8 .add_sense_len = sizeof(scsi_sense_fixed_data_t) - 8
}; };
static scsi_read_format_capacity_data_t const mscd_format_capacity_data = static scsi_read_format_capacity_data_t const mscd_format_capacity_data =
@ -169,8 +169,8 @@ int32_t tud_msc_scsi_cb (uint8_t lun, uint8_t const scsi_cmd[16], void* buffer,
if ( SCSI_CMD_REQUEST_SENSE != scsi_cmd[0] ) if ( SCSI_CMD_REQUEST_SENSE != scsi_cmd[0] )
{ {
mscd_sense_data.sense_key = SCSI_SENSEKEY_NONE; mscd_sense_data.sense_key = SCSI_SENSEKEY_NONE;
mscd_sense_data.additional_sense_code = 0; mscd_sense_data.add_sense_code = 0;
mscd_sense_data.additional_sense_qualifier = 0; mscd_sense_data.add_sense_qualifier = 0;
} }
return len; return len;

View File

@ -237,25 +237,25 @@ VERIFY_STATIC(sizeof(scsi_inquiry_data_t) == 36, "size is not correct");
typedef struct ATTR_PACKED typedef struct ATTR_PACKED
{ {
uint8_t response_code : 7; ///< 70h - current errors, Fixed Format 71h - deferred errors, Fixed Format uint8_t response_code : 7; ///< 70h - current errors, Fixed Format 71h - deferred errors, Fixed Format
uint8_t valid : 1; uint8_t valid : 1;
uint8_t reserved; ///< Obsolete uint8_t TU_RESERVED;
uint8_t sense_key : 4; uint8_t sense_key : 4;
uint8_t : 1; uint8_t : 1;
uint8_t incorrect_len_idicatior : 1; uint8_t ili : 1; ///< Incorrect length indicator
uint8_t end_of_medium : 1; uint8_t end_of_medium : 1;
uint8_t filemark : 1; uint8_t filemark : 1;
uint32_t information; uint32_t information;
uint8_t additional_sense_len; uint8_t add_sense_len;
uint32_t command_specific_info; uint32_t command_specific_info;
uint8_t additional_sense_code; uint8_t add_sense_code;
uint8_t additional_sense_qualifier; uint8_t add_sense_qualifier;
uint8_t field_replaceable_unit_code; uint8_t field_replaceable_unit_code;
uint8_t sense_key_specific[3]; ///< sense key specific valid bit is bit 7 of key[0], aka MSB in Big Endian layout uint8_t sense_key_specific[3]; ///< sense key specific valid bit is bit 7 of key[0], aka MSB in Big Endian layout
} scsi_sense_fixed_data_t; } scsi_sense_fixed_data_t;