Made suggested edits.

This commit is contained in:
Aurorans Solis 2021-07-02 15:37:05 -07:00
parent 04b828ab6c
commit 6ba79825c9

View File

@ -28,16 +28,15 @@ impl FromStr for Card {
.parse::<u32>() .parse::<u32>()
.map_err(|e| AmdFanError::InvalidSuffix(format!("{:?}", e))) .map_err(|e| AmdFanError::InvalidSuffix(format!("{:?}", e)))
.map(|n| Card(n))?; .map(|n| Card(n))?;
match std::fs::read_to_string(format!("{}/{}/device/vendor", ROOT_DIR, card)) { std::fs::read_to_string(format!("{}/{}/device/vendor", ROOT_DIR, card))
Ok(vendor) => { .map_err(|_| AmdFanError::FailedReadVendor)
.and_then(|vendor| {
if vendor.trim() == "0x1002" { if vendor.trim() == "0x1002" {
Ok(card) Ok(card)
} else { } else {
Err(AmdFanError::NotAmdCard) Err(AmdFanError::NotAmdCard)
} }
} })
Err(_) => Err(AmdFanError::FailedReadVendor),
}
} }
} }