diff --git a/bmcd/src/into_legacy_response.rs b/bmcd/src/into_legacy_response.rs index 9b81bb8..de51795 100644 --- a/bmcd/src/into_legacy_response.rs +++ b/bmcd/src/into_legacy_response.rs @@ -97,14 +97,18 @@ pub type LegacyResult = Result; impl From for HttpResponse { fn from(value: LegacyResponse) -> Self { let (response, result, is_uart) = match value { - LegacyResponse::Success(None) => { - (StatusCode::OK, serde_json::Value::String("ok".to_string()), false) - } + LegacyResponse::Success(None) => ( + StatusCode::OK, + serde_json::Value::String("ok".to_string()), + false, + ), LegacyResponse::Success(Some(body)) => (StatusCode::OK, body, false), LegacyResponse::UartData(d) => (StatusCode::OK, serde_json::Value::String(d), true), - LegacyResponse::Error(status_code, msg) => { - (status_code, serde_json::Value::String(msg.into_owned()), false) - } + LegacyResponse::Error(status_code, msg) => ( + status_code, + serde_json::Value::String(msg.into_owned()), + false, + ), }; let msg = if is_uart { diff --git a/bmcd/src/legacy.rs b/bmcd/src/legacy.rs index 0db3b0f..3017d7f 100644 --- a/bmcd/src/legacy.rs +++ b/bmcd/src/legacy.rs @@ -62,7 +62,7 @@ async fn api_entry(bmc: web::Data, query: Query) -> impl Respond }; let Some(ty) = query.get("type") else { - return LegacyResponse::bad_request("Missing `type` parameter") + return LegacyResponse::bad_request("Missing `type` parameter"); }; let bmc = bmc.as_ref(); @@ -144,11 +144,15 @@ fn get_node_param(query: &Query) -> LegacyResult { }; let Ok(node_num) = i32::from_str(node_str) else { - return Err(LegacyResponse::bad_request("Parameter `node` is not a number")); + return Err(LegacyResponse::bad_request( + "Parameter `node` is not a number", + )); }; let Ok(node) = node_num.try_into() else { - return Err(LegacyResponse::bad_request("Parameter `node` is out of range 0..3 of node IDs")); + return Err(LegacyResponse::bad_request( + "Parameter `node` is out of range 0..3 of node IDs", + )); }; Ok(node) @@ -286,7 +290,7 @@ fn get_sdcard_fs_stat() -> anyhow::Result<(u64, u64)> { async fn write_to_uart(bmc: &BmcApplication, query: Query) -> LegacyResult<()> { let node = get_node_param(&query)?; let Some(cmd) = query.get("cmd") else { - return Err(LegacyResponse::bad_request("Missing `cmd` parameter")); + return Err(LegacyResponse::bad_request("Missing `cmd` parameter")); }; let mut data = cmd.clone(); diff --git a/tpi_rs/src/c_interface.rs b/tpi_rs/src/c_interface.rs index 53b8ba7..de83cc4 100644 --- a/tpi_rs/src/c_interface.rs +++ b/tpi_rs/src/c_interface.rs @@ -137,7 +137,7 @@ pub extern "C" fn tpi_get_node_power(node: c_int) -> c_int { #[no_mangle] pub extern "C" fn tpi_reset_node(node: c_int) { let Ok(node_id) = node.try_into().map_err(|e| log::error!("{}", e)) else { - return ; + return; }; execute_routine(|bmc| Box::pin(bmc.reset_node(node_id))); } @@ -211,7 +211,7 @@ pub unsafe extern "C" fn tpi_flash_node(node: c_int, image_path: *const c_char) let node_image = PathBuf::from(bstr); let Ok(node_id) = node.try_into() else { - return FlashingResult::InvalidArgs + return FlashingResult::InvalidArgs; }; RUNTIME.block_on(async move { diff --git a/tpi_rs/src/middleware/firmware_update/rockusb_fwudate.rs b/tpi_rs/src/middleware/firmware_update/rockusb_fwudate.rs index 9bd964a..38c3542 100644 --- a/tpi_rs/src/middleware/firmware_update/rockusb_fwudate.rs +++ b/tpi_rs/src/middleware/firmware_update/rockusb_fwudate.rs @@ -1,5 +1,4 @@ use super::transport::{StdFwUpdateTransport, StdTransportWrapper}; -use rusb::DeviceDescriptor; use super::{FlashProgress, FlashingError, FlashingErrorExt}; use crate::middleware::firmware_update::FlashStatus; use crate::middleware::usbboot; @@ -9,6 +8,7 @@ use rockfile::boot::{ RkBootEntry, RkBootEntryBytes, RkBootHeader, RkBootHeaderBytes, RkBootHeaderEntry, }; use rockusb::libusb::{Transport, TransportIO}; +use rusb::DeviceDescriptor; use rusb::GlobalContext; use std::{mem::size_of, ops::Range, time::Duration}; use tokio::sync::mpsc::Sender; @@ -23,7 +23,12 @@ pub async fn new_rockusb_transport( let mut transport = Transport::from_usb_device(device.open().map_err_into_logged_usb(logging)?) .map_err(|_| FlashingError::UsbError)?; - if BootMode::Maskrom == device.device_descriptor().map_err_into_logged_usb(logging)?.into() { + if BootMode::Maskrom + == device + .device_descriptor() + .map_err_into_logged_usb(logging)? + .into() + { info!("Maskrom mode detected. loading usb-plug.."); transport = download_boot(&mut transport, logging).await?; logging @@ -134,10 +139,10 @@ async fn load_boot_entries( } #[derive(Debug, PartialEq, Eq, Copy, Clone)] - pub enum BootMode { +pub enum BootMode { Maskrom = 0, - Loader = 1, - } + Loader = 1, +} impl From for BootMode { fn from(dd: DeviceDescriptor) -> BootMode { @@ -146,5 +151,5 @@ impl From for BootMode { 1 => BootMode::Loader, _ => unreachable!(), } - } - } + } +}