xref: /DragonOS/kernel/src/driver/base/platform/platform_driver.rs (revision b087521e07f601b30e3d48df788fcc2f09f19566)
1 use crate::driver::{base::device::DevicePrivateData, Driver};
2 
3 use super::{super::device::driver::DriverError, CompatibleTable};
4 
5 lazy_static! {
6     static ref PLATFORM_COMPAT_TABLE: CompatibleTable = CompatibleTable::new(vec!["platform"]);
7 }
8 /// @brief: 实现该trait的设备驱动实例应挂载在platform总线上,
9 ///         同时应该实现Driver trait
10 pub trait PlatformDriver: Driver {
11     fn compatible_table(&self) -> CompatibleTable;
12     /// @brief 探测设备
13     /// @param data 设备初始拥有的基本信息
14     fn probe(&self, data: DevicePrivateData) -> Result<(), DriverError> {
15         if data.compatible_table().matches(&PLATFORM_COMPAT_TABLE) {
16             return Ok(());
17         } else {
18             return Err(DriverError::UnsupportedOperation);
19         }
20     }
21 }
22