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>()
.map_err(|e| AmdFanError::InvalidSuffix(format!("{:?}", e)))
.map(|n| Card(n))?;
match std::fs::read_to_string(format!("{}/{}/device/vendor", ROOT_DIR, card)) {
Ok(vendor) => {
std::fs::read_to_string(format!("{}/{}/device/vendor", ROOT_DIR, card))
.map_err(|_| AmdFanError::FailedReadVendor)
.and_then(|vendor| {
if vendor.trim() == "0x1002" {
Ok(card)
} else {
Err(AmdFanError::NotAmdCard)
}
}
Err(_) => Err(AmdFanError::FailedReadVendor),
}
})
}
}