pci: Rename pcibios_add_device to match
PATCH 1/1 pci: Rename pcibios_add_device to match
The general convention for pcibios_* hooks is that they're named after the corresponding pci_* function they provide a hook for. The exception is pcibios_add_device() which provides a hook for pci_device_add(). This has been irritating me for years so rename it.
Also, remove the export of the microblaze version. The only caller must be compiled as a built-in so there's no reason for the export.
--- arch/microblaze/pci/pci-common.c | 3 +-- arch/powerpc/kernel/pci-common.c | 2 +- arch/powerpc/platforms/powernv/pci-sriov.c | 2 +- arch/s390/pci/pci.c | 2 +- arch/sparc/kernel/pci.c | 2 +- arch/x86/pci/common.c | 2 +- drivers/pci/pci.c | 4 ++-- drivers/pci/probe.c | 4 ++-- include/linux/pci.h | 2 +- 9 files changed, 11 insertions(+), 12 deletions(-)
arch/microblaze/pci/pci-common.c +1 -2
@@ -587,13 +587,12 @@ static void pcibios_fixup_resources(struct pci_dev *dev) }DECLARE_PCI_FIXUP_HEADER (PCI_ANY_ID ,PCI_ANY_ID , pcibios_fixup_resources); -int pcibios_add_device (struct pci_dev *dev) +int pcibios_device_add (struct pci_dev *dev) { dev->irq =of_irq_parse_and_map_pci (dev,0 ,0 );return 0 ; } -EXPORT_SYMBOL (pcibios_add_device);/* * Reparent resource children of pr that conflict with res
arch/powerpc/kernel/pci-common.c +1 -1
@@ -1059,7 +1059,7 @@ void pcibios_bus_add_device(struct pci_dev *dev) ppc_md.pcibios_bus_add_device (dev); } -int pcibios_add_device (struct pci_dev *dev) +int pcibios_device_add (struct pci_dev *dev) {struct irq_domain *d;
arch/powerpc/platforms/powernv/pci-sriov.c +1 -1
@@ -54,7 +54,7 @@* to "new_size", calculated above. Implementing this is a convoluted process * which requires several hooks in the PCI core: * -* 1. In pcibios_add_device() we call pnv_pci_ioda_fixup_iov(). +* 1. In pcibios_device_add() we call pnv_pci_ioda_fixup_iov(). * * At this point the device has been probed and the device's BARs are sized, * but no resource allocations have been done. The SR-IOV BARs are sized
arch/s390/pci/pci.c +1 -1
@@ -561,7 +561,7 @@ static void zpci_cleanup_bus_resources(struct zpci_dev *zdev) zdev->has_resources =0 ; } -int pcibios_add_device (struct pci_dev *pdev) +int pcibios_device_add (struct pci_dev *pdev) {struct zpci_dev *zdev =to_zpci (pdev);struct resource *res;
arch/sparc/kernel/pci.c +1 -1
@@ -1010,7 +1010,7 @@ void pcibios_set_master(struct pci_dev *dev) }#ifdef CONFIG_PCI_IOV -int pcibios_add_device (struct pci_dev *dev) +int pcibios_device_add (struct pci_dev *dev) {struct pci_dev *pdev;
arch/x86/pci/common.c +1 -1
@@ -632,7 +632,7 @@ static void set_dev_domain_options(struct pci_dev *pdev) pdev->hotplug_user_indicators =1 ; } -int pcibios_add_device (struct pci_dev *dev) +int pcibios_device_add (struct pci_dev *dev) {struct pci_setup_rom *rom;struct irq_domain *msidom;
drivers/pci/pci.c +2 -2
@@ -2091,14 +2091,14 @@ void pcim_pin_device(struct pci_dev *pdev)EXPORT_SYMBOL (pcim_pin_device);/* -* pcibios_add_device - provide arch specific hooks when adding device dev +* pcibios_device_add - provide arch specific hooks when adding device dev * @dev: the PCI device being added * * Permits the platform to provide architecture specific functionality when * devices are added. This is the default implementation. Architecture * implementations can override this. */ -int __weak pcibios_add_device (struct pci_dev *dev) +int __weak pcibios_device_add (struct pci_dev *dev) {return 0 ; }
drivers/pci/probe.c +2 -2
@@ -2450,7 +2450,7 @@ static struct irq_domain *pci_dev_msi_domain(struct pci_dev *dev)struct irq_domain *d;/* -* If a domain has been set through the pcibios_add_device() +* If a domain has been set through the pcibios_device_add() * callback, then this is the one (platform code knows best). */ d =dev_get_msi_domain (&dev->dev);
@@ -2518,7 +2518,7 @@ void pci_device_add(struct pci_dev *dev, struct pci_bus *bus)list_add_tail (&dev->bus_list, &bus->devices);up_write (&pci_bus_sem); - ret =pcibios_add_device (dev); + ret =pcibios_device_add (dev);WARN_ON (ret <0 );/* Set up MSI IRQ domain */
include/linux/pci.h +1 -1
@@ -2126,7 +2126,7 @@ void pcibios_disable_device(struct pci_dev *dev);void pcibios_set_master (struct pci_dev *dev);int pcibios_set_pcie_reset_state (struct pci_dev *dev,enum pcie_reset_state state); -int pcibios_add_device (struct pci_dev *dev); +int pcibios_device_add (struct pci_dev *dev);void pcibios_release_device (struct pci_dev *dev);#ifdef CONFIG_PCI void pcibios_penalize_isa_irq (int irq,int active);
Signature · 1 line
2.31.1
Quoted 9 lines · Oliver O'Halloran
The general convention for pcibios_* hooks is that they're named after the corresponding pci_* function they provide a hook for. The exception is
pcibios_add_device()which provides a hook forpci_device_add(). This has been irritating me for years so rename it.Also, remove the export of the microblaze version. The only caller must be compiled as a built-in so there's no reason for the export.
Signed-off-by Oliver O'Halloran <[email protected]>
I fixed up the subject so it matches previous history and applied to pci/enumeration for v5.16, thanks!
Stuff like this really annoys me, too.
Quoted 155 lines
--- arch/microblaze/pci/pci-common.c | 3 +-- arch/powerpc/kernel/pci-common.c | 2 +- arch/powerpc/platforms/powernv/pci-sriov.c | 2 +- arch/s390/pci/pci.c | 2 +- arch/sparc/kernel/pci.c | 2 +- arch/x86/pci/common.c | 2 +- drivers/pci/pci.c | 4 ++-- drivers/pci/probe.c | 4 ++-- include/linux/pci.h | 2 +- 9 files changed, 11 insertions(+), 12 deletions(-)arch/microblaze/pci/pci-common.c +1
-2@@ -587,13 +587,12 @@ static void pcibios_fixup_resources(struct pci_dev *dev) }DECLARE_PCI_FIXUP_HEADER (PCI_ANY_ID ,PCI_ANY_ID , pcibios_fixup_resources); -int pcibios_add_device (struct pci_dev *dev) +int pcibios_device_add (struct pci_dev *dev) { dev->irq =of_irq_parse_and_map_pci (dev,0 ,0 );return 0 ; } -EXPORT_SYMBOL (pcibios_add_device);/* * Reparent resource children of pr that conflict with res arch/powerpc/kernel/pci-common.c +1
-1@@ -1059,7 +1059,7 @@ void pcibios_bus_add_device(struct pci_dev *dev) ppc_md.pcibios_bus_add_device (dev); } -int pcibios_add_device (struct pci_dev *dev) +int pcibios_device_add (struct pci_dev *dev) {struct irq_domain *d;arch/powerpc/platforms/powernv/pci-sriov.c +1
-1@@ -54,7 +54,7 @@* to "new_size", calculated above. Implementing this is a convoluted process * which requires several hooks in the PCI core: * -* 1. In pcibios_add_device() we call pnv_pci_ioda_fixup_iov(). +* 1. In pcibios_device_add() we call pnv_pci_ioda_fixup_iov(). * * At this point the device has been probed and the device's BARs are sized, * but no resource allocations have been done. The SR-IOV BARs are sized arch/s390/pci/pci.c +1
-1@@ -561,7 +561,7 @@ static void zpci_cleanup_bus_resources(struct zpci_dev *zdev) zdev->has_resources =0 ; } -int pcibios_add_device (struct pci_dev *pdev) +int pcibios_device_add (struct pci_dev *pdev) {struct zpci_dev *zdev =to_zpci (pdev);struct resource *res;arch/sparc/kernel/pci.c +1
-1@@ -1010,7 +1010,7 @@ void pcibios_set_master(struct pci_dev *dev) }#ifdef CONFIG_PCI_IOV -int pcibios_add_device (struct pci_dev *dev) +int pcibios_device_add (struct pci_dev *dev) {struct pci_dev *pdev;arch/x86/pci/common.c +1
-1@@ -632,7 +632,7 @@ static void set_dev_domain_options(struct pci_dev *pdev) pdev->hotplug_user_indicators =1 ; } -int pcibios_add_device (struct pci_dev *dev) +int pcibios_device_add (struct pci_dev *dev) {struct pci_setup_rom *rom;struct irq_domain *msidom;drivers/pci/pci.c +2
-2@@ -2091,14 +2091,14 @@ void pcim_pin_device(struct pci_dev *pdev)EXPORT_SYMBOL (pcim_pin_device);/* -* pcibios_add_device - provide arch specific hooks when adding device dev +* pcibios_device_add - provide arch specific hooks when adding device dev * @dev: the PCI device being added * * Permits the platform to provide architecture specific functionality when * devices are added. This is the default implementation. Architecture * implementations can override this. */ -int __weak pcibios_add_device (struct pci_dev *dev) +int __weak pcibios_device_add (struct pci_dev *dev) {return 0 ; }drivers/pci/probe.c +2
-2@@ -2450,7 +2450,7 @@ static struct irq_domain *pci_dev_msi_domain(struct pci_dev *dev)struct irq_domain *d;/* -* If a domain has been set through the pcibios_add_device() +* If a domain has been set through the pcibios_device_add() * callback, then this is the one (platform code knows best). */ d =dev_get_msi_domain (&dev->dev);@@ -2518,7 +2518,7 @@ void pci_device_add(struct pci_dev *dev, struct pci_bus *bus)list_add_tail (&dev->bus_list, &bus->devices);up_write (&pci_bus_sem); - ret =pcibios_add_device (dev); + ret =pcibios_device_add (dev);WARN_ON (ret <0 );/* Set up MSI IRQ domain */ include/linux/pci.h +1
-1@@ -2126,7 +2126,7 @@ void pcibios_disable_device(struct pci_dev *dev);void pcibios_set_master (struct pci_dev *dev);int pcibios_set_pcie_reset_state (struct pci_dev *dev,enum pcie_reset_state state); -int pcibios_add_device (struct pci_dev *dev); +int pcibios_device_add (struct pci_dev *dev);void pcibios_release_device (struct pci_dev *dev);#ifdef CONFIG_PCI void pcibios_penalize_isa_irq (int irq,int active);Signature · 1 line
2.31.1
Quoted 22 lines · Oliver O'Halloran
The general convention for pcibios_* hooks is that they're named after the corresponding pci_* function they provide a hook for. The exception is
pcibios_add_device()which provides a hook forpci_device_add(). This has been irritating me for years so rename it.Also, remove the export of the microblaze version. The only caller must be compiled as a built-in so there's no reason for the export.
Signed-off-by Oliver O'Halloran <[email protected]>--- arch/microblaze/pci/pci-common.c | 3 +-- arch/powerpc/kernel/pci-common.c | 2 +- arch/powerpc/platforms/powernv/pci-sriov.c | 2 +- arch/s390/pci/pci.c | 2 +- arch/sparc/kernel/pci.c | 2 +- arch/x86/pci/common.c | 2 +- drivers/pci/pci.c | 4 ++-- drivers/pci/probe.c | 4 ++-- include/linux/pci.h | 2 +- 9 files changed, 11 insertions(+), 12 deletions(-)
.. snip ..
Quoted 14 lines
arch/s390/pci/pci.c +1
-1@@ -561,7 +561,7 @@ static void zpci_cleanup_bus_resources(struct zpci_dev *zdev) zdev->has_resources =0 ; } -int pcibios_add_device (struct pci_dev *pdev) +int pcibios_device_add (struct pci_dev *pdev) {struct zpci_dev *zdev =to_zpci (pdev);struct resource *res;
.. snip ..
Quoted 1 line
I agree with your assesment this is indeed confusing. Interestingly pcibios_release_device() also doesn't follow the convention exactly as it is called from pci_release_dev() but at least that isn't very confusing.
So for the arch/s390/pci bit: