diff options
Diffstat (limited to 'arch')
-rw-r--r-- | arch/powerpc/platforms/pseries/eeh_cache.c | 17 |
1 files changed, 2 insertions, 15 deletions
diff --git a/arch/powerpc/platforms/pseries/eeh_cache.c b/arch/powerpc/platforms/pseries/eeh_cache.c index c37a8497c60f..b6b462d3c604 100644 --- a/arch/powerpc/platforms/pseries/eeh_cache.c +++ b/arch/powerpc/platforms/pseries/eeh_cache.c | |||
@@ -157,6 +157,7 @@ pci_addr_cache_insert(struct pci_dev *dev, unsigned long alo, | |||
157 | if (!piar) | 157 | if (!piar) |
158 | return NULL; | 158 | return NULL; |
159 | 159 | ||
160 | pci_dev_get(dev); | ||
160 | piar->addr_lo = alo; | 161 | piar->addr_lo = alo; |
161 | piar->addr_hi = ahi; | 162 | piar->addr_hi = ahi; |
162 | piar->pcidev = dev; | 163 | piar->pcidev = dev; |
@@ -178,7 +179,6 @@ static void __pci_addr_cache_insert_device(struct pci_dev *dev) | |||
178 | struct device_node *dn; | 179 | struct device_node *dn; |
179 | struct pci_dn *pdn; | 180 | struct pci_dn *pdn; |
180 | int i; | 181 | int i; |
181 | int inserted = 0; | ||
182 | 182 | ||
183 | dn = pci_device_to_OF_node(dev); | 183 | dn = pci_device_to_OF_node(dev); |
184 | if (!dn) { | 184 | if (!dn) { |
@@ -197,9 +197,6 @@ static void __pci_addr_cache_insert_device(struct pci_dev *dev) | |||
197 | return; | 197 | return; |
198 | } | 198 | } |
199 | 199 | ||
200 | /* The cache holds a reference to the device... */ | ||
201 | pci_dev_get(dev); | ||
202 | |||
203 | /* Walk resources on this device, poke them into the tree */ | 200 | /* Walk resources on this device, poke them into the tree */ |
204 | for (i = 0; i < DEVICE_COUNT_RESOURCE; i++) { | 201 | for (i = 0; i < DEVICE_COUNT_RESOURCE; i++) { |
205 | unsigned long start = pci_resource_start(dev,i); | 202 | unsigned long start = pci_resource_start(dev,i); |
@@ -212,12 +209,7 @@ static void __pci_addr_cache_insert_device(struct pci_dev *dev) | |||
212 | if (start == 0 || ~start == 0 || end == 0 || ~end == 0) | 209 | if (start == 0 || ~start == 0 || end == 0 || ~end == 0) |
213 | continue; | 210 | continue; |
214 | pci_addr_cache_insert(dev, start, end, flags); | 211 | pci_addr_cache_insert(dev, start, end, flags); |
215 | inserted = 1; | ||
216 | } | 212 | } |
217 | |||
218 | /* If there was nothing to add, the cache has no reference... */ | ||
219 | if (!inserted) | ||
220 | pci_dev_put(dev); | ||
221 | } | 213 | } |
222 | 214 | ||
223 | /** | 215 | /** |
@@ -240,7 +232,6 @@ void pci_addr_cache_insert_device(struct pci_dev *dev) | |||
240 | static inline void __pci_addr_cache_remove_device(struct pci_dev *dev) | 232 | static inline void __pci_addr_cache_remove_device(struct pci_dev *dev) |
241 | { | 233 | { |
242 | struct rb_node *n; | 234 | struct rb_node *n; |
243 | int removed = 0; | ||
244 | 235 | ||
245 | restart: | 236 | restart: |
246 | n = rb_first(&pci_io_addr_cache_root.rb_root); | 237 | n = rb_first(&pci_io_addr_cache_root.rb_root); |
@@ -250,16 +241,12 @@ restart: | |||
250 | 241 | ||
251 | if (piar->pcidev == dev) { | 242 | if (piar->pcidev == dev) { |
252 | rb_erase(n, &pci_io_addr_cache_root.rb_root); | 243 | rb_erase(n, &pci_io_addr_cache_root.rb_root); |
253 | removed = 1; | 244 | pci_dev_put(piar->pcidev); |
254 | kfree(piar); | 245 | kfree(piar); |
255 | goto restart; | 246 | goto restart; |
256 | } | 247 | } |
257 | n = rb_next(n); | 248 | n = rb_next(n); |
258 | } | 249 | } |
259 | |||
260 | /* The cache no longer holds its reference to this device... */ | ||
261 | if (removed) | ||
262 | pci_dev_put(dev); | ||
263 | } | 250 | } |
264 | 251 | ||
265 | /** | 252 | /** |