more gdth patches for your amusement
cover more gdth patches for your amusement
This is the rest of the stuff checked into the 'gdth' branch ofgit://git.kernel.org/pub/scm/linux/kernel/git/jgarzik/misc-2.6.git
As noted before, I'm fine with Christoph's gdth work superceding mine, or whatever. This was just me poking around. Hopefully the patches are useful for illustration, if nothing else.
1) [SCSI] gdth: kill gdth_{read,write}[bwl] wrappers
2) [SCSI] gdth: Move probe-time error handling code to end of each function
3) [SCSI] gdth: make some virt ctrlr code common; shuffle SHT members
4) [SCSI] gdth: convert to modern SCSI host alloc/scan
PATCH 1/4 gdth: kill gdth_{read,write}[bwl] wrappers
commit 411b270459eef219c41674e454b111dab610113f
Author: Jeff Garzik <[email protected]> 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].
drivers/scsi/gdth.c | 313 +++++++++++++++++++++++++--------------------------- 1 file changed, 153 insertions(+), 160 deletions(-)
411b270459eef219c41674e454b111dab610113f
drivers/scsi/gdth.c +153 -160
@@ -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
PATCH 2/4 gdth: Move probe-time error handling code to end of each function
In reply to Jeff Garzikcommit 0a65f8353367d22c549652f7b8b9383950e82a46
Author: Jeff Garzik <[email protected]> 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.
drivers/scsi/gdth.c | 223 +++++++++++++++++++++++++--------------------------- 1 file changed, 109 insertions(+), 114 deletions(-)
0a65f8353367d22c549652f7b8b9383950e82a46
drivers/scsi/gdth.c +109 -114
@@ -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)
PATCH 3/4 gdth: make some virt ctrlr code common; shuffle SHT members
In reply to Jeff Garzikcommit 7b45cff696331f7655b4b819c1ef5a9ac6387ac6
Author: Jeff Garzik <[email protected]> Date: Sat Jul 21 05:47:21 2007 -0400
[SCSI] gdth: make some virt ctrlr code common; shuffle SHT members
* New function gdth_register_virt() replaces the three basically-duplicate copies of virtual controller registration.
* shuffle scsi_host_template members such that they appear in the order in which they are defined in the header. this makes is easier to verify when initializers are missing members.
drivers/scsi/gdth.c | 90 +++++++++++++++++++++++++--------------------------- 1 file changed, 44 insertions(+), 46 deletions(-)
7b45cff696331f7655b4b819c1ef5a9ac6387ac6
drivers/scsi/gdth.c +44 -46
@@ -3954,6 +3954,44 @@ int __init option_setup(char *str)return 1 ; } +static int __init gdth_register_virt (struct scsi_host_template *shtp, +gdth_ha_str *ha,int hanum, +struct device *dev,bool isa_dma) +{ +struct Scsi_Host *shp; +unchar b; +int done =0 ; + +if (!virt_ctr) +return 0 ; + + virt_ctr =1 ; + +/* register addit. SCSI channels as virtual controllers */ +for (b =1 ; b < ha->bus_cnt +1 ; ++b) { + shp =scsi_register (shtp,sizeof (gdth_num_str)); + +if (isa_dma) { + shp->unchecked_isa_dma =1 ; + shp->dma_channel = ha->drq; + }else { + shp->unchecked_isa_dma =0 ; + shp->dma_channel =0xff ; + } + + shp->irq = ha->irq; + +gdth_push_vshp (shp); + +NUMDATA (shp)->hanum = (ushort )hanum; +NUMDATA (shp)->busnum = b; + + done++; + } + +return done ?0 : -ENODEV ; +} +static int __init gdth_start_isa (struct scsi_host_template *shtp,ulong32 isa_bios) {
@@ -4038,21 +4076,8 @@ static int __init gdth_start_isa(struct scsi_host_template *shtp, shp->max_id = ha->tid_cnt; shp->max_lun =MAXLUN ; shp->max_channel = virt_ctr ?0 : ha->bus_cnt; -if (virt_ctr) { -unchar b; - virt_ctr =1 ; -/* 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->unchecked_isa_dma =1 ; - shp->irq = ha->irq; - shp->dma_channel = ha->drq; -gdth_push_vshp (shp); -NUMDATA (shp)->hanum = (ushort )hanum; -NUMDATA (shp)->busnum = b; - } - } +gdth_register_virt (shtp, ha, hanum,NULL , true);spin_lock_init (&ha->smp_lock);gdth_enable_int (hanum);
@@ -4165,21 +4190,8 @@ static int __init gdth_start_eisa(struct scsi_host_template *shtp, shp->max_id = ha->tid_cnt; shp->max_lun =MAXLUN ; shp->max_channel = virt_ctr ?0 : ha->bus_cnt; -if (virt_ctr) { -unchar b; - virt_ctr =1 ; -/* 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->unchecked_isa_dma =0 ; - shp->irq = ha->irq; - shp->dma_channel =0xff ; -gdth_push_vshp (shp); -NUMDATA (shp)->hanum = (ushort )hanum; -NUMDATA (shp)->busnum = b; - } - } +gdth_register_virt (shtp, ha, hanum,NULL , false);spin_lock_init (&ha->smp_lock);gdth_enable_int (hanum);
@@ -4306,21 +4318,7 @@ static int __init gdth_start_pci(struct scsi_host_template *shtp, shp->max_lun =MAXLUN ; shp->max_channel = virt_ctr ?0 : ha->bus_cnt; -if (virt_ctr) { -unchar b; - - virt_ctr =1 ; -/* 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->unchecked_isa_dma =0 ; - shp->irq = ha->irq; - shp->dma_channel =0xff ; -gdth_push_vshp (shp); -NUMDATA (shp)->hanum = (ushort )hanum; -NUMDATA (shp)->busnum = b; - } - } +gdth_register_virt (shtp, ha, hanum, &pcistr[ctr].pdev->dev, false);spin_lock_init (&ha->smp_lock);gdth_enable_int (hanum);
@@ -5331,17 +5329,17 @@ static int gdth_slave_configure(struct scsi_device *sdev) }static struct scsi_host_template driver_template = { - .proc_name ="gdth" , - .proc_info = gdth_proc_info, .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, + .slave_configure = gdth_slave_configure, .bios_param = gdth_bios_param, + .proc_info = gdth_proc_info, + .proc_name ="gdth" , .can_queue =GDTH_MAXCMDS , - .slave_configure = gdth_slave_configure, .this_id =-1 , .sg_tablesize =GDTH_MAXSG , .cmd_per_lun =GDTH_MAXC_P_L ,
PATCH 4/4 gdth: convert to modern SCSI host alloc/scan
In reply to Jeff Garzikcommit 3a8d6339b89cee3c3dbffdde8ca5dfd8184fdb07
Author: Jeff Garzik <[email protected]> Date: Sat Jul 21 06:22:20 2007 -0400
[SCSI] gdth: convert to modern SCSI host alloc/scan
drivers/scsi/gdth.c | 131 ++++++++++++++++++++++++++++++++++++++++------------ 1 file changed, 101 insertions(+), 30 deletions(-)
3a8d6339b89cee3c3dbffdde8ca5dfd8184fdb07
drivers/scsi/gdth.c +101 -30
@@ -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); +
Quoted 6 lines · Jeff Garzik
This is the rest of the stuff checked into the 'gdth' branch of
git://git.kernel.org/pub/scm/linux/kernel/git/jgarzik/misc-2.6.gitAs noted before, I'm fine with Christoph's gdth work superceding mine, or whatever. This was just me poking around. Hopefully the patches are useful for illustration, if nothing else.
Illustrating, of course, a guarantee-nothing-breaks, bug-for-bug code movement approach to upgrading the driver.
It intentionally avoids cleanups along the way, other than those explicitly enumerated, to preserve as much behavior as possible (and thus reduce chances of breakage as much as possible).
Jeff
Quoted 11 lines · Jeff Garzik
This is the rest of the stuff checked into the 'gdth' branch of
git://git.kernel.org/pub/scm/linux/kernel/git/jgarzik/misc-2.6.gitAs noted before, I'm fine with Christoph's gdth work superceding mine, or whatever. This was just me poking around. Hopefully the patches are useful for illustration, if nothing else.
1) [SCSI] gdth: kill gdth_{read,write}[bwl] wrappers
2) [SCSI] gdth: Move probe-time error handling code to end of each function
3) [SCSI] gdth: make some virt ctrlr code common; shuffle SHT members
4) [SCSI] gdth: convert to modern SCSI host alloc/scan
OK, we've had these competing patch sets floating around for two months now. Christoph and Jeff, can we get agreement on which is going in?
James
Quoted 8 lines · James Bottomley
Quoted 7 lines · Jeff Garzik
This is the rest of the stuff checked into the 'gdth' branch of
git://git.kernel.org/pub/scm/linux/kernel/git/jgarzik/misc-2.6.gitAs noted before, I'm fine with Christoph's gdth work superceding mine, or whatever. This was just me poking around. Hopefully the patches are useful for illustration, if nothing else.
Quoted 7 lines
Quoted 4 lines
1) [SCSI] gdth: kill gdth_{read,write}[bwl] wrappers
2) [SCSI] gdth: Move probe-time error handling code to end of each function
3) [SCSI] gdth: make some virt ctrlr code common; shuffle SHT members
4) [SCSI] gdth: convert to modern SCSI host alloc/scanOK, we've had these competing patch sets floating around for two months now. Christoph and Jeff, can we get agreement on which is going in?
Well, my opinion is
1) When judging by total amount of positive improvement, Christoph's patches are superior -- he has more overall cleanups than I do.
2) When judging by likelihood of inducing breakage, I feel my changes are superior. My gdth changes tightly adhere to the equivalent-transformation method of shuffing code around, enabling further improvements. IOW, I resisted the urge to make cleanups and fix insignificant, pre-existing bugs during the transformations.
3) I am utterly unmotivated to merge the two patchsets. Someone should make an executive decision, pull one patchset, and drop the other. My coding "mood" has swung from cleaning up code to writing new SAS drivers :)
Jeff
Quoted 14 lines · Jeff Garzik
Quoted 2 lines
OK, we've had these competing patch sets floating around for two months now. Christoph and Jeff, can we get agreement on which is going in?
Well, my opinion is
1) When judging by total amount of positive improvement, Christoph's patches are superior -- he has more overall cleanups than I do.
2) When judging by likelihood of inducing breakage, I feel my changes are superior. My gdth changes tightly adhere to the equivalent-transformation method of shuffing code around, enabling further improvements. IOW, I resisted the urge to make cleanups and fix insignificant, pre-existing bugs during the transformations.
Quoted 3 lines
3) I am utterly unmotivated to merge the two patchsets. Someone should make an executive decision, pull one patchset, and drop the other. My coding "mood" has swung from cleaning up code to writing new SAS drivers :)
Go ahead with your patches as I don't have time working on mine right now. I'll port them ontop of your patches when I get time for it.
Quoted 18 lines · Christoph Hellwig
Quoted 13 lines · Jeff Garzik
Quoted 2 lines
OK, we've had these competing patch sets floating around for two months now. Christoph and Jeff, can we get agreement on which is going in?
Well, my opinion is
1) When judging by total amount of positive improvement, Christoph's patches are superior -- he has more overall cleanups than I do.
2) When judging by likelihood of inducing breakage, I feel my changes are superior. My gdth changes tightly adhere to the equivalent-transformation method of shuffing code around, enabling further improvements. IOW, I resisted the urge to make cleanups and fix insignificant, pre-existing bugs during the transformations.
Quoted 3 lines
3) I am utterly unmotivated to merge the two patchsets. Someone should make an executive decision, pull one patchset, and drop the other. My coding "mood" has swung from cleaning up code to writing new SAS drivers :)
Quoted 6 lines
Go ahead with your patches as I don't have time working on mine right now. I'll port them ontop of your patches when I get time for it.
-
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
I have attempted a merge of both patchsets, and was about to send them but found that some code must be moved to earlier patches if I want bisectability. So it will take me another day to redo the patches and clean them up.
I have went even farther than Christoph with my patchset to totally remove the gdth_ctr_tab array and only use the new gdth_instances LIST_HEAD. I have done that by simply passing gdth_ha_str pointers around instead of hanum's.
On top of that I have my own agenda of cleaning the !use_sg code paths and getting rid of scsi_cmnd abuse, so there is also that.
So the patchset certainly takes the "likelihood of inducing breakage" approach. Being a merge of code from three people and none of them tested. So they will have to be exercised on real hardware before inclusion. Is there someone, perhaps in Adaptec, that can try some code.
Boaz
Quoted 2 lines · Boaz Harrosh
On top of that I have my own agenda of cleaning the !use_sg code paths and getting rid of
scsi_cmndabuse, so there is also that.
This seems like a good time to post my own patch that removes the use of ->scsi_done from gdth. I have a plan to remove the ->scsi_done() callback (drivers will simply call the scsi_done() function directly), and fixing the half-dozen drivers that override it is part of that.
I haven't looked at Christoph's, Jeff's or your patches yet, so this patch may be entirely worthless. My goal with it was not to clean up the driver (though it does a little), but to get gdth out of the way of cleaning up scsi_cmnd.
commit 06142e2394d83929b8b25feab70caab47ddfb791
Author: Matthew Wilcox <[email protected]> Date: Sat Sep 22 22:57:06 2007 -0400
gdth: Make one abuse of scsi_cmnd less obvious
Rather than having internal commands abuse scsi_done to call gdth_scsi_done, have all the places that use to call scsi_done directly call gdth_scsi_done, which now checks whether the command was internal, and calls scsi_done if not.
drivers/scsi/gdth.c +18 -53
@@ -475,7 +475,6 @@ static int gdth_ioctl(struct inode *inode, struct file *filep,static void gdth_flush (int hanum);static int gdth_halt (struct notifier_block *nb,ulong event,void *buf);static int gdth_queuecommand (Scsi_Cmnd *scp,void (*done)(Scsi_Cmnd *)); -static void gdth_scsi_done (struct scsi_cmnd *scp);#ifdef DEBUG_GDTH static unchar DebugState =DEBUG_GDTH ;
@@ -710,13 +709,14 @@ static void gdth_delay(int milliseconds) } } -#if LINUX_VERSION_CODE >=KERNEL_VERSION (2 ,6 ,0 )static void gdth_scsi_done (struct scsi_cmnd *scp) { -TRACE2 (("gdth_scsi_done()\n" )); +TRACE2 (("gdth_scsi_done()\n" )); -if (scp->request) -complete ((struct completion *)scp->request); +if (scp->done == gdth_scsi_done) +complete ((struct completion *)scp->request); +else + scp->scsi_done (scp); } int __gdth_execute(struct scsi_device *sdev, gdth_cmd_str *gdtcmd, char *cmnd,
@@ -738,8 +738,8 @@ int __gdth_execute(struct scsi_device *sdev, gdth_cmd_str *gdtcmd, char *cmnd, scp->cmd_len =12 ;memcpy (scp->cmnd, cmnd,12 ); scp->SCp.this_residual =IOCTL_PRI ;/* priority */ - scp->done = gdth_scsi_done;/* some fn. test this */ -gdth_queuecommand (scp, gdth_scsi_done); + scp->done = gdth_scsi_done; +gdth_queuecommand (scp,NULL );wait_for_completion (&wait); rval = scp->SCp.Status;
@@ -748,42 +748,6 @@ int __gdth_execute(struct scsi_device *sdev, gdth_cmd_str *gdtcmd, char *cmnd,kfree (scp);return rval; } -#else -static void gdth_scsi_done (Scsi_Cmnd *scp) -{ -TRACE2 (("gdth_scsi_done()\n" )); - - scp->request.rq_status =RQ_SCSI_DONE ; -if (scp->request.waiting) -complete (scp->request.waiting); -} - -int __gdth_execute (struct scsi_device *sdev,gdth_cmd_str *gdtcmd,char *cmnd, -int timeout,u32 *info) -{ -Scsi_Cmnd *scp =scsi_allocate_device (sdev,1 , FALSE); -unsigned bufflen = gdtcmd ?sizeof (gdth_cmd_str) :0 ; -DECLARE_COMPLETION_ONSTACK (wait); -int rval; - -if (!scp) -return -ENOMEM ; - scp->cmd_len =12 ; - scp->use_sg =0 ; - scp->SCp.this_residual =IOCTL_PRI ;/* priority */ - scp->request.rq_status =RQ_SCSI_BUSY ; - scp->request.waiting = &wait; -scsi_do_cmd (scp, cmnd, gdtcmd, bufflen, gdth_scsi_done, timeout*HZ ,1 ); -wait_for_completion (&wait); - - rval = scp->SCp.Status; -if (info) - *info = scp->SCp.Message; - -scsi_release_command (scp); -return rval; -} -#endif int gdth_execute (struct Scsi_Host *shost,gdth_cmd_str *gdtcmd,char *cmnd,int timeout,u32 *info)
@@ -2505,7 +2469,7 @@ static void gdth_next(int hanum)if (!nscp->SCp.have_data_in) nscp->SCp.have_data_in++;else - nscp->scsi_done (nscp); +gdth_scsi_done (nscp); } }else if (nscp->done == gdth_scsi_done) {if (!(cmd_index=gdth_special_cmd (hanum,nscp)))
@@ -2524,7 +2488,7 @@ static void gdth_next(int hanum)if (!nscp->SCp.have_data_in) nscp->SCp.have_data_in++;else - nscp->scsi_done (nscp); +gdth_scsi_done (nscp); }else {switch (nscp->cmnd[0 ]) {case TEST_UNIT_READY :
@@ -2550,9 +2514,9 @@ static void gdth_next(int hanum)if (!nscp->SCp.have_data_in) nscp->SCp.have_data_in++;else - nscp->scsi_done (nscp); +gdth_scsi_done (nscp); }else if (gdth_internal_cache_cmd (hanum,nscp)) - nscp->scsi_done (nscp); +gdth_scsi_done (nscp);break ;case ALLOW_MEDIUM_REMOVAL :
@@ -2566,7 +2530,7 @@ static void gdth_next(int hanum)if (!nscp->SCp.have_data_in) nscp->SCp.have_data_in++;else - nscp->scsi_done (nscp); +gdth_scsi_done (nscp); }else { nscp->cmnd[3 ] = (ha->hdr[t].devtype&1 ) ?1 :0 ; TRACE(("Prevent/allow r. %d rem. drive %d\n",
@@ -2602,7 +2566,7 @@ static void gdth_next(int hanum)if (!nscp->SCp.have_data_in) nscp->SCp.have_data_in++;else - nscp->scsi_done (nscp); +gdth_scsi_done (nscp); }else if (!(cmd_index=gdth_fill_cache_cmd (hanum,nscp,t))) this_cmd = FALSE;break ;
@@ -2617,7 +2581,7 @@ static void gdth_next(int hanum)if (!nscp->SCp.have_data_in) nscp->SCp.have_data_in++;else - nscp->scsi_done (nscp); +gdth_scsi_done (nscp);break ; } }
@@ -3630,7 +3594,7 @@ static irqreturn_t gdth_interrupt(int irq,void *dev_id)if (rval ==2 ) {gdth_putq (hanum,scp,scp->SCp.this_residual); }else if (rval ==1 ) { - scp->scsi_done (scp); +gdth_scsi_done (scp); }#ifdef INT_COAL
@@ -4925,14 +4889,15 @@ static int gdth_bios_param(Disk *disk,kdev_t dev,int *ip) } -static int gdth_queuecommand (Scsi_Cmnd *scp,void (*done)(Scsi_Cmnd *)) +static int gdth_queuecommand (struct scsi_cmnd *scp, +void (*done)(struct scsi_cmnd *)) {int hanum;int priority;TRACE (("gdth_queuecommand() cmd 0x%x\n" , scp->cmnd[0 ])); - scp->scsi_done = (void *)done; + scp->scsi_done = done; scp->SCp.have_data_in =1 ; scp->SCp.phase =-1 ; scp->SCp.sent_command =-1 ;
Signature · 4 lines
Intel are signing my paycheques ... these opinions are still mine "Bill, look, we understand that you're interested in selling us this operating system, but compare it to ours. We can't possibly take such a retrograde step."
Quoted 29 lines · Matthew Wilcox
Quoted 2 lines · Boaz Harrosh
On top of that I have my own agenda of cleaning the !use_sg code paths and getting rid of
scsi_cmndabuse, so there is also that.This seems like a good time to post my own patch that removes the use of ->scsi_done from gdth. I have a plan to remove the ->scsi_done() callback (drivers will simply call the
scsi_done()function directly), and fixing the half-dozen drivers that override it is part of that.I haven't looked at Christoph's, Jeff's or your patches yet, so this patch may be entirely worthless. My goal with it was not to clean up the driver (though it does a little), but to get gdth out of the way of cleaning up
scsi_cmnd.commit
06142e2394d83929b8b25feab70caab47ddfb791Author: Matthew Wilcox <[email protected]> Date: Sat Sep 22 22:57:06 2007 -0400gdth: Make one abuse of
scsi_cmndless obviousRather than having internal commands abuse
scsi_doneto callgdth_scsi_done, have all the places that use to callscsi_donedirectly callgdth_scsi_done, which now checks whether the command was internal, and callsscsi_doneif not.Signed-off-by Matthew Wilcox <[email protected]>drivers/scsi/gdth.c +0
-0
drivers/scsi/gdth.c
Quoted 1 line
drivers/scsi/gdth.c +0
-1---
Hi Matthew!
This patch looks grate, Thanks. It is very good for the direction I'm going to. However it does have a smallish conflict with One of Jeff's patches where he completely removes the 2.4.x support.
If it is OK with you I will add your patch to my patchset with your Singed-off-by, minus the conflict?
Boaz
Quoted 6 lines · Boaz Harrosh
This patch looks grate, Thanks. It is very good for the direction I'm going to. However it does have a smallish conflict with One of Jeff's patches where he completely removes the 2.4.x support.
If it is OK with you I will add your patch to my patchset with your Singed-off-by, minus the conflict?
That's absolutely fine; the fewer patches I have to track, the better.
Signature · 4 lines
Intel are signing my paycheques ... these opinions are still mine "Bill, look, we understand that you're interested in selling us this operating system, but compare it to ours. We can't possibly take such a retrograde step."