aboutsummaryrefslogtreecommitdiffstats
path: root/rust/helpers
diff options
context:
space:
mode:
authorDanilo Krummrich <[email protected]>2025-03-21 21:47:54 +0000
committerDanilo Krummrich <[email protected]>2025-04-19 08:20:16 +0000
commita095d0d1e4849ee25c28d43d713a8f433d7f1f27 (patch)
tree8e38d36066ae4862f6e297614a485d3096728393 /rust/helpers
parentMerge tag 'topic/device-context-2025-04-17' into nova-next (diff)
downloadkernel-a095d0d1e4849ee25c28d43d713a8f433d7f1f27.tar.gz
kernel-a095d0d1e4849ee25c28d43d713a8f433d7f1f27.zip
rust: pci: impl TryFrom<&Device> for &pci::Device
Implement TryFrom<&device::Device> for &Device. This allows us to get a &pci::Device from a generic &Device in a safe way; the conversion fails if the device' bus type does not match with the PCI bus type. Reviewed-by: Alice Ryhl <[email protected]> Reviewed-by: Benno Lossin <[email protected]> Link: https://lore.kernel.org/r/[email protected] [ Support device context types, use dev_is_pci() helper. - Danilo ] Signed-off-by: Danilo Krummrich <[email protected]>
Diffstat (limited to 'rust/helpers')
-rw-r--r--rust/helpers/pci.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/rust/helpers/pci.c b/rust/helpers/pci.c
index 8ba22f911459..cd0e6bf2cc4d 100644
--- a/rust/helpers/pci.c
+++ b/rust/helpers/pci.c
@@ -16,3 +16,8 @@ resource_size_t rust_helper_pci_resource_len(struct pci_dev *pdev, int bar)
{
return pci_resource_len(pdev, bar);
}
+
+bool rust_helper_dev_is_pci(const struct device *dev)
+{
+ return dev_is_pci(dev);
+}