aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/block
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/block')
-rw-r--r--drivers/block/cciss.c62
-rw-r--r--drivers/block/cciss.h2
2 files changed, 18 insertions, 46 deletions
diff --git a/drivers/block/cciss.c b/drivers/block/cciss.c
index 83bd091fc6ce..45c4c3131c8f 100644
--- a/drivers/block/cciss.c
+++ b/drivers/block/cciss.c
@@ -2638,16 +2638,6 @@ static void print_cfg_table( CfgTable_struct *tb)
2638} 2638}
2639#endif /* CCISS_DEBUG */ 2639#endif /* CCISS_DEBUG */
2640 2640
2641static void release_io_mem(ctlr_info_t *c)
2642{
2643 /* if IO mem was not protected do nothing */
2644 if( c->io_mem_addr == 0)
2645 return;
2646 release_region(c->io_mem_addr, c->io_mem_length);
2647 c->io_mem_addr = 0;
2648 c->io_mem_length = 0;
2649}
2650
2651static int find_PCI_BAR_index(struct pci_dev *pdev, 2641static int find_PCI_BAR_index(struct pci_dev *pdev,
2652 unsigned long pci_bar_addr) 2642 unsigned long pci_bar_addr)
2653{ 2643{
@@ -2762,36 +2752,18 @@ static int cciss_pci_init(ctlr_info_t *c, struct pci_dev *pdev)
2762 return err; 2752 return err;
2763 } 2753 }
2764 2754
2755 err = pci_request_regions(pdev, "cciss");
2756 if (err) {
2757 printk(KERN_ERR "cciss: Cannot obtain PCI resources, "
2758 "aborting\n");
2759 goto err_out_disable_pdev;
2760 }
2761
2765 subsystem_vendor_id = pdev->subsystem_vendor; 2762 subsystem_vendor_id = pdev->subsystem_vendor;
2766 subsystem_device_id = pdev->subsystem_device; 2763 subsystem_device_id = pdev->subsystem_device;
2767 board_id = (((__u32) (subsystem_device_id << 16) & 0xffff0000) | 2764 board_id = (((__u32) (subsystem_device_id << 16) & 0xffff0000) |
2768 subsystem_vendor_id); 2765 subsystem_vendor_id);
2769 2766
2770 /* search for our IO range so we can protect it */
2771 for(i=0; i<DEVICE_COUNT_RESOURCE; i++)
2772 {
2773 /* is this an IO range */
2774 if( pci_resource_flags(pdev, i) & 0x01 ) {
2775 c->io_mem_addr = pci_resource_start(pdev, i);
2776 c->io_mem_length = pci_resource_end(pdev, i) -
2777 pci_resource_start(pdev, i) +1;
2778#ifdef CCISS_DEBUG
2779 printk("IO value found base_addr[%d] %lx %lx\n", i,
2780 c->io_mem_addr, c->io_mem_length);
2781#endif /* CCISS_DEBUG */
2782 /* register the IO range */
2783 if(!request_region( c->io_mem_addr,
2784 c->io_mem_length, "cciss"))
2785 {
2786 printk(KERN_WARNING "cciss I/O memory range already in use addr=%lx length=%ld\n",
2787 c->io_mem_addr, c->io_mem_length);
2788 c->io_mem_addr= 0;
2789 c->io_mem_length = 0;
2790 }
2791 break;
2792 }
2793 }
2794
2795#ifdef CCISS_DEBUG 2767#ifdef CCISS_DEBUG
2796 printk("command = %x\n", command); 2768 printk("command = %x\n", command);
2797 printk("irq = %x\n", pdev->irq); 2769 printk("irq = %x\n", pdev->irq);
@@ -2826,7 +2798,7 @@ static int cciss_pci_init(ctlr_info_t *c, struct pci_dev *pdev)
2826 if (scratchpad != CCISS_FIRMWARE_READY) { 2798 if (scratchpad != CCISS_FIRMWARE_READY) {
2827 printk(KERN_WARNING "cciss: Board not ready. Timed out.\n"); 2799 printk(KERN_WARNING "cciss: Board not ready. Timed out.\n");
2828 err = -ENODEV; 2800 err = -ENODEV;
2829 goto err_out_disable_pdev; 2801 goto err_out_free_res;
2830 } 2802 }
2831 2803
2832 /* get the address index number */ 2804 /* get the address index number */
@@ -2842,9 +2814,8 @@ static int cciss_pci_init(ctlr_info_t *c, struct pci_dev *pdev)
2842#endif /* CCISS_DEBUG */ 2814#endif /* CCISS_DEBUG */
2843 if (cfg_base_addr_index == -1) { 2815 if (cfg_base_addr_index == -1) {
2844 printk(KERN_WARNING "cciss: Cannot find cfg_base_addr_index\n"); 2816 printk(KERN_WARNING "cciss: Cannot find cfg_base_addr_index\n");
2845 release_io_mem(c);
2846 err = -ENODEV; 2817 err = -ENODEV;
2847 goto err_out_disable_pdev; 2818 goto err_out_free_res;
2848 } 2819 }
2849 2820
2850 cfg_offset = readl(c->vaddr + SA5_CTMEM_OFFSET); 2821 cfg_offset = readl(c->vaddr + SA5_CTMEM_OFFSET);
@@ -2872,7 +2843,7 @@ static int cciss_pci_init(ctlr_info_t *c, struct pci_dev *pdev)
2872 " to access the Smart Array controller %08lx\n", 2843 " to access the Smart Array controller %08lx\n",
2873 (unsigned long)board_id); 2844 (unsigned long)board_id);
2874 err = -ENODEV; 2845 err = -ENODEV;
2875 goto err_out_disable_pdev; 2846 goto err_out_free_res;
2876 } 2847 }
2877 if ( (readb(&c->cfgtable->Signature[0]) != 'C') || 2848 if ( (readb(&c->cfgtable->Signature[0]) != 'C') ||
2878 (readb(&c->cfgtable->Signature[1]) != 'I') || 2849 (readb(&c->cfgtable->Signature[1]) != 'I') ||
@@ -2881,7 +2852,7 @@ static int cciss_pci_init(ctlr_info_t *c, struct pci_dev *pdev)
2881 { 2852 {
2882 printk("Does not appear to be a valid CISS config table\n"); 2853 printk("Does not appear to be a valid CISS config table\n");
2883 err = -ENODEV; 2854 err = -ENODEV;
2884 goto err_out_disable_pdev; 2855 goto err_out_free_res;
2885 } 2856 }
2886 2857
2887#ifdef CONFIG_X86 2858#ifdef CONFIG_X86
@@ -2926,10 +2897,13 @@ static int cciss_pci_init(ctlr_info_t *c, struct pci_dev *pdev)
2926 printk(KERN_WARNING "cciss: unable to get board into" 2897 printk(KERN_WARNING "cciss: unable to get board into"
2927 " simple mode\n"); 2898 " simple mode\n");
2928 err = -ENODEV; 2899 err = -ENODEV;
2929 goto err_out_disable_pdev; 2900 goto err_out_free_res;
2930 } 2901 }
2931 return 0; 2902 return 0;
2932 2903
2904err_out_free_res:
2905 pci_release_regions(pdev);
2906
2933err_out_disable_pdev: 2907err_out_disable_pdev:
2934 pci_disable_device(pdev); 2908 pci_disable_device(pdev);
2935 return err; 2909 return err;
@@ -3276,7 +3250,6 @@ clean4:
3276clean2: 3250clean2:
3277 unregister_blkdev(hba[i]->major, hba[i]->devname); 3251 unregister_blkdev(hba[i]->major, hba[i]->devname);
3278clean1: 3252clean1:
3279 release_io_mem(hba[i]);
3280 hba[i]->busy_initializing = 0; 3253 hba[i]->busy_initializing = 0;
3281 free_hba(i); 3254 free_hba(i);
3282 return(-1); 3255 return(-1);
@@ -3322,7 +3295,6 @@ static void __devexit cciss_remove_one (struct pci_dev *pdev)
3322 pci_disable_msi(hba[i]->pdev); 3295 pci_disable_msi(hba[i]->pdev);
3323#endif /* CONFIG_PCI_MSI */ 3296#endif /* CONFIG_PCI_MSI */
3324 3297
3325 pci_set_drvdata(pdev, NULL);
3326 iounmap(hba[i]->vaddr); 3298 iounmap(hba[i]->vaddr);
3327 cciss_unregister_scsi(i); /* unhook from SCSI subsystem */ 3299 cciss_unregister_scsi(i); /* unhook from SCSI subsystem */
3328 unregister_blkdev(hba[i]->major, hba[i]->devname); 3300 unregister_blkdev(hba[i]->major, hba[i]->devname);
@@ -3349,7 +3321,9 @@ static void __devexit cciss_remove_one (struct pci_dev *pdev)
3349#ifdef CONFIG_CISS_SCSI_TAPE 3321#ifdef CONFIG_CISS_SCSI_TAPE
3350 kfree(hba[i]->scsi_rejects.complete); 3322 kfree(hba[i]->scsi_rejects.complete);
3351#endif 3323#endif
3352 release_io_mem(hba[i]); 3324 pci_release_regions(pdev);
3325 pci_disable_device(pdev);
3326 pci_set_drvdata(pdev, NULL);
3353 free_hba(i); 3327 free_hba(i);
3354} 3328}
3355 3329
diff --git a/drivers/block/cciss.h b/drivers/block/cciss.h
index b24fc0553ccf..868e0d862b0d 100644
--- a/drivers/block/cciss.h
+++ b/drivers/block/cciss.h
@@ -60,8 +60,6 @@ struct ctlr_info
60 __u32 board_id; 60 __u32 board_id;
61 void __iomem *vaddr; 61 void __iomem *vaddr;
62 unsigned long paddr; 62 unsigned long paddr;
63 unsigned long io_mem_addr;
64 unsigned long io_mem_length;
65 CfgTable_struct __iomem *cfgtable; 63 CfgTable_struct __iomem *cfgtable;
66 int interrupts_enabled; 64 int interrupts_enabled;
67 int major; 65 int major;