aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBjorn Helgaas <bjorn.helgaas@hp.com>2006-06-25 08:49:01 -0400
committerLinus Torvalds <torvalds@g5.osdl.org>2006-06-25 13:01:21 -0400
commitc33ac89bc7d697e23ce09ddae73e0ece5f65ad48 (patch)
tree4584fa3aa65ee46d3eb48f7b6b81e4af2d165d0e
parente7b69055820a221d7da29092fd553fd7cd6a97d1 (diff)
[PATCH] CCISS: disable device when returning failure
If something fails after we call pci_enable_device(), we should call pci_disable_device() before returning the failure. Signed-off-by: Bjorn Helgaas <bjorn.helgaas@hp.com> Acked-by: Jeff Garzik <jeff@garzik.org> Acked-by: Mike Miller <mike.miller@hp.com> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
-rw-r--r--drivers/block/cciss.c27
1 files changed, 18 insertions, 9 deletions
diff --git a/drivers/block/cciss.c b/drivers/block/cciss.c
index e2df9eb6b90d..83bd091fc6ce 100644
--- a/drivers/block/cciss.c
+++ b/drivers/block/cciss.c
@@ -2744,7 +2744,7 @@ static int cciss_pci_init(ctlr_info_t *c, struct pci_dev *pdev)
2744 __u64 cfg_offset; 2744 __u64 cfg_offset;
2745 __u32 cfg_base_addr; 2745 __u32 cfg_base_addr;
2746 __u64 cfg_base_addr_index; 2746 __u64 cfg_base_addr_index;
2747 int i; 2747 int i, err;
2748 2748
2749 /* check to see if controller has been disabled */ 2749 /* check to see if controller has been disabled */
2750 /* BEFORE trying to enable it */ 2750 /* BEFORE trying to enable it */
@@ -2752,13 +2752,14 @@ static int cciss_pci_init(ctlr_info_t *c, struct pci_dev *pdev)
2752 if(!(command & 0x02)) 2752 if(!(command & 0x02))
2753 { 2753 {
2754 printk(KERN_WARNING "cciss: controller appears to be disabled\n"); 2754 printk(KERN_WARNING "cciss: controller appears to be disabled\n");
2755 return(-1); 2755 return -ENODEV;
2756 } 2756 }
2757 2757
2758 if (pci_enable_device(pdev)) 2758 err = pci_enable_device(pdev);
2759 if (err)
2759 { 2760 {
2760 printk(KERN_ERR "cciss: Unable to Enable PCI device\n"); 2761 printk(KERN_ERR "cciss: Unable to Enable PCI device\n");
2761 return( -1); 2762 return err;
2762 } 2763 }
2763 2764
2764 subsystem_vendor_id = pdev->subsystem_vendor; 2765 subsystem_vendor_id = pdev->subsystem_vendor;
@@ -2824,7 +2825,8 @@ static int cciss_pci_init(ctlr_info_t *c, struct pci_dev *pdev)
2824 } 2825 }
2825 if (scratchpad != CCISS_FIRMWARE_READY) { 2826 if (scratchpad != CCISS_FIRMWARE_READY) {
2826 printk(KERN_WARNING "cciss: Board not ready. Timed out.\n"); 2827 printk(KERN_WARNING "cciss: Board not ready. Timed out.\n");
2827 return -1; 2828 err = -ENODEV;
2829 goto err_out_disable_pdev;
2828 } 2830 }
2829 2831
2830 /* get the address index number */ 2832 /* get the address index number */
@@ -2841,7 +2843,8 @@ static int cciss_pci_init(ctlr_info_t *c, struct pci_dev *pdev)
2841 if (cfg_base_addr_index == -1) { 2843 if (cfg_base_addr_index == -1) {
2842 printk(KERN_WARNING "cciss: Cannot find cfg_base_addr_index\n"); 2844 printk(KERN_WARNING "cciss: Cannot find cfg_base_addr_index\n");
2843 release_io_mem(c); 2845 release_io_mem(c);
2844 return -1; 2846 err = -ENODEV;
2847 goto err_out_disable_pdev;
2845 } 2848 }
2846 2849
2847 cfg_offset = readl(c->vaddr + SA5_CTMEM_OFFSET); 2850 cfg_offset = readl(c->vaddr + SA5_CTMEM_OFFSET);
@@ -2868,7 +2871,8 @@ static int cciss_pci_init(ctlr_info_t *c, struct pci_dev *pdev)
2868 printk(KERN_WARNING "cciss: Sorry, I don't know how" 2871 printk(KERN_WARNING "cciss: Sorry, I don't know how"
2869 " to access the Smart Array controller %08lx\n", 2872 " to access the Smart Array controller %08lx\n",
2870 (unsigned long)board_id); 2873 (unsigned long)board_id);
2871 return -1; 2874 err = -ENODEV;
2875 goto err_out_disable_pdev;
2872 } 2876 }
2873 if ( (readb(&c->cfgtable->Signature[0]) != 'C') || 2877 if ( (readb(&c->cfgtable->Signature[0]) != 'C') ||
2874 (readb(&c->cfgtable->Signature[1]) != 'I') || 2878 (readb(&c->cfgtable->Signature[1]) != 'I') ||
@@ -2876,7 +2880,8 @@ static int cciss_pci_init(ctlr_info_t *c, struct pci_dev *pdev)
2876 (readb(&c->cfgtable->Signature[3]) != 'S') ) 2880 (readb(&c->cfgtable->Signature[3]) != 'S') )
2877 { 2881 {
2878 printk("Does not appear to be a valid CISS config table\n"); 2882 printk("Does not appear to be a valid CISS config table\n");
2879 return -1; 2883 err = -ENODEV;
2884 goto err_out_disable_pdev;
2880 } 2885 }
2881 2886
2882#ifdef CONFIG_X86 2887#ifdef CONFIG_X86
@@ -2920,10 +2925,14 @@ static int cciss_pci_init(ctlr_info_t *c, struct pci_dev *pdev)
2920 { 2925 {
2921 printk(KERN_WARNING "cciss: unable to get board into" 2926 printk(KERN_WARNING "cciss: unable to get board into"
2922 " simple mode\n"); 2927 " simple mode\n");
2923 return -1; 2928 err = -ENODEV;
2929 goto err_out_disable_pdev;
2924 } 2930 }
2925 return 0; 2931 return 0;
2926 2932
2933err_out_disable_pdev:
2934 pci_disable_device(pdev);
2935 return err;
2927} 2936}
2928 2937
2929/* 2938/*