* [PATCH 1/4] gdth: kill gdth_{read,write}[bwl] wrappers
2007-07-21 20:34 [PATCH 0/4] more gdth patches for your amusement Jeff Garzik
@ 2007-07-21 20:34 ` Jeff Garzik
2007-07-21 20:35 ` [PATCH 2/4] gdth: Move probe-time error handling code to end of each function Jeff Garzik
` (4 subsequent siblings)
5 siblings, 0 replies; 13+ messages in thread
From: Jeff Garzik @ 2007-07-21 20:34 UTC (permalink / raw)
To: linux-scsi; +Cc: Christoph Hellwig, achim_leubner, Andrew Morton
commit 411b270459eef219c41674e454b111dab610113f
Author: Jeff Garzik <jeff@garzik.org>
Date: Fri Jul 20 23:24:13 2007 -0400
[SCSI] gdth: kill gdth_{read,write}[bwl] wrappers
They are direct equivalents to {read,write}[bwl].
Signed-off-by: Jeff Garzik <jeff@garzik.org>
drivers/scsi/gdth.c | 313 +++++++++++++++++++++++++---------------------------
1 file changed, 153 insertions(+), 160 deletions(-)
411b270459eef219c41674e454b111dab610113f
diff --git a/drivers/scsi/gdth.c b/drivers/scsi/gdth.c
index a6636b8..4cdba0c 100644
--- a/drivers/scsi/gdth.c
+++ b/drivers/scsi/gdth.c
@@ -294,13 +294,6 @@ static struct timer_list gdth_timer;
#define BUS_L2P(a,b) ((b)>(a)->virt_bus ? (b-1):(b))
-#define gdth_readb(addr) readb(addr)
-#define gdth_readw(addr) readw(addr)
-#define gdth_readl(addr) readl(addr)
-#define gdth_writeb(b,addr) writeb((b),(addr))
-#define gdth_writew(b,addr) writew((b),(addr))
-#define gdth_writel(b,addr) writel((b),(addr))
-
static unchar gdth_drq_tab[4] = {5,6,7,7}; /* DRQ table */
static unchar gdth_irq_tab[6] = {0,10,11,12,14,0}; /* IRQ table */
static unchar gdth_polling; /* polling if TRUE */
@@ -544,7 +537,7 @@ static int __init gdth_search_isa(ulong32 bios_adr)
TRACE(("gdth_search_isa() bios adr. %x\n",bios_adr));
if ((addr = ioremap(bios_adr+BIOS_ID_OFFS, sizeof(ulong32))) != NULL) {
- id = gdth_readl(addr);
+ id = readl(addr);
iounmap(addr);
if (id == GDT2_ID) /* GDT2000 */
return 1;
@@ -778,22 +771,22 @@ static int __init gdth_init_isa(ulong32 bios_adr,gdth_ha_str *ha)
return 0;
}
dp2_ptr = ha->brd;
- gdth_writeb(1, &dp2_ptr->io.memlock); /* switch off write protection */
+ writeb(1, &dp2_ptr->io.memlock); /* switch off write protection */
/* reset interface area */
memset_io(&dp2_ptr->u, 0, sizeof(dp2_ptr->u));
- if (gdth_readl(&dp2_ptr->u) != 0) {
+ if (readl(&dp2_ptr->u) != 0) {
printk("GDT-ISA: Initialization error (DPMEM write error)\n");
iounmap(ha->brd);
return 0;
}
/* disable board interrupts, read DRQ and IRQ */
- gdth_writeb(0xff, &dp2_ptr->io.irqdel);
- gdth_writeb(0x00, &dp2_ptr->io.irqen);
- gdth_writeb(0x00, &dp2_ptr->u.ic.S_Status);
- gdth_writeb(0x00, &dp2_ptr->u.ic.Cmd_Index);
+ writeb(0xff, &dp2_ptr->io.irqdel);
+ writeb(0x00, &dp2_ptr->io.irqen);
+ writeb(0x00, &dp2_ptr->u.ic.S_Status);
+ writeb(0x00, &dp2_ptr->u.ic.Cmd_Index);
- irq_drq = gdth_readb(&dp2_ptr->io.rq);
+ irq_drq = readb(&dp2_ptr->io.rq);
for (i=0; i<3; ++i) {
if ((irq_drq & 1)==0)
break;
@@ -801,7 +794,7 @@ static int __init gdth_init_isa(ulong32 bios_adr,gdth_ha_str *ha)
}
ha->drq = gdth_drq_tab[i];
- irq_drq = gdth_readb(&dp2_ptr->io.rq) >> 3;
+ irq_drq = readb(&dp2_ptr->io.rq) >> 3;
for (i=1; i<5; ++i) {
if ((irq_drq & 1)==0)
break;
@@ -810,12 +803,12 @@ static int __init gdth_init_isa(ulong32 bios_adr,gdth_ha_str *ha)
ha->irq = gdth_irq_tab[i];
/* deinitialize services */
- gdth_writel(bios_adr, &dp2_ptr->u.ic.S_Info[0]);
- gdth_writeb(0xff, &dp2_ptr->u.ic.S_Cmd_Indx);
- gdth_writeb(0, &dp2_ptr->io.event);
+ writel(bios_adr, &dp2_ptr->u.ic.S_Info[0]);
+ writeb(0xff, &dp2_ptr->u.ic.S_Cmd_Indx);
+ writeb(0, &dp2_ptr->io.event);
retries = INIT_RETRIES;
gdth_delay(20);
- while (gdth_readb(&dp2_ptr->u.ic.S_Status) != 0xff) {
+ while (readb(&dp2_ptr->u.ic.S_Status) != 0xff) {
if (--retries == 0) {
printk("GDT-ISA: Initialization error (DEINIT failed)\n");
iounmap(ha->brd);
@@ -823,9 +816,9 @@ static int __init gdth_init_isa(ulong32 bios_adr,gdth_ha_str *ha)
}
gdth_delay(1);
}
- prot_ver = (unchar)gdth_readl(&dp2_ptr->u.ic.S_Info[0]);
- gdth_writeb(0, &dp2_ptr->u.ic.Status);
- gdth_writeb(0xff, &dp2_ptr->io.irqdel);
+ prot_ver = (unchar)readl(&dp2_ptr->u.ic.S_Info[0]);
+ writeb(0, &dp2_ptr->u.ic.Status);
+ writeb(0xff, &dp2_ptr->io.irqdel);
if (prot_ver != PROTOCOL_VERSION) {
printk("GDT-ISA: Illegal protocol version\n");
iounmap(ha->brd);
@@ -839,15 +832,15 @@ static int __init gdth_init_isa(ulong32 bios_adr,gdth_ha_str *ha)
ha->brd_phys = bios_adr >> 4;
/* special request to controller BIOS */
- gdth_writel(0x00, &dp2_ptr->u.ic.S_Info[0]);
- gdth_writel(0x00, &dp2_ptr->u.ic.S_Info[1]);
- gdth_writel(0x01, &dp2_ptr->u.ic.S_Info[2]);
- gdth_writel(0x00, &dp2_ptr->u.ic.S_Info[3]);
- gdth_writeb(0xfe, &dp2_ptr->u.ic.S_Cmd_Indx);
- gdth_writeb(0, &dp2_ptr->io.event);
+ writel(0x00, &dp2_ptr->u.ic.S_Info[0]);
+ writel(0x00, &dp2_ptr->u.ic.S_Info[1]);
+ writel(0x01, &dp2_ptr->u.ic.S_Info[2]);
+ writel(0x00, &dp2_ptr->u.ic.S_Info[3]);
+ writeb(0xfe, &dp2_ptr->u.ic.S_Cmd_Indx);
+ writeb(0, &dp2_ptr->io.event);
retries = INIT_RETRIES;
gdth_delay(20);
- while (gdth_readb(&dp2_ptr->u.ic.S_Status) != 0xfe) {
+ while (readb(&dp2_ptr->u.ic.S_Status) != 0xfe) {
if (--retries == 0) {
printk("GDT-ISA: Initialization error\n");
iounmap(ha->brd);
@@ -855,8 +848,8 @@ static int __init gdth_init_isa(ulong32 bios_adr,gdth_ha_str *ha)
}
gdth_delay(1);
}
- gdth_writeb(0, &dp2_ptr->u.ic.Status);
- gdth_writeb(0xff, &dp2_ptr->io.irqdel);
+ writeb(0, &dp2_ptr->u.ic.Status);
+ writeb(0xff, &dp2_ptr->io.irqdel);
ha->dma64_support = 0;
return 1;
@@ -893,8 +886,8 @@ static int __init gdth_init_pci(gdth_pci_str *pcistr,gdth_ha_str *ha)
}
/* check and reset interface area */
dp6_ptr = ha->brd;
- gdth_writel(DPMEM_MAGIC, &dp6_ptr->u);
- if (gdth_readl(&dp6_ptr->u) != DPMEM_MAGIC) {
+ writel(DPMEM_MAGIC, &dp6_ptr->u);
+ if (readl(&dp6_ptr->u) != DPMEM_MAGIC) {
printk("GDT-PCI: Cannot access DPMEM at 0x%lx (shadowed?)\n",
pcistr->dpmem);
found = FALSE;
@@ -905,7 +898,7 @@ static int __init gdth_init_pci(gdth_pci_str *pcistr,gdth_ha_str *ha)
printk("GDT-PCI: Initialization error (DPMEM remap error)\n");
return 0;
}
- if (gdth_readw(ha->brd) != 0xffff) {
+ if (readw(ha->brd) != 0xffff) {
TRACE2(("init_pci_old() address 0x%x busy\n", i));
continue;
}
@@ -918,8 +911,8 @@ static int __init gdth_init_pci(gdth_pci_str *pcistr,gdth_ha_str *ha)
return 0;
}
dp6_ptr = ha->brd;
- gdth_writel(DPMEM_MAGIC, &dp6_ptr->u);
- if (gdth_readl(&dp6_ptr->u) == DPMEM_MAGIC) {
+ writel(DPMEM_MAGIC, &dp6_ptr->u);
+ if (readl(&dp6_ptr->u) == DPMEM_MAGIC) {
printk("GDT-PCI: Use free address at 0x%x\n", i);
found = TRUE;
break;
@@ -932,24 +925,24 @@ static int __init gdth_init_pci(gdth_pci_str *pcistr,gdth_ha_str *ha)
}
}
memset_io(&dp6_ptr->u, 0, sizeof(dp6_ptr->u));
- if (gdth_readl(&dp6_ptr->u) != 0) {
+ if (readl(&dp6_ptr->u) != 0) {
printk("GDT-PCI: Initialization error (DPMEM write error)\n");
iounmap(ha->brd);
return 0;
}
/* disable board interrupts, deinit services */
- gdth_writeb(0xff, &dp6_ptr->io.irqdel);
- gdth_writeb(0x00, &dp6_ptr->io.irqen);
- gdth_writeb(0x00, &dp6_ptr->u.ic.S_Status);
- gdth_writeb(0x00, &dp6_ptr->u.ic.Cmd_Index);
-
- gdth_writel(pcistr->dpmem, &dp6_ptr->u.ic.S_Info[0]);
- gdth_writeb(0xff, &dp6_ptr->u.ic.S_Cmd_Indx);
- gdth_writeb(0, &dp6_ptr->io.event);
+ writeb(0xff, &dp6_ptr->io.irqdel);
+ writeb(0x00, &dp6_ptr->io.irqen);
+ writeb(0x00, &dp6_ptr->u.ic.S_Status);
+ writeb(0x00, &dp6_ptr->u.ic.Cmd_Index);
+
+ writel(pcistr->dpmem, &dp6_ptr->u.ic.S_Info[0]);
+ writeb(0xff, &dp6_ptr->u.ic.S_Cmd_Indx);
+ writeb(0, &dp6_ptr->io.event);
retries = INIT_RETRIES;
gdth_delay(20);
- while (gdth_readb(&dp6_ptr->u.ic.S_Status) != 0xff) {
+ while (readb(&dp6_ptr->u.ic.S_Status) != 0xff) {
if (--retries == 0) {
printk("GDT-PCI: Initialization error (DEINIT failed)\n");
iounmap(ha->brd);
@@ -957,9 +950,9 @@ static int __init gdth_init_pci(gdth_pci_str *pcistr,gdth_ha_str *ha)
}
gdth_delay(1);
}
- prot_ver = (unchar)gdth_readl(&dp6_ptr->u.ic.S_Info[0]);
- gdth_writeb(0, &dp6_ptr->u.ic.S_Status);
- gdth_writeb(0xff, &dp6_ptr->io.irqdel);
+ prot_ver = (unchar)readl(&dp6_ptr->u.ic.S_Info[0]);
+ writeb(0, &dp6_ptr->u.ic.S_Status);
+ writeb(0xff, &dp6_ptr->io.irqdel);
if (prot_ver != PROTOCOL_VERSION) {
printk("GDT-PCI: Illegal protocol version\n");
iounmap(ha->brd);
@@ -970,15 +963,15 @@ static int __init gdth_init_pci(gdth_pci_str *pcistr,gdth_ha_str *ha)
ha->ic_all_size = sizeof(dp6_ptr->u);
/* special command to controller BIOS */
- gdth_writel(0x00, &dp6_ptr->u.ic.S_Info[0]);
- gdth_writel(0x00, &dp6_ptr->u.ic.S_Info[1]);
- gdth_writel(0x00, &dp6_ptr->u.ic.S_Info[2]);
- gdth_writel(0x00, &dp6_ptr->u.ic.S_Info[3]);
- gdth_writeb(0xfe, &dp6_ptr->u.ic.S_Cmd_Indx);
- gdth_writeb(0, &dp6_ptr->io.event);
+ writel(0x00, &dp6_ptr->u.ic.S_Info[0]);
+ writel(0x00, &dp6_ptr->u.ic.S_Info[1]);
+ writel(0x00, &dp6_ptr->u.ic.S_Info[2]);
+ writel(0x00, &dp6_ptr->u.ic.S_Info[3]);
+ writeb(0xfe, &dp6_ptr->u.ic.S_Cmd_Indx);
+ writeb(0, &dp6_ptr->io.event);
retries = INIT_RETRIES;
gdth_delay(20);
- while (gdth_readb(&dp6_ptr->u.ic.S_Status) != 0xfe) {
+ while (readb(&dp6_ptr->u.ic.S_Status) != 0xfe) {
if (--retries == 0) {
printk("GDT-PCI: Initialization error\n");
iounmap(ha->brd);
@@ -986,8 +979,8 @@ static int __init gdth_init_pci(gdth_pci_str *pcistr,gdth_ha_str *ha)
}
gdth_delay(1);
}
- gdth_writeb(0, &dp6_ptr->u.ic.S_Status);
- gdth_writeb(0xff, &dp6_ptr->io.irqdel);
+ writeb(0, &dp6_ptr->u.ic.S_Status);
+ writeb(0xff, &dp6_ptr->io.irqdel);
ha->dma64_support = 0;
@@ -1003,8 +996,8 @@ static int __init gdth_init_pci(gdth_pci_str *pcistr,gdth_ha_str *ha)
}
/* check and reset interface area */
dp6c_ptr = ha->brd;
- gdth_writel(DPMEM_MAGIC, &dp6c_ptr->u);
- if (gdth_readl(&dp6c_ptr->u) != DPMEM_MAGIC) {
+ writel(DPMEM_MAGIC, &dp6c_ptr->u);
+ if (readl(&dp6c_ptr->u) != DPMEM_MAGIC) {
printk("GDT-PCI: Cannot access DPMEM at 0x%lx (shadowed?)\n",
pcistr->dpmem);
found = FALSE;
@@ -1015,7 +1008,7 @@ static int __init gdth_init_pci(gdth_pci_str *pcistr,gdth_ha_str *ha)
printk("GDT-PCI: Initialization error (DPMEM remap error)\n");
return 0;
}
- if (gdth_readw(ha->brd) != 0xffff) {
+ if (readw(ha->brd) != 0xffff) {
TRACE2(("init_pci_plx() address 0x%x busy\n", i));
continue;
}
@@ -1028,8 +1021,8 @@ static int __init gdth_init_pci(gdth_pci_str *pcistr,gdth_ha_str *ha)
return 0;
}
dp6c_ptr = ha->brd;
- gdth_writel(DPMEM_MAGIC, &dp6c_ptr->u);
- if (gdth_readl(&dp6c_ptr->u) == DPMEM_MAGIC) {
+ writel(DPMEM_MAGIC, &dp6c_ptr->u);
+ if (readl(&dp6c_ptr->u) == DPMEM_MAGIC) {
printk("GDT-PCI: Use free address at 0x%x\n", i);
found = TRUE;
break;
@@ -1042,7 +1035,7 @@ static int __init gdth_init_pci(gdth_pci_str *pcistr,gdth_ha_str *ha)
}
}
memset_io(&dp6c_ptr->u, 0, sizeof(dp6c_ptr->u));
- if (gdth_readl(&dp6c_ptr->u) != 0) {
+ if (readl(&dp6c_ptr->u) != 0) {
printk("GDT-PCI: Initialization error (DPMEM write error)\n");
iounmap(ha->brd);
return 0;
@@ -1052,17 +1045,17 @@ static int __init gdth_init_pci(gdth_pci_str *pcistr,gdth_ha_str *ha)
outb(0x00,PTR2USHORT(&ha->plx->control1));
outb(0xff,PTR2USHORT(&ha->plx->edoor_reg));
- gdth_writeb(0x00, &dp6c_ptr->u.ic.S_Status);
- gdth_writeb(0x00, &dp6c_ptr->u.ic.Cmd_Index);
+ writeb(0x00, &dp6c_ptr->u.ic.S_Status);
+ writeb(0x00, &dp6c_ptr->u.ic.Cmd_Index);
- gdth_writel(pcistr->dpmem, &dp6c_ptr->u.ic.S_Info[0]);
- gdth_writeb(0xff, &dp6c_ptr->u.ic.S_Cmd_Indx);
+ writel(pcistr->dpmem, &dp6c_ptr->u.ic.S_Info[0]);
+ writeb(0xff, &dp6c_ptr->u.ic.S_Cmd_Indx);
outb(1,PTR2USHORT(&ha->plx->ldoor_reg));
retries = INIT_RETRIES;
gdth_delay(20);
- while (gdth_readb(&dp6c_ptr->u.ic.S_Status) != 0xff) {
+ while (readb(&dp6c_ptr->u.ic.S_Status) != 0xff) {
if (--retries == 0) {
printk("GDT-PCI: Initialization error (DEINIT failed)\n");
iounmap(ha->brd);
@@ -1070,8 +1063,8 @@ static int __init gdth_init_pci(gdth_pci_str *pcistr,gdth_ha_str *ha)
}
gdth_delay(1);
}
- prot_ver = (unchar)gdth_readl(&dp6c_ptr->u.ic.S_Info[0]);
- gdth_writeb(0, &dp6c_ptr->u.ic.Status);
+ prot_ver = (unchar)readl(&dp6c_ptr->u.ic.S_Info[0]);
+ writeb(0, &dp6c_ptr->u.ic.Status);
if (prot_ver != PROTOCOL_VERSION) {
printk("GDT-PCI: Illegal protocol version\n");
iounmap(ha->brd);
@@ -1082,17 +1075,17 @@ static int __init gdth_init_pci(gdth_pci_str *pcistr,gdth_ha_str *ha)
ha->ic_all_size = sizeof(dp6c_ptr->u);
/* special command to controller BIOS */
- gdth_writel(0x00, &dp6c_ptr->u.ic.S_Info[0]);
- gdth_writel(0x00, &dp6c_ptr->u.ic.S_Info[1]);
- gdth_writel(0x00, &dp6c_ptr->u.ic.S_Info[2]);
- gdth_writel(0x00, &dp6c_ptr->u.ic.S_Info[3]);
- gdth_writeb(0xfe, &dp6c_ptr->u.ic.S_Cmd_Indx);
+ writel(0x00, &dp6c_ptr->u.ic.S_Info[0]);
+ writel(0x00, &dp6c_ptr->u.ic.S_Info[1]);
+ writel(0x00, &dp6c_ptr->u.ic.S_Info[2]);
+ writel(0x00, &dp6c_ptr->u.ic.S_Info[3]);
+ writeb(0xfe, &dp6c_ptr->u.ic.S_Cmd_Indx);
outb(1,PTR2USHORT(&ha->plx->ldoor_reg));
retries = INIT_RETRIES;
gdth_delay(20);
- while (gdth_readb(&dp6c_ptr->u.ic.S_Status) != 0xfe) {
+ while (readb(&dp6c_ptr->u.ic.S_Status) != 0xfe) {
if (--retries == 0) {
printk("GDT-PCI: Initialization error\n");
iounmap(ha->brd);
@@ -1100,7 +1093,7 @@ static int __init gdth_init_pci(gdth_pci_str *pcistr,gdth_ha_str *ha)
}
gdth_delay(1);
}
- gdth_writeb(0, &dp6c_ptr->u.ic.S_Status);
+ writeb(0, &dp6c_ptr->u.ic.S_Status);
ha->dma64_support = 0;
@@ -1128,12 +1121,12 @@ static int __init gdth_init_pci(gdth_pci_str *pcistr,gdth_ha_str *ha)
/* Ensure that it is safe to access the non HW portions of DPMEM.
* Aditional check needed for Xscale based RAID controllers */
- while( ((int)gdth_readb(&dp6m_ptr->i960r.sema0_reg) ) & 3 )
+ while( ((int)readb(&dp6m_ptr->i960r.sema0_reg) ) & 3 )
gdth_delay(1);
/* check and reset interface area */
- gdth_writel(DPMEM_MAGIC, &dp6m_ptr->u);
- if (gdth_readl(&dp6m_ptr->u) != DPMEM_MAGIC) {
+ writel(DPMEM_MAGIC, &dp6m_ptr->u);
+ if (readl(&dp6m_ptr->u) != DPMEM_MAGIC) {
printk("GDT-PCI: Cannot access DPMEM at 0x%lx (shadowed?)\n",
pcistr->dpmem);
found = FALSE;
@@ -1144,7 +1137,7 @@ static int __init gdth_init_pci(gdth_pci_str *pcistr,gdth_ha_str *ha)
printk("GDT-PCI: Initialization error (DPMEM remap error)\n");
return 0;
}
- if (gdth_readw(ha->brd) != 0xffff) {
+ if (readw(ha->brd) != 0xffff) {
TRACE2(("init_pci_mpr() address 0x%x busy\n", i));
continue;
}
@@ -1157,8 +1150,8 @@ static int __init gdth_init_pci(gdth_pci_str *pcistr,gdth_ha_str *ha)
return 0;
}
dp6m_ptr = ha->brd;
- gdth_writel(DPMEM_MAGIC, &dp6m_ptr->u);
- if (gdth_readl(&dp6m_ptr->u) == DPMEM_MAGIC) {
+ writel(DPMEM_MAGIC, &dp6m_ptr->u);
+ if (readl(&dp6m_ptr->u) == DPMEM_MAGIC) {
printk("GDT-PCI: Use free address at 0x%x\n", i);
found = TRUE;
break;
@@ -1173,18 +1166,18 @@ static int __init gdth_init_pci(gdth_pci_str *pcistr,gdth_ha_str *ha)
memset_io(&dp6m_ptr->u, 0, sizeof(dp6m_ptr->u));
/* disable board interrupts, deinit services */
- gdth_writeb(gdth_readb(&dp6m_ptr->i960r.edoor_en_reg) | 4,
+ writeb(readb(&dp6m_ptr->i960r.edoor_en_reg) | 4,
&dp6m_ptr->i960r.edoor_en_reg);
- gdth_writeb(0xff, &dp6m_ptr->i960r.edoor_reg);
- gdth_writeb(0x00, &dp6m_ptr->u.ic.S_Status);
- gdth_writeb(0x00, &dp6m_ptr->u.ic.Cmd_Index);
+ writeb(0xff, &dp6m_ptr->i960r.edoor_reg);
+ writeb(0x00, &dp6m_ptr->u.ic.S_Status);
+ writeb(0x00, &dp6m_ptr->u.ic.Cmd_Index);
- gdth_writel(pcistr->dpmem, &dp6m_ptr->u.ic.S_Info[0]);
- gdth_writeb(0xff, &dp6m_ptr->u.ic.S_Cmd_Indx);
- gdth_writeb(1, &dp6m_ptr->i960r.ldoor_reg);
+ writel(pcistr->dpmem, &dp6m_ptr->u.ic.S_Info[0]);
+ writeb(0xff, &dp6m_ptr->u.ic.S_Cmd_Indx);
+ writeb(1, &dp6m_ptr->i960r.ldoor_reg);
retries = INIT_RETRIES;
gdth_delay(20);
- while (gdth_readb(&dp6m_ptr->u.ic.S_Status) != 0xff) {
+ while (readb(&dp6m_ptr->u.ic.S_Status) != 0xff) {
if (--retries == 0) {
printk("GDT-PCI: Initialization error (DEINIT failed)\n");
iounmap(ha->brd);
@@ -1192,8 +1185,8 @@ static int __init gdth_init_pci(gdth_pci_str *pcistr,gdth_ha_str *ha)
}
gdth_delay(1);
}
- prot_ver = (unchar)gdth_readl(&dp6m_ptr->u.ic.S_Info[0]);
- gdth_writeb(0, &dp6m_ptr->u.ic.S_Status);
+ prot_ver = (unchar)readl(&dp6m_ptr->u.ic.S_Info[0]);
+ writeb(0, &dp6m_ptr->u.ic.S_Status);
if (prot_ver != PROTOCOL_VERSION) {
printk("GDT-PCI: Illegal protocol version\n");
iounmap(ha->brd);
@@ -1204,15 +1197,15 @@ static int __init gdth_init_pci(gdth_pci_str *pcistr,gdth_ha_str *ha)
ha->ic_all_size = sizeof(dp6m_ptr->u);
/* special command to controller BIOS */
- gdth_writel(0x00, &dp6m_ptr->u.ic.S_Info[0]);
- gdth_writel(0x00, &dp6m_ptr->u.ic.S_Info[1]);
- gdth_writel(0x00, &dp6m_ptr->u.ic.S_Info[2]);
- gdth_writel(0x00, &dp6m_ptr->u.ic.S_Info[3]);
- gdth_writeb(0xfe, &dp6m_ptr->u.ic.S_Cmd_Indx);
- gdth_writeb(1, &dp6m_ptr->i960r.ldoor_reg);
+ writel(0x00, &dp6m_ptr->u.ic.S_Info[0]);
+ writel(0x00, &dp6m_ptr->u.ic.S_Info[1]);
+ writel(0x00, &dp6m_ptr->u.ic.S_Info[2]);
+ writel(0x00, &dp6m_ptr->u.ic.S_Info[3]);
+ writeb(0xfe, &dp6m_ptr->u.ic.S_Cmd_Indx);
+ writeb(1, &dp6m_ptr->i960r.ldoor_reg);
retries = INIT_RETRIES;
gdth_delay(20);
- while (gdth_readb(&dp6m_ptr->u.ic.S_Status) != 0xfe) {
+ while (readb(&dp6m_ptr->u.ic.S_Status) != 0xfe) {
if (--retries == 0) {
printk("GDT-PCI: Initialization error\n");
iounmap(ha->brd);
@@ -1220,14 +1213,14 @@ static int __init gdth_init_pci(gdth_pci_str *pcistr,gdth_ha_str *ha)
}
gdth_delay(1);
}
- gdth_writeb(0, &dp6m_ptr->u.ic.S_Status);
+ writeb(0, &dp6m_ptr->u.ic.S_Status);
/* read FW version to detect 64-bit DMA support */
- gdth_writeb(0xfd, &dp6m_ptr->u.ic.S_Cmd_Indx);
- gdth_writeb(1, &dp6m_ptr->i960r.ldoor_reg);
+ writeb(0xfd, &dp6m_ptr->u.ic.S_Cmd_Indx);
+ writeb(1, &dp6m_ptr->i960r.ldoor_reg);
retries = INIT_RETRIES;
gdth_delay(20);
- while (gdth_readb(&dp6m_ptr->u.ic.S_Status) != 0xfd) {
+ while (readb(&dp6m_ptr->u.ic.S_Status) != 0xfd) {
if (--retries == 0) {
printk("GDT-PCI: Initialization error (DEINIT failed)\n");
iounmap(ha->brd);
@@ -1235,8 +1228,8 @@ static int __init gdth_init_pci(gdth_pci_str *pcistr,gdth_ha_str *ha)
}
gdth_delay(1);
}
- prot_ver = (unchar)(gdth_readl(&dp6m_ptr->u.ic.S_Info[0]) >> 16);
- gdth_writeb(0, &dp6m_ptr->u.ic.S_Status);
+ prot_ver = (unchar)(readl(&dp6m_ptr->u.ic.S_Info[0]) >> 16);
+ writeb(0, &dp6m_ptr->u.ic.S_Status);
if (prot_ver < 0x2b) /* FW < x.43: no 64-bit DMA support */
ha->dma64_support = 0;
else
@@ -1267,21 +1260,21 @@ static void __init gdth_enable_int(int hanum)
outb(0x01, ha->bmic + EINTENABREG);
} else if (ha->type == GDT_ISA) {
dp2_ptr = ha->brd;
- gdth_writeb(1, &dp2_ptr->io.irqdel);
- gdth_writeb(0, &dp2_ptr->u.ic.Cmd_Index);
- gdth_writeb(1, &dp2_ptr->io.irqen);
+ writeb(1, &dp2_ptr->io.irqdel);
+ writeb(0, &dp2_ptr->u.ic.Cmd_Index);
+ writeb(1, &dp2_ptr->io.irqen);
} else if (ha->type == GDT_PCI) {
dp6_ptr = ha->brd;
- gdth_writeb(1, &dp6_ptr->io.irqdel);
- gdth_writeb(0, &dp6_ptr->u.ic.Cmd_Index);
- gdth_writeb(1, &dp6_ptr->io.irqen);
+ writeb(1, &dp6_ptr->io.irqdel);
+ writeb(0, &dp6_ptr->u.ic.Cmd_Index);
+ writeb(1, &dp6_ptr->io.irqen);
} else if (ha->type == GDT_PCINEW) {
outb(0xff, PTR2USHORT(&ha->plx->edoor_reg));
outb(0x03, PTR2USHORT(&ha->plx->control1));
} else if (ha->type == GDT_PCIMPR) {
dp6m_ptr = ha->brd;
- gdth_writeb(0xff, &dp6m_ptr->i960r.edoor_reg);
- gdth_writeb(gdth_readb(&dp6m_ptr->i960r.edoor_en_reg) & ~4,
+ writeb(0xff, &dp6m_ptr->i960r.edoor_reg);
+ writeb(readb(&dp6m_ptr->i960r.edoor_en_reg) & ~4,
&dp6m_ptr->i960r.edoor_en_reg);
}
spin_unlock_irqrestore(&ha->smp_lock, flags);
@@ -1305,15 +1298,15 @@ static int gdth_get_status(unchar *pIStatus,int irq)
*pIStatus = inb((ushort)ha->bmic + EDOORREG);
else if (ha->type == GDT_ISA)
*pIStatus =
- gdth_readb(&((gdt2_dpram_str __iomem *)ha->brd)->u.ic.Cmd_Index);
+ readb(&((gdt2_dpram_str __iomem *)ha->brd)->u.ic.Cmd_Index);
else if (ha->type == GDT_PCI)
*pIStatus =
- gdth_readb(&((gdt6_dpram_str __iomem *)ha->brd)->u.ic.Cmd_Index);
+ readb(&((gdt6_dpram_str __iomem *)ha->brd)->u.ic.Cmd_Index);
else if (ha->type == GDT_PCINEW)
*pIStatus = inb(PTR2USHORT(&ha->plx->edoor_reg));
else if (ha->type == GDT_PCIMPR)
*pIStatus =
- gdth_readb(&((gdt6m_dpram_str __iomem *)ha->brd)->i960r.edoor_reg);
+ readb(&((gdt6m_dpram_str __iomem *)ha->brd)->i960r.edoor_reg);
if (*pIStatus)
return i; /* board found */
@@ -1333,14 +1326,14 @@ static int gdth_test_busy(int hanum)
if (ha->type == GDT_EISA)
gdtsema0 = (int)inb(ha->bmic + SEMA0REG);
else if (ha->type == GDT_ISA)
- gdtsema0 = (int)gdth_readb(&((gdt2_dpram_str __iomem *)ha->brd)->u.ic.Sema0);
+ gdtsema0 = (int)readb(&((gdt2_dpram_str __iomem *)ha->brd)->u.ic.Sema0);
else if (ha->type == GDT_PCI)
- gdtsema0 = (int)gdth_readb(&((gdt6_dpram_str __iomem *)ha->brd)->u.ic.Sema0);
+ gdtsema0 = (int)readb(&((gdt6_dpram_str __iomem *)ha->brd)->u.ic.Sema0);
else if (ha->type == GDT_PCINEW)
gdtsema0 = (int)inb(PTR2USHORT(&ha->plx->sema0_reg));
else if (ha->type == GDT_PCIMPR)
gdtsema0 =
- (int)gdth_readb(&((gdt6m_dpram_str __iomem *)ha->brd)->i960r.sema0_reg);
+ (int)readb(&((gdt6m_dpram_str __iomem *)ha->brd)->i960r.sema0_reg);
return (gdtsema0 & 1);
}
@@ -1376,13 +1369,13 @@ static void gdth_set_sema0(int hanum)
if (ha->type == GDT_EISA) {
outb(1, ha->bmic + SEMA0REG);
} else if (ha->type == GDT_ISA) {
- gdth_writeb(1, &((gdt2_dpram_str __iomem *)ha->brd)->u.ic.Sema0);
+ writeb(1, &((gdt2_dpram_str __iomem *)ha->brd)->u.ic.Sema0);
} else if (ha->type == GDT_PCI) {
- gdth_writeb(1, &((gdt6_dpram_str __iomem *)ha->brd)->u.ic.Sema0);
+ writeb(1, &((gdt6_dpram_str __iomem *)ha->brd)->u.ic.Sema0);
} else if (ha->type == GDT_PCINEW) {
outb(1, PTR2USHORT(&ha->plx->sema0_reg));
} else if (ha->type == GDT_PCIMPR) {
- gdth_writeb(1, &((gdt6m_dpram_str __iomem *)ha->brd)->i960r.sema0_reg);
+ writeb(1, &((gdt6m_dpram_str __iomem *)ha->brd)->i960r.sema0_reg);
}
}
@@ -1418,30 +1411,30 @@ static void gdth_copy_command(int hanum)
/* set offset and service, copy command to DPMEM */
if (ha->type == GDT_ISA) {
dp2_ptr = ha->brd;
- gdth_writew(dp_offset + DPMEM_COMMAND_OFFSET,
+ writew(dp_offset + DPMEM_COMMAND_OFFSET,
&dp2_ptr->u.ic.comm_queue[cmd_no].offset);
- gdth_writew((ushort)cmd_ptr->Service,
+ writew((ushort)cmd_ptr->Service,
&dp2_ptr->u.ic.comm_queue[cmd_no].serv_id);
memcpy_toio(&dp2_ptr->u.ic.gdt_dpr_cmd[dp_offset],cmd_ptr,cp_count);
} else if (ha->type == GDT_PCI) {
dp6_ptr = ha->brd;
- gdth_writew(dp_offset + DPMEM_COMMAND_OFFSET,
+ writew(dp_offset + DPMEM_COMMAND_OFFSET,
&dp6_ptr->u.ic.comm_queue[cmd_no].offset);
- gdth_writew((ushort)cmd_ptr->Service,
+ writew((ushort)cmd_ptr->Service,
&dp6_ptr->u.ic.comm_queue[cmd_no].serv_id);
memcpy_toio(&dp6_ptr->u.ic.gdt_dpr_cmd[dp_offset],cmd_ptr,cp_count);
} else if (ha->type == GDT_PCINEW) {
dp6c_ptr = ha->brd;
- gdth_writew(dp_offset + DPMEM_COMMAND_OFFSET,
+ writew(dp_offset + DPMEM_COMMAND_OFFSET,
&dp6c_ptr->u.ic.comm_queue[cmd_no].offset);
- gdth_writew((ushort)cmd_ptr->Service,
+ writew((ushort)cmd_ptr->Service,
&dp6c_ptr->u.ic.comm_queue[cmd_no].serv_id);
memcpy_toio(&dp6c_ptr->u.ic.gdt_dpr_cmd[dp_offset],cmd_ptr,cp_count);
} else if (ha->type == GDT_PCIMPR) {
dp6m_ptr = ha->brd;
- gdth_writew(dp_offset + DPMEM_COMMAND_OFFSET,
+ writew(dp_offset + DPMEM_COMMAND_OFFSET,
&dp6m_ptr->u.ic.comm_queue[cmd_no].offset);
- gdth_writew((ushort)cmd_ptr->Service,
+ writew((ushort)cmd_ptr->Service,
&dp6m_ptr->u.ic.comm_queue[cmd_no].serv_id);
memcpy_toio(&dp6m_ptr->u.ic.gdt_dpr_cmd[dp_offset],cmd_ptr,cp_count);
}
@@ -1477,13 +1470,13 @@ static void gdth_release_event(int hanum)
outl(ha->ccb_phys, ha->bmic + MAILBOXREG);
outb(ha->pccb->Service, ha->bmic + LDOORREG);
} else if (ha->type == GDT_ISA) {
- gdth_writeb(0, &((gdt2_dpram_str __iomem *)ha->brd)->io.event);
+ writeb(0, &((gdt2_dpram_str __iomem *)ha->brd)->io.event);
} else if (ha->type == GDT_PCI) {
- gdth_writeb(0, &((gdt6_dpram_str __iomem *)ha->brd)->io.event);
+ writeb(0, &((gdt6_dpram_str __iomem *)ha->brd)->io.event);
} else if (ha->type == GDT_PCINEW) {
outb(1, PTR2USHORT(&ha->plx->ldoor_reg));
} else if (ha->type == GDT_PCIMPR) {
- gdth_writeb(1, &((gdt6m_dpram_str __iomem *)ha->brd)->i960r.ldoor_reg);
+ writeb(1, &((gdt6m_dpram_str __iomem *)ha->brd)->i960r.ldoor_reg);
}
}
@@ -3166,32 +3159,32 @@ static irqreturn_t gdth_interrupt(int irq,void *dev_id)
dp2_ptr = ha->brd;
if (IStatus & 0x80) { /* error flag */
IStatus &= ~0x80;
- ha->status = gdth_readw(&dp2_ptr->u.ic.Status);
+ ha->status = readw(&dp2_ptr->u.ic.Status);
TRACE2(("gdth_interrupt() error %d/%d\n",IStatus,ha->status));
} else /* no error */
ha->status = S_OK;
- ha->info = gdth_readl(&dp2_ptr->u.ic.Info[0]);
- ha->service = gdth_readw(&dp2_ptr->u.ic.Service);
- ha->info2 = gdth_readl(&dp2_ptr->u.ic.Info[1]);
+ ha->info = readl(&dp2_ptr->u.ic.Info[0]);
+ ha->service = readw(&dp2_ptr->u.ic.Service);
+ ha->info2 = readl(&dp2_ptr->u.ic.Info[1]);
- gdth_writeb(0xff, &dp2_ptr->io.irqdel); /* acknowledge interrupt */
- gdth_writeb(0, &dp2_ptr->u.ic.Cmd_Index);/* reset command index */
- gdth_writeb(0, &dp2_ptr->io.Sema1); /* reset status semaphore */
+ writeb(0xff, &dp2_ptr->io.irqdel); /* acknowledge interrupt */
+ writeb(0, &dp2_ptr->u.ic.Cmd_Index);/* reset command index */
+ writeb(0, &dp2_ptr->io.Sema1); /* reset status semaphore */
} else if (ha->type == GDT_PCI) {
dp6_ptr = ha->brd;
if (IStatus & 0x80) { /* error flag */
IStatus &= ~0x80;
- ha->status = gdth_readw(&dp6_ptr->u.ic.Status);
+ ha->status = readw(&dp6_ptr->u.ic.Status);
TRACE2(("gdth_interrupt() error %d/%d\n",IStatus,ha->status));
} else /* no error */
ha->status = S_OK;
- ha->info = gdth_readl(&dp6_ptr->u.ic.Info[0]);
- ha->service = gdth_readw(&dp6_ptr->u.ic.Service);
- ha->info2 = gdth_readl(&dp6_ptr->u.ic.Info[1]);
+ ha->info = readl(&dp6_ptr->u.ic.Info[0]);
+ ha->service = readw(&dp6_ptr->u.ic.Service);
+ ha->info2 = readl(&dp6_ptr->u.ic.Info[1]);
- gdth_writeb(0xff, &dp6_ptr->io.irqdel); /* acknowledge interrupt */
- gdth_writeb(0, &dp6_ptr->u.ic.Cmd_Index);/* reset command index */
- gdth_writeb(0, &dp6_ptr->io.Sema1); /* reset status semaphore */
+ writeb(0xff, &dp6_ptr->io.irqdel); /* acknowledge interrupt */
+ writeb(0, &dp6_ptr->u.ic.Cmd_Index);/* reset command index */
+ writeb(0, &dp6_ptr->io.Sema1); /* reset status semaphore */
} else if (ha->type == GDT_PCINEW) {
if (IStatus & 0x80) { /* error flag */
IStatus &= ~0x80;
@@ -3214,7 +3207,7 @@ static irqreturn_t gdth_interrupt(int irq,void *dev_id)
ha->status = pcs->ext_status & 0xffff;
else
#endif
- ha->status = gdth_readw(&dp6m_ptr->i960r.status);
+ ha->status = readw(&dp6m_ptr->i960r.status);
TRACE2(("gdth_interrupt() error %d/%d\n",IStatus,ha->status));
} else /* no error */
ha->status = S_OK;
@@ -3227,18 +3220,18 @@ static irqreturn_t gdth_interrupt(int irq,void *dev_id)
} else
#endif
{
- ha->info = gdth_readl(&dp6m_ptr->i960r.info[0]);
- ha->service = gdth_readw(&dp6m_ptr->i960r.service);
- ha->info2 = gdth_readl(&dp6m_ptr->i960r.info[1]);
+ ha->info = readl(&dp6m_ptr->i960r.info[0]);
+ ha->service = readw(&dp6m_ptr->i960r.service);
+ ha->info2 = readl(&dp6m_ptr->i960r.info[1]);
}
/* event string */
if (IStatus == ASYNCINDEX) {
if (ha->service != SCREENSERVICE &&
(ha->fw_vers & 0xff) >= 0x1a) {
- ha->dvr.severity = gdth_readb
+ ha->dvr.severity = readb
(&((gdt6m_dpram_str __iomem *)ha->brd)->i960r.severity);
for (i = 0; i < 256; ++i) {
- ha->dvr.event_string[i] = gdth_readb
+ ha->dvr.event_string[i] = readb
(&((gdt6m_dpram_str __iomem *)ha->brd)->i960r.evt_str[i]);
if (ha->dvr.event_string[i] == 0)
break;
@@ -3251,8 +3244,8 @@ static irqreturn_t gdth_interrupt(int irq,void *dev_id)
if (!coalesced)
#endif
{
- gdth_writeb(0xff, &dp6m_ptr->i960r.edoor_reg);
- gdth_writeb(0, &dp6m_ptr->i960r.sema1_reg);
+ writeb(0xff, &dp6m_ptr->i960r.edoor_reg);
+ writeb(0, &dp6m_ptr->i960r.sema1_reg);
}
} else {
TRACE2(("gdth_interrupt() unknown controller type\n"));
@@ -3337,8 +3330,8 @@ static irqreturn_t gdth_interrupt(int irq,void *dev_id)
/* coalescing only for new GDT_PCIMPR controllers available */
if (ha->type == GDT_PCIMPR && coalesced) {
- gdth_writeb(0xff, &dp6m_ptr->i960r.edoor_reg);
- gdth_writeb(0, &dp6m_ptr->i960r.sema1_reg);
+ writeb(0xff, &dp6m_ptr->i960r.edoor_reg);
+ writeb(0, &dp6m_ptr->i960r.sema1_reg);
}
#endif
^ permalink raw reply related [flat|nested] 13+ messages in thread* [PATCH 2/4] gdth: Move probe-time error handling code to end of each function
2007-07-21 20:34 [PATCH 0/4] more gdth patches for your amusement Jeff Garzik
2007-07-21 20:34 ` [PATCH 1/4] gdth: kill gdth_{read,write}[bwl] wrappers Jeff Garzik
@ 2007-07-21 20:35 ` Jeff Garzik
2007-07-21 20:35 ` [PATCH 3/4] gdth: make some virt ctrlr code common; shuffle SHT members Jeff Garzik
` (3 subsequent siblings)
5 siblings, 0 replies; 13+ messages in thread
From: Jeff Garzik @ 2007-07-21 20:35 UTC (permalink / raw)
To: linux-scsi; +Cc: Christoph Hellwig, achim_leubner, Andrew Morton
commit 0a65f8353367d22c549652f7b8b9383950e82a46
Author: Jeff Garzik <jeff@garzik.org>
Date: Sat Jul 21 15:38:05 2007 -0400
[SCSI] gdth: Move probe-time error handling code to end of each function
Use standard laddered-goto error handling approach in three probe-time
functions.
Signed-off-by: Jeff Garzik <jeff@garzik.org>
drivers/scsi/gdth.c | 223 +++++++++++++++++++++++++---------------------------
1 file changed, 109 insertions(+), 114 deletions(-)
0a65f8353367d22c549652f7b8b9383950e82a46
diff --git a/drivers/scsi/gdth.c b/drivers/scsi/gdth.c
index 4cdba0c..a399420 100644
--- a/drivers/scsi/gdth.c
+++ b/drivers/scsi/gdth.c
@@ -3964,13 +3964,11 @@ static int __init gdth_start_isa(struct scsi_host_template *shtp,
shp = scsi_register(shtp, sizeof(gdth_ext_str));
if (shp == NULL)
- return 1; /* continue looping */
+ goto err_out;
ha = HADATA(shp);
- if (!gdth_init_isa(isa_bios, ha)) {
- scsi_unregister(shp);
- return 1; /* continue looping */
- }
+ if (!gdth_init_isa(isa_bios, ha))
+ goto err_out_shp;
#ifdef __ia64__
return 0; /* end loop: success */
@@ -3981,14 +3979,11 @@ static int __init gdth_start_isa(struct scsi_host_template *shtp,
if (request_irq(ha->irq, gdth_interrupt, IRQF_DISABLED, "gdth", ha)) {
printk("GDT-ISA: Unable to allocate IRQ\n");
- scsi_unregister(shp);
- return 1; /* continue looping */
+ goto err_out_shp;
}
if (request_dma(ha->drq, "gdth")) {
printk("GDT-ISA: Unable to allocate DMA channel\n");
- free_irq(ha->irq, ha);
- scsi_unregister(shp);
- return 1; /* continue looping */
+ goto err_out_irq;
}
set_dma_mode(ha->drq, DMA_MODE_CASCADE);
@@ -4030,25 +4025,7 @@ static int __init gdth_start_isa(struct scsi_host_template *shtp,
if (ha->pscratch == NULL || ha->pmsg == NULL ||
!gdth_search_drives(hanum)) {
printk("GDT-ISA: Error during device scan\n");
- gdth_pop_shp();
-
-#ifdef INT_COAL
- if (ha->coal_stat)
- pci_free_consistent(ha->pdev, sizeof(gdth_coal_status) *
- MAXOFFSETS, ha->coal_stat,
- ha->coal_stat_phys);
-#endif
-
- if (ha->pscratch)
- pci_free_consistent(ha->pdev, GDTH_SCRATCH,
- ha->pscratch, ha->scratch_phys);
- if (ha->pmsg)
- pci_free_consistent(ha->pdev, sizeof(gdth_msg_str),
- ha->pmsg, ha->msg_phys);
-
- free_irq(ha->irq,ha);
- scsi_unregister(shp);
- return 1; /* continue looping */
+ goto err_out_ha;
}
if (hdr_channel < 0 || hdr_channel > ha->bus_cnt)
@@ -4079,9 +4056,32 @@ static int __init gdth_start_isa(struct scsi_host_template *shtp,
spin_lock_init(&ha->smp_lock);
gdth_enable_int(hanum);
-#endif /* !__ia64__ */
return 1; /* continue looping */
+
+err_out_ha:
+ gdth_pop_shp();
+
+#ifdef INT_COAL
+ if (ha->coal_stat)
+ pci_free_consistent(ha->pdev, sizeof(gdth_coal_status) *
+ MAXOFFSETS, ha->coal_stat,
+ ha->coal_stat_phys);
+#endif
+
+ if (ha->pscratch)
+ pci_free_consistent(ha->pdev, GDTH_SCRATCH,
+ ha->pscratch, ha->scratch_phys);
+ if (ha->pmsg)
+ pci_free_consistent(ha->pdev, sizeof(gdth_msg_str),
+ ha->pmsg, ha->msg_phys);
+err_out_irq:
+ free_irq(ha->irq, ha);
+#endif /* !__ia64__ */
+err_out_shp:
+ scsi_unregister(shp);
+err_out:
+ return 1; /* continue looping */
}
static int __init gdth_start_eisa(struct scsi_host_template *shtp,
@@ -4094,13 +4094,11 @@ static int __init gdth_start_eisa(struct scsi_host_template *shtp,
shp = scsi_register(shtp,sizeof(gdth_ext_str));
if (shp == NULL)
- return 1; /* continue looping */
+ goto err_out;
ha = HADATA(shp);
- if (!gdth_init_eisa(eisa_slot,ha)) {
- scsi_unregister(shp);
- return 1; /* continue looping */
- }
+ if (!gdth_init_eisa(eisa_slot,ha))
+ goto err_out_shp;
/* controller found and initialized */
printk("Configuring GDT-EISA HA at Slot %d IRQ %u\n",
@@ -4108,8 +4106,7 @@ static int __init gdth_start_eisa(struct scsi_host_template *shtp,
if (request_irq(ha->irq,gdth_interrupt,IRQF_DISABLED,"gdth",ha)) {
printk("GDT-EISA: Unable to allocate IRQ\n");
- scsi_unregister(shp);
- return 1; /* continue looping */
+ goto err_out_shp;
}
shp->unchecked_isa_dma = 0;
@@ -4155,26 +4152,7 @@ static int __init gdth_start_eisa(struct scsi_host_template *shtp,
if (ha->pscratch == NULL || ha->pmsg == NULL ||
!gdth_search_drives(hanum)) {
printk("GDT-EISA: Error during device scan\n");
- gdth_pop_shp();
-
-#ifdef INT_COAL
- if (ha->coal_stat)
- pci_free_consistent(ha->pdev, sizeof(gdth_coal_status) *
- MAXOFFSETS, ha->coal_stat,
- ha->coal_stat_phys);
-#endif
- if (ha->pscratch)
- pci_free_consistent(ha->pdev, GDTH_SCRATCH,
- ha->pscratch, ha->scratch_phys);
- if (ha->pmsg)
- pci_free_consistent(ha->pdev, sizeof(gdth_msg_str),
- ha->pmsg, ha->msg_phys);
- if (ha->ccb_phys)
- pci_unmap_single(ha->pdev,ha->ccb_phys,
- sizeof(gdth_cmd_str),PCI_DMA_BIDIRECTIONAL);
- free_irq(ha->irq,ha);
- scsi_unregister(shp);
- return 1; /* continue looping */
+ goto err_out_ha;
}
if (hdr_channel < 0 || hdr_channel > ha->bus_cnt)
@@ -4207,6 +4185,30 @@ static int __init gdth_start_eisa(struct scsi_host_template *shtp,
gdth_enable_int(hanum);
return 1; /* continue looping */
+
+err_out_ha:
+ gdth_pop_shp();
+
+#ifdef INT_COAL
+ if (ha->coal_stat)
+ pci_free_consistent(ha->pdev, sizeof(gdth_coal_status) *
+ MAXOFFSETS, ha->coal_stat,
+ ha->coal_stat_phys);
+#endif
+ if (ha->pscratch)
+ pci_free_consistent(ha->pdev, GDTH_SCRATCH,
+ ha->pscratch, ha->scratch_phys);
+ if (ha->pmsg)
+ pci_free_consistent(ha->pdev, sizeof(gdth_msg_str),
+ ha->pmsg, ha->msg_phys);
+ if (ha->ccb_phys)
+ pci_unmap_single(ha->pdev,ha->ccb_phys,
+ sizeof(gdth_cmd_str),PCI_DMA_BIDIRECTIONAL);
+ free_irq(ha->irq, ha);
+err_out_shp:
+ scsi_unregister(shp);
+err_out:
+ return 1; /* continue looping */
}
static int __init gdth_start_pci(struct scsi_host_template *shtp,
@@ -4215,19 +4217,17 @@ static int __init gdth_start_pci(struct scsi_host_template *shtp,
struct Scsi_Host *shp;
dma_addr_t scratch_dma_handle = 0;
gdth_ha_str *ha;
- int i, hanum, err;
+ int i, hanum;
if (gdth_ctr_count >= MAXHA)
return 0; /* end loop: success */
shp = scsi_register(shtp,sizeof(gdth_ext_str));
if (shp == NULL)
- return 1; /* continue looping */
+ goto err_out;
ha = HADATA(shp);
- if (!gdth_init_pci(&pcistr[ctr],ha)) {
- scsi_unregister(shp);
- return 1; /* continue looping */
- }
+ if (!gdth_init_pci(&pcistr[ctr],ha))
+ goto err_out_shp;
/* controller found and initialized */
printk("Configuring GDT-PCI HA at %d/%d IRQ %u\n",
@@ -4237,8 +4237,7 @@ static int __init gdth_start_pci(struct scsi_host_template *shtp,
if (request_irq(ha->irq, gdth_interrupt,
IRQF_DISABLED | IRQF_SHARED, "gdth", ha)) {
printk("GDT-PCI: Unable to allocate IRQ\n");
- scsi_unregister(shp);
- return 1; /* continue looping */
+ goto err_out_shp;
}
shp->unchecked_isa_dma = 0;
@@ -4275,58 +4274,32 @@ static int __init gdth_start_pci(struct scsi_host_template *shtp,
ha->cmd_tab[i].cmnd = UNUSED_CMND;
ha->scan_mode = rescan ? 0x10 : 0;
- err = FALSE;
if (ha->pscratch == NULL || ha->pmsg == NULL ||
- !gdth_search_drives(hanum)) {
- err = TRUE;
- } else {
- if (hdr_channel < 0 || hdr_channel > ha->bus_cnt)
- hdr_channel = ha->bus_cnt;
- ha->virt_bus = hdr_channel;
-
- if (!(ha->cache_feat & ha->raw_feat & ha->screen_feat &
- GDT_64BIT) ||
- /* 64-bit DMA only supported from FW >= x.43 */
- (!ha->dma64_support)) {
- if (pci_set_dma_mask(pcistr[ctr].pdev, DMA_32BIT_MASK)){
- printk(KERN_WARNING "GDT-PCI %d: Unable to "
- "set 32-bit DMA\n", hanum);
- err = TRUE;
- }
- } else {
- shp->max_cmd_len = 16;
- if (!pci_set_dma_mask(pcistr[ctr].pdev,DMA_64BIT_MASK)){
- printk("GDT-PCI %d: 64-bit DMA enabled\n",
- hanum);
- } else if (pci_set_dma_mask(pcistr[ctr].pdev,
- DMA_32BIT_MASK)) {
- printk(KERN_WARNING "GDT-PCI %d: Unable to set "
- "64/32-bit DMA\n", hanum);
- err = TRUE;
- }
- }
- }
+ !gdth_search_drives(hanum))
+ goto err_out_ha;
- if (err) {
- printk("GDT-PCI %d: Error during device scan\n", hanum);
- gdth_pop_shp();
-
-#ifdef INT_COAL
- if (ha->coal_stat)
- pci_free_consistent(ha->pdev, sizeof(gdth_coal_status) *
- MAXOFFSETS, ha->coal_stat,
- ha->coal_stat_phys);
-#endif
+ if (hdr_channel < 0 || hdr_channel > ha->bus_cnt)
+ hdr_channel = ha->bus_cnt;
+ ha->virt_bus = hdr_channel;
- if (ha->pscratch)
- pci_free_consistent(ha->pdev, GDTH_SCRATCH,
- ha->pscratch, ha->scratch_phys);
- if (ha->pmsg)
- pci_free_consistent(ha->pdev, sizeof(gdth_msg_str),
- ha->pmsg, ha->msg_phys);
- free_irq(ha->irq,ha);
- scsi_unregister(shp);
- return 1; /* continue looping */
+ if (!(ha->cache_feat & ha->raw_feat & ha->screen_feat & GDT_64BIT) ||
+ /* 64-bit DMA only supported from FW >= x.43 */
+ (!ha->dma64_support)) {
+ if (pci_set_dma_mask(pcistr[ctr].pdev, DMA_32BIT_MASK)){
+ printk(KERN_WARNING "GDT-PCI %d: Unable to "
+ "set 32-bit DMA\n", hanum);
+ goto err_out_ha;
+ }
+ } else {
+ shp->max_cmd_len = 16;
+ if (!pci_set_dma_mask(pcistr[ctr].pdev, DMA_64BIT_MASK)) {
+ printk("GDT-PCI %d: 64-bit DMA enabled\n",
+ hanum);
+ } else if (pci_set_dma_mask(pcistr[ctr].pdev, DMA_32BIT_MASK)) {
+ printk(KERN_WARNING "GDT-PCI %d: Unable to set "
+ "64/32-bit DMA\n", hanum);
+ goto err_out_ha;
+ }
}
shp->max_id = ha->tid_cnt;
@@ -4353,6 +4326,28 @@ static int __init gdth_start_pci(struct scsi_host_template *shtp,
gdth_enable_int(hanum);
return 1; /* continue looping */
+
+err_out_ha:
+ gdth_pop_shp();
+
+#ifdef INT_COAL
+ if (ha->coal_stat)
+ pci_free_consistent(ha->pdev, sizeof(gdth_coal_status) *
+ MAXOFFSETS, ha->coal_stat,
+ ha->coal_stat_phys);
+#endif
+
+ if (ha->pscratch)
+ pci_free_consistent(ha->pdev, GDTH_SCRATCH,
+ ha->pscratch, ha->scratch_phys);
+ if (ha->pmsg)
+ pci_free_consistent(ha->pdev, sizeof(gdth_msg_str),
+ ha->pmsg, ha->msg_phys);
+ free_irq(ha->irq, ha);
+err_out_shp:
+ scsi_unregister(shp);
+err_out:
+ return 1; /* continue looping */
}
static int __init gdth_detect(struct scsi_host_template *shtp)
^ permalink raw reply related [flat|nested] 13+ messages in thread* [PATCH 4/4] gdth: convert to modern SCSI host alloc/scan
2007-07-21 20:34 [PATCH 0/4] more gdth patches for your amusement Jeff Garzik
` (2 preceding siblings ...)
2007-07-21 20:35 ` [PATCH 3/4] gdth: make some virt ctrlr code common; shuffle SHT members Jeff Garzik
@ 2007-07-21 20:36 ` Jeff Garzik
2007-07-21 20:38 ` [PATCH 0/4] more gdth patches for your amusement Jeff Garzik
2007-09-15 14:12 ` James Bottomley
5 siblings, 0 replies; 13+ messages in thread
From: Jeff Garzik @ 2007-07-21 20:36 UTC (permalink / raw)
To: linux-scsi; +Cc: Christoph Hellwig, achim_leubner, Andrew Morton
commit 3a8d6339b89cee3c3dbffdde8ca5dfd8184fdb07
Author: Jeff Garzik <jeff@garzik.org>
Date: Sat Jul 21 06:22:20 2007 -0400
[SCSI] gdth: convert to modern SCSI host alloc/scan
Signed-off-by: Jeff Garzik <jeff@garzik.org>
drivers/scsi/gdth.c | 131 ++++++++++++++++++++++++++++++++++++++++------------
1 file changed, 101 insertions(+), 30 deletions(-)
3a8d6339b89cee3c3dbffdde8ca5dfd8184fdb07
diff --git a/drivers/scsi/gdth.c b/drivers/scsi/gdth.c
index 7235b1e..10b3bf8 100644
--- a/drivers/scsi/gdth.c
+++ b/drivers/scsi/gdth.c
@@ -3960,7 +3960,7 @@ static int __init gdth_register_virt(struct scsi_host_template *shtp,
{
struct Scsi_Host *shp;
unchar b;
- int done = 0;
+ int rc, done = 0;
if (!virt_ctr)
return 0;
@@ -3969,7 +3969,7 @@ static int __init gdth_register_virt(struct scsi_host_template *shtp,
/* register addit. SCSI channels as virtual controllers */
for (b = 1; b < ha->bus_cnt + 1; ++b) {
- shp = scsi_register(shtp, sizeof(gdth_num_str));
+ shp = scsi_host_alloc(shtp, sizeof(gdth_num_str));
if (isa_dma) {
shp->unchecked_isa_dma = 1;
@@ -3981,12 +3981,17 @@ static int __init gdth_register_virt(struct scsi_host_template *shtp,
shp->irq = ha->irq;
- gdth_push_vshp(shp);
+ rc = scsi_add_host(shp, dev);
+ if (rc)
+ scsi_host_put(shp);
+ else {
+ gdth_push_vshp(shp);
- NUMDATA(shp)->hanum = (ushort)hanum;
- NUMDATA(shp)->busnum = b;
+ NUMDATA(shp)->hanum = (ushort)hanum;
+ NUMDATA(shp)->busnum = b;
- done++;
+ done++;
+ }
}
return done ? 0 : -ENODEV;
@@ -3997,10 +4002,10 @@ static int __init gdth_start_isa(struct scsi_host_template *shtp,
{
struct Scsi_Host *shp;
gdth_ha_str *ha;
- int i, hanum;
+ int i, hanum, rc;
dma_addr_t scratch_dma_handle = 0;
- shp = scsi_register(shtp, sizeof(gdth_ext_str));
+ shp = scsi_host_alloc(shtp, sizeof(gdth_ext_str));
if (shp == NULL)
goto err_out;
@@ -4009,6 +4014,8 @@ static int __init gdth_start_isa(struct scsi_host_template *shtp,
goto err_out_shp;
#ifdef __ia64__
+ if (scsi_add_host(shp, NULL))
+ scsi_host_put(shp);
return 0; /* end loop: success */
#else
/* controller found and initialized */
@@ -4077,13 +4084,26 @@ static int __init gdth_start_isa(struct scsi_host_template *shtp,
shp->max_lun = MAXLUN;
shp->max_channel = virt_ctr ? 0 : ha->bus_cnt;
- gdth_register_virt(shtp, ha, hanum, NULL, true);
-
spin_lock_init(&ha->smp_lock);
+
+ rc = scsi_add_host(shp, NULL);
+ if (rc) {
+ printk("GDT-ISA: Error adding host\n");
+ goto err_out_ha;
+ }
+
+ rc = gdth_register_virt(shtp, ha, hanum, NULL, true);
+ if (rc) {
+ printk("GDT-ISA: Error adding virt controllers\n");
+ goto err_out_host;
+ }
+
gdth_enable_int(hanum);
return 1; /* continue looping */
+err_out_host:
+ scsi_remove_host(shp);
err_out_ha:
gdth_pop_shp();
@@ -4104,7 +4124,7 @@ err_out_irq:
free_irq(ha->irq, ha);
#endif /* !__ia64__ */
err_out_shp:
- scsi_unregister(shp);
+ scsi_host_put(shp);
err_out:
return 1; /* continue looping */
}
@@ -4114,10 +4134,10 @@ static int __init gdth_start_eisa(struct scsi_host_template *shtp,
{
struct Scsi_Host *shp;
gdth_ha_str *ha;
- int i, hanum;
+ int i, hanum, rc;
dma_addr_t scratch_dma_handle = 0;
- shp = scsi_register(shtp,sizeof(gdth_ext_str));
+ shp = scsi_host_alloc(shtp, sizeof(gdth_ext_str));
if (shp == NULL)
goto err_out;
@@ -4191,13 +4211,26 @@ static int __init gdth_start_eisa(struct scsi_host_template *shtp,
shp->max_lun = MAXLUN;
shp->max_channel = virt_ctr ? 0 : ha->bus_cnt;
- gdth_register_virt(shtp, ha, hanum, NULL, false);
-
spin_lock_init(&ha->smp_lock);
+
+ rc = scsi_add_host(shp, NULL);
+ if (rc) {
+ printk("GDT-EISA: Error adding host\n");
+ goto err_out_ha;
+ }
+
+ rc = gdth_register_virt(shtp, ha, hanum, NULL, false);
+ if (rc) {
+ printk("GDT-EISA: Error adding virt controllers\n");
+ goto err_out_host;
+ }
+
gdth_enable_int(hanum);
return 1; /* continue looping */
+err_out_host:
+ scsi_remove_host(shp);
err_out_ha:
gdth_pop_shp();
@@ -4218,7 +4251,7 @@ err_out_ha:
sizeof(gdth_cmd_str),PCI_DMA_BIDIRECTIONAL);
free_irq(ha->irq, ha);
err_out_shp:
- scsi_unregister(shp);
+ scsi_host_put(shp);
err_out:
return 1; /* continue looping */
}
@@ -4229,11 +4262,11 @@ static int __init gdth_start_pci(struct scsi_host_template *shtp,
struct Scsi_Host *shp;
dma_addr_t scratch_dma_handle = 0;
gdth_ha_str *ha;
- int i, hanum;
+ int i, hanum, rc;
if (gdth_ctr_count >= MAXHA)
return 0; /* end loop: success */
- shp = scsi_register(shtp,sizeof(gdth_ext_str));
+ shp = scsi_host_alloc(shtp, sizeof(gdth_ext_str));
if (shp == NULL)
goto err_out;
@@ -4318,13 +4351,26 @@ static int __init gdth_start_pci(struct scsi_host_template *shtp,
shp->max_lun = MAXLUN;
shp->max_channel = virt_ctr ? 0 : ha->bus_cnt;
- gdth_register_virt(shtp, ha, hanum, &pcistr[ctr].pdev->dev, false);
-
spin_lock_init(&ha->smp_lock);
+
+ rc = scsi_add_host(shp, NULL);
+ if (rc) {
+ printk("GDT-PCI: Error adding host\n");
+ goto err_out_ha;
+ }
+
+ rc = gdth_register_virt(shtp, ha, hanum, &pcistr[ctr].pdev->dev, false);
+ if (rc) {
+ printk("GDT-PCI: Error adding virt controllers\n");
+ goto err_out_host;
+ }
+
gdth_enable_int(hanum);
return 1; /* continue looping */
+err_out_host:
+ scsi_remove_host(shp);
err_out_ha:
gdth_pop_shp();
@@ -4343,7 +4389,7 @@ err_out_ha:
ha->pmsg, ha->msg_phys);
free_irq(ha->irq, ha);
err_out_shp:
- scsi_unregister(shp);
+ scsi_host_put(shp);
err_out:
return 1; /* continue looping */
}
@@ -4351,7 +4397,7 @@ err_out:
static int __init gdth_detect(struct scsi_host_template *shtp)
{
gdth_pci_str pcistr[MAXHA];
- int cnt,ctr;
+ int cnt, ctr, i;
unchar b;
#ifdef DEBUG_GDTH
@@ -4374,7 +4420,7 @@ static int __init gdth_detect(struct scsi_host_template *shtp)
if (disable) {
printk("GDT-HA: Controller driver disabled from command line !\n");
- return 0;
+ return -ENODEV;
}
printk("GDT-HA: Storage RAID Controller Driver. Version: %s\n",GDTH_VERSION_STR);
@@ -4438,14 +4484,22 @@ static int __init gdth_detect(struct scsi_host_template *shtp)
register_reboot_notifier(&gdth_notifier);
}
gdth_polling = FALSE;
- return gdth_ctr_vcount;
+
+ for (i = 0; i < gdth_ctr_vcount; i++)
+ if (gdth_ctr_vtab[i])
+ scsi_scan_host(gdth_ctr_vtab[i]);
+
+ return gdth_ctr_vcount > 0 ? 0 : -ENODEV;
}
-static int gdth_release(struct Scsi_Host *shp)
+static void __exit gdth_release(struct Scsi_Host *shp)
{
int hanum;
gdth_ha_str *ha;
+ if (!shp)
+ return;
+
TRACE2(("gdth_release()\n"));
if (NUMDATA(shp)->busnum == 0) {
hanum = NUMDATA(shp)->hanum;
@@ -4491,8 +4545,7 @@ static int gdth_release(struct Scsi_Host *shp)
}
}
- scsi_unregister(shp);
- return 0;
+ scsi_host_put(shp);
}
@@ -5329,9 +5382,8 @@ static int gdth_slave_configure(struct scsi_device *sdev)
}
static struct scsi_host_template driver_template = {
+ .module = THIS_MODULE,
.name = "GDT SCSI Disk Array Controller",
- .detect = gdth_detect,
- .release = gdth_release,
.info = gdth_info,
.queuecommand = gdth_queuecommand,
.eh_bus_reset_handler = gdth_eh_bus_reset,
@@ -5347,7 +5399,26 @@ static struct scsi_host_template driver_template = {
.use_clustering = ENABLE_CLUSTERING,
};
-#include "scsi_module.c"
#ifndef MODULE
__setup("gdth=", option_setup);
#endif
+
+static int __init gdth_mod_init(void)
+{
+ return gdth_detect(&driver_template);
+}
+
+static void __exit gdth_mod_exit(void)
+{
+ int i;
+
+ for (i = 0; i < gdth_ctr_vcount; i++)
+ if (gdth_ctr_vtab[i])
+ scsi_remove_host(gdth_ctr_vtab[i]);
+ for (i = 0; i < gdth_ctr_vcount; i++)
+ gdth_release(gdth_ctr_vtab[i]);
+}
+
+module_init(gdth_mod_init);
+module_exit(gdth_mod_exit);
+
^ permalink raw reply related [flat|nested] 13+ messages in thread