From ab79782a7863fbea44458830eeb044c65cadffa1 Mon Sep 17 00:00:00 2001 From: Julien CLEMENT Date: Wed, 21 Dec 2022 20:36:18 +0100 Subject: [PATCH] refacto async mutex usage Signed-off-by: Julien CLEMENT --- src/drivers/atapi/mod.rs | 8 +++----- src/fs/iso/mod.rs | 6 +++--- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/src/drivers/atapi/mod.rs b/src/drivers/atapi/mod.rs index 80c4b32..2d10d15 100644 --- a/src/drivers/atapi/mod.rs +++ b/src/drivers/atapi/mod.rs @@ -67,8 +67,7 @@ lazy_static! { pub async fn init() { println!("Detecting drives"); - let guard = DRIVE.lock().await; - match guard.as_ref() { + match DRIVE.lock().await.as_ref() { None => println!("No drive detected :("), Some(drive) => { let drive_type = match drive.current_drive { @@ -324,7 +323,6 @@ impl ATABus { pub async fn print_block() { - let mut guard = DRIVE.lock().await; - guard.as_mut().unwrap().read_block(500).await; - serial_println!("{:x?}", guard.as_mut().unwrap().block); + let block = DRIVE.lock().await.as_mut().unwrap().read_block(500).await; + serial_println!("{:x?}", block); } \ No newline at end of file diff --git a/src/fs/iso/mod.rs b/src/fs/iso/mod.rs index b525f56..d6310ad 100644 --- a/src/fs/iso/mod.rs +++ b/src/fs/iso/mod.rs @@ -6,10 +6,10 @@ use crate::utils::unserialize; use iso9660::{IsoPrimVolDesc}; pub async fn init_prim_vol_desc() { - let mut guard = DRIVE + let desc_block = DRIVE .lock() - .await; - let desc_block = guard.as_mut() + .await + .as_mut() .unwrap() .read_block(iso9660::ISO_PRIM_VOLDESC_BLOCK) .await;