aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorDave Peterson <dsp@llnl.gov>2006-03-26 04:38:44 -0500
committerLinus Torvalds <torvalds@g5.osdl.org>2006-03-26 11:57:07 -0500
commit637beb697b8dc7b9d7a35c2b6488332e77963ded (patch)
treefa6fd86af71c724936049a147646dbfbda53722a /drivers
parente8a491b401dbbc5af9fe6483dc558d76343bfbb3 (diff)
[PATCH] EDAC: i82875p cleanup
- Fix i82875p_probe1() so it calls pci_get_device() instead of pci_find_device(). - Fix i82875p_probe1() so it cleans up properly on failure. - Fix i82875p_init() so it cleans up properly on failure. Signed-off-by: David S. Peterson <dsp@llnl.gov> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/edac/i82875p_edac.c54
1 files changed, 32 insertions, 22 deletions
diff --git a/drivers/edac/i82875p_edac.c b/drivers/edac/i82875p_edac.c
index a547c30473e4..c521178183de 100644
--- a/drivers/edac/i82875p_edac.c
+++ b/drivers/edac/i82875p_edac.c
@@ -289,7 +289,7 @@ static int i82875p_probe1(struct pci_dev *pdev, int dev_idx)
289 289
290 debugf0("%s()\n", __func__); 290 debugf0("%s()\n", __func__);
291 291
292 ovrfl_pdev = pci_find_device(PCI_VEND_DEV(INTEL, 82875_6), NULL); 292 ovrfl_pdev = pci_get_device(PCI_VEND_DEV(INTEL, 82875_6), NULL);
293 293
294 if (!ovrfl_pdev) { 294 if (!ovrfl_pdev) {
295 /* 295 /*
@@ -302,26 +302,26 @@ static int i82875p_probe1(struct pci_dev *pdev, int dev_idx)
302 ovrfl_pdev = 302 ovrfl_pdev =
303 pci_scan_single_device(pdev->bus, PCI_DEVFN(6, 0)); 303 pci_scan_single_device(pdev->bus, PCI_DEVFN(6, 0));
304 if (!ovrfl_pdev) 304 if (!ovrfl_pdev)
305 goto fail; 305 return -ENODEV;
306 } 306 }
307#ifdef CONFIG_PROC_FS 307#ifdef CONFIG_PROC_FS
308 if (!ovrfl_pdev->procent && pci_proc_attach_device(ovrfl_pdev)) { 308 if (!ovrfl_pdev->procent && pci_proc_attach_device(ovrfl_pdev)) {
309 i82875p_printk(KERN_ERR, 309 i82875p_printk(KERN_ERR,
310 "%s(): Failed to attach overflow device\n", 310 "%s(): Failed to attach overflow device\n",
311 __func__); 311 __func__);
312 goto fail; 312 return -ENODEV;
313 } 313 }
314#endif /* CONFIG_PROC_FS */ 314#endif /* CONFIG_PROC_FS */
315 if (pci_enable_device(ovrfl_pdev)) { 315 if (pci_enable_device(ovrfl_pdev)) {
316 i82875p_printk(KERN_ERR, 316 i82875p_printk(KERN_ERR,
317 "%s(): Failed to enable overflow device\n", 317 "%s(): Failed to enable overflow device\n",
318 __func__); 318 __func__);
319 goto fail; 319 return -ENODEV;
320 } 320 }
321 321
322 if (pci_request_regions(ovrfl_pdev, pci_name(ovrfl_pdev))) { 322 if (pci_request_regions(ovrfl_pdev, pci_name(ovrfl_pdev))) {
323#ifdef CORRECT_BIOS 323#ifdef CORRECT_BIOS
324 goto fail; 324 goto fail0;
325#endif 325#endif
326 } 326 }
327 /* cache is irrelevant for PCI bus reads/writes */ 327 /* cache is irrelevant for PCI bus reads/writes */
@@ -331,7 +331,7 @@ static int i82875p_probe1(struct pci_dev *pdev, int dev_idx)
331 if (!ovrfl_window) { 331 if (!ovrfl_window) {
332 i82875p_printk(KERN_ERR, "%s(): Failed to ioremap bar6\n", 332 i82875p_printk(KERN_ERR, "%s(): Failed to ioremap bar6\n",
333 __func__); 333 __func__);
334 goto fail; 334 goto fail1;
335 } 335 }
336 336
337 /* need to find out the number of channels */ 337 /* need to find out the number of channels */
@@ -345,7 +345,7 @@ static int i82875p_probe1(struct pci_dev *pdev, int dev_idx)
345 345
346 if (!mci) { 346 if (!mci) {
347 rc = -ENOMEM; 347 rc = -ENOMEM;
348 goto fail; 348 goto fail2;
349 } 349 }
350 350
351 debugf3("%s(): init mci\n", __func__); 351 debugf3("%s(): init mci\n", __func__);
@@ -402,25 +402,26 @@ static int i82875p_probe1(struct pci_dev *pdev, int dev_idx)
402 402
403 if (edac_mc_add_mc(mci)) { 403 if (edac_mc_add_mc(mci)) {
404 debugf3("%s(): failed edac_mc_add_mc()\n", __func__); 404 debugf3("%s(): failed edac_mc_add_mc()\n", __func__);
405 goto fail; 405 goto fail3;
406 } 406 }
407 407
408 /* get this far and it's successful */ 408 /* get this far and it's successful */
409 debugf3("%s(): success\n", __func__); 409 debugf3("%s(): success\n", __func__);
410 return 0; 410 return 0;
411 411
412 fail: 412fail3:
413 if (mci) 413 edac_mc_free(mci);
414 edac_mc_free(mci);
415 414
416 if (ovrfl_window) 415fail2:
417 iounmap(ovrfl_window); 416 iounmap(ovrfl_window);
418 417
419 if (ovrfl_pdev) { 418fail1:
420 pci_release_regions(ovrfl_pdev); 419 pci_release_regions(ovrfl_pdev);
421 pci_disable_device(ovrfl_pdev);
422 }
423 420
421#ifdef CORRECT_BIOS
422fail0:
423#endif
424 pci_disable_device(ovrfl_pdev);
424 /* NOTE: the ovrfl proc entry and pci_dev are intentionally left */ 425 /* NOTE: the ovrfl proc entry and pci_dev are intentionally left */
425 return rc; 426 return rc;
426} 427}
@@ -497,24 +498,33 @@ static int __init i82875p_init(void)
497 debugf3("%s()\n", __func__); 498 debugf3("%s()\n", __func__);
498 pci_rc = pci_register_driver(&i82875p_driver); 499 pci_rc = pci_register_driver(&i82875p_driver);
499 if (pci_rc < 0) 500 if (pci_rc < 0)
500 return pci_rc; 501 goto fail0;
501 if (mci_pdev == NULL) { 502 if (mci_pdev == NULL) {
502 i82875p_registered = 0;
503 mci_pdev = 503 mci_pdev =
504 pci_get_device(PCI_VENDOR_ID_INTEL, 504 pci_get_device(PCI_VENDOR_ID_INTEL,
505 PCI_DEVICE_ID_INTEL_82875_0, NULL); 505 PCI_DEVICE_ID_INTEL_82875_0, NULL);
506 if (!mci_pdev) { 506 if (!mci_pdev) {
507 debugf0("875p pci_get_device fail\n"); 507 debugf0("875p pci_get_device fail\n");
508 return -ENODEV; 508 pci_rc = -ENODEV;
509 goto fail1;
509 } 510 }
510 pci_rc = i82875p_init_one(mci_pdev, i82875p_pci_tbl); 511 pci_rc = i82875p_init_one(mci_pdev, i82875p_pci_tbl);
511 if (pci_rc < 0) { 512 if (pci_rc < 0) {
512 debugf0("875p init fail\n"); 513 debugf0("875p init fail\n");
513 pci_dev_put(mci_pdev); 514 pci_rc = -ENODEV;
514 return -ENODEV; 515 goto fail1;
515 } 516 }
516 } 517 }
517 return 0; 518 return 0;
519
520fail1:
521 pci_unregister_driver(&i82875p_driver);
522
523fail0:
524 if (mci_pdev != NULL)
525 pci_dev_put(mci_pdev);
526
527 return pci_rc;
518} 528}
519 529
520 530