Skip to content

chromium_ec: Use portio if /dev/cros_ec does not exist #124

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 4, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion framework_lib/src/chromium_ec/cros_ec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ struct CrosEcCommandV2 {
data: [u8; IN_SIZE],
}

const DEV_PATH: &str = "/dev/cros_ec";
pub const DEV_PATH: &str = "/dev/cros_ec";

lazy_static! {
static ref CROS_EC_FD: Arc<Mutex<Option<std::fs::File>>> = Arc::new(Mutex::new(None));
Expand Down
22 changes: 14 additions & 8 deletions framework_lib/src/chromium_ec/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -239,14 +239,20 @@ impl Default for CrosEc {
///
/// Depending on the availability we choose the first one as default
fn available_drivers() -> Vec<CrosEcDriverType> {
vec![
#[cfg(feature = "win_driver")]
CrosEcDriverType::Windows,
#[cfg(feature = "cros_ec_driver")]
CrosEcDriverType::CrosEc,
#[cfg(not(feature = "windows"))]
CrosEcDriverType::Portio,
]
let mut drivers = vec![];

#[cfg(feature = "win_driver")]
drivers.push(CrosEcDriverType::Windows);

#[cfg(feature = "cros_ec_driver")]
if std::path::Path::new(cros_ec::DEV_PATH).exists() {
drivers.push(CrosEcDriverType::CrosEc);
}

#[cfg(not(feature = "windows"))]
drivers.push(CrosEcDriverType::Portio);

drivers
}

impl CrosEc {
Expand Down