Trait kernel::pci::Driver

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

    const ID_TABLE: IdTable<Self::IdInfo>;

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

The PCI driver trait.

§Example


 struct MyDriver;

 kernel::pci_device_table!(
     PCI_TABLE,
     MODULE_PCI_TABLE,
     <MyDriver as pci::Driver>::IdInfo,
     [
         (pci::DeviceId::from_id(bindings::PCI_VENDOR_ID_REDHAT, bindings::PCI_ANY_ID as _), ())
     ]
 );

 impl pci::Driver for MyDriver {
     type IdInfo = ();
     const ID_TABLE: pci::IdTable<Self::IdInfo> = &PCI_TABLE;

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

Drivers must implement this trait in order to get a PCI driver registered. Please refer to the Adapter documentation for an example.

Required Associated Types§

source

type IdInfo: 'static

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

TODO: Use associated_type_defaults once stabilized:

type IdInfo: ’static = ();

Required Associated Constants§

source

const ID_TABLE: IdTable<Self::IdInfo>

The table of device ids supported by the driver.

Required Methods§

source

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

PCI 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§