]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
rust: Update PCI binding safety comments and add inline compiler hint
authorAlistair Popple <apopple@nvidia.com>
Wed, 30 Jul 2025 01:34:16 +0000 (11:34 +1000)
committerDanilo Krummrich <dakr@kernel.org>
Fri, 15 Aug 2025 18:24:10 +0000 (20:24 +0200)
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@kernel.org>
Cc: Danilo Krummrich <dakr@kernel.org>
Cc: Bjorn Helgaas <bhelgaas@google.com>
Cc: Krzysztof Wilczyński <kwilczynski@kernel.org>
Cc: Miguel Ojeda <ojeda@kernel.org>
Cc: Alex Gaynor <alex.gaynor@gmail.com>
Cc: Boqun Feng <boqun.feng@gmail.com>
Cc: Gary Guo <gary@garyguo.net>
Cc: Björn Roy Baron <bjorn3_gh@protonmail.com>
Cc: Benno Lossin <lossin@kernel.org>
Cc: Andreas Hindborg <a.hindborg@kernel.org>
Cc: Alice Ryhl <aliceryhl@google.com>
Cc: Trevor Gross <tmgross@umich.edu>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Rafael J. Wysocki <rafael@kernel.org>
Cc: John Hubbard <jhubbard@nvidia.com>
Cc: Alexandre Courbot <acourbot@nvidia.com>
Cc: linux-pci@vger.kernel.org
Cc: linux-kernel@vger.kernel.org
Signed-off-by: Alistair Popple <apopple@nvidia.com>
Link: https://lore.kernel.org/r/20250730013417.640593-1-apopple@nvidia.com
Signed-off-by: Danilo Krummrich <dakr@kernel.org>
rust/kernel/pci.rs

index 71d25dbcb392bbf1f8dacbd2fc8291f7163b9ba2..5fa74d62773041e863ff1ae9a60b50929b3b8c10 100644 (file)
@@ -388,14 +388,18 @@ impl<Ctx: device::DeviceContext> Device<Ctx> {
 
 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 }
     }