summaryrefslogtreecommitdiff
path: root/rust/kernel
diff options
context:
space:
mode:
authorJohn Hubbard <jhubbard@nvidia.com>2025-08-29 15:36:32 -0700
committerDanilo Krummrich <dakr@kernel.org>2025-09-01 20:29:08 +0200
commit7bb02685fb5aa8f97568a2beb568a15c5c544454 (patch)
tree26351a1be2b3f047b63252989efcde836d1ab815 /rust/kernel
parent1b8ac37677d307cd0fc10f6bf9bceae2c282bdb4 (diff)
rust: pci: inline several tiny functions
Several previous commits added Vendor and Class functionality. As part of that, the new functions were inlined where appropriate. But that left this file with inconsistent use of inlining. Fix that by inlining the remaining items that should be. Cc: Danilo Krummrich <dakr@kernel.org> Cc: Elle Rhumsaa <elle@weathered-steel.dev> Reviewed-by: Alexandre Courbot <acourbot@nvidia.com> Signed-off-by: John Hubbard <jhubbard@nvidia.com> Link: https://lore.kernel.org/r/20250829223632.144030-7-jhubbard@nvidia.com Signed-off-by: Danilo Krummrich <dakr@kernel.org>
Diffstat (limited to 'rust/kernel')
-rw-r--r--rust/kernel/pci.rs5
1 files changed, 5 insertions, 0 deletions
diff --git a/rust/kernel/pci.rs b/rust/kernel/pci.rs
index 391baf95929a..78271bf88cea 100644
--- a/rust/kernel/pci.rs
+++ b/rust/kernel/pci.rs
@@ -134,6 +134,7 @@ impl DeviceId {
/// Equivalent to C's `PCI_DEVICE` macro.
///
/// Create a new `pci::DeviceId` from a vendor and device ID.
+ #[inline]
pub const fn from_id(vendor: Vendor, device: u32) -> Self {
Self(bindings::pci_device_id {
vendor: vendor.as_raw() as u32,
@@ -150,6 +151,7 @@ impl DeviceId {
/// Equivalent to C's `PCI_DEVICE_CLASS` macro.
///
/// Create a new `pci::DeviceId` from a class number and mask.
+ #[inline]
pub const fn from_class(class: u32, class_mask: u32) -> Self {
Self(bindings::pci_device_id {
vendor: DeviceId::PCI_ANY_ID,
@@ -387,6 +389,7 @@ impl<const SIZE: usize> Bar<SIZE> {
}
impl Bar {
+ #[inline]
fn index_is_valid(index: u32) -> bool {
// A `struct pci_dev` owns an array of resources with at most `PCI_NUM_RESOURCES` entries.
index < bindings::PCI_NUM_RESOURCES
@@ -409,6 +412,7 @@ impl<const SIZE: usize> Deref for Bar<SIZE> {
}
impl<Ctx: device::DeviceContext> Device<Ctx> {
+ #[inline]
fn as_raw(&self) -> *mut bindings::pci_dev {
self.0.get()
}
@@ -582,6 +586,7 @@ impl Device<device::Core> {
}
/// Enable bus-mastering for this device.
+ #[inline]
pub fn set_master(&self) {
// SAFETY: `self.as_raw` is guaranteed to be a pointer to a valid `struct pci_dev`.
unsafe { bindings::pci_set_master(self.as_raw()) };