Commit 705f83df authored by David Jeffery's avatar David Jeffery Committed by James Simmons

[PATCH] ips driver 2/6

This patch is some simple code consolidation.
A new function ips_abort_init() is created
and consolidates some repeated code that is
used if there is an error during initialization
of the adapter.
parent ab804805
...@@ -530,6 +530,7 @@ static void copy_mem_info(IPS_INFOSTR *, char *, int); ...@@ -530,6 +530,7 @@ static void copy_mem_info(IPS_INFOSTR *, char *, int);
static int copy_info(IPS_INFOSTR *, char *, ...); static int copy_info(IPS_INFOSTR *, char *, ...);
static int ips_get_version_info(ips_ha_t *ha, IPS_VERSION_DATA *Buffer, int intr ); static int ips_get_version_info(ips_ha_t *ha, IPS_VERSION_DATA *Buffer, int intr );
static void ips_version_check(ips_ha_t *ha, int intr); static void ips_version_check(ips_ha_t *ha, int intr);
static int ips_abort_init(ips_ha_t *ha, struct Scsi_Host *sh, int index);
static int ips_init_phase2( int index ); static int ips_init_phase2( int index );
#if LINUX_VERSION_CODE >= LinuxVersionCode(2,4,0) #if LINUX_VERSION_CODE >= LinuxVersionCode(2,4,0)
...@@ -7392,6 +7393,14 @@ static Scsi_Host_Template driver_template = IPS; ...@@ -7392,6 +7393,14 @@ static Scsi_Host_Template driver_template = IPS;
#include "scsi_module.c" #include "scsi_module.c"
#endif #endif
static int ips_abort_init(ips_ha_t *ha, struct Scsi_Host *sh, int index){
ha->active = 0;
ips_free(ha);
scsi_unregister(sh);
ips_ha[index] = 0;
ips_sh[index] = 0;
return -1;
}
#if LINUX_VERSION_CODE >= LinuxVersionCode(2,4,0) #if LINUX_VERSION_CODE >= LinuxVersionCode(2,4,0)
...@@ -7582,24 +7591,14 @@ static int ips_init_phase1( struct pci_dev *pci_dev, int *indexPtr ) ...@@ -7582,24 +7591,14 @@ static int ips_init_phase1( struct pci_dev *pci_dev, int *indexPtr )
if (!ha->enq) { if (!ha->enq) {
printk(KERN_WARNING "Unable to allocate host inquiry structure\n" ); printk(KERN_WARNING "Unable to allocate host inquiry structure\n" );
ha->active = 0; return ips_abort_init(ha, sh, index);
ips_free(ha);
scsi_unregister(sh);
ips_ha[index] = 0;
ips_sh[index] = 0;
return -1;
} }
ha->adapt = pci_alloc_consistent(ha->pcidev, sizeof(IPS_ADAPTER) + ha->adapt = pci_alloc_consistent(ha->pcidev, sizeof(IPS_ADAPTER) +
sizeof(IPS_IO_CMD), &dma_address); sizeof(IPS_IO_CMD), &dma_address);
if (!ha->adapt) { if (!ha->adapt) {
printk(KERN_WARNING "Unable to allocate host adapt & dummy structures\n"); printk(KERN_WARNING "Unable to allocate host adapt & dummy structures\n");
ha->active = 0; return ips_abort_init(ha, sh, index);
ips_free(ha);
scsi_unregister(sh);
ips_ha[index] = 0;
ips_sh[index] = 0;
return -1;
} }
ha->adapt->hw_status_start = dma_address; ha->adapt->hw_status_start = dma_address;
ha->dummy = (void *)(ha->adapt + 1); ha->dummy = (void *)(ha->adapt + 1);
...@@ -7608,36 +7607,21 @@ static int ips_init_phase1( struct pci_dev *pci_dev, int *indexPtr ) ...@@ -7608,36 +7607,21 @@ static int ips_init_phase1( struct pci_dev *pci_dev, int *indexPtr )
if (!ha->conf) { if (!ha->conf) {
printk(KERN_WARNING "Unable to allocate host conf structure\n" ); printk(KERN_WARNING "Unable to allocate host conf structure\n" );
ha->active = 0; return ips_abort_init(ha, sh, index);
ips_free(ha);
scsi_unregister(sh);
ips_ha[index] = 0;
ips_sh[index] = 0;
return -1;
} }
ha->nvram = kmalloc(sizeof(IPS_NVRAM_P5), GFP_KERNEL); ha->nvram = kmalloc(sizeof(IPS_NVRAM_P5), GFP_KERNEL);
if (!ha->nvram) { if (!ha->nvram) {
printk(KERN_WARNING "Unable to allocate host NVRAM structure\n" ); printk(KERN_WARNING "Unable to allocate host NVRAM structure\n" );
ha->active = 0; return ips_abort_init(ha, sh, index);
ips_free(ha);
scsi_unregister(sh);
ips_ha[index] = 0;
ips_sh[index] = 0;
return -1;
} }
ha->subsys = kmalloc(sizeof(IPS_SUBSYS), GFP_KERNEL); ha->subsys = kmalloc(sizeof(IPS_SUBSYS), GFP_KERNEL);
if (!ha->subsys) { if (!ha->subsys) {
printk(KERN_WARNING "Unable to allocate host subsystem structure\n" ); printk(KERN_WARNING "Unable to allocate host subsystem structure\n" );
ha->active = 0; return ips_abort_init(ha, sh, index);
ips_free(ha);
scsi_unregister(sh);
ips_ha[index] = 0;
ips_sh[index] = 0;
return -1;
} }
for (count = PAGE_SIZE, ha->ioctl_order = 0; for (count = PAGE_SIZE, ha->ioctl_order = 0;
...@@ -7746,24 +7730,14 @@ static int ips_init_phase1( struct pci_dev *pci_dev, int *indexPtr ) ...@@ -7746,24 +7730,14 @@ static int ips_init_phase1( struct pci_dev *pci_dev, int *indexPtr )
* Initialization failed * Initialization failed
*/ */
printk(KERN_WARNING "Unable to initialize controller\n" ); printk(KERN_WARNING "Unable to initialize controller\n" );
ha->active = 0; return ips_abort_init(ha, sh, index);
ips_free(ha);
scsi_unregister(sh);
ips_ha[index] = 0;
ips_sh[index] = 0;
return -1;
} }
} }
/* Install the interrupt handler */ /* Install the interrupt handler */
if (request_irq(irq, do_ipsintr, SA_SHIRQ, ips_name, ha)) { if (request_irq(irq, do_ipsintr, SA_SHIRQ, ips_name, ha)) {
printk(KERN_WARNING "Unable to install interrupt handler\n" ); printk(KERN_WARNING "Unable to install interrupt handler\n" );
ha->active = 0; return ips_abort_init(ha, sh, index);
ips_free(ha);
scsi_unregister(sh);
ips_ha[index] = 0;
ips_sh[index] = 0;
return -1;
} }
/* /*
...@@ -7772,13 +7746,8 @@ static int ips_init_phase1( struct pci_dev *pci_dev, int *indexPtr ) ...@@ -7772,13 +7746,8 @@ static int ips_init_phase1( struct pci_dev *pci_dev, int *indexPtr )
ha->max_cmds = 1; ha->max_cmds = 1;
if (!ips_allocatescbs(ha)) { if (!ips_allocatescbs(ha)) {
printk(KERN_WARNING "Unable to allocate a CCB\n" ); printk(KERN_WARNING "Unable to allocate a CCB\n" );
ha->active = 0;
free_irq(ha->irq, ha); free_irq(ha->irq, ha);
ips_free(ha); return ips_abort_init(ha, sh, index);
scsi_unregister(sh);
ips_ha[index] = 0;
ips_sh[index] = 0;
return -1;
} }
*indexPtr = index; *indexPtr = index;
...@@ -7814,13 +7783,8 @@ static int ips_init_phase2( int index ) ...@@ -7814,13 +7783,8 @@ static int ips_init_phase2( int index )
if (!ips_hainit(ha)) { if (!ips_hainit(ha)) {
printk(KERN_WARNING "Unable to initialize controller\n" ); printk(KERN_WARNING "Unable to initialize controller\n" );
ha->active = 0;
ips_free(ha);
free_irq(ha->irq, ha); free_irq(ha->irq, ha);
scsi_unregister(sh); return ips_abort_init(ha, sh, index);
ips_ha[index] = NULL;
ips_sh[index] = NULL;
return -1;
} }
/* Free the temporary SCB */ /* Free the temporary SCB */
ips_deallocatescbs(ha, 1); ips_deallocatescbs(ha, 1);
...@@ -7828,13 +7792,8 @@ static int ips_init_phase2( int index ) ...@@ -7828,13 +7792,8 @@ static int ips_init_phase2( int index )
/* allocate CCBs */ /* allocate CCBs */
if (!ips_allocatescbs(ha)) { if (!ips_allocatescbs(ha)) {
printk(KERN_WARNING "Unable to allocate CCBs\n" ); printk(KERN_WARNING "Unable to allocate CCBs\n" );
ha->active = 0;
ips_free(ha);
free_irq(ha->irq, ha); free_irq(ha->irq, ha);
scsi_unregister(sh); return ips_abort_init(ha, sh, index);
ips_ha[index] = NULL;
ips_sh[index] = NULL;
return -1;
} }
/* finish setting values */ /* finish setting values */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment