Trait kernel::platform::Driver

source ·
pub trait Driver: Send {
    type IdInfo: 'static;

    const OF_ID_TABLE: Option<IdTable<Self::IdInfo>>;

    // Required method
    fn probe(
        dev: &Device<Core>,
        id_info: Option<&Self::IdInfo>
    ) -> Result<Pin<KBox<Self>>>;
}
Expand description

The platform driver trait.

Drivers must implement this trait in order to get a platform driver registered.

§Example


 struct MyDriver;

 kernel::of_device_table!(
     OF_TABLE,
     MODULE_OF_TABLE,
     <MyDriver as platform::Driver>::IdInfo,
     [
         (of::DeviceId::new(c_str!("test,device")), ())
     ]
 );

 impl platform::Driver for MyDriver {
     type IdInfo = ();
     const OF_ID_TABLE: Option<of::IdTable<Self::IdInfo>> = Some(&OF_TABLE);

     fn probe(
         _pdev: &platform::Device<Core>,
         _id_info: Option<&Self::IdInfo>,
     ) -> Result<Pin<KBox<Self>>> {
         Err(ENODEV)
     }
 }

Required Associated Types§

source

type IdInfo: 'static

The type holding driver private data about each device id supported by the driver.

TODO: Use associated_type_defaults once stabilized:

type IdInfo: ’static = ();

Required Associated Constants§

source

const OF_ID_TABLE: Option<IdTable<Self::IdInfo>>

The table of OF device ids supported by the driver.

Required Methods§

source

fn probe( dev: &Device<Core>, id_info: Option<&Self::IdInfo> ) -> Result<Pin<KBox<Self>>>

Platform driver probe.

Called when a new platform device is added or discovered. Implementers should attempt to initialize the device here.

Object Safety§

This trait is not object safe.

Implementors§