mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2026-09-18 23:09:29 +02:00
rust: pci: use Option<&IdInfo> for device ID info
It is possible that `pci_device_id_any` will be passed to the driver, e.g. `driver_override` is used on the device. Therefore, the driver must be able to handle the case where `driver_data` is 0. Thus, update the `probe` functions to get `Option`. The current code cannot tell if the info does not exist or is the first entry; however this will be achievable once the code is updated to use a `&'static IdInfo` pointer instead of indices. Signed-off-by: Gary Guo <gary@garyguo.net> Reviewed-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Link: https://patch.msgid.link/20260629-id_info-v2-3-56fccbe9c5ef@garyguo.net Signed-off-by: Danilo Krummrich <dakr@kernel.org>
This commit is contained in:
committed by
Danilo Krummrich
parent
e49f626ef5
commit
4fcbf7f1e4
@@ -73,7 +73,7 @@ impl pci::Driver for DmaSampleDriver {
|
||||
|
||||
fn probe<'bound>(
|
||||
pdev: &'bound pci::Device<Core<'_>>,
|
||||
_info: &'bound Self::IdInfo,
|
||||
_info: Option<&'bound Self::IdInfo>,
|
||||
) -> impl PinInit<Self, Error> + 'bound {
|
||||
pin_init::pin_init_scope(move || {
|
||||
dev_info!(pdev, "Probe DMA test driver.\n");
|
||||
|
||||
@@ -100,7 +100,7 @@ impl pci::Driver for ParentDriver {
|
||||
|
||||
fn probe<'bound>(
|
||||
pdev: &'bound pci::Device<Core<'_>>,
|
||||
_info: &'bound Self::IdInfo,
|
||||
_info: Option<&'bound Self::IdInfo>,
|
||||
) -> impl PinInit<Self::Data<'bound>, Error> + 'bound {
|
||||
try_pin_init!(ParentData {
|
||||
// SAFETY: `ParentData` is the driver's private data, which is dropped when the
|
||||
|
||||
@@ -144,7 +144,7 @@ impl pci::Driver for SampleDriver {
|
||||
|
||||
fn probe<'bound>(
|
||||
pdev: &'bound pci::Device<Core<'_>>,
|
||||
info: &'bound Self::IdInfo,
|
||||
info: Option<&'bound Self::IdInfo>,
|
||||
) -> impl PinInit<Self::Data<'bound>, Error> + 'bound {
|
||||
let vendor = pdev.vendor_id();
|
||||
dev_dbg!(
|
||||
@@ -153,6 +153,7 @@ impl pci::Driver for SampleDriver {
|
||||
vendor,
|
||||
pdev.device_id()
|
||||
);
|
||||
let info = info.ok_or(ENODEV)?;
|
||||
|
||||
pdev.enable_device_mem()?;
|
||||
pdev.set_master();
|
||||
|
||||
Reference in New Issue
Block a user