[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <20250730013417.640593-1-apopple@nvidia.com>
Date: Wed, 30 Jul 2025 11:34:16 +1000
From: Alistair Popple <apopple@...dia.com>
To: rust-for-linux@...r.kernel.org
Cc: Alistair Popple <apopple@...dia.com>,
Danilo Krummrich <dakr@...nel.org>,
Bjorn Helgaas <bhelgaas@...gle.com>,
Krzysztof Wilczyński <kwilczynski@...nel.org>,
Miguel Ojeda <ojeda@...nel.org>,
Alex Gaynor <alex.gaynor@...il.com>,
Boqun Feng <boqun.feng@...il.com>,
Gary Guo <gary@...yguo.net>,
Björn Roy Baron <bjorn3_gh@...tonmail.com>,
Benno Lossin <lossin@...nel.org>,
Andreas Hindborg <a.hindborg@...nel.org>,
Alice Ryhl <aliceryhl@...gle.com>,
Trevor Gross <tmgross@...ch.edu>,
Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
"Rafael J. Wysocki" <rafael@...nel.org>,
John Hubbard <jhubbard@...dia.com>,
Alexandre Courbot <acourbot@...dia.com>,
linux-pci@...r.kernel.org,
linux-kernel@...r.kernel.org
Subject: [PATCH v3 1/2] rust: Update PCI binding safety comments and add inline compiler hint
Update the safety comments to be consistent with other safety comments
in the PCI bindings. Also add an inline compiler hint.
Suggested-by: Danilo Krummrich <dakr@...nel.org>
Cc: Danilo Krummrich <dakr@...nel.org>
Cc: Bjorn Helgaas <bhelgaas@...gle.com>
Cc: Krzysztof Wilczyński <kwilczynski@...nel.org>
Cc: Miguel Ojeda <ojeda@...nel.org>
Cc: Alex Gaynor <alex.gaynor@...il.com>
Cc: Boqun Feng <boqun.feng@...il.com>
Cc: Gary Guo <gary@...yguo.net>
Cc: Björn Roy Baron <bjorn3_gh@...tonmail.com>
Cc: Benno Lossin <lossin@...nel.org>
Cc: Andreas Hindborg <a.hindborg@...nel.org>
Cc: Alice Ryhl <aliceryhl@...gle.com>
Cc: Trevor Gross <tmgross@...ch.edu>
Cc: Greg Kroah-Hartman <gregkh@...uxfoundation.org>
Cc: Rafael J. Wysocki <rafael@...nel.org>
Cc: John Hubbard <jhubbard@...dia.com>
Cc: Alexandre Courbot <acourbot@...dia.com>
Cc: linux-pci@...r.kernel.org
Cc: linux-kernel@...r.kernel.org
Signed-off-by: Alistair Popple <apopple@...dia.com>
---
Changes for v3:
- Updated capitalisation of SAFETY comments
---
rust/kernel/pci.rs | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/rust/kernel/pci.rs b/rust/kernel/pci.rs
index 8435f8132e381..7da1712398938 100644
--- a/rust/kernel/pci.rs
+++ b/rust/kernel/pci.rs
@@ -371,14 +371,18 @@ fn as_raw(&self) -> *mut bindings::pci_dev {
impl Device {
/// Returns the PCI vendor ID.
+ #[inline]
pub fn vendor_id(&self) -> u16 {
- // SAFETY: `self.as_raw` is a valid pointer to a `struct pci_dev`.
+ // SAFETY: By its type invariant `self.as_raw` is always a valid pointer to a
+ // `struct pci_dev`.
unsafe { (*self.as_raw()).vendor }
}
/// Returns the PCI device ID.
+ #[inline]
pub fn device_id(&self) -> u16 {
- // SAFETY: `self.as_raw` is a valid pointer to a `struct pci_dev`.
+ // SAFETY: By its type invariant `self.as_raw` is always a valid pointer to a
+ // `struct pci_dev`.
unsafe { (*self.as_raw()).device }
}
--
2.47.2
Powered by blists - more mailing lists