Skip to content

Commit 0287355

Browse files
committed
windows: Check if device is set before using
Now an error because DeviceIoControl doesn't accept an option anymore Signed-off-by: Daniel Schaefer <dhs@frame.work>
1 parent 7a47493 commit 0287355

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

framework_lib/src/chromium_ec/windows.rs

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,13 @@ pub fn read_memory(offset: u16, length: u16) -> EcResult<Vec<u8>> {
5555
let retb: u32 = 0;
5656
unsafe {
5757
let device = DEVICE.lock().unwrap();
58+
let device = if let Some(device) = *device {
59+
device
60+
} else {
61+
return EcResult::Err(EcError::DeviceError("No EC device".to_string()));
62+
};
5863
DeviceIoControl(
59-
*device,
64+
device,
6065
IOCTL_CROSEC_RDMEM,
6166
Some(const_ptr),
6267
ptr_size,
@@ -93,8 +98,13 @@ pub fn send_command(command: u16, command_version: u8, data: &[u8]) -> EcResult<
9398

9499
unsafe {
95100
let device = DEVICE.lock().unwrap();
101+
let device = if let Some(device) = *device {
102+
device
103+
} else {
104+
return EcResult::Err(EcError::DeviceError("No EC device".to_string()));
105+
};
96106
DeviceIoControl(
97-
*device,
107+
device,
98108
IOCTL_CROSEC_XCMD,
99109
Some(const_ptr),
100110
size.try_into().unwrap(),

0 commit comments

Comments
 (0)