summaryrefslogtreecommitdiff
path: root/rust/kernel/pci.rs
diff options
context:
space:
mode:
Diffstat (limited to 'rust/kernel/pci.rs')
-rw-r--r--rust/kernel/pci.rs11
1 files changed, 11 insertions, 0 deletions
diff --git a/rust/kernel/pci.rs b/rust/kernel/pci.rs
index cae4e274f776..72d38f23f914 100644
--- a/rust/kernel/pci.rs
+++ b/rust/kernel/pci.rs
@@ -24,6 +24,10 @@ use core::{
};
use kernel::prelude::*;
+mod id;
+
+pub use self::id::{Class, ClassMask};
+
/// An adapter for the registration of PCI drivers.
pub struct Adapter<T: Driver>(T);
@@ -459,6 +463,13 @@ impl Device {
// - by its type invariant `self.as_raw` is always a valid pointer to a `struct pci_dev`.
Ok(unsafe { bindings::pci_resource_len(self.as_raw(), bar.try_into()?) })
}
+
+ /// Returns the PCI class as a `Class` struct.
+ #[inline]
+ pub fn pci_class(&self) -> Class {
+ // SAFETY: `self.as_raw` is a valid pointer to a `struct pci_dev`.
+ Class::from_raw(unsafe { (*self.as_raw()).class })
+ }
}
impl Device<device::Bound> {