Update the safety comments to be consistent with other safety comments in the PCI bindings. Also add an inline compiler hint. Signed-off-by: Alistair Popple <apopple@xxxxxxxxxx> Suggested-by: Danilo Krummrich <dakr@xxxxxxxxxx> Cc: Danilo Krummrich <dakr@xxxxxxxxxx> Cc: Bjorn Helgaas <bhelgaas@xxxxxxxxxx> Cc: "Krzysztof Wilczyński" <kwilczynski@xxxxxxxxxx> Cc: Miguel Ojeda <ojeda@xxxxxxxxxx> Cc: Alex Gaynor <alex.gaynor@xxxxxxxxx> Cc: Boqun Feng <boqun.feng@xxxxxxxxx> Cc: Gary Guo <gary@xxxxxxxxxxx> Cc: "Björn Roy Baron" <bjorn3_gh@xxxxxxxxxxxxxx> Cc: Benno Lossin <lossin@xxxxxxxxxx> Cc: Andreas Hindborg <a.hindborg@xxxxxxxxxx> Cc: Alice Ryhl <aliceryhl@xxxxxxxxxx> Cc: Trevor Gross <tmgross@xxxxxxxxx> Cc: Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx> Cc: "Rafael J. Wysocki" <rafael@xxxxxxxxxx> Cc: John Hubbard <jhubbard@xxxxxxxxxx> Cc: Alexandre Courbot <acourbot@xxxxxxxxxx> Cc: linux-pci@xxxxxxxxxxxxxxx Cc: linux-kernel@xxxxxxxxxxxxxxx --- Changes for v2: - New for v2 --- 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 8435f8132e38..5c35a66a5251 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