mirror of
https://github.com/torvalds/linux.git
synced 2026-07-27 17:47:41 +02:00
PCI: Add pci_resource_is_io() and pci_resource_is_mem() helpers
Add helpers to check whether a PCI resource is of I/O port or memory type. These replace the open-coded pci_resource_flags() with IORESOURCE_IO and IORESOURCE_MEM pattern used across the tree. Suggested-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com> Signed-off-by: Krzysztof Wilczyński <kwilczynski@kernel.org> Signed-off-by: Bjorn Helgaas <bhelgaas@google.com> Tested-by: Shivaprasad G Bhat <sbhat@linux.ibm.com> Reviewed-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com> Link: https://patch.msgid.link/20260508043543.217179-3-kwilczynski@kernel.org
This commit is contained in:
parent
d29eac5921
commit
77c5f3def4
|
|
@ -2300,6 +2300,31 @@ int pci_iobar_pfn(struct pci_dev *pdev, int bar, struct vm_area_struct *vma);
|
|||
CONCATENATE(__pci_dev_for_each_res, COUNT_ARGS(__VA_ARGS__)) \
|
||||
(dev, res, __VA_ARGS__)
|
||||
|
||||
/**
|
||||
* pci_resource_is_io - check if a PCI resource is of I/O port type.
|
||||
* @dev: PCI device to check.
|
||||
* @resno: The resource number (BAR index) to check.
|
||||
*
|
||||
* Returns true if the resource type is I/O port.
|
||||
*/
|
||||
static inline bool pci_resource_is_io(const struct pci_dev *dev, int resno)
|
||||
{
|
||||
return resource_type(pci_resource_n(dev, resno)) == IORESOURCE_IO;
|
||||
}
|
||||
|
||||
/**
|
||||
* pci_resource_is_mem - check if a PCI resource is of memory type.
|
||||
* @dev: PCI device to check.
|
||||
* @resno: The resource number (BAR index) to check.
|
||||
*
|
||||
* Returns true if the resource type is memory, including
|
||||
* prefetchable memory.
|
||||
*/
|
||||
static inline bool pci_resource_is_mem(const struct pci_dev *dev, int resno)
|
||||
{
|
||||
return resource_type(pci_resource_n(dev, resno)) == IORESOURCE_MEM;
|
||||
}
|
||||
|
||||
/*
|
||||
* Similar to the helpers above, these manipulate per-pci_dev
|
||||
* driver-specific data. They are really just a wrapper around
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user