refacto async mutex usage
All checks were successful
continuous-integration/drone/push Build is passing

Signed-off-by: Julien CLEMENT <julien.clement@epita.fr>
This commit is contained in:
Julien CLEMENT 2022-12-21 20:36:18 +01:00
parent b9544293e5
commit ab79782a78
2 changed files with 6 additions and 8 deletions

@ -67,8 +67,7 @@ lazy_static! {
pub async fn init() { pub async fn init() {
println!("Detecting drives"); println!("Detecting drives");
let guard = DRIVE.lock().await; match DRIVE.lock().await.as_ref() {
match guard.as_ref() {
None => println!("No drive detected :("), None => println!("No drive detected :("),
Some(drive) => { Some(drive) => {
let drive_type = match drive.current_drive { let drive_type = match drive.current_drive {
@ -324,7 +323,6 @@ impl ATABus {
pub async fn print_block() { pub async fn print_block() {
let mut guard = DRIVE.lock().await; let block = DRIVE.lock().await.as_mut().unwrap().read_block(500).await;
guard.as_mut().unwrap().read_block(500).await; serial_println!("{:x?}", block);
serial_println!("{:x?}", guard.as_mut().unwrap().block);
} }

@ -6,10 +6,10 @@ use crate::utils::unserialize;
use iso9660::{IsoPrimVolDesc}; use iso9660::{IsoPrimVolDesc};
pub async fn init_prim_vol_desc() { pub async fn init_prim_vol_desc() {
let mut guard = DRIVE let desc_block = DRIVE
.lock() .lock()
.await; .await
let desc_block = guard.as_mut() .as_mut()
.unwrap() .unwrap()
.read_block(iso9660::ISO_PRIM_VOLDESC_BLOCK) .read_block(iso9660::ISO_PRIM_VOLDESC_BLOCK)
.await; .await;