diff options
author | Bjorn Helgaas <bhelgaas@google.com> | 2012-07-11 19:05:43 -0400 |
---|---|---|
committer | Bjorn Helgaas <bhelgaas@google.com> | 2012-07-11 19:05:43 -0400 |
commit | fe6dacdb1a31957825c0876de7cdea4c356aca30 (patch) | |
tree | 5ed43b9d8cb73dafdd73f222ad8c89b4e6762a5d /drivers/pci/setup-res.c | |
parent | d6776e6d5c2f8db0252f447b09736075e1bbe387 (diff) |
PCI: reorder __pci_assign_resource() (no change)
Reorder functions so __pci_assign_resource(), _pci_assign_resource(),
and pci_assign_resource() are closer together. No code change.
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Diffstat (limited to 'drivers/pci/setup-res.c')
-rw-r--r-- | drivers/pci/setup-res.c | 104 |
1 files changed, 52 insertions, 52 deletions
diff --git a/drivers/pci/setup-res.c b/drivers/pci/setup-res.c index be76ebacf486..3ce9fa317d1d 100644 --- a/drivers/pci/setup-res.c +++ b/drivers/pci/setup-res.c | |||
@@ -127,33 +127,6 @@ void pci_disable_bridge_window(struct pci_dev *dev) | |||
127 | pci_write_config_dword(dev, PCI_PREF_BASE_UPPER32, 0xffffffff); | 127 | pci_write_config_dword(dev, PCI_PREF_BASE_UPPER32, 0xffffffff); |
128 | } | 128 | } |
129 | 129 | ||
130 | static int __pci_assign_resource(struct pci_bus *bus, struct pci_dev *dev, | ||
131 | int resno, resource_size_t size, resource_size_t align) | ||
132 | { | ||
133 | struct resource *res = dev->resource + resno; | ||
134 | resource_size_t min; | ||
135 | int ret; | ||
136 | |||
137 | min = (res->flags & IORESOURCE_IO) ? PCIBIOS_MIN_IO : PCIBIOS_MIN_MEM; | ||
138 | |||
139 | /* First, try exact prefetching match.. */ | ||
140 | ret = pci_bus_alloc_resource(bus, res, size, align, min, | ||
141 | IORESOURCE_PREFETCH, | ||
142 | pcibios_align_resource, dev); | ||
143 | |||
144 | if (ret < 0 && (res->flags & IORESOURCE_PREFETCH)) { | ||
145 | /* | ||
146 | * That failed. | ||
147 | * | ||
148 | * But a prefetching area can handle a non-prefetching | ||
149 | * window (it will just not perform as well). | ||
150 | */ | ||
151 | ret = pci_bus_alloc_resource(bus, res, size, align, min, 0, | ||
152 | pcibios_align_resource, dev); | ||
153 | } | ||
154 | return ret; | ||
155 | } | ||
156 | |||
157 | /* | 130 | /* |
158 | * Generic function that returns a value indicating that the device's | 131 | * Generic function that returns a value indicating that the device's |
159 | * original BIOS BAR address was not saved and so is not available for | 132 | * original BIOS BAR address was not saved and so is not available for |
@@ -206,6 +179,33 @@ static int pci_revert_fw_address(struct resource *res, struct pci_dev *dev, | |||
206 | return ret; | 179 | return ret; |
207 | } | 180 | } |
208 | 181 | ||
182 | static int __pci_assign_resource(struct pci_bus *bus, struct pci_dev *dev, | ||
183 | int resno, resource_size_t size, resource_size_t align) | ||
184 | { | ||
185 | struct resource *res = dev->resource + resno; | ||
186 | resource_size_t min; | ||
187 | int ret; | ||
188 | |||
189 | min = (res->flags & IORESOURCE_IO) ? PCIBIOS_MIN_IO : PCIBIOS_MIN_MEM; | ||
190 | |||
191 | /* First, try exact prefetching match.. */ | ||
192 | ret = pci_bus_alloc_resource(bus, res, size, align, min, | ||
193 | IORESOURCE_PREFETCH, | ||
194 | pcibios_align_resource, dev); | ||
195 | |||
196 | if (ret < 0 && (res->flags & IORESOURCE_PREFETCH)) { | ||
197 | /* | ||
198 | * That failed. | ||
199 | * | ||
200 | * But a prefetching area can handle a non-prefetching | ||
201 | * window (it will just not perform as well). | ||
202 | */ | ||
203 | ret = pci_bus_alloc_resource(bus, res, size, align, min, 0, | ||
204 | pcibios_align_resource, dev); | ||
205 | } | ||
206 | return ret; | ||
207 | } | ||
208 | |||
209 | static int _pci_assign_resource(struct pci_dev *dev, int resno, | 209 | static int _pci_assign_resource(struct pci_dev *dev, int resno, |
210 | resource_size_t size, resource_size_t min_align) | 210 | resource_size_t size, resource_size_t min_align) |
211 | { | 211 | { |
@@ -239,31 +239,6 @@ static int _pci_assign_resource(struct pci_dev *dev, int resno, | |||
239 | return ret; | 239 | return ret; |
240 | } | 240 | } |
241 | 241 | ||
242 | int pci_reassign_resource(struct pci_dev *dev, int resno, resource_size_t addsize, | ||
243 | resource_size_t min_align) | ||
244 | { | ||
245 | struct resource *res = dev->resource + resno; | ||
246 | resource_size_t new_size; | ||
247 | int ret; | ||
248 | |||
249 | if (!res->parent) { | ||
250 | dev_info(&dev->dev, "BAR %d: can't reassign an unassigned resource %pR " | ||
251 | "\n", resno, res); | ||
252 | return -EINVAL; | ||
253 | } | ||
254 | |||
255 | /* already aligned with min_align */ | ||
256 | new_size = resource_size(res) + addsize; | ||
257 | ret = _pci_assign_resource(dev, resno, new_size, min_align); | ||
258 | if (!ret) { | ||
259 | res->flags &= ~IORESOURCE_STARTALIGN; | ||
260 | dev_info(&dev->dev, "BAR %d: reassigned %pR\n", resno, res); | ||
261 | if (resno < PCI_BRIDGE_RESOURCES) | ||
262 | pci_update_resource(dev, resno); | ||
263 | } | ||
264 | return ret; | ||
265 | } | ||
266 | |||
267 | int pci_assign_resource(struct pci_dev *dev, int resno) | 242 | int pci_assign_resource(struct pci_dev *dev, int resno) |
268 | { | 243 | { |
269 | struct resource *res = dev->resource + resno; | 244 | struct resource *res = dev->resource + resno; |
@@ -299,6 +274,31 @@ int pci_assign_resource(struct pci_dev *dev, int resno) | |||
299 | return ret; | 274 | return ret; |
300 | } | 275 | } |
301 | 276 | ||
277 | int pci_reassign_resource(struct pci_dev *dev, int resno, resource_size_t addsize, | ||
278 | resource_size_t min_align) | ||
279 | { | ||
280 | struct resource *res = dev->resource + resno; | ||
281 | resource_size_t new_size; | ||
282 | int ret; | ||
283 | |||
284 | if (!res->parent) { | ||
285 | dev_info(&dev->dev, "BAR %d: can't reassign an unassigned resource %pR " | ||
286 | "\n", resno, res); | ||
287 | return -EINVAL; | ||
288 | } | ||
289 | |||
290 | /* already aligned with min_align */ | ||
291 | new_size = resource_size(res) + addsize; | ||
292 | ret = _pci_assign_resource(dev, resno, new_size, min_align); | ||
293 | if (!ret) { | ||
294 | res->flags &= ~IORESOURCE_STARTALIGN; | ||
295 | dev_info(&dev->dev, "BAR %d: reassigned %pR\n", resno, res); | ||
296 | if (resno < PCI_BRIDGE_RESOURCES) | ||
297 | pci_update_resource(dev, resno); | ||
298 | } | ||
299 | return ret; | ||
300 | } | ||
301 | |||
302 | int pci_enable_resources(struct pci_dev *dev, int mask) | 302 | int pci_enable_resources(struct pci_dev *dev, int mask) |
303 | { | 303 | { |
304 | u16 cmd, old_cmd; | 304 | u16 cmd, old_cmd; |