Skip to content

Commit

Permalink
tool: Make Access require Send and 'static
Browse files Browse the repository at this point in the history
This allows the Configurator to send a `Ec<Box<dyn Access>>` through a
channel to a background thread. This could be done differently, but
presumably there's no reason to have an `Access` implementation this
doesn't apply to.
  • Loading branch information
ids1024 authored and MilesBHuff committed Apr 20, 2021
1 parent ddf706d commit f329fb3
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
6 changes: 3 additions & 3 deletions tool/src/access/lpc/direct.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@ use crate::{
use super::*;

/// Use direct hardware access. Unsafe due to not having mutual exclusion
pub struct AccessLpcDirect<T: Timeout + 'static> {
pub struct AccessLpcDirect<T: Timeout + Send + 'static> {
cmd: u16,
dbg: u16,
timeout: T,
}

impl<T: Timeout> AccessLpcDirect<T> {
impl<T: Timeout + Send> AccessLpcDirect<T> {
/// Checks that Super I/O ID matches and then returns access object
pub unsafe fn new(timeout: T) -> Result<Self, Error> {
// Make sure EC ID matches
Expand Down Expand Up @@ -71,7 +71,7 @@ impl<T: Timeout> AccessLpcDirect<T> {
}
}

impl<T: Timeout> Access for AccessLpcDirect<T> {
impl<T: Timeout + Send> Access for AccessLpcDirect<T> {
unsafe fn command(&mut self, cmd: u8, data: &mut [u8]) -> Result<u8, Error> {
// Test data length
if data.len() > self.data_size() {
Expand Down
2 changes: 1 addition & 1 deletion tool/src/access/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ pub use self::lpc::*;
mod lpc;

/// Access method for running an EC command
pub trait Access: Downcast {
pub trait Access: Downcast + Send + 'static {
/// Sends a command using the access method. Only internal use is recommended
unsafe fn command(&mut self, cmd: u8, data: &mut [u8]) -> Result<u8, Error>;

Expand Down

0 comments on commit f329fb3

Please sign in to comment.