From 88173de7e315278105c4aa63988c70fd3f3d2a04 Mon Sep 17 00:00:00 2001 From: Tim Crawford Date: Mon, 30 Dec 2024 15:47:41 -0700 Subject: [PATCH] Rename `FAN_{GET,SET}` to `FAN_{GET,SET}_PWM` Make the command and function names explicit that they are for controlling fan PWM duty. Signed-off-by: Tim Crawford --- src/board/system76/common/smfi.c | 12 ++++++------ src/common/include/common/command.h | 8 ++++---- tool/src/ec.rs | 12 ++++++------ tool/src/main.rs | 16 ++++++++-------- 4 files changed, 24 insertions(+), 24 deletions(-) diff --git a/src/board/system76/common/smfi.c b/src/board/system76/common/smfi.c index 225675aa8..938db59b1 100644 --- a/src/board/system76/common/smfi.c +++ b/src/board/system76/common/smfi.c @@ -123,7 +123,7 @@ static enum Result cmd_print(void) { return RES_OK; } -static enum Result cmd_fan_get(void) { +static enum Result cmd_fan_get_pwm(void) { switch (smfi_cmd[SMFI_CMD_DATA]) { case 1: smfi_cmd[SMFI_CMD_DATA + 1] = fan1_pwm_actual; @@ -139,7 +139,7 @@ static enum Result cmd_fan_get(void) { return RES_ERR; } -static enum Result cmd_fan_set(void) { +static enum Result cmd_fan_set_pwm(void) { switch (smfi_cmd[SMFI_CMD_DATA]) { case 1: // Set duty cycle of FAN1 @@ -384,11 +384,11 @@ void smfi_event(void) { case CMD_PRINT: smfi_cmd[SMFI_CMD_RES] = cmd_print(); break; - case CMD_FAN_GET: - smfi_cmd[SMFI_CMD_RES] = cmd_fan_get(); + case CMD_FAN_GET_PWM: + smfi_cmd[SMFI_CMD_RES] = cmd_fan_get_pwm(); break; - case CMD_FAN_SET: - smfi_cmd[SMFI_CMD_RES] = cmd_fan_set(); + case CMD_FAN_SET_PWM: + smfi_cmd[SMFI_CMD_RES] = cmd_fan_set_pwm(); break; case CMD_KEYMAP_GET: smfi_cmd[SMFI_CMD_RES] = cmd_keymap_get(); diff --git a/src/common/include/common/command.h b/src/common/include/common/command.h index 15c1ad31e..13b2e8730 100644 --- a/src/common/include/common/command.h +++ b/src/common/include/common/command.h @@ -20,10 +20,10 @@ enum Command { CMD_SPI = 5, // Reset EC CMD_RESET = 6, - // Get fan speeds - CMD_FAN_GET = 7, - // Set fan speeds - CMD_FAN_SET = 8, + // Get fan PWM duty + CMD_FAN_GET_PWM = 7, + // Set fan PWM duty + CMD_FAN_SET_PWM = 8, // Get keyboard map index CMD_KEYMAP_GET = 9, // Set keyboard map index diff --git a/tool/src/ec.rs b/tool/src/ec.rs index 0bd793784..b53b0262a 100644 --- a/tool/src/ec.rs +++ b/tool/src/ec.rs @@ -24,8 +24,8 @@ enum Cmd { Print = 4, Spi = 5, Reset = 6, - FanGet = 7, - FanSet = 8, + FanGetPwm = 7, + FanSetPwm = 8, KeymapGet = 9, KeymapSet = 10, LedGetValue = 11, @@ -187,22 +187,22 @@ impl Ec { } /// Read fan duty cycle by fan index - pub unsafe fn fan_get(&mut self, index: u8) -> Result { + pub unsafe fn fan_get_pwm(&mut self, index: u8) -> Result { let mut data = [ index, 0 ]; - self.command(Cmd::FanGet, &mut data)?; + self.command(Cmd::FanGetPwm, &mut data)?; Ok(data[1]) } /// Set fan duty cycle by fan index - pub unsafe fn fan_set(&mut self, index: u8, duty: u8) -> Result<(), Error> { + pub unsafe fn fan_set_pwm(&mut self, index: u8, duty: u8) -> Result<(), Error> { let mut data = [ index, duty ]; - self.command(Cmd::FanSet, &mut data) + self.command(Cmd::FanSetPwm, &mut data) } /// Read keymap data by layout, output pin, and input pin diff --git a/tool/src/main.rs b/tool/src/main.rs index a31da3fe9..aac131af9 100644 --- a/tool/src/main.rs +++ b/tool/src/main.rs @@ -266,15 +266,15 @@ unsafe fn print(ec: &mut Ec>, message: &[u8]) -> Result<(), Erro Ok(()) } -unsafe fn fan_get(ec: &mut Ec>, index: u8) -> Result<(), Error> { - let duty = ec.fan_get(index)?; +unsafe fn fan_get_pwm(ec: &mut Ec>, index: u8) -> Result<(), Error> { + let duty = ec.fan_get_pwm(index)?; println!("{}", duty); Ok(()) } -unsafe fn fan_set(ec: &mut Ec>, index: u8, duty: u8) -> Result<(), Error> { - ec.fan_set(index, duty) +unsafe fn fan_set_pwm(ec: &mut Ec>, index: u8, duty: u8) -> Result<(), Error> { + ec.fan_set_pwm(index, duty) } unsafe fn keymap_get(ec: &mut Ec>, layer: u8, output: u8, input: u8) -> Result<(), Error> { @@ -316,7 +316,7 @@ fn parse_color(s: &str) -> Result<(u8, u8, u8), String> { #[clap(rename_all = "snake_case")] enum SubCommand { Console, - Fan { + FanPwm { index: u8, duty: Option, }, @@ -438,16 +438,16 @@ fn main() { process::exit(1); }, }, - SubCommand::Fan { index, duty } => { + SubCommand::FanPwm { index, duty } => { match duty { - Some(duty) => match unsafe { fan_set(&mut ec, index, duty) } { + Some(duty) => match unsafe { fan_set_pwm(&mut ec, index, duty) } { Ok(()) => (), Err(err) => { eprintln!("failed to set fan {} to {}: {:X?}", index, duty, err); process::exit(1); }, }, - None => match unsafe { fan_get(&mut ec, index) } { + None => match unsafe { fan_get_pwm(&mut ec, index) } { Ok(()) => (), Err(err) => { eprintln!("failed to get fan {}: {:X?}", index, err);