ia64/linux-2.6.18-xen.hg

changeset 816:f77ac4979fae

Backport: PCI: define PCI resource names in an 'enum'

commit fde09c6d8f92de0c9f75698a75f0989f2234c517
Author: Yu Zhao <yu.zhao@intel.com>
Date: Sat Nov 22 02:39:32 2008 +0800

PCI: define PCI resource names in an 'enum'

This patch moves all definitions of the PCI resource names to an
'enum',
and also replaces some hard-coded resource variables with symbol
names. This change eases introduction of device specific
resources.

Reviewed-by: Bjorn Helgaas <bjorn.helgaas@hp.com>
Signed-off-by: Yu Zhao <yu.zhao@intel.com>
Signed-off-by: Jesse Barnes <jbarnes@virtuousgeek.org>

Signed-off-by: Yu Zhao <yu.zhao@intel.com>
author Keir Fraser <keir.fraser@citrix.com>
date Fri Mar 13 08:50:15 2009 +0000 (2009-03-13)
parents f0dd7eb92bc9
children 9b150690cb22
files drivers/pci/pci-sysfs.c drivers/pci/probe.c drivers/pci/proc.c include/linux/pci.h
line diff
     1.1 --- a/drivers/pci/pci-sysfs.c	Fri Mar 13 07:42:13 2009 +0000
     1.2 +++ b/drivers/pci/pci-sysfs.c	Fri Mar 13 08:50:15 2009 +0000
     1.3 @@ -85,11 +85,13 @@ resource_show(struct device * dev, struc
     1.4  	struct pci_dev * pci_dev = to_pci_dev(dev);
     1.5  	char * str = buf;
     1.6  	int i;
     1.7 -	int max = 7;
     1.8 +	int max;
     1.9  	resource_size_t start, end;
    1.10  
    1.11  	if (pci_dev->subordinate)
    1.12  		max = DEVICE_COUNT_RESOURCE;
    1.13 +	else
    1.14 +		max = PCI_BRIDGE_RESOURCES;
    1.15  
    1.16  	for (i = 0; i < max; i++) {
    1.17  		struct resource *res =  &pci_dev->resource[i];
     2.1 --- a/drivers/pci/probe.c	Fri Mar 13 07:42:13 2009 +0000
     2.2 +++ b/drivers/pci/probe.c	Fri Mar 13 08:50:15 2009 +0000
     2.3 @@ -417,7 +417,7 @@ pci_alloc_child_bus(struct pci_bus *pare
     2.4  	child->bridge = get_device(&bridge->dev);
     2.5  
     2.6  	/* Set up default resource pointers and names.. */
     2.7 -	for (i = 0; i < 4; i++) {
     2.8 +	for (i = 0; i < PCI_BRIDGE_RESOURCE_NUM; i++) {
     2.9  		child->resource[i] = &bridge->resource[PCI_BRIDGE_RESOURCES+i];
    2.10  		child->resource[i]->name = child->name;
    2.11  	}
     3.1 --- a/drivers/pci/proc.c	Fri Mar 13 07:42:13 2009 +0000
     3.2 +++ b/drivers/pci/proc.c	Fri Mar 13 08:50:15 2009 +0000
     3.3 @@ -348,15 +348,16 @@ static int show_device(struct seq_file *
     3.4  			dev->vendor,
     3.5  			dev->device,
     3.6  			dev->irq);
     3.7 -	/* Here should be 7 and not PCI_NUM_RESOURCES as we need to preserve compatibility */
     3.8 -	for (i=0; i<7; i++) {
     3.9 +
    3.10 +	/* only print standard and ROM resources to preserve compatibility */
    3.11 +	for (i = 0; i <= PCI_ROM_RESOURCE; i++) {
    3.12  		resource_size_t start, end;
    3.13  		pci_resource_to_user(dev, i, &dev->resource[i], &start, &end);
    3.14  		seq_printf(m, "\t%16llx",
    3.15  			(unsigned long long)(start |
    3.16  			(dev->resource[i].flags & PCI_REGION_FLAG_MASK)));
    3.17  	}
    3.18 -	for (i=0; i<7; i++) {
    3.19 +	for (i = 0; i <= PCI_ROM_RESOURCE; i++) {
    3.20  		resource_size_t start, end;
    3.21  		pci_resource_to_user(dev, i, &dev->resource[i], &start, &end);
    3.22  		seq_printf(m, "\t%16llx",
     4.1 --- a/include/linux/pci.h	Fri Mar 13 07:42:13 2009 +0000
     4.2 +++ b/include/linux/pci.h	Fri Mar 13 08:50:15 2009 +0000
     4.3 @@ -65,8 +65,31 @@ enum pci_mmap_state {
     4.4  #define PCI_DMA_NONE		3
     4.5  
     4.6  #define DEVICE_COUNT_COMPATIBLE	4
     4.7 -#define DEVICE_COUNT_RESOURCE	12
     4.8  
     4.9 +/*
    4.10 + *  For PCI devices, the region numbers are assigned this way:
    4.11 + */
    4.12 +enum {
    4.13 +	/* #0-5: standard PCI resources */
    4.14 +	PCI_STD_RESOURCES,
    4.15 +	PCI_STD_RESOURCE_END = 5,
    4.16 +
    4.17 +	/* #6: expansion ROM resource */
    4.18 +	PCI_ROM_RESOURCE,
    4.19 +
    4.20 +	/* resources assigned to buses behind the bridge */
    4.21 +#define PCI_BRIDGE_RESOURCE_NUM 4
    4.22 +
    4.23 +	PCI_BRIDGE_RESOURCES,
    4.24 +	PCI_BRIDGE_RESOURCE_END = PCI_BRIDGE_RESOURCES +
    4.25 +				  PCI_BRIDGE_RESOURCE_NUM - 1,
    4.26 +
    4.27 +	/* total resources associated with a PCI device */
    4.28 +	PCI_NUM_RESOURCES,
    4.29 +
    4.30 +	/* preserve this for compatibility */
    4.31 +	DEVICE_COUNT_RESOURCE
    4.32 +};
    4.33  typedef int __bitwise pci_power_t;
    4.34  
    4.35  #define PCI_D0		((pci_power_t __force) 0)
    4.36 @@ -204,18 +227,6 @@ static inline void pci_remove_saved_cap(
    4.37  	hlist_del(&cap->next);
    4.38  }
    4.39  
    4.40 -/*
    4.41 - *  For PCI devices, the region numbers are assigned this way:
    4.42 - *
    4.43 - *	0-5	standard PCI regions
    4.44 - *	6	expansion ROM
    4.45 - *	7-10	bridges: address space assigned to buses behind the bridge
    4.46 - */
    4.47 -
    4.48 -#define PCI_ROM_RESOURCE	6
    4.49 -#define PCI_BRIDGE_RESOURCES	7
    4.50 -#define PCI_NUM_RESOURCES	11
    4.51 -
    4.52  #ifndef PCI_BUS_NUM_RESOURCES
    4.53  #define PCI_BUS_NUM_RESOURCES	8
    4.54  #endif