From 2062df2f5f58d4e9dd956e5852e2ace6f1e5162b Mon Sep 17 00:00:00 2001 From: Rene van der Meer Date: Sun, 10 Dec 2023 17:00:34 +0100 Subject: [PATCH] Remove /proc/cpuinfo Hardware field check This field was removed from /proc/cpuinfo in a recent update. --- src/spi/hal.rs | 9 +++------ src/system.rs | 14 +------------- 2 files changed, 4 insertions(+), 19 deletions(-) diff --git a/src/spi/hal.rs b/src/spi/hal.rs index 88293bae..c28bba8b 100644 --- a/src/spi/hal.rs +++ b/src/spi/hal.rs @@ -1,6 +1,6 @@ use embedded_hal::{ delay::DelayNs, - spi::{self, ErrorType, SpiBus, SpiDevice, Operation}, + spi::{self, ErrorType, Operation, SpiBus, SpiDevice}, }; use embedded_hal_nb::spi::FullDuplex; use std::io; @@ -115,10 +115,7 @@ impl> SimpleHalSpiDevice { } impl> SpiDevice for SimpleHalSpiDevice { - fn transaction( - &mut self, - operations: &mut [Operation<'_, u8>] - ) -> Result<(), Error> { + fn transaction(&mut self, operations: &mut [Operation<'_, u8>]) -> Result<(), Error> { for op in operations { match op { Operation::Read(read) => { @@ -158,7 +155,7 @@ impl> SpiDevice for SimpleHalSpiDevice { } } } - Ok(()) + Ok(()) } } diff --git a/src/system.rs b/src/system.rs index 1bfa40cb..7cd8fd39 100644 --- a/src/system.rs +++ b/src/system.rs @@ -161,25 +161,13 @@ fn parse_proc_cpuinfo() -> Result { Err(_) => return Err(Error::UnknownModel), }); - let mut hardware: String = String::new(); let mut revision: String = String::new(); for line in proc_cpuinfo.lines().flatten() { - if let Some(line_value) = line.strip_prefix("Hardware\t: ") { - hardware = String::from(line_value); - } else if let Some(line_value) = line.strip_prefix("Revision\t: ") { + if let Some(line_value) = line.strip_prefix("Revision\t: ") { revision = String::from(line_value).to_lowercase(); } } - // Return an error if we don't recognize the SoC. This check is - // done to prevent accidentally identifying a non-Pi SBC as a Pi - // solely based on the revision field. - match &hardware[..] { - "BCM2708" | "BCM2835" | "BCM2709" | "BCM2836" | "BCM2710" | "BCM2837" | "BCM2837A1" - | "BCM2837B0" | "RP3A0-AU" | "BCM2710A1" | "BCM2711" | "BCM2712" => {} - _ => return Err(Error::UnknownModel), - } - let model = if (revision.len() == 4) || (revision.len() == 8) { // Older revisions are 4 characters long, or 8 if they've been over-volted match &revision[revision.len() - 4..] {