aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/pci/setup-res.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/pci/setup-res.c')
-rw-r--r--drivers/pci/setup-res.c24
1 files changed, 11 insertions, 13 deletions
diff --git a/drivers/pci/setup-res.c b/drivers/pci/setup-res.c
index 2dbd96cce2d8..32e8d88a4619 100644
--- a/drivers/pci/setup-res.c
+++ b/drivers/pci/setup-res.c
@@ -26,11 +26,13 @@
26#include "pci.h" 26#include "pci.h"
27 27
28 28
29void pci_update_resource(struct pci_dev *dev, struct resource *res, int resno) 29void pci_update_resource(struct pci_dev *dev, int resno)
30{ 30{
31 struct pci_bus_region region; 31 struct pci_bus_region region;
32 u32 new, check, mask; 32 u32 new, check, mask;
33 int reg; 33 int reg;
34 enum pci_bar_type type;
35 struct resource *res = dev->resource + resno;
34 36
35 /* 37 /*
36 * Ignore resources for unimplemented BARs and unused resource slots 38 * Ignore resources for unimplemented BARs and unused resource slots
@@ -61,17 +63,13 @@ void pci_update_resource(struct pci_dev *dev, struct resource *res, int resno)
61 else 63 else
62 mask = (u32)PCI_BASE_ADDRESS_MEM_MASK; 64 mask = (u32)PCI_BASE_ADDRESS_MEM_MASK;
63 65
64 if (resno < 6) { 66 reg = pci_resource_bar(dev, resno, &type);
65 reg = PCI_BASE_ADDRESS_0 + 4 * resno; 67 if (!reg)
66 } else if (resno == PCI_ROM_RESOURCE) { 68 return;
69 if (type != pci_bar_unknown) {
67 if (!(res->flags & IORESOURCE_ROM_ENABLE)) 70 if (!(res->flags & IORESOURCE_ROM_ENABLE))
68 return; 71 return;
69 new |= PCI_ROM_ADDRESS_ENABLE; 72 new |= PCI_ROM_ADDRESS_ENABLE;
70 reg = dev->rom_base_reg;
71 } else {
72 /* Hmm, non-standard resource. */
73
74 return; /* kill uninitialised var warning */
75 } 73 }
76 74
77 pci_write_config_dword(dev, reg, new); 75 pci_write_config_dword(dev, reg, new);
@@ -134,7 +132,7 @@ int pci_assign_resource(struct pci_dev *dev, int resno)
134 132
135 align = resource_alignment(res); 133 align = resource_alignment(res);
136 if (!align) { 134 if (!align) {
137 dev_err(&dev->dev, "BAR %d: can't allocate resource (bogus " 135 dev_info(&dev->dev, "BAR %d: can't allocate resource (bogus "
138 "alignment) %pR flags %#lx\n", 136 "alignment) %pR flags %#lx\n",
139 resno, res, res->flags); 137 resno, res, res->flags);
140 return -EINVAL; 138 return -EINVAL;
@@ -157,12 +155,12 @@ int pci_assign_resource(struct pci_dev *dev, int resno)
157 } 155 }
158 156
159 if (ret) { 157 if (ret) {
160 dev_err(&dev->dev, "BAR %d: can't allocate %s resource %pR\n", 158 dev_info(&dev->dev, "BAR %d: can't allocate %s resource %pR\n",
161 resno, res->flags & IORESOURCE_IO ? "I/O" : "mem", res); 159 resno, res->flags & IORESOURCE_IO ? "I/O" : "mem", res);
162 } else { 160 } else {
163 res->flags &= ~IORESOURCE_STARTALIGN; 161 res->flags &= ~IORESOURCE_STARTALIGN;
164 if (resno < PCI_BRIDGE_RESOURCES) 162 if (resno < PCI_BRIDGE_RESOURCES)
165 pci_update_resource(dev, res, resno); 163 pci_update_resource(dev, resno);
166 } 164 }
167 165
168 return ret; 166 return ret;
@@ -197,7 +195,7 @@ int pci_assign_resource_fixed(struct pci_dev *dev, int resno)
197 dev_err(&dev->dev, "BAR %d: can't allocate %s resource %pR\n", 195 dev_err(&dev->dev, "BAR %d: can't allocate %s resource %pR\n",
198 resno, res->flags & IORESOURCE_IO ? "I/O" : "mem", res); 196 resno, res->flags & IORESOURCE_IO ? "I/O" : "mem", res);
199 } else if (resno < PCI_BRIDGE_RESOURCES) { 197 } else if (resno < PCI_BRIDGE_RESOURCES) {
200 pci_update_resource(dev, res, resno); 198 pci_update_resource(dev, resno);
201 } 199 }
202 200
203 return ret; 201 return ret;