tool: Make Access require Send and 'static

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.
This commit is contained in:
Ian Douglas Scott
2021-04-12 07:32:53 -07:00
committed by Jeremy Soller
parent 16778e4a41
commit 84d5c6b79d
2 changed files with 4 additions and 4 deletions

View File

@ -13,13 +13,13 @@ use crate::{
use super::*; use super::*;
/// Use direct hardware access. Unsafe due to not having mutual exclusion /// 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, cmd: u16,
dbg: u16, dbg: u16,
timeout: T, 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 /// Checks that Super I/O ID matches and then returns access object
pub unsafe fn new(timeout: T) -> Result<Self, Error> { pub unsafe fn new(timeout: T) -> Result<Self, Error> {
// Make sure EC ID matches // Make sure EC ID matches
@ -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> { unsafe fn command(&mut self, cmd: u8, data: &mut [u8]) -> Result<u8, Error> {
// Test data length // Test data length
if data.len() > self.data_size() { if data.len() > self.data_size() {

View File

@ -23,7 +23,7 @@ pub use self::lpc::*;
mod lpc; mod lpc;
/// Access method for running an EC command /// 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 /// 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>; unsafe fn command(&mut self, cmd: u8, data: &mut [u8]) -> Result<u8, Error>;