mirror of
https://github.com/torvalds/linux.git
synced 2026-12-03 20:06:35 +00:00
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]>
24 lines
456 B
C
24 lines
456 B
C
// SPDX-License-Identifier: GPL-2.0
|
|
|
|
#include <linux/pci.h>
|
|
|
|
void rust_helper_pci_set_drvdata(struct pci_dev *pdev, void *data)
|
|
{
|
|
pci_set_drvdata(pdev, data);
|
|
}
|
|
|
|
void *rust_helper_pci_get_drvdata(struct pci_dev *pdev)
|
|
{
|
|
return pci_get_drvdata(pdev);
|
|
}
|
|
|
|
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);
|
|
}
|