PCI: add help pci_dev_id
Subsystems (4)
Heiner Kallweit
maintainercover PCI: add help pci_dev_id
In several places in the kernel we find PCI_DEVID used like this:PCI_DEVID(dev->bus->number, dev->devfn) Therefore create a helper for it.
Heiner Kallweit (3):
PCI: add helper pci_dev_id
PCI: use helper pci_dev_id
r8169: use new helper pci_dev_id
drivers/net/ethernet/realtek/r8169.c | 3 +-- drivers/pci/msi.c | 6 +++--- drivers/pci/search.c | 10 +++------- include/linux/pci.h | 5 +++++ 4 files changed, 12 insertions(+), 12 deletions(-)
Signature · 1 line
2.21.0
Heiner Kallweit
maintainerPATCH 1/3 PCI: add helper pci_dev_id
In several places in the kernel we find PCI_DEVID used like this:PCI_DEVID(dev->bus->number, dev->devfn) Therefore create a helper for it.
--- include/linux/pci.h | 5 +++++ 1 file changed, 5 insertions(+)
include/linux/pci.h +5 -0
@@ -598,6 +598,11 @@ struct pci_bus {#define to_pci_bus (n) container_of(n, struct pci_bus, dev) +static inline u16 pci_dev_id (struct pci_dev *dev) +{ +return PCI_DEVID (dev->bus->number, dev->devfn); +} +/* * Returns true if the PCI bus is root (behind host-PCI bridge), * false otherwise
Signature · 1 line
2.21.0
Heiner Kallweit
maintainerPATCH 2/3 PCI: use helper pci_dev_id
In reply to Heiner KallweitUse new helper pci_dev_id() to simplify the code.
--- drivers/pci/msi.c | 6 +++--- drivers/pci/search.c | 10 +++------- 2 files changed, 6 insertions(+), 10 deletions(-)
drivers/pci/msi.c +3 -3
@@ -1338,7 +1338,7 @@ irq_hw_number_t pci_msi_domain_calc_hwirq(struct pci_dev *dev, struct msi_desc *desc) {return (irq_hw_number_t )desc->msi_attrib.entry_nr | -PCI_DEVID (dev->bus->number, dev->devfn) <<11 | +pci_dev_id (dev) <<11 | (pci_domain_nr (dev->bus) &0xFFFFFFFF ) <<27 ; }
@@ -1508,7 +1508,7 @@ static int get_msi_id_cb(struct pci_dev *pdev, u16 alias, void *data)u32 pci_msi_domain_get_msi_rid (struct irq_domain *domain,struct pci_dev *pdev) {struct device_node *of_node; -u32 rid =PCI_DEVID (pdev->bus->number, pdev->devfn); +u32 rid =pci_dev_id (pdev);pci_for_each_dma_alias (pdev, get_msi_id_cb, &rid);
@@ -1531,7 +1531,7 @@ u32 pci_msi_domain_get_msi_rid(struct irq_domain *domain, struct pci_dev *pdev)struct irq_domain *pci_msi_get_device_domain (struct pci_dev *pdev) {struct irq_domain *dom; -u32 rid =PCI_DEVID (pdev->bus->number, pdev->devfn); +u32 rid =pci_dev_id (pdev);pci_for_each_dma_alias (pdev, get_msi_id_cb, &rid); dom =of_msi_map_get_device_domain (&pdev->dev, rid);
drivers/pci/search.c +3 -7
@@ -33,7 +33,7 @@ int pci_for_each_dma_alias(struct pci_dev *pdev,struct pci_bus *bus;int ret; - ret =fn (pdev,PCI_DEVID (pdev->bus->number, pdev->devfn), data); + ret =fn (pdev,pci_dev_id (pdev), data);if (ret)return ret;
@@ -88,9 +88,7 @@ int pci_for_each_dma_alias(struct pci_dev *pdev,return ret;continue ;case PCI_EXP_TYPE_PCIE_BRIDGE : - ret =fn (tmp, -PCI_DEVID (tmp->bus->number, - tmp->devfn), data); + ret =fn (tmp,pci_dev_id (tmp), data);if (ret)return ret;continue ;
@@ -101,9 +99,7 @@ int pci_for_each_dma_alias(struct pci_dev *pdev,PCI_DEVID (tmp->subordinate->number, PCI_DEVFN(0, 0)), data); else - ret =fn (tmp, -PCI_DEVID (tmp->bus->number, - tmp->devfn), data); + ret =fn (tmp,pci_dev_id (tmp), data);if (ret)return ret; }
Signature · 1 line
2.21.0
Heiner Kallweit
maintainerPATCH 3/3 r8169: use new helper pci_dev_id
In reply to Heiner KallweitUse new helper pci_dev_id() to simplify the code.
--- drivers/net/ethernet/realtek/r8169.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/net/ethernet/realtek/r8169.c +1 -2
@@ -7020,8 +7020,7 @@ static int r8169_mdio_register(struct rtl8169_private *tp) new_bus->priv = tp; new_bus->parent = &pdev->dev; new_bus->irq[0 ] =PHY_IGNORE_INTERRUPT ; -snprintf (new_bus->id,MII_BUS_ID_SIZE ,"r8169-%x" , -PCI_DEVID (pdev->bus->number, pdev->devfn)); +snprintf (new_bus->id,MII_BUS_ID_SIZE ,"r8169-%x" ,pci_dev_id (pdev)); new_bus->read = r8169_mdio_read_reg; new_bus->write = r8169_mdio_write_reg;
Signature · 1 line
2.21.0
David Miller
maintainerFrom: Heiner Kallweit <[email protected]>
Date: Fri, 19 Apr 2019 20:27:45 +0200
Quoted 3 lines
In several places in the kernel we find
PCI_DEVIDused like this:PCI_DEVID(dev->bus->number, dev->devfn)Therefore create a helper for it.
I'll wait for an ACK from the PCI folks on patch #1.
Quoted 8 lines · David Miller
From: Heiner Kallweit <[email protected]>
Date: Fri, 19 Apr 2019 20:27:45 +0200Quoted 3 lines
In several places in the kernel we find
PCI_DEVIDused like this:PCI_DEVID(dev->bus->number, dev->devfn)Therefore create a helper for it.I'll wait for an ACK from the PCI folks on patch #1.
#1 and #2 touch PCI, #3 is a trivial r8169 patch. There are a few other places where this helper could be used (powernv/npu-dma.c, amdkfd/kfd_topology.c, amd_iommu.c, intel-iommu.c, intel_irq_remapping.c, stmmac_pci.c, chromeos_laptop.c).
I think it would be easier for me to collect acks for the trivial changes to those places and merge the whole shebang via PCI.
Heiner, do you want to update those other places, too?
Bjorn
From: Bjorn Helgaas <[email protected]>
Date: Mon, 22 Apr 2019 08:20:20 -0500
Quoted 10 lines · David Miller
Quoted 8 lines
From: Heiner Kallweit <[email protected]>
Date: Fri, 19 Apr 2019 20:27:45 +0200Quoted 3 lines
In several places in the kernel we find
PCI_DEVIDused like this:PCI_DEVID(dev->bus->number, dev->devfn)Therefore create a helper for it.I'll wait for an ACK from the PCI folks on patch #1.
Quoted 7 lines
#1 and #2 touch PCI, #3 is a trivial r8169 patch. There are a few other places where this helper could be used (
powernv/npu-dma.c,amdkfd/kfd_topology.c,amd_iommu.c,intel-iommu.c,intel_irq_remapping.c,stmmac_pci.c,chromeos_laptop.c).I think it would be easier for me to collect acks for the trivial changes to those places and merge the whole shebang via PCI.
That's fine with me, you can add my:
Heiner Kallweit
maintainerQuoted 15 lines · Bjorn Helgaas
Quoted 8 lines · David Miller
From: Heiner Kallweit <[email protected]>
Date: Fri, 19 Apr 2019 20:27:45 +0200Quoted 3 lines
In several places in the kernel we find
PCI_DEVIDused like this:PCI_DEVID(dev->bus->number, dev->devfn)Therefore create a helper for it.I'll wait for an ACK from the PCI folks on patch #1.
#1 and #2 touch PCI, #3 is a trivial r8169 patch. There are a few other places where this helper could be used (
powernv/npu-dma.c,amdkfd/kfd_topology.c,amd_iommu.c,intel-iommu.c,intel_irq_remapping.c,stmmac_pci.c,chromeos_laptop.c).
Quoted 5 lines
I think it would be easier for me to collect acks for the trivial changes to those places and merge the whole shebang via PCI.
Heiner, do you want to update those other places, too?
Yes, will do so.
Quoted 2 lines
Bjorn
Heiner