scsi: use is_dead_bus for the css and renesas dead-bus checks

Replaces the inlined status/sense predicate with the shared helper; no behaviour change.
This commit is contained in:
Matthew Jackson
2026-09-27 00:55:43 -07:00
parent 1bc8e4d6e7
commit 7923e34493
2 changed files with 4 additions and 12 deletions
+1 -5
View File
@@ -22,11 +22,7 @@ impl Error {
/// True if this is a transport-layer SCSI failure (bus dead). /// True if this is a transport-layer SCSI failure (bus dead).
pub fn is_transport_failure(&self) -> bool { pub fn is_transport_failure(&self) -> bool {
matches!( matches!(self, Error::Scsi(s) if crate::scsi::is_dead_bus(s))
self,
Error::Scsi(s)
if s.status == crate::scsi::SCSI_STATUS_TRANSPORT_FAILURE && s.sense.is_none()
)
} }
} }
+3 -7
View File
@@ -37,7 +37,7 @@ pub fn is_renesas(scsi: &mut dyn ScsiTransport) -> std::result::Result<bool, Unl
// Only a senseless transport-failure status is a dead bus; anything // Only a senseless transport-failure status is a dead bus; anything
// else the transport reports as `Err` is the drive refusing. // else the transport reports as `Err` is the drive refusing.
Err(e) => { Err(e) => {
if e.status == crate::scsi::SCSI_STATUS_TRANSPORT_FAILURE && e.sense.is_none() { if crate::scsi::is_dead_bus(&e) {
tracing::warn!( tracing::warn!(
target: "freemkv::disc", target: "freemkv::disc",
phase = "renesas_probe_transport_fault", phase = "renesas_probe_transport_fault",
@@ -86,11 +86,7 @@ impl Renesas {
// fire-and-forget (payload-less); its own status is not the signal. // fire-and-forget (payload-less); its own status is not the signal.
match scsi.execute(&KNOCK_A5AAAA_CDB, DataDirection::None, &mut [], 5_000) { match scsi.execute(&KNOCK_A5AAAA_CDB, DataDirection::None, &mut [], 5_000) {
Ok(_) => {} Ok(_) => {}
Err(e) Err(e) if crate::scsi::is_dead_bus(&e) => return Err(UnlockError::Transport),
if e.status == crate::scsi::SCSI_STATUS_TRANSPORT_FAILURE && e.sense.is_none() =>
{
return Err(UnlockError::Transport);
}
Err(_) => {} // a drive that refuses the knock still gets the B read tried Err(_) => {} // a drive that refuses the knock still gets the B read tried
} }
read_is_good(scsi, &RB_B0_500000_CDB) read_is_good(scsi, &RB_B0_500000_CDB)
@@ -108,7 +104,7 @@ fn read_is_good(
match scsi.execute(cdb, DataDirection::FromDevice, &mut buf, 5_000) { match scsi.execute(cdb, DataDirection::FromDevice, &mut buf, 5_000) {
Ok(r) => Ok(r.status == 0), Ok(r) => Ok(r.status == 0),
Err(e) => { Err(e) => {
if e.status == crate::scsi::SCSI_STATUS_TRANSPORT_FAILURE && e.sense.is_none() { if crate::scsi::is_dead_bus(&e) {
return Err(UnlockError::Transport); return Err(UnlockError::Transport);
} }
Ok(false) Ok(false)