pub trait Driver {
type IdInfo: 'static;
type Data<'bound>: Send + 'bound;
const ID_TABLE: IdTable<Self::IdInfo>;
// Required method
fn probe<'bound>(
dev: &'bound Device<Core<'_>>,
id_info: &'bound Self::IdInfo,
) -> impl PinInit<Self::Data<'bound>, Error> + 'bound;
// Provided method
fn unbind<'bound>(
dev: &'bound Device<Core<'_>>,
this: Pin<&Self::Data<'bound>>,
) { ... }
}Expand description
The PCI driver trait.
§Examples
struct MyDriver;
kernel::pci_device_table!(
PCI_TABLE,
MODULE_PCI_TABLE,
<MyDriver as pci::Driver>::IdInfo,
[
(
pci::DeviceId::from_id(pci::Vendor::REDHAT, bindings::PCI_ANY_ID as u32),
(),
)
]
);
impl pci::Driver for MyDriver {
type IdInfo = ();
type Data<'bound> = Self;
const ID_TABLE: pci::IdTable<Self::IdInfo> = &PCI_TABLE;
fn probe<'bound>(
_pdev: &'bound pci::Device<Core<'_>>,
_id_info: &'bound Self::IdInfo,
) -> impl PinInit<Self::Data<'bound>, Error> + 'bound {
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 Constants§
Required Associated Types§
Required Methods§
Provided Methods§
Sourcefn unbind<'bound>(dev: &'bound Device<Core<'_>>, this: Pin<&Self::Data<'bound>>)
fn unbind<'bound>(dev: &'bound Device<Core<'_>>, this: Pin<&Self::Data<'bound>>)
PCI driver unbind.
Called when a Device is unbound from its bound Driver. Implementing this callback
is optional.
This callback serves as a place for drivers to perform teardown operations that require a
&Device<Core> or &Device<Bound> reference. For instance, drivers may try to perform I/O
operations to gracefully tear down the device.
Otherwise, release operations for driver resources should be performed in Drop.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".