From 7d9874e522f200873768c5d94b4e8f4b79d7afcb Mon Sep 17 00:00:00 2001 From: bunnie Date: Sun, 14 Jan 2024 23:58:20 +0800 Subject: [PATCH] strip trailing whitespace on mass-storage --- libs/mass-storage/packing/packing/src/bit.rs | 2 +- .../packing/packing/src/endian/big.rs | 16 ++++++------- .../packing/packing/src/endian/little.rs | 12 +++++----- .../mass-storage/packing/packing/src/error.rs | 2 +- .../packing/packing/src/packed.rs | 12 +++++----- .../packing/packing_codegen/src/lib.rs | 6 ++--- .../packing/packing_tests/src/fuzz_endian.rs | 16 ++++++------- .../usbd_scsi/src/block_device.rs | 6 ++--- .../usbd_scsi/src/scsi/commands/command.rs | 6 ++--- .../usbd_scsi/src/scsi/commands/control.rs | 2 +- .../usbd_scsi/src/scsi/commands/format.rs | 12 +++++----- .../usbd_scsi/src/scsi/commands/inquiry.rs | 24 +++++++++---------- .../src/scsi/commands/mode_select.rs | 4 ++-- .../usbd_scsi/src/scsi/commands/mode_sense.rs | 20 ++++++++-------- .../commands/prevent_allow_medium_removal.rs | 2 +- .../usbd_scsi/src/scsi/commands/read.rs | 2 +- .../src/scsi/commands/report_luns.rs | 4 ++-- .../src/scsi/commands/request_sense.rs | 6 ++--- .../src/scsi/commands/send_diagnostic.rs | 16 ++++++------- .../src/scsi/commands/start_stop_unit.rs | 14 +++++------ .../src/scsi/commands/synchronize_cache.rs | 10 ++++---- .../src/scsi/commands/test_unit_ready.rs | 2 +- .../usbd_scsi/src/scsi/commands/verify.rs | 14 +++++------ .../usbd_scsi/src/scsi/commands/write.rs | 8 +++---- .../src/scsi/enums/additional_sense_code.rs | 6 ++--- .../usbd_scsi/src/scsi/enums/response_code.rs | 2 +- .../src/scsi/enums/version_descriptor.rs | 2 +- 27 files changed, 114 insertions(+), 114 deletions(-) diff --git a/libs/mass-storage/packing/packing/src/bit.rs b/libs/mass-storage/packing/packing/src/bit.rs index 0e7f61816..36b87c990 100644 --- a/libs/mass-storage/packing/packing/src/bit.rs +++ b/libs/mass-storage/packing/packing/src/bit.rs @@ -11,7 +11,7 @@ use crate::{ /// Trait signifying a single bit in a byte. 7 = most significant bit, 0 = least significant bit pub trait Bit: IsLess + Unsigned { - /// The mask used to discard bits before this bit (i.e. if this bit is 5, ANDing this mask with + /// The mask used to discard bits before this bit (i.e. if this bit is 5, ANDing this mask with /// a u8 will ensure bits 7 and 6 are 0. const HEAD_MASK: u8 = ((1_u16 << (Self::USIZE + 1)) - 1) as u8; /// The mask used to extract the single bit from a byte diff --git a/libs/mass-storage/packing/packing/src/endian/big.rs b/libs/mass-storage/packing/packing/src/endian/big.rs index 5804d49e5..4653afbbc 100644 --- a/libs/mass-storage/packing/packing/src/endian/big.rs +++ b/libs/mass-storage/packing/packing/src/endian/big.rs @@ -37,7 +37,7 @@ impl Endian for BigEndian { // Case 2: More than 1 byte but the LSB at the end of the input // is already in position 0 so no shifting is required } else if E::USIZE == 0 { - // Since we aren't shrinking the data down by aligning the fields, the output + // Since we aren't shrinking the data down by aligning the fields, the output // buffer must be at least as long as the input assert!(output_bytes.len() >= input_bytes.len()); @@ -52,13 +52,13 @@ impl Endian for BigEndian { output_bytes[o_start] &= S::HEAD_MASK; } - // Note: Case 3 and 4 could be merged with some minor tweaks around the input start + // Note: Case 3 and 4 could be merged with some minor tweaks around the input start // and an extra negative offset to output index for case 4 but I've left them // split up for ease of debugging while testing edge cases for now. // Case 3: More than 1 byte and LSB at the end ISN'T at position 0 and we aren't // shrinking the data down by aligning the fields. We need to shift every byte } else if S::USIZE >= E::USIZE { - // Since we aren't shrinking the data down by aligning the fields, the output + // Since we aren't shrinking the data down by aligning the fields, the output // buffer must be at least as long as the input assert!(output_bytes.len() >= input_bytes.len()); @@ -66,7 +66,7 @@ impl Endian for BigEndian { let o_start = o_len - i_len; for i in 0..i_len { - output_bytes[o_start + i] = + output_bytes[o_start + i] = match i { // No prior byte, just masked and shifted left by the number of bits // we need to fill the space in the last byte @@ -80,12 +80,12 @@ impl Endian for BigEndian { _ => (input_bytes[i-1] << (8-E::USIZE)) | (input_bytes[i] >> E::USIZE), }; - } + } - // Case 4: More than 1 byte and LSB at the end ISN'T at position 0 and we ARE + // Case 4: More than 1 byte and LSB at the end ISN'T at position 0 and we ARE // shrinking the data down by 1 byte by aligning the fields. We need to shift every byte } else { - // Since we are shrinking the data down by aligning the fields, the output + // Since we are shrinking the data down by aligning the fields, the output // buffer can be 1 smaller than the input assert!(output_bytes.len() >= input_bytes.len() - 1); @@ -93,7 +93,7 @@ impl Endian for BigEndian { let o_start = o_len - (i_len - 1); for i in 1..i_len { - output_bytes[o_start + i - 1] = + output_bytes[o_start + i - 1] = match i { // No prior byte, just masked and shifted left by the number of bits // we need to fill the space in the last byte diff --git a/libs/mass-storage/packing/packing/src/endian/little.rs b/libs/mass-storage/packing/packing/src/endian/little.rs index 7c98a9fd1..cb607fb01 100644 --- a/libs/mass-storage/packing/packing/src/endian/little.rs +++ b/libs/mass-storage/packing/packing/src/endian/little.rs @@ -37,7 +37,7 @@ impl Endian for LittleEndian { // Case 2: More than 1 byte but the MSB at the beginning of the input // is already in position 7 so no shifting is required } else if S::USIZE == 7 { - // Since we aren't shrinking the data down by aligning the fields, the output + // Since we aren't shrinking the data down by aligning the fields, the output // buffer must be at least as long as the input assert!(output_bytes.len() >= input_bytes.len()); @@ -50,19 +50,19 @@ impl Endian for LittleEndian { output_bytes[i_len-1] >>= E::USIZE; } - // Note: Case 3 and 4 could be merged with some minor tweaks around the input start + // Note: Case 3 and 4 could be merged with some minor tweaks around the input start // and an extra negative offset to output index for case 4 but I've left them // split up for ease of debugging while testing edge cases for now. // Case 3: More than 1 byte, MSB at the beginning ISN'T at position 7 and we aren't // shrinking the data down by aligning the fields. We need to shift every byte } else { let n_bytes = if S::USIZE >= E::USIZE { - // Since we aren't shrinking the data down by aligning the fields, the output + // Since we aren't shrinking the data down by aligning the fields, the output // buffer must be at least as long as the input assert!(output_bytes.len() >= input_bytes.len()); i_len } else { - // Since we are shrinking the data down by aligning the fields, the output + // Since we are shrinking the data down by aligning the fields, the output // buffer can be 1 smaller than the input assert!(output_bytes.len() >= input_bytes.len() - 1); i_len - 1 @@ -92,8 +92,8 @@ impl Endian for LittleEndian { output_bytes[i] |= val << S::USIZE+1; } - } - } + } + } } fn restore_field_bits(input_bytes: &[u8], output_bytes: &mut [u8]) { diff --git a/libs/mass-storage/packing/packing/src/error.rs b/libs/mass-storage/packing/packing/src/error.rs index 39d7bcc32..d976925fd 100644 --- a/libs/mass-storage/packing/packing/src/error.rs +++ b/libs/mass-storage/packing/packing/src/error.rs @@ -10,7 +10,7 @@ use core::convert::Infallible; #[derive(Debug, Clone, Copy, PartialEq, Eq)] pub enum Error { /// Pack or Unpack method called with a slice of insufficient length - /// Check the `PACK_BYTES_LEN` on the struct impl + /// Check the `PACK_BYTES_LEN` on the struct impl InsufficientBytes, /// Attempted to unpack an enum but the value found didn't match any diff --git a/libs/mass-storage/packing/packing/src/packed.rs b/libs/mass-storage/packing/packing/src/packed.rs index b1bc23539..553732991 100644 --- a/libs/mass-storage/packing/packing/src/packed.rs +++ b/libs/mass-storage/packing/packing/src/packed.rs @@ -13,13 +13,13 @@ pub trait PackedSize where Self: Sized { } /// Trait that enables endian aware conversion to/from bytes for packable types -/// +/// /// Mostly for primitives. Currently expected to accept/return arrays by proc macro. -/// Benchmarking showed allocating a new 1 to 8 byte array during to/from bytes +/// Benchmarking showed allocating a new 1 to 8 byte array during to/from bytes /// performed exactly the same as manual bit shifting or various other shenanigans. /// /// TODO: Above perf statement likely only holds true up to a certain size. Currently -/// nested structs and packing/unpacking them to/from &mut [u8] is not supported. +/// nested structs and packing/unpacking them to/from &mut [u8] is not supported. pub trait PackedBytes: PackedSize { type Error; fn to_bytes(&self) -> Result; @@ -29,9 +29,9 @@ pub trait PackedBytes: PackedSize { /// Trait that enables packing and unpacking to/from byte slices /// /// This is the trait that the proc macro implements on structs. Supports arbitrary -/// field alignment - i.e. fields needn't start or end on 8-bit byte boundaries. -/// For example, 2 bools, a 10-bit number and a 4-bit number could be packed into -/// a pair of bytes such that the 10-bit number straddles them and doesn't align with +/// field alignment - i.e. fields needn't start or end on 8-bit byte boundaries. +/// For example, 2 bools, a 10-bit number and a 4-bit number could be packed into +/// a pair of bytes such that the 10-bit number straddles them and doesn't align with /// any byte boundaries /// /// Allowing arbitray field alignment should be zero-cost as the field definitions diff --git a/libs/mass-storage/packing/packing_codegen/src/lib.rs b/libs/mass-storage/packing/packing_codegen/src/lib.rs index 6f43000ef..fa26ab3f4 100644 --- a/libs/mass-storage/packing/packing_codegen/src/lib.rs +++ b/libs/mass-storage/packing/packing_codegen/src/lib.rs @@ -104,7 +104,7 @@ const PKD_ATTR: &str = "pkd"; /// /// However, this derive also supports inferring field alignments from the width of the field type, where the /// last field ended, etc. This is provided so projects can use it for the complex explicit case mentioned above -/// but also use it for the more trivial alignments you'd expect from repr(C) or repr(Packed). `width` and +/// but also use it for the more trivial alignments you'd expect from repr(C) or repr(Packed). `width` and /// `space` were added to allow the case where most of the struct is as you'd expect but a handful of fields /// are slightly different. This was working at the time of implementation but has no tests around it currently /// so may get broken. //TODO: add tests for all supported cases. @@ -339,7 +339,7 @@ usize_field!(StartBit, "StartBit", "StartBit"); usize_field!(EndBit, "EndBit", "EndBit"); -fn get_attr<'a, I, Ta: 'a, Tb, F>(iter: I, _span: Span, scope: Scope, default: Tb, filter_map: F) -> Result +fn get_attr<'a, I, Ta: 'a, Tb, F>(iter: I, _span: Span, scope: Scope, default: Tb, filter_map: F) -> Result where I: Iterator, Tb: Clone + Name + Debug, @@ -709,7 +709,7 @@ fn derive_struct( if end_set { if w != end - bit { error_or_diagnostic(f.name.span(), - format!("Field specifies width of {} but calculated width is {}. Check width, start/end byte/bit attributes", + format!("Field specifies width of {} but calculated width is {}. Check width, start/end byte/bit attributes", w, end - bit))?; } } else { diff --git a/libs/mass-storage/packing/packing_tests/src/fuzz_endian.rs b/libs/mass-storage/packing/packing_tests/src/fuzz_endian.rs index 51e8a890a..b280625a4 100644 --- a/libs/mass-storage/packing/packing_tests/src/fuzz_endian.rs +++ b/libs/mass-storage/packing/packing_tests/src/fuzz_endian.rs @@ -76,31 +76,31 @@ mod tests { match p.little_endian { true => >::to_bytes::(&(p.n as u8)), false => >::to_bytes::(&(p.n as u8)), - }.unwrap().to_vec() + }.unwrap().to_vec() }, 2 => { match p.little_endian { true => >::to_bytes::(&(p.n as u16)), false => >::to_bytes::(&(p.n as u16)), - }.unwrap().to_vec() + }.unwrap().to_vec() }, 3..=4 => { match p.little_endian { true => >::to_bytes::(&(p.n as u32)), false => >::to_bytes::(&(p.n as u32)), - }.unwrap().to_vec() + }.unwrap().to_vec() }, 5..=8 => { match p.little_endian { true => >::to_bytes::(&(p.n as u64)), false => >::to_bytes::(&(p.n as u64)), - }.unwrap().to_vec() + }.unwrap().to_vec() }, _ => { match p.little_endian { true => >::to_bytes::(&p.n), false => >::to_bytes::(&p.n), - }.unwrap().to_vec() + }.unwrap().to_vec() }, }; @@ -254,7 +254,7 @@ mod tests { let mut aligned_field_bytes = Vec::new(); aligned_field_bytes.resize(p.total_bytes, 0); - + match (p.start, p.end, p.little_endian) { (7, 7, true) => LittleEndian::align_field_bits::(&restored_field_bytes, &mut aligned_field_bytes), (7, 7, false) => BigEndian::align_field_bits::(&restored_field_bytes, &mut aligned_field_bytes), @@ -538,10 +538,10 @@ mod tests { } if let Err(e) = pretty_error( - &aligned_field_bytes, + &aligned_field_bytes, &restored_field_bytes2, &restored_field_bytes, - p.start as usize, + p.start as usize, p.end as usize, ) { panic!("restored->aligned->restored round trip failed: {}", e); diff --git a/libs/mass-storage/usbd_scsi/src/block_device.rs b/libs/mass-storage/usbd_scsi/src/block_device.rs index e2c1c2578..1def3a262 100644 --- a/libs/mass-storage/usbd_scsi/src/block_device.rs +++ b/libs/mass-storage/usbd_scsi/src/block_device.rs @@ -13,8 +13,8 @@ pub enum BlockDeviceError { WriteError, /// Error during erase; most likely value read back after erase was wrong - /// - /// STM32 flash programming app note implies this is possible but doesn't say under what + /// + /// STM32 flash programming app note implies this is possible but doesn't say under what /// circumstances. Is the flash knackered if this happens? EraseError, @@ -32,7 +32,7 @@ pub trait BlockDevice { /// Write the `block` buffer to the block indicated by `lba` fn write_block(&mut self, lba: u32, block: &[u8]) -> Result<(), BlockDeviceError>; - + /// Get the maxium valid lba (logical block address) fn max_lba(&self) -> u32; } \ No newline at end of file diff --git a/libs/mass-storage/usbd_scsi/src/scsi/commands/command.rs b/libs/mass-storage/usbd_scsi/src/scsi/commands/command.rs index ca97130a5..f4adafa2d 100644 --- a/libs/mass-storage/usbd_scsi/src/scsi/commands/command.rs +++ b/libs/mass-storage/usbd_scsi/src/scsi/commands/command.rs @@ -43,7 +43,7 @@ impl Command { OpCode::Read6 => Ok(Command::Read(checked_extract::(cbw)?.into())), OpCode::Read10 => Ok(Command::Read(checked_extract::(cbw)?.into())), OpCode::Read12 => Ok(Command::Read(checked_extract::(cbw)?.into())), - OpCode::ReadCapacity10 => Ok(Command::ReadCapacity(checked_extract(cbw)?)), + OpCode::ReadCapacity10 => Ok(Command::ReadCapacity(checked_extract(cbw)?)), OpCode::ReadFormatCapacities => Ok(Command::ReadFormatCapacities(checked_extract(cbw)?)), OpCode::Inquiry => Ok(Command::Inquiry(checked_extract(cbw)?)), OpCode::TestUnitReady => Ok(Command::TestUnitReady(checked_extract(cbw)?)), @@ -68,8 +68,8 @@ impl Command { } -fn checked_extract(cbw: &CommandBlockWrapper_NEW) -> Result -where +fn checked_extract(cbw: &CommandBlockWrapper_NEW) -> Result +where T: ParsePackedStruct, Error: From<::Error>, { diff --git a/libs/mass-storage/usbd_scsi/src/scsi/commands/control.rs b/libs/mass-storage/usbd_scsi/src/scsi/commands/control.rs index 2198f7d48..716797b2c 100644 --- a/libs/mass-storage/usbd_scsi/src/scsi/commands/control.rs +++ b/libs/mass-storage/usbd_scsi/src/scsi/commands/control.rs @@ -12,7 +12,7 @@ use packing::Packed; pub struct Control { #[pkd(7, 6, 0, 0)] pub vendor_specific: u8, - + #[pkd(2, 2, 0, 0)] pub normal_aca: bool, } \ No newline at end of file diff --git a/libs/mass-storage/usbd_scsi/src/scsi/commands/format.rs b/libs/mass-storage/usbd_scsi/src/scsi/commands/format.rs index 71c84e23b..3d35e3cdb 100644 --- a/libs/mass-storage/usbd_scsi/src/scsi/commands/format.rs +++ b/libs/mass-storage/usbd_scsi/src/scsi/commands/format.rs @@ -15,22 +15,22 @@ use crate::scsi::{ pub struct FormatCommand { #[pkd(7, 0, 0, 0)] pub op_code: u8, - + #[pkd(7, 6, 1, 1)] pub format_protection_information: u8, - + #[pkd(5, 5, 1, 1)] pub long_list: bool, - + #[pkd(4, 4, 1, 1)] pub format_data: bool, - + #[pkd(3, 3, 1, 1)] pub complete_list: bool, - + #[pkd(2, 0, 1, 1)] pub defect_list_format: u8, - + #[pkd(7, 0, 5, 5)] pub control: Control, } diff --git a/libs/mass-storage/usbd_scsi/src/scsi/commands/inquiry.rs b/libs/mass-storage/usbd_scsi/src/scsi/commands/inquiry.rs index 4ee4f4a9a..91b855e71 100644 --- a/libs/mass-storage/usbd_scsi/src/scsi/commands/inquiry.rs +++ b/libs/mass-storage/usbd_scsi/src/scsi/commands/inquiry.rs @@ -19,7 +19,7 @@ use crate::scsi::{ pub struct InquiryCommand { #[pkd(7, 0, 0, 0)] pub op_code: u8, - + /// If set, return vital data related to the page_code field #[pkd(0, 0, 1, 1)] pub enable_vital_product_data: bool, @@ -39,20 +39,20 @@ impl ParsePackedStruct for InquiryCommand {} /* - if evpd + if evpd return data related to page_code (spc-4 section 7.8) - if unsupported(page_code) - return CHECK_CONDITION and set SENSE: + if unsupported(page_code) + return CHECK_CONDITION and set SENSE: key: ILLEGAL_REQUEST additional code: INVALID_FIELD_IN_CBD - + if !evpd return standard inquiry data (spc-4 section 6.4.2) if page_code != 0 - return CHECK_CONDITION and set SENSE: + return CHECK_CONDITION and set SENSE: key: ILLEGAL_REQUEST - additional code: INVALID_FIELD_IN_CBD -*/ + additional code: INVALID_FIELD_IN_CBD +*/ #[test] @@ -63,19 +63,19 @@ fn test_inquiry() { bytes[0] |= 0b00000001; cmd.enable_vital_product_data = true; - assert_eq!(cmd, InquiryCommand::unpack(&bytes).unwrap()); + assert_eq!(cmd, InquiryCommand::unpack(&bytes).unwrap()); bytes[1] = 0x99; cmd.page_code = 0x99; - assert_eq!(cmd, InquiryCommand::unpack(&bytes).unwrap()); + assert_eq!(cmd, InquiryCommand::unpack(&bytes).unwrap()); let al = 9999; bytes[2] = ((al >> 8) & 0xFF) as u8; bytes[3] = ((al >> 0) & 0xFF) as u8; cmd.allocation_length = al; - assert_eq!(cmd, InquiryCommand::unpack(&bytes).unwrap()); + assert_eq!(cmd, InquiryCommand::unpack(&bytes).unwrap()); bytes[4] = 0x31; cmd.control = 0x31; - assert_eq!(cmd, InquiryCommand::unpack(&bytes).unwrap()); + assert_eq!(cmd, InquiryCommand::unpack(&bytes).unwrap()); } \ No newline at end of file diff --git a/libs/mass-storage/usbd_scsi/src/scsi/commands/mode_select.rs b/libs/mass-storage/usbd_scsi/src/scsi/commands/mode_select.rs index b5901ef25..d4f323dc5 100644 --- a/libs/mass-storage/usbd_scsi/src/scsi/commands/mode_select.rs +++ b/libs/mass-storage/usbd_scsi/src/scsi/commands/mode_select.rs @@ -20,7 +20,7 @@ pub struct ModeSelectXCommand { pub struct ModeSelect6Command { #[pkd(7, 0, 0, 0)] pub op_code: u8, - + #[pkd(4, 4, 1, 1)] pub page_format: bool, @@ -46,7 +46,7 @@ impl From for ModeSelectXCommand { pub struct ModeSelect10Command { #[pkd(7, 0, 0, 0)] pub op_code: u8, - + #[pkd(4, 4, 1, 1)] pub page_format: bool, diff --git a/libs/mass-storage/usbd_scsi/src/scsi/commands/mode_sense.rs b/libs/mass-storage/usbd_scsi/src/scsi/commands/mode_sense.rs index 78e94b5ab..485bfbb09 100644 --- a/libs/mass-storage/usbd_scsi/src/scsi/commands/mode_sense.rs +++ b/libs/mass-storage/usbd_scsi/src/scsi/commands/mode_sense.rs @@ -39,29 +39,29 @@ pub struct ModeSenseXCommand { pub struct ModeSense6Command { #[pkd(7, 0, 0, 0)] pub op_code: u8, - + #[pkd(3, 3, 1, 1)] pub disable_block_descriptors: bool, - + #[pkd(7, 6, 2, 2)] pub page_control: PageControl, - + #[pkd(5, 0, 2, 2)] pub page_code: u8, - + #[pkd(7, 0, 3, 3)] pub subpage_code: u8, - + #[pkd(7, 0, 4, 4)] pub allocation_length: u8, - + #[pkd(7, 0, 5, 5)] pub control: Control, } impl ParsePackedStruct for ModeSense6Command {} impl From for ModeSenseXCommand { fn from(m: ModeSense6Command) -> Self { - Self { + Self { command_length: CommandLength::C6, page_control: m.page_control, } @@ -73,7 +73,7 @@ impl From for ModeSenseXCommand { pub struct ModeSense10Command { #[pkd(7, 0, 0, 0)] pub op_code: u8, - + #[pkd(4, 4, 1, 1)] pub long_lba_accepted: bool, @@ -85,7 +85,7 @@ pub struct ModeSense10Command { #[pkd(5, 0, 2, 2)] pub page_code: u8, - + #[pkd(7, 0, 3, 3)] pub subpage_code: u8, @@ -100,7 +100,7 @@ impl From for ModeSenseXCommand { fn from(m: ModeSense10Command) -> Self { Self { command_length: CommandLength::C10, - page_control: m.page_control, + page_control: m.page_control, } } } \ No newline at end of file diff --git a/libs/mass-storage/usbd_scsi/src/scsi/commands/prevent_allow_medium_removal.rs b/libs/mass-storage/usbd_scsi/src/scsi/commands/prevent_allow_medium_removal.rs index 417af9125..730f6844b 100644 --- a/libs/mass-storage/usbd_scsi/src/scsi/commands/prevent_allow_medium_removal.rs +++ b/libs/mass-storage/usbd_scsi/src/scsi/commands/prevent_allow_medium_removal.rs @@ -15,7 +15,7 @@ use crate::scsi::{ pub struct PreventAllowMediumRemovalCommand { #[pkd(7, 0, 0, 0)] pub op_code: u8, - + #[pkd(1, 0, 4, 4)] pub prevent: u8, diff --git a/libs/mass-storage/usbd_scsi/src/scsi/commands/read.rs b/libs/mass-storage/usbd_scsi/src/scsi/commands/read.rs index 6578fdca8..8d2d66e96 100644 --- a/libs/mass-storage/usbd_scsi/src/scsi/commands/read.rs +++ b/libs/mass-storage/usbd_scsi/src/scsi/commands/read.rs @@ -66,7 +66,7 @@ pub struct Read10Command { pub lba: u32, #[pkd(4, 0, 6, 6)] - pub group_number: u8, + pub group_number: u8, #[pkd(7, 0, 7, 8)] pub transfer_length: u16, diff --git a/libs/mass-storage/usbd_scsi/src/scsi/commands/report_luns.rs b/libs/mass-storage/usbd_scsi/src/scsi/commands/report_luns.rs index 6f3048b96..6b08a5eee 100644 --- a/libs/mass-storage/usbd_scsi/src/scsi/commands/report_luns.rs +++ b/libs/mass-storage/usbd_scsi/src/scsi/commands/report_luns.rs @@ -18,10 +18,10 @@ pub struct ReportLunsCommand { #[pkd(7, 0, 2, 2)] pub select_report: u8, - + #[pkd(7, 0, 6, 9)] pub allocation_length: u32, - + #[pkd(7, 0, 11, 11)] pub control: Control, } diff --git a/libs/mass-storage/usbd_scsi/src/scsi/commands/request_sense.rs b/libs/mass-storage/usbd_scsi/src/scsi/commands/request_sense.rs index 27056e442..412faafac 100644 --- a/libs/mass-storage/usbd_scsi/src/scsi/commands/request_sense.rs +++ b/libs/mass-storage/usbd_scsi/src/scsi/commands/request_sense.rs @@ -15,13 +15,13 @@ use crate::scsi::{ pub struct RequestSenseCommand { #[pkd(7, 0, 0, 0)] pub op_code: u8, - + #[pkd(0, 0, 1, 1)] pub descriptor_format: bool, - + #[pkd(7, 0, 4, 4)] pub allocation_length: u8, - + #[pkd(7, 0, 5, 5)] pub control: Control, } diff --git a/libs/mass-storage/usbd_scsi/src/scsi/commands/send_diagnostic.rs b/libs/mass-storage/usbd_scsi/src/scsi/commands/send_diagnostic.rs index 0eb80411b..d55871d15 100644 --- a/libs/mass-storage/usbd_scsi/src/scsi/commands/send_diagnostic.rs +++ b/libs/mass-storage/usbd_scsi/src/scsi/commands/send_diagnostic.rs @@ -12,28 +12,28 @@ use crate::scsi::{ #[derive(Clone, Copy, Eq, PartialEq, Debug, Packed)] #[packed(big_endian, lsb0)] -pub struct SendDiagnosticCommand { +pub struct SendDiagnosticCommand { #[pkd(7, 0, 0, 0)] pub op_code: u8, - + #[pkd(7, 5, 1, 1)] pub self_test_code: u8, - + #[pkd(4, 4, 1, 1)] pub page_format: bool, - + #[pkd(2, 2, 1, 1)] pub self_test: bool, - + #[pkd(1, 1, 1, 1)] pub device_offline: bool, - + #[pkd(0, 0, 1, 1)] pub unit_offline: bool, - + #[pkd(7, 0, 3, 4)] pub parameter_list_length: u16, - + #[pkd(7, 0, 5, 5)] pub control: Control, } diff --git a/libs/mass-storage/usbd_scsi/src/scsi/commands/start_stop_unit.rs b/libs/mass-storage/usbd_scsi/src/scsi/commands/start_stop_unit.rs index 832fc0789..55bd29bab 100644 --- a/libs/mass-storage/usbd_scsi/src/scsi/commands/start_stop_unit.rs +++ b/libs/mass-storage/usbd_scsi/src/scsi/commands/start_stop_unit.rs @@ -15,25 +15,25 @@ use crate::scsi::{ pub struct StartStopUnitCommand { #[pkd(7, 0, 0, 0)] pub op_code: u8, - + #[pkd(0, 0, 1, 1)] pub immediate: bool, - + #[pkd(3, 0, 3, 3)] pub power_condition_modifier: u8, - + #[pkd(7, 4, 4, 4)] pub power_condition: u8, - + #[pkd(2, 2, 4, 4)] pub no_flush: bool, - + #[pkd(1, 1, 4, 4)] pub load_eject: bool, - + #[pkd(0, 0, 4, 4)] pub start: bool, - + #[pkd(7, 0, 5, 5)] pub control: Control, } diff --git a/libs/mass-storage/usbd_scsi/src/scsi/commands/synchronize_cache.rs b/libs/mass-storage/usbd_scsi/src/scsi/commands/synchronize_cache.rs index 8cc7061a8..672399ced 100644 --- a/libs/mass-storage/usbd_scsi/src/scsi/commands/synchronize_cache.rs +++ b/libs/mass-storage/usbd_scsi/src/scsi/commands/synchronize_cache.rs @@ -15,19 +15,19 @@ use crate::scsi::{ pub struct SynchronizeCache10Command { #[pkd(7, 0, 0, 0)] pub op_code: u8, - + #[pkd(1, 1, 1, 1)] pub immediate: bool, - + #[pkd(7, 0, 2, 5)] pub lba: u32, - + #[pkd(4, 0, 6, 6)] pub group_number: u8, - + #[pkd(7, 0, 7, 8)] pub number_of_blocks: u16, - + #[pkd(7, 0, 9, 9)] pub control: Control, } diff --git a/libs/mass-storage/usbd_scsi/src/scsi/commands/test_unit_ready.rs b/libs/mass-storage/usbd_scsi/src/scsi/commands/test_unit_ready.rs index 57d05a910..9d0d79b3a 100644 --- a/libs/mass-storage/usbd_scsi/src/scsi/commands/test_unit_ready.rs +++ b/libs/mass-storage/usbd_scsi/src/scsi/commands/test_unit_ready.rs @@ -15,7 +15,7 @@ use crate::scsi::{ pub struct TestUnitReadyCommand { #[pkd(7, 0, 0, 0)] pub op_code: u8, - + #[pkd(7, 0, 5, 5)] pub control: Control, } diff --git a/libs/mass-storage/usbd_scsi/src/scsi/commands/verify.rs b/libs/mass-storage/usbd_scsi/src/scsi/commands/verify.rs index 95da0874a..8dc92dac5 100644 --- a/libs/mass-storage/usbd_scsi/src/scsi/commands/verify.rs +++ b/libs/mass-storage/usbd_scsi/src/scsi/commands/verify.rs @@ -15,25 +15,25 @@ use crate::scsi::{ pub struct Verify10Command { #[pkd(7, 0, 0, 0)] pub op_code: u8, - + #[pkd(7, 5, 1, 1)] pub vr_protect: u8, - + #[pkd(4, 4, 1, 1)] pub dpo: bool, - + #[pkd(1, 1, 1, 1)] pub byte_check: u8, - + #[pkd(7, 0, 2, 5)] pub lba: u32, - + #[pkd(4, 0, 6, 6)] pub group_number: u8, - + #[pkd(7, 0, 7, 8)] pub verification_length: u16, - + #[pkd(7, 0, 9, 9)] pub control: Control, } diff --git a/libs/mass-storage/usbd_scsi/src/scsi/commands/write.rs b/libs/mass-storage/usbd_scsi/src/scsi/commands/write.rs index 63b0d0814..e8754e715 100644 --- a/libs/mass-storage/usbd_scsi/src/scsi/commands/write.rs +++ b/libs/mass-storage/usbd_scsi/src/scsi/commands/write.rs @@ -46,13 +46,13 @@ impl From for WriteXCommand { pub struct Write10Command { #[pkd(7, 0, 0, 0)] pub op_code: u8, - + #[pkd(7, 5, 1, 1)] pub wr_protect: u8, #[pkd(4, 4, 1, 1)] pub dpo: bool, - + #[pkd(3, 3, 1, 1)] pub fua: bool, @@ -86,13 +86,13 @@ impl From for WriteXCommand { pub struct Write12Command { #[pkd(7, 0, 0, 0)] pub op_code: u8, - + #[pkd(7, 5, 1, 1)] pub wr_protect: u8, #[pkd(4, 4, 1, 1)] pub dpo: bool, - + #[pkd(3, 3, 1, 1)] pub fua: bool, diff --git a/libs/mass-storage/usbd_scsi/src/scsi/enums/additional_sense_code.rs b/libs/mass-storage/usbd_scsi/src/scsi/enums/additional_sense_code.rs index 1506ea196..703b44f9e 100644 --- a/libs/mass-storage/usbd_scsi/src/scsi/enums/additional_sense_code.rs +++ b/libs/mass-storage/usbd_scsi/src/scsi/enums/additional_sense_code.rs @@ -5,7 +5,7 @@ // SPDX-LIcense-Identifier: Apache 2.0 // There are many more variants (see asc-num.txt) but these are the ones the scsi code -// currently uses +// currently uses #[derive(Clone, Copy, Debug, PartialEq, Eq)] pub enum AdditionalSenseCode { /// ASC 0x20, ASCQ: 0x0 - INVALID COMMAND OPERATION CODE @@ -74,13 +74,13 @@ impl packing::PackedBytes<[u8; 2]> for AdditionalSenseCode { fn to_bytes(&self) -> Result<[u8; 2], Self::Error> { Ok([self.asc(), self.ascq()]) } - + fn from_bytes(bytes: [u8; 2]) -> Result { let [asc, ascq] = bytes; Self::from(asc, ascq).ok_or(packing::Error::InvalidEnumDiscriminant) } } - + impl Default for AdditionalSenseCode { fn default() -> Self { diff --git a/libs/mass-storage/usbd_scsi/src/scsi/enums/response_code.rs b/libs/mass-storage/usbd_scsi/src/scsi/enums/response_code.rs index 237bf7f01..7f0f10b22 100644 --- a/libs/mass-storage/usbd_scsi/src/scsi/enums/response_code.rs +++ b/libs/mass-storage/usbd_scsi/src/scsi/enums/response_code.rs @@ -9,7 +9,7 @@ use packing::Packed; #[derive(Clone, Copy, Eq, PartialEq, Debug, Packed)] pub enum ResponseCode { FixedSenseData = 0x70, - DescriptorSenseData = 0x72, + DescriptorSenseData = 0x72, } impl Default for ResponseCode { fn default() -> Self { diff --git a/libs/mass-storage/usbd_scsi/src/scsi/enums/version_descriptor.rs b/libs/mass-storage/usbd_scsi/src/scsi/enums/version_descriptor.rs index a2a655a01..b4c029da6 100644 --- a/libs/mass-storage/usbd_scsi/src/scsi/enums/version_descriptor.rs +++ b/libs/mass-storage/usbd_scsi/src/scsi/enums/version_descriptor.rs @@ -215,7 +215,7 @@ pub enum VersionDescriptor { BCCNoVersionClaimed = 0x0380, /// MMC-4 (no version claimed) MMC4NoVersionClaimed = 0x03A0, - /// MMC-4 T10/1545-D revision 5"}, + /// MMC-4 T10/1545-D revision 5"}, MMC4T101545DRevision5 = 0x03B0, /// MMC-4 T10/1545-D revision 5a MMC4T101545DRevision5a = 0x03B1,