Skip to content

Commit

Permalink
Remove /proc/cpuinfo Hardware field check
Browse files Browse the repository at this point in the history
This field was removed from /proc/cpuinfo in a recent update.
  • Loading branch information
golemparts committed Dec 10, 2023
1 parent 5ead54e commit 2062df2
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 19 deletions.
9 changes: 3 additions & 6 deletions 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;
Expand Down Expand Up @@ -115,10 +115,7 @@ impl<B: SpiBus<u8>> SimpleHalSpiDevice<B> {
}

impl<B: SpiBus<u8>> SpiDevice<u8> for SimpleHalSpiDevice<B> {
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) => {
Expand Down Expand Up @@ -158,7 +155,7 @@ impl<B: SpiBus<u8>> SpiDevice<u8> for SimpleHalSpiDevice<B> {
}
}
}
Ok(())
Ok(())
}
}

Expand Down
14 changes: 1 addition & 13 deletions src/system.rs
Expand Up @@ -161,25 +161,13 @@ fn parse_proc_cpuinfo() -> Result<Model> {
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..] {
Expand Down

0 comments on commit 2062df2

Please sign in to comment.