Skip to content

Commit 6a64d07

Browse files
committed
Also require root before initializing MEC portio
Signed-off-by: Daniel Schaefer <[email protected]>
1 parent 7fbd80d commit 6a64d07

File tree

1 file changed

+10
-8
lines changed

1 file changed

+10
-8
lines changed

framework_lib/src/chromium_ec/portio.rs

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -90,14 +90,6 @@ fn init() -> bool {
9090
Initialized::NotYet => {}
9191
}
9292

93-
// First try on MEC
94-
portio_mec::init();
95-
let ec_id = portio_mec::transfer_read(MEC_MEMMAP_OFFSET + EC_MEMMAP_ID, 2);
96-
if ec_id[0] == b'E' && ec_id[1] == b'C' {
97-
*init = Initialized::SucceededMec;
98-
return true;
99-
}
100-
10193
// In Linux userspace has to first request access to ioports
10294
// TODO: Close these again after we're done
10395
#[cfg(target_os = "linux")]
@@ -106,6 +98,16 @@ fn init() -> bool {
10698
*init = Initialized::Failed;
10799
return false;
108100
}
101+
102+
// First try on MEC
103+
portio_mec::init();
104+
let ec_id = portio_mec::transfer_read(MEC_MEMMAP_OFFSET + EC_MEMMAP_ID, 2);
105+
if ec_id[0] == b'E' && ec_id[1] == b'C' {
106+
*init = Initialized::SucceededMec;
107+
return true;
108+
} else {
109+
}
110+
109111
#[cfg(target_os = "linux")]
110112
unsafe {
111113
// 8 for request/response header, 0xFF for response

0 commit comments

Comments
 (0)