Commit b7245e82 authored by Matthew Wilcox's avatar Matthew Wilcox Committed by Greg Kroah-Hartman

[PATCH] reimplement pci proc name

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.
parent 67a8eb7c
...@@ -389,7 +389,8 @@ int pci_proc_attach_device(struct pci_dev *dev) ...@@ -389,7 +389,8 @@ int pci_proc_attach_device(struct pci_dev *dev)
return -EACCES; return -EACCES;
if (!(de = bus->procdir)) { 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); de = bus->procdir = proc_mkdir(name, proc_bus_pci_dir);
if (!de) if (!de)
return -ENOMEM; return -ENOMEM;
......
...@@ -194,6 +194,18 @@ pcibios_resource_to_bus(struct pci_dev *dev, struct pci_bus_region *region, ...@@ -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 #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__ */ #endif /* __KERNEL__ */
/* Values for the `which' argument to sys_pciconfig_iobase. */ /* Values for the `which' argument to sys_pciconfig_iobase. */
......
...@@ -102,6 +102,16 @@ struct pci_controller { ...@@ -102,6 +102,16 @@ struct pci_controller {
#define PCI_CONTROLLER(busdev) ((struct pci_controller *) busdev->sysdata) #define PCI_CONTROLLER(busdev) ((struct pci_controller *) busdev->sysdata)
#define pci_domain_nr(busdev) (PCI_CONTROLLER(busdev)->segment) #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 */ /* generic pci stuff */
#include <asm-generic/pci.h> #include <asm-generic/pci.h>
......
...@@ -269,6 +269,13 @@ pci_dac_dma_sync_single(struct pci_dev *pdev, dma64_addr_t dma_addr, size_t len, ...@@ -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. */ /* Return the index of the PCI controller for device PDEV. */
#define pci_domain_nr(bus) ((struct pci_controller *)(bus)->sysdata)->index #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 */ /* 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, int pci_mmap_page_range(struct pci_dev *pdev, struct vm_area_struct *vma,
enum pci_mmap_state mmap_state, int write_combine); enum pci_mmap_state mmap_state, int write_combine);
......
...@@ -88,6 +88,13 @@ static inline int pci_dma_supported(struct pci_dev *hwdev, u64 mask) ...@@ -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); 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; struct vm_area_struct;
/* Map a range of PCI memory or I/O space for a device into user space */ /* 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, int pci_mmap_page_range(struct pci_dev *pdev, struct vm_area_struct *vma,
......
...@@ -191,6 +191,13 @@ pci_dac_dma_sync_single(struct pci_dev *pdev, dma64_addr_t dma_addr, size_t len, ...@@ -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); 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. */ /* Platform support for /proc/bus/pci/X/Y mmap()s. */
#define HAVE_PCI_MMAP #define HAVE_PCI_MMAP
......
...@@ -768,6 +768,11 @@ static inline int pci_module_init(struct pci_driver *drv) ...@@ -768,6 +768,11 @@ static inline int pci_module_init(struct pci_driver *drv)
*/ */
#ifndef CONFIG_PCI_DOMAINS #ifndef CONFIG_PCI_DOMAINS
static inline int pci_domain_nr(struct pci_bus *bus) { return 0; } 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
#endif /* !CONFIG_PCI */ #endif /* !CONFIG_PCI */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment