[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20250428140137.468709-4-dakr@kernel.org>
Date: Mon, 28 Apr 2025 16:00:29 +0200
From: Danilo Krummrich <dakr@...nel.org>
To: gregkh@...uxfoundation.org,
rafael@...nel.org,
bhelgaas@...gle.com,
kwilczynski@...nel.org,
zhiw@...dia.com,
cjia@...dia.com,
jhubbard@...dia.com,
bskeggs@...dia.com,
acurrid@...dia.com,
joelagnelf@...dia.com,
ttabi@...dia.com,
acourbot@...dia.com,
ojeda@...nel.org,
alex.gaynor@...il.com,
boqun.feng@...il.com,
gary@...yguo.net,
bjorn3_gh@...tonmail.com,
benno.lossin@...ton.me,
a.hindborg@...nel.org,
aliceryhl@...gle.com,
tmgross@...ch.edu
Cc: linux-pci@...r.kernel.org,
rust-for-linux@...r.kernel.org,
linux-kernel@...r.kernel.org,
Danilo Krummrich <dakr@...nel.org>
Subject: [PATCH v2 3/3] samples: rust: pci: take advantage of Devres::access_with()
For the I/O operations executed from the probe() method, take advantage
of Devres::access_with(), avoiding the atomic check and RCU read lock
required otherwise entirely.
Signed-off-by: Danilo Krummrich <dakr@...nel.org>
---
samples/rust/rust_driver_pci.rs | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/samples/rust/rust_driver_pci.rs b/samples/rust/rust_driver_pci.rs
index 9ce3a7323a16..15147e4401b2 100644
--- a/samples/rust/rust_driver_pci.rs
+++ b/samples/rust/rust_driver_pci.rs
@@ -83,12 +83,12 @@ fn probe(pdev: &pci::Device<Core>, info: &Self::IdInfo) -> Result<Pin<KBox<Self>
GFP_KERNEL,
)?;
- let res = drvdata
- .bar
- .try_access_with(|b| Self::testdev(info, b))
- .ok_or(ENXIO)??;
-
- dev_info!(pdev.as_ref(), "pci-testdev data-match count: {}\n", res);
+ let bar = drvdata.bar.access(pdev.as_ref())?;
+ dev_info!(
+ pdev.as_ref(),
+ "pci-testdev data-match count: {}\n",
+ Self::testdev(info, bar)?
+ );
Ok(drvdata.into())
}
--
2.49.0
Powered by blists - more mailing lists