diff options
author | Michael Ellerman <michael@ellerman.id.au> | 2006-11-22 02:26:16 -0500 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@suse.de> | 2006-12-20 13:54:42 -0500 |
commit | d3bac118fb27a365d5e9f54f4a078eb9b42f968f (patch) | |
tree | 0443f7d5fd25d011bebb5f1e67223c96336565a2 | |
parent | d86f90f9913d27bb968132bf63499c56bca56db6 (diff) |
PCI: Create __pci_bus_find_cap_start() from __pci_bus_find_cap()
The current implementation of __pci_bus_find_cap() does two things,
first it determines the start of the capability chain for the device,
and then it trys to find the requested capability.
Split these out, so that we can use the two parts independantly in
a subsequent patch. Externally visible behaviour should be unchanged.
Signed-off-by: Michael Ellerman <michael@ellerman.id.au>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
-rw-r--r-- | drivers/pci/pci.c | 28 |
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 | } |
97 | EXPORT_SYMBOL_GPL(pci_find_next_capability); | 97 | EXPORT_SYMBOL_GPL(pci_find_next_capability); |
98 | 98 | ||
99 | static int __pci_bus_find_cap(struct pci_bus *bus, unsigned int devfn, u8 hdr_type, int cap) | 99 | static 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 | */ |
141 | int pci_find_capability(struct pci_dev *dev, int cap) | 140 | int 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 | */ |
159 | int pci_bus_find_capability(struct pci_bus *bus, unsigned int devfn, int cap) | 164 | int 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 | /** |