Skip to content

Commit ed2ca59

Browse files
Merge pull request #124 from FrameworkComputer/driver-support
chromium_ec: Use portio if /dev/cros_ec does not exist
2 parents 3e819a2 + 98e8788 commit ed2ca59

File tree

2 files changed

+15
-9
lines changed

2 files changed

+15
-9
lines changed

framework_lib/src/chromium_ec/cros_ec.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ struct CrosEcCommandV2 {
5555
data: [u8; IN_SIZE],
5656
}
5757

58-
const DEV_PATH: &str = "/dev/cros_ec";
58+
pub const DEV_PATH: &str = "/dev/cros_ec";
5959

6060
lazy_static! {
6161
static ref CROS_EC_FD: Arc<Mutex<Option<std::fs::File>>> = Arc::new(Mutex::new(None));

framework_lib/src/chromium_ec/mod.rs

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -240,14 +240,20 @@ impl Default for CrosEc {
240240
///
241241
/// Depending on the availability we choose the first one as default
242242
fn available_drivers() -> Vec<CrosEcDriverType> {
243-
vec![
244-
#[cfg(feature = "win_driver")]
245-
CrosEcDriverType::Windows,
246-
#[cfg(feature = "cros_ec_driver")]
247-
CrosEcDriverType::CrosEc,
248-
#[cfg(not(feature = "windows"))]
249-
CrosEcDriverType::Portio,
250-
]
243+
let mut drivers = vec![];
244+
245+
#[cfg(feature = "win_driver")]
246+
drivers.push(CrosEcDriverType::Windows);
247+
248+
#[cfg(feature = "cros_ec_driver")]
249+
if std::path::Path::new(cros_ec::DEV_PATH).exists() {
250+
drivers.push(CrosEcDriverType::CrosEc);
251+
}
252+
253+
#[cfg(not(feature = "windows"))]
254+
drivers.push(CrosEcDriverType::Portio);
255+
256+
drivers
251257
}
252258

253259
impl CrosEc {

0 commit comments

Comments
 (0)