Skip to content

Commit

Permalink
thermal: tidy things up a bit
Browse files Browse the repository at this point in the history
  • Loading branch information
hawkw committed May 21, 2024
1 parent 53fe03f commit 847f170
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 15 deletions.
4 changes: 1 addition & 3 deletions task/thermal/src/bsp/gimlet_bcdef.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ use crate::{
};
pub use drv_gimlet_seq_api::SeqError;
use drv_gimlet_seq_api::{PowerState, Sequencer};
use drv_i2c_devices::max31790::Max31790;
use task_sensor_api::SensorId;
use task_thermal_api::ThermalProperties;
use userlib::{task_slot, units::Celsius, TaskId, UnwrapLite};
Expand Down Expand Up @@ -166,8 +165,7 @@ impl Bsp {

pub fn new(i2c_task: TaskId) -> Self {
// Initializes and build a handle to the fan controller IC
let fctrl =
Max31790State::new(Max31790::new(&devices::max31790(i2c_task)[0]));
let fctrl = Max31790State::new(&devices::max31790(i2c_task)[0]);

// Handle for the sequencer task, which we check for power state
let seq = Sequencer::from(SEQ.get_task_id());
Expand Down
13 changes: 4 additions & 9 deletions task/thermal/src/bsp/sidecar_bcd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ use crate::control::{
ChannelType, ControllerInitError, Device, FanControl, Fans, InputChannel,
Max31790State, PidConfig, TemperatureSensor,
};
use drv_i2c_devices::max31790::Max31790;
use drv_i2c_devices::tmp451::*;
pub use drv_sidecar_seq_api::SeqError;
use drv_sidecar_seq_api::{Sequencer, TofinoSeqState, TofinoSequencerPolicy};
Expand Down Expand Up @@ -128,11 +127,11 @@ impl Bsp {
// Run the function on each fan control chip
match self.fan_control(0.into()) {
Ok(c) => fctrl(c),
Err(e) => last_err = Err(e.into()),
Err(e) => last_err = Err(e),
}
match self.fan_control(4.into()) {
Ok(c) => fctrl(c),
Err(e) => last_err = Err(e.into()),
Err(e) => last_err = Err(e),
}
last_err
}
Expand Down Expand Up @@ -174,12 +173,8 @@ impl Bsp {
// fan presence
let seq = Sequencer::from(SEQUENCER.get_task_id());

let fctrl_east = Max31790State::new(Max31790::new(
&devices::max31790_east(i2c_task),
));
let fctrl_west = Max31790State::new(Max31790::new(
&devices::max31790_west(i2c_task),
));
let fctrl_east = Max31790State::new(&devices::max31790_east(i2c_task));
let fctrl_west = Max31790State::new(&devices::max31790_west(i2c_task));

Self {
seq,
Expand Down
6 changes: 3 additions & 3 deletions task/thermal/src/control.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use crate::{
bsp::{self, Bsp, PowerBitmask},
Fan, ThermalError, Trace,
};
use drv_i2c_api::ResponseCode;
use drv_i2c_api::{I2cDevice, ResponseCode};
use drv_i2c_devices::{
max31790::{I2cWatchdog, Max31790},
nvme_bmc::NvmeBmc,
Expand Down Expand Up @@ -295,9 +295,9 @@ pub(crate) struct Max31790State {
}

impl Max31790State {
pub(crate) fn new(max31790: Max31790) -> Self {
pub(crate) fn new(dev: &I2cDevice) -> Self {
let mut this = Self {
max31790,
max31790: Max31790::new(dev),
initialized: false,
};
// When we first start up, try to initialize the fan controller a few
Expand Down

0 comments on commit 847f170

Please sign in to comment.