]> git.hungrycats.org Git - linux/commitdiff
[PATCH] reimplement pci proc name
authorMatthew Wilcox <willy@debian.org>
Fri, 20 Jun 2003 05:31:01 +0000 (22:31 -0700)
committerGreg Kroah-Hartman <greg@kroah.com>
Fri, 20 Jun 2003 05:31:01 +0000 (22:31 -0700)
Hi Greg.  Ivan's not happy with the solution I came up with for naming
/proc/bus/pci and Anton would prefer something slightly different too,
so I abstracted the name out so each architecture can do its own thing.

This is against 2.5.72 so won't apply cleanly to your tree (it
applies to bitkeeper as of a few minutes ago with only minor offsets).
I've implemented the original name for non-PCI-domain machines; done what
ia64 and alpha need, respectively (assuming I didn't misunderstand Ivan),
and plopped in the Old Way of doing things for Sparc64, PPC and PPC64.
Maintainers may alter this to whatever degree of complexity they wish.

drivers/pci/proc.c
include/asm-alpha/pci.h
include/asm-ia64/pci.h
include/asm-ppc/pci.h
include/asm-ppc64/pci.h
include/asm-sparc64/pci.h
include/linux/pci.h

index 6607a3b7ce2f594f322b5402f916651ba7c1409b..44d859888d5bf0850df9ef1433582ed5f565d4c7 100644 (file)
@@ -389,7 +389,8 @@ int pci_proc_attach_device(struct pci_dev *dev)
                return -EACCES;
 
        if (!(de = bus->procdir)) {
-               sprintf(name, "%02x", bus->number);
+               if (!pci_name_bus(name, bus))
+                       return -EEXIST;
                de = bus->procdir = proc_mkdir(name, proc_bus_pci_dir);
                if (!de)
                        return -ENOMEM;
index d23b1f5db70c801d5b8af9edf7f5143f117c57be..34d0376dc322d613271e158a7c56375c618eefa1 100644 (file)
@@ -194,6 +194,18 @@ pcibios_resource_to_bus(struct pci_dev *dev, struct pci_bus_region *region,
 
 #define pci_domain_nr(bus) ((struct pci_controller *)(bus)->sysdata)->index
 
+/* Bus number == domain number until we get above 256 busses */
+static inline int pci_name_bus(char *name, struct pci_bus *bus)
+{
+       int domain = pci_domain_nr(bus)
+       if (domain < 256) {
+               sprintf(name, "%02x", domain);
+       } else {
+               sprintf(name, "%04x:%02x", domain, bus->number);
+       }
+       return 0;
+}
+
 #endif /* __KERNEL__ */
 
 /* Values for the `which' argument to sys_pciconfig_iobase.  */
index 13e56cfe1e3ca89164546d0c7e55c060c3bf4fd4..129436b9e7302496dbbf6d6e4f127e6dde22445d 100644 (file)
@@ -102,6 +102,16 @@ struct pci_controller {
 #define PCI_CONTROLLER(busdev) ((struct pci_controller *) busdev->sysdata)
 #define pci_domain_nr(busdev)    (PCI_CONTROLLER(busdev)->segment)
 
+static inline int pci_name_bus(char *name, struct pci_bus *bus)
+{
+       if (pci_domain_nr(bus) == 0) {
+               sprintf(name, "%02x", bus->number);
+       } else {
+               sprintf(name, "%04x:%02x", pci_domain_nr(bus), bus->number);
+       }
+       return 0;
+}
+
 /* generic pci stuff */
 #include <asm-generic/pci.h>
 
index ae9f2d0d8a4f06ace793ba11d2d1d5c69929a13e..0f535e374c9764624c7660fd4519e06381e6c764 100644 (file)
@@ -269,6 +269,13 @@ pci_dac_dma_sync_single(struct pci_dev *pdev, dma64_addr_t dma_addr, size_t len,
 /* Return the index of the PCI controller for device PDEV. */
 #define pci_domain_nr(bus) ((struct pci_controller *)(bus)->sysdata)->index
 
+/* Set the name of the bus as it appears in /proc/bus/pci */
+static inline int pci_name_bus(char *name, struct pci_bus *bus)
+{
+       sprintf(name, "%02x", bus->number);
+       return 0;
+}
+
 /* Map a range of PCI memory or I/O space for a device into user space */
 int pci_mmap_page_range(struct pci_dev *pdev, struct vm_area_struct *vma,
                        enum pci_mmap_state mmap_state, int write_combine);
index 12c74914bc5dfb9e6c67ae2ee842712386feb055..28968302803179054d6d23e24b73541315cc63c9 100644 (file)
@@ -88,6 +88,13 @@ static inline int pci_dma_supported(struct pci_dev *hwdev, u64 mask)
 
 extern int pci_domain_nr(struct pci_bus *bus);
 
+/* Set the name of the bus as it appears in /proc/bus/pci */
+static inline int pci_name_bus(char *name, struct pci_bus *bus)
+{
+       sprintf(name, "%02x", bus->number);
+       return 0;
+}
+
 struct vm_area_struct;
 /* Map a range of PCI memory or I/O space for a device into user space */
 int pci_mmap_page_range(struct pci_dev *pdev, struct vm_area_struct *vma,
index 440e7ac0c934e4d2bffe3fc3be2e587aae4ff992..c276200453a3a7397fd7017ad079abd912ebddf3 100644 (file)
@@ -191,6 +191,13 @@ pci_dac_dma_sync_single(struct pci_dev *pdev, dma64_addr_t dma_addr, size_t len,
 
 extern int pci_domain_nr(struct pci_bus *bus);
 
+/* Set the name of the bus as it appears in /proc/bus/pci */
+static inline int pci_name_bus(char *name, struct pci_bus *bus)
+{
+       sprintf(name, "%02x", bus->number);
+       return 0;
+}
+
 /* Platform support for /proc/bus/pci/X/Y mmap()s. */
 
 #define HAVE_PCI_MMAP
index 87ad2d6fd1e76643af7f2189bb5815cf182cfc50..0a2ecb5fd9e792fba5b3124146d917b2bde427eb 100644 (file)
@@ -768,6 +768,11 @@ static inline int pci_module_init(struct pci_driver *drv)
  */
 #ifndef CONFIG_PCI_DOMAINS
 static inline int pci_domain_nr(struct pci_bus *bus) { return 0; }
+static inline int pci_name_bus(char *name, struct pci_bus *bus)
+{
+       sprintf(name, "%02x", bus->number);
+       return 0;
+}
 #endif
 
 #endif /* !CONFIG_PCI */