samples: rust: pci: take advantage of Devres::access()

For the I/O operations executed from the probe() method, take advantage
of Devres::access(), avoiding the atomic check and RCU read lock required
otherwise entirely.

Reviewed-by: Alexandre Courbot <acourbot@nvidia.com>
Acked-by: Boqun Feng <boqun.feng@gmail.com>
Reviewed-by: Joel Fernandes <joelagnelf@nvidia.com>
Link: https://lore.kernel.org/r/20250428140137.468709-4-dakr@kernel.org
Signed-off-by: Danilo Krummrich <dakr@kernel.org>
This commit is contained in:
Danilo Krummrich 2025-04-28 16:00:29 +02:00
parent f301cb978c
commit b75a99e107
1 changed files with 6 additions and 6 deletions

View File

@ -83,12 +83,12 @@ fn probe(pdev: &pci::Device<Core>, info: &Self::IdInfo) -> Result<Pin<KBox<Self>
GFP_KERNEL, GFP_KERNEL,
)?; )?;
let res = drvdata let bar = drvdata.bar.access(pdev.as_ref())?;
.bar dev_info!(
.try_access_with(|b| Self::testdev(info, b)) pdev.as_ref(),
.ok_or(ENXIO)??; "pci-testdev data-match count: {}\n",
Self::testdev(info, bar)?
dev_info!(pdev.as_ref(), "pci-testdev data-match count: {}\n", res); );
Ok(drvdata.into()) Ok(drvdata.into())
} }