aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/pci/pci.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/pci/pci.c')
-rw-r--r--drivers/pci/pci.c28
1 files changed, 19 insertions, 9 deletions
diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c
index 5a14b73cf3a1..4627a51d1d6c 100644
--- a/drivers/pci/pci.c
+++ b/drivers/pci/pci.c
@@ -96,10 +96,10 @@ int pci_find_next_capability(struct pci_dev *dev, u8 pos, int cap)
96} 96}
97EXPORT_SYMBOL_GPL(pci_find_next_capability); 97EXPORT_SYMBOL_GPL(pci_find_next_capability);
98 98
99static int __pci_bus_find_cap(struct pci_bus *bus, unsigned int devfn, u8 hdr_type, int cap) 99static int __pci_bus_find_cap_start(struct pci_bus *bus,
100 unsigned int devfn, u8 hdr_type)
100{ 101{
101 u16 status; 102 u16 status;
102 u8 pos;
103 103
104 pci_bus_read_config_word(bus, devfn, PCI_STATUS, &status); 104 pci_bus_read_config_word(bus, devfn, PCI_STATUS, &status);
105 if (!(status & PCI_STATUS_CAP_LIST)) 105 if (!(status & PCI_STATUS_CAP_LIST))
@@ -108,15 +108,14 @@ static int __pci_bus_find_cap(struct pci_bus *bus, unsigned int devfn, u8 hdr_ty
108 switch (hdr_type) { 108 switch (hdr_type) {
109 case PCI_HEADER_TYPE_NORMAL: 109 case PCI_HEADER_TYPE_NORMAL:
110 case PCI_HEADER_TYPE_BRIDGE: 110 case PCI_HEADER_TYPE_BRIDGE:
111 pos = PCI_CAPABILITY_LIST; 111 return PCI_CAPABILITY_LIST;
112 break;
113 case PCI_HEADER_TYPE_CARDBUS: 112 case PCI_HEADER_TYPE_CARDBUS:
114 pos = PCI_CB_CAPABILITY_LIST; 113 return PCI_CB_CAPABILITY_LIST;
115 break;
116 default: 114 default:
117 return 0; 115 return 0;
118 } 116 }
119 return __pci_find_next_cap(bus, devfn, pos, cap); 117
118 return 0;
120} 119}
121 120
122/** 121/**
@@ -140,7 +139,13 @@ static int __pci_bus_find_cap(struct pci_bus *bus, unsigned int devfn, u8 hdr_ty
140 */ 139 */
141int pci_find_capability(struct pci_dev *dev, int cap) 140int pci_find_capability(struct pci_dev *dev, int cap)
142{ 141{
143 return __pci_bus_find_cap(dev->bus, dev->devfn, dev->hdr_type, cap); 142 int pos;
143
144 pos = __pci_bus_find_cap_start(dev->bus, dev->devfn, dev->hdr_type);
145 if (pos)
146 pos = __pci_find_next_cap(dev->bus, dev->devfn, pos, cap);
147
148 return pos;
144} 149}
145 150
146/** 151/**
@@ -158,11 +163,16 @@ int pci_find_capability(struct pci_dev *dev, int cap)
158 */ 163 */
159int pci_bus_find_capability(struct pci_bus *bus, unsigned int devfn, int cap) 164int pci_bus_find_capability(struct pci_bus *bus, unsigned int devfn, int cap)
160{ 165{
166 int pos;
161 u8 hdr_type; 167 u8 hdr_type;
162 168
163 pci_bus_read_config_byte(bus, devfn, PCI_HEADER_TYPE, &hdr_type); 169 pci_bus_read_config_byte(bus, devfn, PCI_HEADER_TYPE, &hdr_type);
164 170
165 return __pci_bus_find_cap(bus, devfn, hdr_type & 0x7f, cap); 171 pos = __pci_bus_find_cap_start(bus, devfn, hdr_type & 0x7f);
172 if (pos)
173 pos = __pci_find_next_cap(bus, devfn, pos, cap);
174
175 return pos;
166} 176}
167 177
168/** 178/**