aha1542: Various improvements
cover aha1542: Various improvements
Hello,
this patch series updates aha1542 driver to not use deprecated initialization, removes dead code, ugly macros and simplifies the code. No major CodingStyle fixes yet.
Tested on AHA-1542B.
aha1542.c | 1687 +++++++++++++++++++------------------------------------------- aha1542.h | 136 +--- 2 files changed, 583 insertions(+), 1240 deletions(-)
Signature · 1 line
Ondrej Zary
PATCH 1/36 aha1542: Stop using scsi_module.c
Convert aha1542 to use scsi_add_host instead of scsi_module.c Use pnp_driver and isa_driver to manage cards.
--- drivers/scsi/aha1542.c | 300 +++++++++++++++++++++++++++--------------------- drivers/scsi/aha1542.h | 2 +- 2 files changed, 169 insertions(+), 133 deletions(-)
drivers/scsi/aha1542.c +168 -132
@@ -35,7 +35,8 @@#include <linux/proc_fs.h> #include <linux/init.h> #include <linux/spinlock.h> -#include <linux/isapnp.h> +#include <linux/isa.h> +#include <linux/pnp.h> #include <linux/blkdev.h> #include <linux/slab.h>
@@ -71,7 +72,7 @@/* Boards 3,4 slots are reserved for ISAPnP scans */ -static unsigned int bases[MAXBOARDS ]__initdata = {0x330 ,0x334 ,0 ,0 }; +static unsigned int bases[MAXBOARDS ] = {0x330 ,0x334 ,0 ,0 };/* set by aha1542_setup according to the command line; they also may be marked __initdata, but require zero initializers then */
@@ -79,7 +80,7 @@ static unsigned int bases[MAXBOARDS] __initdata = {0x330, 0x334, 0, 0};static int setup_called[MAXBOARDS ];static int setup_buson[MAXBOARDS ];static int setup_busoff[MAXBOARDS ]; -static int setup_dmaspeed[MAXBOARDS ]__initdata = {-1 ,-1 ,-1 ,-1 }; +static int setup_dmaspeed[MAXBOARDS ] = {-1 ,-1 ,-1 ,-1 };/* * LILO/Module params: aha1542=<PORTBASE>[,<BUSON>,<BUSOFF>[,<DMASPEED>]]
@@ -103,18 +104,6 @@ static bool isapnp = 0;static int aha1542[] = {0x330 ,11 ,4 ,-1 };module_param_array (aha1542, int,NULL ,0 );module_param (isapnp, bool,0 ); - -static struct isapnp_device_id id_table[]__initdata = { - { -ISAPNP_ANY_ID ,ISAPNP_ANY_ID , -ISAPNP_VENDOR ('A' ,'D' ,'P' ),ISAPNP_FUNCTION (0x1542 ), -0 - }, - {0 } -}; - -MODULE_DEVICE_TABLE (isapnp, id_table); -#else static int isapnp =1 ;#endif
@@ -221,7 +210,7 @@ fail:/* Only used at boot time, so we do not need to worry about latency as much here */ -static int __init aha1542_in (unsigned int base,unchar * cmdp,int len) +static int aha1542_in (unsigned int base,unchar *cmdp,int len) {unsigned long flags;
@@ -242,7 +231,7 @@ fail:/* Similar to aha1542_in, except that we wait a very short period of time. We use this if we know the board is alive and awake, but we are not sure if the board will respond to the command we are about to send or not */ -static int __init aha1542_in1 (unsigned int base,unchar * cmdp,int len) +static int aha1542_in1 (unsigned int base,unchar *cmdp,int len) {unsigned long flags;
@@ -314,7 +303,7 @@ static int makecode(unsigned hosterr, unsigned scsierr)return scsierr | (hosterr <<16 ); } -static int __init aha1542_test_port (int bse,struct Scsi_Host *shpnt) +static int aha1542_test_port (int bse,struct Scsi_Host *shpnt) {unchar inquiry_cmd[] = {CMD_INQUIRY };unchar inquiry_result[4 ];
@@ -744,7 +733,7 @@ fail:aha1542_intr_reset (bse); } -static int __init aha1542_getconfig (int base_io,unsigned char *irq_level,unsigned char *dma_chan,unsigned char *scsi_id) +static int aha1542_getconfig (int base_io,unsigned char *irq_level,unsigned char *dma_chan,unsigned char *scsi_id) {unchar inquiry_cmd[] = {CMD_RETCONF };unchar inquiry_result[3 ];
@@ -813,7 +802,7 @@ fail:/* This function should only be called for 1542C boards - we can detect the special firmware settings and unlock the board */ -static int __init aha1542_mbenable (int base) +static int aha1542_mbenable (int base) {static unchar mbenable_cmd[3 ];static unchar mbenable_result[2 ];
@@ -848,7 +837,7 @@ fail: }/* Query the board to find out if it is a 1542 or a 1740, or whatever. */ -static int __init aha1542_query (int base_io,int *transl) +static int aha1542_query (int base_io,int *transl) {unchar inquiry_cmd[] = {CMD_INQUIRY };unchar inquiry_result[4 ];
@@ -963,7 +952,7 @@ __setup("aha1542=",do_setup);#endif /* return non-zero on detection */ -static int __init aha1542_detect (struct scsi_host_template * tpnt) +static struct Scsi_Host *aha1542_hw_init (struct scsi_host_template *tpnt,struct device *pdev,int indx) {unsigned char dma_chan;unsigned char irq_level;
@@ -972,87 +961,18 @@ static int __init aha1542_detect(struct scsi_host_template * tpnt)unsigned int base_io;int trans;struct Scsi_Host *shpnt =NULL ; -int count =0 ; -int indx;DEB (printk ("aha1542_detect: \n" )); tpnt->proc_name ="aha1542" ; -#ifdef MODULE - bases[0 ] = aha1542[0 ]; - setup_buson[0 ] = aha1542[1 ]; - setup_busoff[0 ] = aha1542[2 ]; - { -int atbt =-1 ; -switch (aha1542[3 ]) { -case 5 : - atbt =0x00 ; -break ; -case 6 : - atbt =0x04 ; -break ; -case 7 : - atbt =0x01 ; -break ; -case 8 : - atbt =0x02 ; -break ; -case 10 : - atbt =0x03 ; -break ; - }; - setup_dmaspeed[0 ] = atbt; - } -#endif - -/* -* Hunt for ISA Plug'n'Pray Adaptecs (AHA1535) -*/ - -if (isapnp) - { -struct pnp_dev *pdev =NULL ; -for (indx =0 ; indx <ARRAY_SIZE (bases); indx++) { -if (bases[indx]) -continue ; - pdev =pnp_find_dev (NULL ,ISAPNP_VENDOR ('A' ,'D' ,'P' ), -ISAPNP_FUNCTION (0x1542 ), pdev); -if (pdev==NULL ) -break ; -/* -* Activate the PnP card -*/ - -if (pnp_device_attach (pdev)<0 ) -continue ; - -if (pnp_activate_dev (pdev)<0 ) { -pnp_device_detach (pdev); -continue ; - } - -if (!pnp_port_valid (pdev,0 )) { -pnp_device_detach (pdev); -continue ; - } - - bases[indx] =pnp_port_start (pdev,0 ); - -/* The card can be queried for its DMA, we have -the DMA set up that is enough */ - -printk (KERN_INFO "ISAPnP found an AHA1535 at I/O 0x%03X\n" , bases[indx]); - } - } -for (indx =0 ; indx <ARRAY_SIZE (bases); indx++)if (bases[indx] !=0 &&request_region (bases[indx],4 ,"aha1542" )) { - shpnt =scsi_register (tpnt, + shpnt =scsi_host_alloc (tpnt,sizeof (struct aha1542_hostdata ));if (shpnt==NULL ) {release_region (bases[indx],4 ); -continue ; +return NULL ; }if (!aha1542_test_port (bases[indx], shpnt)) goto unregister;
@@ -1137,60 +1057,37 @@ fail:HOSTDATA (shpnt)->aha1542_last_mbo_used = (AHA1542_MAILBOXES -1 );memset (HOSTDATA (shpnt)->SCint,0 ,sizeof (HOSTDATA (shpnt)->SCint));spin_unlock_irqrestore (&aha1542_lock, flags); -#if 0 -DEB (printk (" *** READ CAPACITY ***\n" )); - { -unchar buf[8 ]; -static unchar cmd[] = {READ_CAPACITY ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 }; -int i; - -for (i =0 ; i <sizeof (buf); ++i) - buf[i] =0x87 ; -for (i =0 ; i <2 ; ++i) -if (!aha1542_command (i, cmd, buf,sizeof (buf))) { -printk (KERN_DEBUG "aha_detect: LU %d sector_size %d device_size %d\n" , - i,xscsi2int (buf +4 ),xscsi2int (buf)); - } +if (scsi_add_host (shpnt, pdev)) { +if (shpnt->dma_channel !=0xff ) +free_dma (shpnt->dma_channel); +free_irq (irq_level, shpnt); + goto unregister; } -DEB (printk (" *** NOW RUNNING MY OWN TEST *** \n" )); +scsi_scan_host (shpnt); -for (i =0 ; i <4 ; ++i) { -unsigned char cmd[10 ]; - static buffer[512]; - - cmd[0 ] =READ_10 ; - cmd[1 ] =0 ; -xany2scsi (cmd +2 , i); - cmd[6 ] =0 ; - cmd[7 ] =0 ; - cmd[8 ] =1 ; - cmd[9 ] =0 ; -aha1542_command (0 , cmd, buffer,512 ); - } -#endif - count++; -continue ; +return shpnt; unregister:release_region (bases[indx],4 ); -scsi_unregister (shpnt); -continue ; +scsi_host_put (shpnt); +return NULL ; }; -return count; +return NULL ; }static int aha1542_release (struct Scsi_Host *shost) { +scsi_remove_host (shost);if (shost->irq)free_irq (shost->irq, shost);if (shost->dma_channel !=0xff )free_dma (shost->dma_channel);if (shost->io_port && shost->n_io_port)release_region (shost->io_port, shost->n_io_port); -scsi_unregister (shost); +scsi_host_put (shost);return 0 ; }
@@ -1661,12 +1558,10 @@ static int aha1542_biosparam(struct scsi_device *sdev, }MODULE_LICENSE ("GPL" ); -static struct scsi_host_template driver_template = { + .module =THIS_MODULE , .proc_name ="aha1542" , .name ="Adaptec 1542" , - .detect = aha1542_detect, - .release = aha1542_release, .queuecommand = aha1542_queuecommand, .eh_device_reset_handler= aha1542_dev_reset, .eh_bus_reset_handler = aha1542_bus_reset,
@@ -1679,4 +1574,145 @@ static struct scsi_host_template driver_template = { .unchecked_isa_dma = 1, .use_clustering = ENABLE_CLUSTERING, }; -#include "scsi_module.c" + +static int aha1542_isa_match (struct device *pdev,unsigned int ndev) +{ +struct Scsi_Host *sh =aha1542_hw_init (&driver_template, pdev, ndev); + +if (!sh) +return 0 ; + +dev_set_drvdata (pdev, sh); +return 1 ; +} + +static int aha1542_isa_remove (struct device *pdev, +unsigned int ndev) +{ +aha1542_release (dev_get_drvdata (pdev)); +dev_set_drvdata (pdev,NULL ); +return 0 ; +} + +static struct isa_driver aha1542_isa_driver = { + .match = aha1542_isa_match, + .remove = aha1542_isa_remove, + .driver = { + .name ="aha1542" + }, +}; +static int isa_registered; + +#ifdef CONFIG_PNP +static struct pnp_device_id aha1542_pnp_ids[] = { + { .id ="ADP1542" }, + { .id ="" } +}; +MODULE_DEVICE_TABLE (pnp, aha1542_pnp_ids); + +static int aha1542_pnp_probe (struct pnp_dev *pdev,const struct pnp_device_id *id) +{ +int indx; +struct Scsi_Host *sh; + +for (indx =0 ; indx <ARRAY_SIZE (bases); indx++) { +if (bases[indx]) +continue ; + +if (pnp_activate_dev (pdev) <0 ) +continue ; + + bases[indx] =pnp_port_start (pdev,0 ); + +/* The card can be queried for its DMA, we have +the DMA set up that is enough */ + +printk (KERN_INFO "ISAPnP found an AHA1535 at I/O 0x%03X\n" , bases[indx]); + } + + sh =aha1542_hw_init (&driver_template, &pdev->dev, indx); +if (!sh) +return -ENODEV ; + +pnp_set_drvdata (pdev, sh); +return 0 ; +} + +static void aha1542_pnp_remove (struct pnp_dev *pdev) +{ +aha1542_release (pnp_get_drvdata (pdev)); +pnp_set_drvdata (pdev,NULL ); +} + +static struct pnp_driver aha1542_pnp_driver = { + .name ="aha1542" , + .id_table = aha1542_pnp_ids, + .probe = aha1542_pnp_probe, + .remove = aha1542_pnp_remove, +}; +static int pnp_registered; +#endif /* CONFIG_PNP */ + +static int __init aha1542_init (void ) +{ +int ret =0 ; +#ifdef MODULE +int atbt =-1 ; + + bases[0 ] = aha1542[0 ]; + setup_buson[0 ] = aha1542[1 ]; + setup_busoff[0 ] = aha1542[2 ]; + +switch (aha1542[3 ]) { +case 5 : + atbt =0x00 ; +break ; +case 6 : + atbt =0x04 ; +break ; +case 7 : + atbt =0x01 ; +break ; +case 8 : + atbt =0x02 ; +break ; +case 10 : + atbt =0x03 ; +break ; + }; + setup_dmaspeed[0 ] = atbt; +#endif + +#ifdef CONFIG_PNP +if (isapnp) { + ret =pnp_register_driver (&aha1542_pnp_driver); +if (!ret) + pnp_registered =1 ; + } +#endif + ret =isa_register_driver (&aha1542_isa_driver,MAXBOARDS ); +if (!ret) + isa_registered =1 ; + +#ifdef CONFIG_PNP +if (pnp_registered) + ret =0 ; +#endif +if (isa_registered) + ret =0 ; + +return ret; +} + +static void __exit aha1542_exit(void) +{ +#ifdef CONFIG_PNP +if (pnp_registered) +pnp_unregister_driver (&aha1542_pnp_driver); +#endif +if (isa_registered) +isa_unregister_driver (&aha1542_isa_driver); +} + +module_init (aha1542_init); +module_exit (aha1542_exit);
drivers/scsi/aha1542.h +1 -1
@@ -131,7 +131,7 @@ struct ccb { /* Command Control Block 5.3 *//* REQUEST SENSE */ }; -static int aha1542_detect (struct scsi_host_template *); +static struct Scsi_Host *aha1542_hw_init (struct scsi_host_template *tpnt,struct device *pdev,int indx);static int aha1542_queuecommand (struct Scsi_Host *,struct scsi_cmnd *);static int aha1542_bus_reset (Scsi_Cmnd * SCpnt);static int aha1542_dev_reset (Scsi_Cmnd * SCpnt);
Signature · 1 line
Ondrej Zary
PATCH 2/36 aha1542: remove dead code
In reply to Ondrej ZaryRemove dead code.
--- drivers/scsi/aha1542.c | 243 +----------------------------------------------- drivers/scsi/aha1542.h | 6 -- 2 files changed, 1 insertion(+), 248 deletions(-)
drivers/scsi/aha1542.c +1 -242
@@ -570,13 +570,6 @@ static int aha1542_queuecommand_lck(Scsi_Cmnd * SCpnt, void (*done) (Scsi_Cmnd *if (*cmd ==REQUEST_SENSE ) {/* Don't do the command - we have the sense data already */ -#if 0 -/* scsi_request_sense() provides a buffer of size 256, -so there is no reason to expect equality */ -if (bufflen !=SCSI_SENSE_BUFFERSIZE ) -printk (KERN_CRIT "aha1542: Wrong buffer length supplied " -"for request sense (%d)\n" , bufflen); -#endif SCpnt->result =0 ;done (SCpnt);return 0 ;
@@ -1095,24 +1088,14 @@ static int aha1542_restart(struct Scsi_Host *shost) {int i;int count =0 ; -#if 0 -unchar ahacmd =CMD_START_SCSI ; -#endif for (i =0 ; i <AHA1542_MAILBOXES ; i++)if (HOSTDATA (shost)->SCint[i] && !(HOSTDATA (shost)->SCint[i]->device->soft_reset)) { -#if 0 -HOSTDATA (shost)->mb[i].status =1 ;/* Indicate ready to restart... */ -#endif count++; }printk (KERN_DEBUG "Potential to restart %d stalled commands...\n" , count); -#if 0 -/* start scsi command */ -if (count) -aha1542_out (shost->io_port, &ahacmd,1 ); -#endif +return 0 ; }
@@ -1177,39 +1160,6 @@ static int aha1542_dev_reset(Scsi_Cmnd * SCpnt) "Trying device reset for target\n");return SUCCESS ; - - -#ifdef ERIC_neverdef -/* -* With the 1542 we apparently never get an interrupt to -* acknowledge a device reset being sent. Then again, Leonard -* says we are doing this wrong in the first place... -* -* Take a wait and see attitude. If we get spurious interrupts, -* then the device reset is doing something sane and useful, and -* we will wait for the interrupt to post completion. -*/ -printk (KERN_WARNING "Sent BUS DEVICE RESET to target %d\n" , SCpnt->target); - -/* -* Free the command block for all commands running on this -* target... -*/ -for (i =0 ; i <AHA1542_MAILBOXES ; i++) { -if (HOSTDATA (SCpnt->host)->SCint[i] && -HOSTDATA (SCpnt->host)->SCint[i]->target == SCpnt->target) { -Scsi_Cmnd *SCtmp; - SCtmp =HOSTDATA (SCpnt->host)->SCint[i]; -kfree (SCtmp->host_scribble); - SCtmp->host_scribble =NULL ; -HOSTDATA (SCpnt->host)->SCint[i] =NULL ; -HOSTDATA (SCpnt->host)->mb[i].status =0 ; - } - } -return SUCCESS ; - -return FAILED ; -#endif /* ERIC_neverdef */ }static int aha1542_bus_reset (Scsi_Cmnd * SCpnt)
@@ -1344,197 +1294,6 @@ fail:return FAILED ; } -#if 0 -/* -* These are the old error handling routines. They are only temporarily -* here while we play with the new error handling code. -*/ -static int aha1542_old_abort (Scsi_Cmnd * SCpnt) -{ -#if 0 -unchar ahacmd =CMD_START_SCSI ; -unsigned long flags; -struct mailbox *mb; -int mbi, mbo, i; - -printk (KERN_DEBUG "In aha1542_abort: %x %x\n" , -inb (STATUS (SCpnt->host->io_port)), -inb (INTRFLAGS (SCpnt->host->io_port))); - -spin_lock_irqsave (&aha1542_lock, flags); - mb =HOSTDATA (SCpnt->host)->mb; - mbi =HOSTDATA (SCpnt->host)->aha1542_last_mbi_used +1 ; -if (mbi >=2 *AHA1542_MAILBOXES ) - mbi =AHA1542_MAILBOXES ; - -do { -if (mb[mbi].status !=0 ) -break ; - mbi++; -if (mbi >=2 *AHA1542_MAILBOXES ) - mbi =AHA1542_MAILBOXES ; - }while (mbi !=HOSTDATA (SCpnt->host)->aha1542_last_mbi_used); -spin_unlock_irqrestore (&aha1542_lock, flags); - -if (mb[mbi].status) { -printk (KERN_ERR "Lost interrupt discovered on irq %d - attempting to recover\n" , - SCpnt->host->irq); -aha1542_intr_handle (SCpnt->host,NULL ); -return 0 ; - } -/* OK, no lost interrupt. Try looking to see how many pending commands -we think we have. */ - -for (i =0 ; i <AHA1542_MAILBOXES ; i++) -if (HOSTDATA (SCpnt->host)->SCint[i]) { -if (HOSTDATA (SCpnt->host)->SCint[i] == SCpnt) { -printk (KERN_ERR "Timed out command pending for %s\n" , - SCpnt->request->rq_disk ? - SCpnt->request->rq_disk->disk_name :"?" - ); -if (HOSTDATA (SCpnt->host)->mb[i].status) { -printk (KERN_ERR "OGMB still full - restarting\n" ); -aha1542_out (SCpnt->host->io_port, &ahacmd,1 ); - }; - }else -printk (KERN_ERR "Other pending command %s\n" , - SCpnt->request->rq_disk ? - SCpnt->request->rq_disk->disk_name :"?" - ); - } -#endif - -DEB (printk ("aha1542_abort\n" )); -#if 0 -spin_lock_irqsave (&aha1542_lock, flags); -for (mbo =0 ; mbo <AHA1542_MAILBOXES ; mbo++) { -if (SCpnt ==HOSTDATA (SCpnt->host)->SCint[mbo]) { - mb[mbo].status =2 ;/* Abort command */ -aha1542_out (SCpnt->host->io_port, &ahacmd,1 );/* start scsi command */ -spin_unlock_irqrestore (&aha1542_lock, flags); -break ; - } - } -if (AHA1542_MAILBOXES == mbo) -spin_unlock_irqrestore (&aha1542_lock, flags); -#endif -return SCSI_ABORT_SNOOZE ; -} - -/* We do not implement a reset function here, but the upper level code -assumes that it will get some kind of response for the command in -SCpnt. We must oblige, or the command will hang the scsi system. -For a first go, we assume that the 1542 notifies us with all of the -pending commands (it does implement soft reset, after all). */ - -static int aha1542_old_reset (Scsi_Cmnd * SCpnt,unsigned int reset_flags) -{ -unchar ahacmd =CMD_START_SCSI ; -int i; - -/* -* See if a bus reset was suggested. -*/ -if (reset_flags &SCSI_RESET_SUGGEST_BUS_RESET ) { -/* -* This does a scsi reset for all devices on the bus. -* In principle, we could also reset the 1542 - should -* we do this? Try this first, and we can add that later -* if it turns out to be useful. -*/ -outb (HRST |SCRST ,CONTROL (SCpnt->host->io_port)); - -/* -* Wait for the thing to settle down a bit. Unfortunately -* this is going to basically lock up the machine while we -* wait for this to complete. To be 100% correct, we need to -* check for timeout, and if we are doing something like this -* we are pretty desperate anyways. -*/ -WAIT (STATUS (SCpnt->host->io_port), -STATMASK ,INIT |IDLE ,STST |DIAGF |INVDCMD |DF |CDF ); - -/* -* We need to do this too before the 1542 can interact with -* us again. -*/ -setup_mailboxes (SCpnt->host->io_port, SCpnt->host); - -/* -* Now try to pick up the pieces. Restart all commands -* that are currently active on the bus, and reset all of -* the datastructures. We have some time to kill while -* things settle down, so print a nice message. -*/ -printk (KERN_WARNING "Sent BUS RESET to scsi host %d\n" , SCpnt->host->host_no); - -for (i =0 ; i <AHA1542_MAILBOXES ; i++) -if (HOSTDATA (SCpnt->host)->SCint[i] !=NULL ) { -Scsi_Cmnd *SCtmp; - SCtmp =HOSTDATA (SCpnt->host)->SCint[i]; - SCtmp->result =DID_RESET <<16 ; -kfree (SCtmp->host_scribble); - SCtmp->host_scribble =NULL ; -printk (KERN_WARNING "Sending DID_RESET for target %d\n" , SCpnt->target); - SCtmp->scsi_done (SCpnt); - -HOSTDATA (SCpnt->host)->SCint[i] =NULL ; -HOSTDATA (SCpnt->host)->mb[i].status =0 ; - } -/* -* Now tell the mid-level code what we did here. Since -* we have restarted all of the outstanding commands, -* then report SUCCESS. -*/ -return (SCSI_RESET_SUCCESS |SCSI_RESET_BUS_RESET ); -fail: -printk (KERN_CRIT "aha1542.c: Unable to perform hard reset.\n" ); -printk (KERN_CRIT "Power cycle machine to reset\n" ); -return (SCSI_RESET_ERROR |SCSI_RESET_BUS_RESET ); - - - }else { -/* This does a selective reset of just the one device */ -/* First locate the ccb for this command */ -for (i =0 ; i <AHA1542_MAILBOXES ; i++) -if (HOSTDATA (SCpnt->host)->SCint[i] == SCpnt) { -HOSTDATA (SCpnt->host)->ccb[i].op =0x81 ;/* BUS DEVICE RESET */ -/* Now tell the 1542 to flush all pending commands for this target */ -aha1542_out (SCpnt->host->io_port, &ahacmd,1 ); - -/* Here is the tricky part. What to do next. Do we get an interrupt -for the commands that we aborted with the specified target, or -do we generate this on our own? Try it without first and see -what happens */ -printk (KERN_WARNING "Sent BUS DEVICE RESET to target %d\n" , SCpnt->target); - -/* If the first does not work, then try the second. I think the -first option is more likely to be correct. Free the command -block for all commands running on this target... */ -for (i =0 ; i <AHA1542_MAILBOXES ; i++) -if (HOSTDATA (SCpnt->host)->SCint[i] && -HOSTDATA (SCpnt->host)->SCint[i]->target == SCpnt->target) { -Scsi_Cmnd *SCtmp; - SCtmp =HOSTDATA (SCpnt->host)->SCint[i]; - SCtmp->result =DID_RESET <<16 ; -kfree (SCtmp->host_scribble); - SCtmp->host_scribble =NULL ; -printk (KERN_WARNING "Sending DID_RESET for target %d\n" , SCpnt->target); - SCtmp->scsi_done (SCpnt); - -HOSTDATA (SCpnt->host)->SCint[i] =NULL ; -HOSTDATA (SCpnt->host)->mb[i].status =0 ; - } -return SCSI_RESET_SUCCESS ; - } - } -/* No active command at this time, so this means that each time we got -some kind of response the last time through. Tell the mid-level code -to request sense information in order to decide what to do next. */ -return SCSI_RESET_PUNT ; -} -#endif /* end of big comment block around old_abort + old_reset */ -static int aha1542_biosparam (struct scsi_device *sdev,struct block_device *bdev,sector_t capacity,int *ip) {
drivers/scsi/aha1542.h +0 -6
@@ -100,12 +100,6 @@ static inline void any2scsi(u8 *p, u32 v)#define scsi2int (up) ( (((long)*(up)) << 16) + (((long)(up)[1]) << 8) + ((long)(up)[2]) ) -#define xany2scsi (up, p) \ -(up)[0] = ((long)(p)) >> 24; \ -(up)[1] = ((long)(p)) >> 16; \ -(up)[2] = ((long)(p)) >> 8; \ -(up)[3] = ((long)(p)); -#define xscsi2int (up) ( (((long)(up)[0]) << 24) + (((long)(up)[1]) << 16) \ + (((long)(up)[2]) << 8) + ((long)(up)[3]) )
Signature · 1 line
Ondrej Zary
PATCH 3/36 aha1542: Remove SCSI_BUF_PA, SCSI_SG_PA, AHA1542_SCATTER and AHA1542_CMDLUN
In reply to Ondrej ZaryRemove SCSI_BUF_PA, SCSI_SG_PA, AHA1542_SCATTER and AHA1542_CMDLUN macros
--- drivers/scsi/aha1542.c | 23 ++++++++++------------- drivers/scsi/aha1542.h | 2 -- 2 files changed, 10 insertions(+), 15 deletions(-)
drivers/scsi/aha1542.c +10 -13
@@ -46,10 +46,6 @@#include "scsi.h" #include <scsi/scsi_host.h> #include "aha1542.h" - -#define SCSI_BUF_PA (address) isa_virt_to_bus(address) -#define SCSI_SG_PA (sgent) (isa_page_to_bus(sg_page((sgent))) + (sgent)->offset) -#include <linux/stat.h> #ifdef DEBUG
@@ -463,7 +459,7 @@ static void aha1542_intr_handle(struct Scsi_Host *shost)return ; }; - mbo = (scsi2int (mb[mbi].ccbptr) - (SCSI_BUF_PA (&ccb[0 ]))) /sizeof (struct ccb ); + mbo = (scsi2int (mb[mbi].ccbptr) - (isa_virt_to_bus (&ccb[0 ]))) /sizeof (struct ccb ); mbistatus = mb[mbi].status; mb[mbi].status =0 ;HOSTDATA (shost)->aha1542_last_mbi_used = mbi;
@@ -622,7 +618,7 @@ static int aha1542_queuecommand_lck(Scsi_Cmnd * SCpnt, void (*done) (Scsi_Cmnd *printk (KERN_DEBUG "Sending command (%d %x)..." , mbo, done);#endif -any2scsi (mb[mbo].ccbptr,SCSI_BUF_PA (&ccb[mbo]));/* This gets trashed for some reason */ +any2scsi (mb[mbo].ccbptr,isa_virt_to_bus (&ccb[mbo]));/* This gets trashed for some reason */ memset (&ccb[mbo],0 ,sizeof (struct ccb ));
@@ -653,11 +649,12 @@ static int aha1542_queuecommand_lck(Scsi_Cmnd * SCpnt, void (*done) (Scsi_Cmnd *return SCSI_MLQUEUE_HOST_BUSY ; }scsi_for_each_sg (SCpnt, sg, sg_count, i) { -any2scsi (cptr[i].dataptr,SCSI_SG_PA (sg)); +any2scsi (cptr[i].dataptr,isa_page_to_bus (sg_page (sg)) + + sg->offset);any2scsi (cptr[i].datalen, sg->length); };any2scsi (ccb[mbo].datalen, sg_count *sizeof (struct chain )); -any2scsi (ccb[mbo].dataptr,SCSI_BUF_PA (cptr)); +any2scsi (ccb[mbo].dataptr,isa_virt_to_bus (cptr));#ifdef DEBUG printk ("cptr %x: " , cptr); ptr = (unsigned char *) cptr;
@@ -713,10 +710,10 @@ static void setup_mailboxes(int bse, struct Scsi_Host *shpnt)for (i =0 ; i <AHA1542_MAILBOXES ; i++) { mb[i].status = mb[AHA1542_MAILBOXES + i].status =0 ; -any2scsi (mb[i].ccbptr,SCSI_BUF_PA (&ccb[i])); +any2scsi (mb[i].ccbptr,isa_virt_to_bus (&ccb[i])); };aha1542_intr_reset (bse);/* reset interrupts, so they don't block */ -any2scsi ((cmd +2 ),SCSI_BUF_PA (mb)); +any2scsi ((cmd +2 ),isa_virt_to_bus (mb));aha1542_out (bse, cmd,5 );WAIT (INTRFLAGS (bse),INTRMASK ,HACC ,0 );while (0 ) {
@@ -1139,7 +1136,7 @@ static int aha1542_dev_reset(Scsi_Cmnd * SCpnt)HOSTDATA (SCpnt->device->host)->aha1542_last_mbo_used = mbo;spin_unlock_irqrestore (&aha1542_lock, flags); -any2scsi (mb[mbo].ccbptr,SCSI_BUF_PA (&ccb[mbo]));/* This gets trashed for some reason */ +any2scsi (mb[mbo].ccbptr,isa_virt_to_bus (&ccb[mbo]));/* This gets trashed for some reason */ memset (&ccb[mbo],0 ,sizeof (struct ccb ));
@@ -1328,8 +1325,8 @@ static struct scsi_host_template driver_template = { .bios_param = aha1542_biosparam, .can_queue = AHA1542_MAILBOXES, .this_id = 7, - .sg_tablesize = AHA1542_SCATTER, - .cmd_per_lun = AHA1542_CMDLUN, + .sg_tablesize = 16, + .cmd_per_lun = 1, .unchecked_isa_dma = 1, .use_clustering = ENABLE_CLUSTERING, };
drivers/scsi/aha1542.h +0 -2
@@ -138,7 +138,5 @@ static int aha1542_biosparam(struct scsi_device *, struct block_device *, sector_t, int *);#define AHA1542_MAILBOXES 8 -#define AHA1542_SCATTER 16 -#define AHA1542_CMDLUN 1#endif
Signature · 1 line
Ondrej Zary
PATCH 4/36 aha1542: Remove HOSTDATA macro
In reply to Ondrej ZaryRemove HOSTDATA macro and use shost_priv instead
--- drivers/scsi/aha1542.c | 114 +++++++++++++++++++++++------------------------- 1 file changed, 55 insertions(+), 59 deletions(-)
drivers/scsi/aha1542.c +55 -59
@@ -118,8 +118,6 @@ struct aha1542_hostdata {struct ccb ccb[AHA1542_MAILBOXES ]; }; -#define HOSTDATA (host) ((struct aha1542_hostdata *) &host->hostdata) -static DEFINE_SPINLOCK (aha1542_lock);
@@ -382,6 +380,7 @@ static irqreturn_t do_aha1542_intr_handle(int dummy, void *dev_id)/* A "high" level interrupt handler */ static void aha1542_intr_handle (struct Scsi_Host *shost) { +struct aha1542_hostdata *aha1542 =shost_priv (shost);void (*my_done) (Scsi_Cmnd *) =NULL ;int errstatus, mbi, mbo, mbistatus;int number_serviced;
@@ -389,11 +388,8 @@ static void aha1542_intr_handle(struct Scsi_Host *shost)Scsi_Cmnd *SCtmp;int flag;int needs_restart; -struct mailbox *mb; -struct ccb *ccb; - - mb =HOSTDATA (shost)->mb; - ccb =HOSTDATA (shost)->ccb; +struct mailbox *mb = aha1542->mb; +struct ccb *ccb = aha1542->ccb;#ifdef DEBUG {
@@ -435,7 +431,7 @@ static void aha1542_intr_handle(struct Scsi_Host *shost)aha1542_intr_reset (shost->io_port);spin_lock_irqsave (&aha1542_lock, flags); - mbi =HOSTDATA (shost)->aha1542_last_mbi_used +1 ; + mbi = aha1542->aha1542_last_mbi_used +1 ;if (mbi >=2 *AHA1542_MAILBOXES ) mbi =AHA1542_MAILBOXES ;
@@ -445,7 +441,7 @@ static void aha1542_intr_handle(struct Scsi_Host *shost) mbi++;if (mbi >=2 *AHA1542_MAILBOXES ) mbi =AHA1542_MAILBOXES ; - }while (mbi !=HOSTDATA (shost)->aha1542_last_mbi_used); + }while (mbi != aha1542->aha1542_last_mbi_used);if (mb[mbi].status ==0 ) {spin_unlock_irqrestore (&aha1542_lock, flags);
@@ -462,7 +458,7 @@ static void aha1542_intr_handle(struct Scsi_Host *shost) mbo = (scsi2int (mb[mbi].ccbptr) - (isa_virt_to_bus (&ccb[0 ]))) /sizeof (struct ccb ); mbistatus = mb[mbi].status; mb[mbi].status =0 ; -HOSTDATA (shost)->aha1542_last_mbi_used = mbi; + aha1542->aha1542_last_mbi_used = mbi;spin_unlock_irqrestore (&aha1542_lock, flags);#ifdef DEBUG
@@ -480,7 +476,7 @@ static void aha1542_intr_handle(struct Scsi_Host *shost)printk (KERN_DEBUG "...done %d %d\n" , mbo, mbi);#endif - SCtmp =HOSTDATA (shost)->SCint[mbo]; + SCtmp = aha1542->SCint[mbo];if (!SCtmp || !SCtmp->scsi_done) {printk (KERN_WARNING "aha1542_intr_handle: Unexpected interrupt\n" );
@@ -533,8 +529,8 @@ static void aha1542_intr_handle(struct Scsi_Host *shost) } DEB(if (errstatus) printk("aha1542_intr_handle: returning %6x\n", errstatus)); SCtmp->result = errstatus; -HOSTDATA (shost)->SCint[mbo] =NULL ;/* This effectively frees up the mailbox slot, as -far as queuecommand is concerned */ + aha1542->SCint[mbo] =NULL ;/* This effectively frees up the mailbox slot, as +far as queuecommand is concerned */ my_done (SCtmp); number_serviced++; };
@@ -542,6 +538,7 @@ static void aha1542_intr_handle(struct Scsi_Host *shost)static int aha1542_queuecommand_lck (Scsi_Cmnd * SCpnt,void (*done) (Scsi_Cmnd *)) { +struct aha1542_hostdata *aha1542 =shost_priv (SCpnt->device->host);unchar ahacmd =CMD_START_SCSI ;unchar direction;unchar *cmd = (unchar *) SCpnt->cmnd;
@@ -550,14 +547,11 @@ static int aha1542_queuecommand_lck(Scsi_Cmnd * SCpnt, void (*done) (Scsi_Cmnd *unsigned long flags;int bufflen =scsi_bufflen (SCpnt);int mbo; -struct mailbox *mb; -struct ccb *ccb; +struct mailbox *mb = aha1542->mb; +struct ccb *ccb = aha1542->ccb; DEB(int i); - mb =HOSTDATA (SCpnt->device->host)->mb; - ccb =HOSTDATA (SCpnt->device->host)->ccb; - DEB(if (target > 1) { SCpnt->result = DID_TIME_OUT << 16; done(SCpnt); return 0;
@@ -593,25 +587,25 @@ static int aha1542_queuecommand_lck(Scsi_Cmnd * SCpnt, void (*done) (Scsi_Cmnd *is how the host adapter will scan for them */ spin_lock_irqsave (&aha1542_lock, flags); - mbo =HOSTDATA (SCpnt->device->host)->aha1542_last_mbo_used +1 ; + mbo = aha1542->aha1542_last_mbo_used +1 ;if (mbo >=AHA1542_MAILBOXES ) mbo =0 ;do { -if (mb[mbo].status ==0 &&HOSTDATA (SCpnt->device->host)->SCint[mbo] ==NULL ) +if (mb[mbo].status ==0 && aha1542->SCint[mbo] ==NULL )break ; mbo++;if (mbo >=AHA1542_MAILBOXES ) mbo =0 ; - }while (mbo !=HOSTDATA (SCpnt->device->host)->aha1542_last_mbo_used); + }while (mbo != aha1542->aha1542_last_mbo_used); -if (mb[mbo].status ||HOSTDATA (SCpnt->device->host)->SCint[mbo]) +if (mb[mbo].status || aha1542->SCint[mbo])panic ("Unable to find empty mailbox for aha1542.\n" ); -HOSTDATA (SCpnt->device->host)->SCint[mbo] = SCpnt;/* This will effectively prevent someone else from -screwing with this cdb. */ + aha1542->SCint[mbo] = SCpnt;/* This will effectively prevent someone else from +screwing with this cdb. */ -HOSTDATA (SCpnt->device->host)->aha1542_last_mbo_used = mbo; + aha1542->aha1542_last_mbo_used = mbo;spin_unlock_irqrestore (&aha1542_lock, flags);#ifdef DEBUG
@@ -645,7 +639,7 @@ static int aha1542_queuecommand_lck(Scsi_Cmnd * SCpnt, void (*done) (Scsi_Cmnd * cptr = (struct chain *) SCpnt->host_scribble;if (cptr ==NULL ) {/* free the claimed mailbox slot */ -HOSTDATA (SCpnt->device->host)->SCint[mbo] =NULL ; + aha1542->SCint[mbo] =NULL ;return SCSI_MLQUEUE_HOST_BUSY ; }scsi_for_each_sg (SCpnt, sg, sg_count, i) {
@@ -699,15 +693,13 @@ static DEF_SCSI_QCMD(aha1542_queuecommand)/* Initialize mailboxes */ static void setup_mailboxes (int bse,struct Scsi_Host *shpnt) { +struct aha1542_hostdata *aha1542 =shost_priv (shpnt);int i; -struct mailbox *mb; -struct ccb *ccb; +struct mailbox *mb = aha1542->mb; +struct ccb *ccb = aha1542->ccb;unchar cmd[5 ] = {CMD_MBINIT ,AHA1542_MAILBOXES ,0 ,0 ,0 }; - mb =HOSTDATA (shpnt)->mb; - ccb =HOSTDATA (shpnt)->ccb; -for (i =0 ; i <AHA1542_MAILBOXES ; i++) { mb[i].status = mb[AHA1542_MAILBOXES + i].status =0 ;any2scsi (mb[i].ccbptr,isa_virt_to_bus (&ccb[i]));
@@ -951,6 +943,7 @@ static struct Scsi_Host *aha1542_hw_init(struct scsi_host_template *tpnt, structunsigned int base_io;int trans;struct Scsi_Host *shpnt =NULL ; +struct aha1542_hostdata *aha1542;DEB (printk ("aha1542_detect: \n" ));
@@ -964,6 +957,7 @@ static struct Scsi_Host *aha1542_hw_init(struct scsi_host_template *tpnt, structrelease_region (bases[indx],4 );return NULL ; } + aha1542 =shost_priv (shpnt);if (!aha1542_test_port (bases[indx], shpnt)) goto unregister;
@@ -1040,12 +1034,12 @@ fail: shpnt->n_io_port =4 ;/* Number of bytes of I/O space used */ shpnt->dma_channel = dma_chan; shpnt->irq = irq_level; -HOSTDATA (shpnt)->bios_translation = trans; + aha1542->bios_translation = trans;if (trans ==BIOS_TRANSLATION_25563 )printk (KERN_INFO "aha1542.c: Using extended bios translation\n" ); -HOSTDATA (shpnt)->aha1542_last_mbi_used = (2 *AHA1542_MAILBOXES -1 ); -HOSTDATA (shpnt)->aha1542_last_mbo_used = (AHA1542_MAILBOXES -1 ); -memset (HOSTDATA (shpnt)->SCint,0 ,sizeof (HOSTDATA (shpnt)->SCint)); + aha1542->aha1542_last_mbi_used = (2 *AHA1542_MAILBOXES -1 ); + aha1542->aha1542_last_mbo_used = (AHA1542_MAILBOXES -1 ); +memset (aha1542->SCint,0 ,sizeof (aha1542->SCint));spin_unlock_irqrestore (&aha1542_lock, flags);if (scsi_add_host (shpnt, pdev)) {
@@ -1083,12 +1077,13 @@ static int aha1542_release(struct Scsi_Host *shost)static int aha1542_restart (struct Scsi_Host *shost) { +struct aha1542_hostdata *aha1542 =shost_priv (shost);int i;int count =0 ;for (i =0 ; i <AHA1542_MAILBOXES ; i++) -if (HOSTDATA (shost)->SCint[i] && - !(HOSTDATA (shost)->SCint[i]->device->soft_reset)) { +if (aha1542->SCint[i] && + !(aha1542->SCint[i]->device->soft_reset)) { count++; }printk (KERN_DEBUG "Potential to restart %d stalled commands...\n" , count);
@@ -1102,38 +1097,36 @@ static int aha1542_restart(struct Scsi_Host *shost)*/ static int aha1542_dev_reset (Scsi_Cmnd * SCpnt) { +struct aha1542_hostdata *aha1542 =shost_priv (SCpnt->device->host);unsigned long flags; -struct mailbox *mb; +struct mailbox *mb = aha1542->mb;unchar target = SCpnt->device->id;unchar lun = SCpnt->device->lun;int mbo; -struct ccb *ccb; +struct ccb *ccb = aha1542->ccb;unchar ahacmd =CMD_START_SCSI ; - ccb =HOSTDATA (SCpnt->device->host)->ccb; - mb =HOSTDATA (SCpnt->device->host)->mb; -spin_lock_irqsave (&aha1542_lock, flags); - mbo =HOSTDATA (SCpnt->device->host)->aha1542_last_mbo_used +1 ; + mbo = aha1542->aha1542_last_mbo_used +1 ;if (mbo >=AHA1542_MAILBOXES ) mbo =0 ;do { -if (mb[mbo].status ==0 &&HOSTDATA (SCpnt->device->host)->SCint[mbo] ==NULL ) +if (mb[mbo].status ==0 && aha1542->SCint[mbo] ==NULL )break ; mbo++;if (mbo >=AHA1542_MAILBOXES ) mbo =0 ; - }while (mbo !=HOSTDATA (SCpnt->device->host)->aha1542_last_mbo_used); + }while (mbo != aha1542->aha1542_last_mbo_used); -if (mb[mbo].status ||HOSTDATA (SCpnt->device->host)->SCint[mbo]) +if (mb[mbo].status || aha1542->SCint[mbo])panic ("Unable to find empty mailbox for aha1542.\n" ); -HOSTDATA (SCpnt->device->host)->SCint[mbo] = SCpnt;/* This will effectively -prevent someone else from -screwing with this cdb. */ + aha1542->SCint[mbo] = SCpnt;/* This will effectively +prevent someone else from +screwing with this cdb. */ -HOSTDATA (SCpnt->device->host)->aha1542_last_mbo_used = mbo; + aha1542->aha1542_last_mbo_used = mbo;spin_unlock_irqrestore (&aha1542_lock, flags);any2scsi (mb[mbo].ccbptr,isa_virt_to_bus (&ccb[mbo]));/* This gets trashed for some reason */
@@ -1161,6 +1154,7 @@ static int aha1542_dev_reset(Scsi_Cmnd * SCpnt)static int aha1542_bus_reset (Scsi_Cmnd * SCpnt) { +struct aha1542_hostdata *aha1542 =shost_priv (SCpnt->device->host);int i;/*
@@ -1194,9 +1188,9 @@ static int aha1542_bus_reset(Scsi_Cmnd * SCpnt)printk (KERN_WARNING "Sent BUS RESET to scsi host %d\n" , SCpnt->device->host->host_no);for (i =0 ; i <AHA1542_MAILBOXES ; i++) { -if (HOSTDATA (SCpnt->device->host)->SCint[i] !=NULL ) { +if (aha1542->SCint[i] !=NULL ) {Scsi_Cmnd *SCtmp; - SCtmp =HOSTDATA (SCpnt->device->host)->SCint[i]; + SCtmp = aha1542->SCint[i];if (SCtmp->device->soft_reset) {
@@ -1210,8 +1204,8 @@ static int aha1542_bus_reset(Scsi_Cmnd * SCpnt) }kfree (SCtmp->host_scribble); SCtmp->host_scribble =NULL ; -HOSTDATA (SCpnt->device->host)->SCint[i] =NULL ; -HOSTDATA (SCpnt->device->host)->mb[i].status =0 ; + aha1542->SCint[i] =NULL ; + aha1542->mb[i].status =0 ; } }
@@ -1225,6 +1219,7 @@ fail:static int aha1542_host_reset (Scsi_Cmnd * SCpnt) { +struct aha1542_hostdata *aha1542 =shost_priv (SCpnt->device->host);int i;/*
@@ -1263,9 +1258,9 @@ static int aha1542_host_reset(Scsi_Cmnd * SCpnt)printk (KERN_WARNING "Sent BUS RESET to scsi host %d\n" , SCpnt->device->host->host_no);for (i =0 ; i <AHA1542_MAILBOXES ; i++) { -if (HOSTDATA (SCpnt->device->host)->SCint[i] !=NULL ) { +if (aha1542->SCint[i] !=NULL ) {Scsi_Cmnd *SCtmp; - SCtmp =HOSTDATA (SCpnt->device->host)->SCint[i]; + SCtmp = aha1542->SCint[i];if (SCtmp->device->soft_reset) {/*
@@ -1278,8 +1273,8 @@ static int aha1542_host_reset(Scsi_Cmnd * SCpnt) }kfree (SCtmp->host_scribble); SCtmp->host_scribble =NULL ; -HOSTDATA (SCpnt->device->host)->SCint[i] =NULL ; -HOSTDATA (SCpnt->device->host)->mb[i].status =0 ; + aha1542->SCint[i] =NULL ; + aha1542->mb[i].status =0 ; } }
@@ -1294,10 +1289,11 @@ fail:static int aha1542_biosparam (struct scsi_device *sdev,struct block_device *bdev,sector_t capacity,int *ip) { +struct aha1542_hostdata *aha1542 =shost_priv (sdev->host);int translation_algorithm;int size = capacity; - translation_algorithm =HOSTDATA (sdev->host)->bios_translation; + translation_algorithm = aha1542->bios_translation;if ((size >>11 ) >1024 && translation_algorithm ==BIOS_TRANSLATION_25563 ) {/* Please verify that this is the same as what DOS returns */
Signature · 1 line
Ondrej Zary
PATCH 5/36 aha1542: Convert aha1542_intr_reset to function
In reply to Ondrej ZaryConvert aha1542_intr_reset macro to inline function
--- drivers/scsi/aha1542.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/scsi/aha1542.c +4 -1
@@ -128,7 +128,10 @@ static void setup_mailboxes(int base_io, struct Scsi_Host *shpnt);static int aha1542_restart (struct Scsi_Host *shost);static void aha1542_intr_handle (struct Scsi_Host *shost); -#define aha1542_intr_reset (base) outb(IRST, CONTROL(base)) +static inline void aha1542_intr_reset (u16 base) +{ +outb (IRST ,CONTROL (base)); +}#define WAIT (port, mask, allof, noneof) \ { register int WAITbits; \
Signature · 1 line
Ondrej Zary
PATCH 6/36 aha1542: Use u8 instead of unchar
In reply to Ondrej Zary--- drivers/scsi/aha1542.c | 50 ++++++++++++++++++++++++------------------------ drivers/scsi/aha1542.h | 42 ++++++++++++++++++++-------------------- 2 files changed, 46 insertions(+), 46 deletions(-)
drivers/scsi/aha1542.c +25 -25
@@ -168,7 +168,7 @@ static void aha1542_stat(void)routine does not send something out while we are in the middle of this. Fortunately, it is only at boot time that multi-byte messages are ever sent. */ -static int aha1542_out (unsigned int base,unchar * cmdp,int len) +static int aha1542_out (unsigned int base,u8 *cmdp,int len) {unsigned long flags =0 ;int got_lock;
@@ -207,7 +207,7 @@ fail:/* Only used at boot time, so we do not need to worry about latency as much here */ -static int aha1542_in (unsigned int base,unchar *cmdp,int len) +static int aha1542_in (unsigned int base,u8 *cmdp,int len) {unsigned long flags;
@@ -228,7 +228,7 @@ fail:/* Similar to aha1542_in, except that we wait a very short period of time. We use this if we know the board is alive and awake, but we are not sure if the board will respond to the command we are about to send or not */ -static int aha1542_in1 (unsigned int base,unchar *cmdp,int len) +static int aha1542_in1 (unsigned int base,u8 *cmdp,int len) {unsigned long flags;
@@ -302,9 +302,9 @@ static int makecode(unsigned hosterr, unsigned scsierr)static int aha1542_test_port (int bse,struct Scsi_Host *shpnt) { -unchar inquiry_cmd[] = {CMD_INQUIRY }; -unchar inquiry_result[4 ]; -unchar *cmdp; +u8 inquiry_cmd[] = {CMD_INQUIRY }; +u8 inquiry_result[4 ]; +u8 *cmdp;int len;volatile int debug =0 ;
@@ -542,11 +542,11 @@ static void aha1542_intr_handle(struct Scsi_Host *shost)static int aha1542_queuecommand_lck (Scsi_Cmnd * SCpnt,void (*done) (Scsi_Cmnd *)) {struct aha1542_hostdata *aha1542 =shost_priv (SCpnt->device->host); -unchar ahacmd =CMD_START_SCSI ; -unchar direction; -unchar *cmd = (unchar *) SCpnt->cmnd; -unchar target = SCpnt->device->id; -unchar lun = SCpnt->device->lun; +u8 ahacmd =CMD_START_SCSI ; +u8 direction; +u8 *cmd = (u8 *) SCpnt->cmnd; +u8 target = SCpnt->device->id; +u8 lun = SCpnt->device->lun;unsigned long flags;int bufflen =scsi_bufflen (SCpnt);int mbo;
@@ -674,7 +674,7 @@ static int aha1542_queuecommand_lck(Scsi_Cmnd * SCpnt, void (*done) (Scsi_Cmnd *int i;printk (KERN_DEBUG "aha1542_command: sending.. " );for (i =0 ; i <sizeof (ccb[mbo]) -10 ; i++) - printk("%02x ", ((unchar *) & ccb[mbo])[i]); + printk("%02x ", ((u8 *) &ccb[mbo])[i]); };#endif
@@ -701,7 +701,7 @@ static void setup_mailboxes(int bse, struct Scsi_Host *shpnt)struct mailbox *mb = aha1542->mb;struct ccb *ccb = aha1542->ccb; -unchar cmd[5 ] = {CMD_MBINIT ,AHA1542_MAILBOXES ,0 ,0 ,0 }; +u8 cmd[5 ] = {CMD_MBINIT ,AHA1542_MAILBOXES ,0 ,0 ,0 };for (i =0 ; i <AHA1542_MAILBOXES ; i++) { mb[i].status = mb[AHA1542_MAILBOXES + i].status =0 ;
@@ -720,8 +720,8 @@ fail:static int aha1542_getconfig (int base_io,unsigned char *irq_level,unsigned char *dma_chan,unsigned char *scsi_id) { -unchar inquiry_cmd[] = {CMD_RETCONF }; -unchar inquiry_result[3 ]; +u8 inquiry_cmd[] = {CMD_RETCONF }; +u8 inquiry_result[3 ];int i; i =inb (STATUS (base_io));if (i &DF ) {
@@ -789,8 +789,8 @@ fail:static int aha1542_mbenable (int base) { -static unchar mbenable_cmd[3 ]; -static unchar mbenable_result[2 ]; +static u8 mbenable_cmd[3 ]; +static u8 mbenable_result[2 ];int retval; retval =BIOS_TRANSLATION_6432 ;
@@ -824,8 +824,8 @@ fail:/* Query the board to find out if it is a 1542 or a 1740, or whatever. */ static int aha1542_query (int base_io,int *transl) { -unchar inquiry_cmd[] = {CMD_INQUIRY }; -unchar inquiry_result[4 ]; +u8 inquiry_cmd[] = {CMD_INQUIRY }; +u8 inquiry_result[4 ];int i; i =inb (STATUS (base_io));if (i &DF ) {
@@ -968,8 +968,8 @@ static struct Scsi_Host *aha1542_hw_init(struct scsi_host_template *tpnt, struct/* Set the Bus on/off-times as not to ruin floppy performance */ { -unchar oncmd[] = {CMD_BUSON_TIME ,7 }; -unchar offcmd[] = {CMD_BUSOFF_TIME ,5 }; +u8 oncmd[] = {CMD_BUSON_TIME ,7 }; +u8 offcmd[] = {CMD_BUSOFF_TIME ,5 };if (setup_called[indx]) { oncmd[1 ] = setup_buson[indx];
@@ -982,7 +982,7 @@ static struct Scsi_Host *aha1542_hw_init(struct scsi_host_template *tpnt, structaha1542_out (base_io, offcmd,2 );WAIT (INTRFLAGS (base_io),INTRMASK ,HACC ,0 );if (setup_dmaspeed[indx] >=0 ) { -unchar dmacmd[] = {CMD_DMASPEED ,0 }; +u8 dmacmd[] = {CMD_DMASPEED ,0 }; dmacmd[1 ] = setup_dmaspeed[indx];aha1542_intr_reset (base_io);aha1542_out (base_io, dmacmd,2 );
@@ -1103,11 +1103,11 @@ static int aha1542_dev_reset(Scsi_Cmnd * SCpnt)struct aha1542_hostdata *aha1542 =shost_priv (SCpnt->device->host);unsigned long flags;struct mailbox *mb = aha1542->mb; -unchar target = SCpnt->device->id; -unchar lun = SCpnt->device->lun; +u8 target = SCpnt->device->id; +u8 lun = SCpnt->device->lun;int mbo;struct ccb *ccb = aha1542->ccb; -unchar ahacmd =CMD_START_SCSI ; +u8 ahacmd =CMD_START_SCSI ;spin_lock_irqsave (&aha1542_lock, flags); mbo = aha1542->aha1542_last_mbo_used +1 ;
drivers/scsi/aha1542.h +21 -21
58 lines not on this page · raw message
Signature · 1 line
Ondrej Zary
PATCH 7/36 aha1542: Reorder functions to remove forward declarations
In reply to Ondrej Zary--- drivers/scsi/aha1542.c | 51 +++++++++++++++++++++++------------------------- drivers/scsi/aha1542.h | 12 ------------ 2 files changed, 24 insertions(+), 39 deletions(-)
drivers/scsi/aha1542.c +24 -27
@@ -124,10 +124,6 @@ static DEFINE_SPINLOCK(aha1542_lock);#define WAITnexttimeout 3000000 -static void setup_mailboxes (int base_io,struct Scsi_Host *shpnt); -static int aha1542_restart (struct Scsi_Host *shost); -static void aha1542_intr_handle (struct Scsi_Host *shost); -static inline void aha1542_intr_reset (u16 base) {outb (IRST ,CONTROL (base));
@@ -368,16 +364,20 @@ fail:return 0 ;/* 0 = not ok */ } -/* A quick wrapper for do_aha1542_intr_handle to grab the spin lock */ -static irqreturn_t do_aha1542_intr_handle (int dummy,void *dev_id) +static int aha1542_restart (struct Scsi_Host *shost) { -unsigned long flags; -struct Scsi_Host *shost = dev_id; +struct aha1542_hostdata *aha1542 =shost_priv (shost); +int i; +int count =0 ; -spin_lock_irqsave (shost->host_lock, flags); -aha1542_intr_handle (shost); -spin_unlock_irqrestore (shost->host_lock, flags); -return IRQ_HANDLED ; +for (i =0 ; i <AHA1542_MAILBOXES ; i++) +if (aha1542->SCint[i] && + !(aha1542->SCint[i]->device->soft_reset)) { + count++; + } +printk (KERN_DEBUG "Potential to restart %d stalled commands...\n" , count); + +return 0 ; }/* A "high" level interrupt handler */
@@ -539,6 +539,18 @@ static void aha1542_intr_handle(struct Scsi_Host *shost) }; } +/* A quick wrapper for do_aha1542_intr_handle to grab the spin lock */ +static irqreturn_t do_aha1542_intr_handle (int dummy,void *dev_id) +{ +unsigned long flags; +struct Scsi_Host *shost = dev_id; + +spin_lock_irqsave (shost->host_lock, flags); +aha1542_intr_handle (shost); +spin_unlock_irqrestore (shost->host_lock, flags); +return IRQ_HANDLED ; +} +static int aha1542_queuecommand_lck (Scsi_Cmnd * SCpnt,void (*done) (Scsi_Cmnd *)) {struct aha1542_hostdata *aha1542 =shost_priv (SCpnt->device->host);
@@ -1078,21 +1090,6 @@ static int aha1542_release(struct Scsi_Host *shost)return 0 ; } -static int aha1542_restart (struct Scsi_Host *shost) -{ -struct aha1542_hostdata *aha1542 =shost_priv (shost); -int i; -int count =0 ; - -for (i =0 ; i <AHA1542_MAILBOXES ; i++) -if (aha1542->SCint[i] && - !(aha1542->SCint[i]->device->soft_reset)) { - count++; - } -printk (KERN_DEBUG "Potential to restart %d stalled commands...\n" , count); - -return 0 ; -}/* * This is a device reset. This is handled by sending a special command
drivers/scsi/aha1542.h +0 -12
@@ -125,18 +125,6 @@ struct ccb { /* Command Control Block 5.3 */ /* REQUEST SENSE */ }; -static struct Scsi_Host *aha1542_hw_init (struct scsi_host_template *tpnt,struct device *pdev,int indx); -static int aha1542_queuecommand (struct Scsi_Host *,struct scsi_cmnd *); -static int aha1542_bus_reset (Scsi_Cmnd * SCpnt); -static int aha1542_dev_reset (Scsi_Cmnd * SCpnt); -static int aha1542_host_reset (Scsi_Cmnd * SCpnt); -#if 0 -static int aha1542_old_abort (Scsi_Cmnd * SCpnt); -static int aha1542_old_reset (Scsi_Cmnd *,unsigned int ); -#endif -static int aha1542_biosparam (struct scsi_device *,struct block_device *, -sector_t ,int *); -#define AHA1542_MAILBOXES 8#endif
Signature · 1 line
Ondrej Zary
PATCH 8/36 aha1542: remove empty aha1542_stat
In reply to Ondrej Zary--- drivers/scsi/aha1542.c | 16 +--------------- 1 file changed, 1 insertion(+), 15 deletions(-)
drivers/scsi/aha1542.c +1 -15
@@ -154,12 +154,6 @@ static inline void aha1542_intr_reset(u16 base) } \ } -static void aha1542_stat (void ) -{ -/* int s = inb(STATUS), i = inb(INTRFLAGS); -printk("status=%x intrflags=%x\n", s, i, WAITnexttimeout-WAITtimeout); */ -} -/* This is a bit complicated, but we need to make sure that an interrupt routine does not send something out while we are in the middle of this. Fortunately, it is only at boot time that multi-byte messages
@@ -196,7 +190,6 @@ fail:if (got_lock)spin_unlock_irqrestore (&aha1542_lock, flags);printk (KERN_ERR "aha1542_out failed(%d): " , len +1 ); -aha1542_stat ();return 1 ; }
@@ -217,7 +210,6 @@ static int aha1542_in(unsigned int base, u8 *cmdp, int len) fail:spin_unlock_irqrestore (&aha1542_lock, flags);printk (KERN_ERR "aha1542_in failed(%d): " , len +1 ); -aha1542_stat ();return 1 ; }
@@ -590,7 +582,6 @@ static int aha1542_queuecommand_lck(Scsi_Cmnd * SCpnt, void (*done) (Scsi_Cmnd *printk (KERN_DEBUG "aha1542_queuecommand: dev %d cmd %02x pos %d len %d " , target, *cmd, i, bufflen); else printk(KERN_DEBUG "aha1542_command: dev %d cmd %02x pos %d len %d ", target, *cmd, i, bufflen); -aha1542_stat ();printk (KERN_DEBUG "aha1542_queuecommand: dumping scsi cmd:" );for (i =0 ; i < SCpnt->cmd_len; i++)printk ("%02x " , cmd[i]);
@@ -691,12 +682,10 @@ static int aha1542_queuecommand_lck(Scsi_Cmnd * SCpnt, void (*done) (Scsi_Cmnd *#endif if (done) { - DEB(printk("aha1542_queuecommand: now waiting for interrupt "); -aha1542_stat ()); +DEB (printk ("aha1542_queuecommand: now waiting for interrupt " )); SCpnt->scsi_done = done; mb[mbo].status =1 ;aha1542_out (SCpnt->device->host->io_port, &ahacmd,1 );/* start scsi command */ -DEB (aha1542_stat ()); }else printk ("aha1542_queuecommand: done can't be NULL\n" );
@@ -1017,11 +1006,8 @@ fail:printk (", DMA priority %d" , dma_chan);printk ("\n" ); -DEB (aha1542_stat ());setup_mailboxes (base_io, shpnt); -DEB (aha1542_stat ()); -DEB (printk ("aha1542_detect: enable interrupt channel %d\n" , irq_level));spin_lock_irqsave (&aha1542_lock, flags); if (request_irq(irq_level, do_aha1542_intr_handle, 0,
Signature · 1 line
Ondrej Zary
PATCH 9/36 aha1542: Use BIT() macro
In reply to Ondrej Zary--- drivers/scsi/aha1542.h | 37 +++++++++++++++++++------------------ 1 file changed, 19 insertions(+), 18 deletions(-)
drivers/scsi/aha1542.h +19 -18
@@ -36,29 +36,30 @@/* I/O Port interface 4.2 */ /* READ */ #define STATUS (base) base -#define STST 0x80/* Self Test in Progress */ -#define DIAGF 0x40/* Internal Diagnostic Failure */ -#define INIT 0x20/* Mailbox Initialization Required */ -#define IDLE 0x10/* SCSI Host Adapter Idle */ -#define CDF 0x08/* Command/Data Out Port Full */ -#define DF 0x04/* Data In Port Full */ -#define INVDCMD 0x01/* Invalid H A Command */ -#define STATMASK 0xfd/* 0x02 is reserved */ +#define STST BIT(7)/* Self Test in Progress */ +#define DIAGF BIT(6)/* Internal Diagnostic Failure */ +#define INIT BIT(5)/* Mailbox Initialization Required */ +#define IDLE BIT(4)/* SCSI Host Adapter Idle */ +#define CDF BIT(3)/* Command/Data Out Port Full */ +#define DF BIT(2)/* Data In Port Full */ +/* BIT(1) is reserved */ +#define INVDCMD BIT(0)/* Invalid H A Command */ +#define STATMASK (STST | DIAGF | INIT | IDLE | CDF | DF | INVDCMD)#define INTRFLAGS (base) (STATUS(base)+2) -#define ANYINTR 0x80/* Any Interrupt */ -#define SCRD 0x08/* SCSI Reset Detected */ -#define HACC 0x04/* HA Command Complete */ -#define MBOA 0x02/* MBO Empty */ -#define MBIF 0x01/* MBI Full */ -#define INTRMASK 0x8f +#define ANYINTR BIT(7)/* Any Interrupt */ +#define SCRD BIT(3)/* SCSI Reset Detected */ +#define HACC BIT(2)/* HA Command Complete */ +#define MBOA BIT(1)/* MBO Empty */ +#define MBIF BIT(0)/* MBI Full */ +#define INTRMASK (ANYINTR | SCRD | HACC | MBOA | MBIF)/* WRITE */ #define CONTROL (base) STATUS(base) -#define HRST 0x80/* Hard Reset */ -#define SRST 0x40/* Soft Reset */ -#define IRST 0x20/* Interrupt Reset */ -#define SCRST 0x10/* SCSI Bus Reset */ +#define HRST BIT(7)/* Hard Reset */ +#define SRST BIT(6)/* Soft Reset */ +#define IRST BIT(5)/* Interrupt Reset */ +#define SCRST BIT(4)/* SCSI Bus Reset */ /* READ/WRITE */ #define DATA (base) (STATUS(base)+1)
Signature · 1 line
Ondrej Zary
PATCH 10/36 aha1542: Remove WAIT and WAITd macros
In reply to Ondrej ZaryConvert the ugly WAIT and WAITd macros into wait_mask function.
--- drivers/scsi/aha1542.c | 104 ++++++++++++++++++++++++++---------------------- 1 file changed, 57 insertions(+), 47 deletions(-)
drivers/scsi/aha1542.c +57 -47
@@ -120,39 +120,32 @@ struct aha1542_hostdata {static DEFINE_SPINLOCK (aha1542_lock); - - -#define WAITnexttimeout 3000000 -static inline void aha1542_intr_reset (u16 base) {outb (IRST ,CONTROL (base)); } -#define WAIT (port, mask, allof, noneof) \ - { register int WAITbits; \ - register int WAITtimeout = WAITnexttimeout; \ - while (1) { \ - WAITbits = inb(port) & (mask); \ - if ((WAITbits & (allof)) == (allof) && ((WAITbits & (noneof)) == 0)) \ - break; \ - if (--WAITtimeout == 0) goto fail; \ - } \ - } - -/* Similar to WAIT, except we use the udelay call to regulate the -amount of time we wait. */ -#define WAITd (port, mask, allof, noneof, timeout) \ - { register int WAITbits; \ - register int WAITtimeout = timeout; \ - while (1) { \ - WAITbits = inb(port) & (mask); \ - if ((WAITbits & (allof)) == (allof) && ((WAITbits & (noneof)) == 0)) \ - break; \ - mdelay(1); \ - if (--WAITtimeout == 0) goto fail; \ - } \ - } +static inline bool wait_mask (u16 port,u8 mask,u8 allof,u8 noneof,int timeout) +{ +bool delayed = true; + +if (timeout ==0 ) { + timeout =3000000 ; + delayed = false; + } + +while (1 ) { +u8 bits =inb (port) & mask; +if ((bits & allof) == allof && ((bits & noneof) ==0 )) +break ; +if (delayed) +mdelay (1 ); +if (--timeout ==0 ) +return false; + } + +return true; +}/* This is a bit complicated, but we need to make sure that an interrupt routine does not send something out while we are in the middle of this.
@@ -166,7 +159,8 @@ static int aha1542_out(unsigned int base, u8 *cmdp, int len)if (len ==1 ) { got_lock =0 ;while (1 ==1 ) { -WAIT (STATUS (base),CDF ,0 ,CDF ); +if (!wait_mask (STATUS (base),CDF ,0 ,CDF ,0 )) + goto fail;spin_lock_irqsave (&aha1542_lock, flags);if (inb (STATUS (base)) &CDF ) {spin_unlock_irqrestore (&aha1542_lock, flags);
@@ -180,7 +174,8 @@ static int aha1542_out(unsigned int base, u8 *cmdp, int len)spin_lock_irqsave (&aha1542_lock, flags); got_lock =1 ;while (len--) { -WAIT (STATUS (base),CDF ,0 ,CDF ); +if (!wait_mask (STATUS (base),CDF ,0 ,CDF ,0 )) + goto fail;outb (*cmdp++,DATA (base)); }spin_unlock_irqrestore (&aha1542_lock, flags);
@@ -202,7 +197,8 @@ static int aha1542_in(unsigned int base, u8 *cmdp, int len)spin_lock_irqsave (&aha1542_lock, flags);while (len--) { -WAIT (STATUS (base),DF ,DF ,0 ); +if (!wait_mask (STATUS (base),DF ,DF ,0 ,0 )) + goto fail; *cmdp++ =inb (DATA (base)); }spin_unlock_irqrestore (&aha1542_lock, flags);
@@ -222,7 +218,8 @@ static int aha1542_in1(unsigned int base, u8 *cmdp, int len)spin_lock_irqsave (&aha1542_lock, flags);while (len--) { -WAITd (STATUS (base),DF ,DF ,0 ,100 ); +if (!wait_mask (STATUS (base),DF ,DF ,0 ,100 )) + goto fail; *cmdp++ =inb (DATA (base)); }spin_unlock_irqrestore (&aha1542_lock, flags);
@@ -313,7 +310,8 @@ static int aha1542_test_port(int bse, struct Scsi_Host *shpnt) debug =1 ;/* Expect INIT and IDLE, any of the others are bad */ -WAIT (STATUS (bse),STATMASK ,INIT |IDLE ,STST |DIAGF |INVDCMD |DF |CDF ); +if (!wait_mask (STATUS (bse),STATMASK ,INIT |IDLE ,STST |DIAGF |INVDCMD |DF |CDF ,0 )) + goto fail; debug =2 ;/* Shouldn't have generated any interrupts during reset */
@@ -331,7 +329,8 @@ static int aha1542_test_port(int bse, struct Scsi_Host *shpnt) cmdp = &inquiry_result[0 ];while (len--) { -WAIT (STATUS (bse),DF ,DF ,0 ); +if (!wait_mask (STATUS (bse),DF ,DF ,0 ,0 )) + goto fail; *cmdp++ =inb (DATA (bse)); }
@@ -342,7 +341,8 @@ static int aha1542_test_port(int bse, struct Scsi_Host *shpnt) debug =9 ;/* When HACC, command is completed, and we're though testing */ -WAIT (INTRFLAGS (bse),HACC ,HACC ,0 ); +if (!wait_mask (INTRFLAGS (bse),HACC ,HACC ,0 ,0 )) + goto fail;/* now initialize adapter */ debug =10 ;
@@ -711,7 +711,8 @@ static void setup_mailboxes(int bse, struct Scsi_Host *shpnt)aha1542_intr_reset (bse);/* reset interrupts, so they don't block */ any2scsi ((cmd +2 ),isa_virt_to_bus (mb));aha1542_out (bse, cmd,5 ); -WAIT (INTRFLAGS (bse),INTRMASK ,HACC ,0 ); +if (!wait_mask (INTRFLAGS (bse),INTRMASK ,HACC ,0 ,0 )) + goto fail;while (0 ) { fail:printk (KERN_ERR "aha1542_detect: failed setting up mailboxes\n" );
@@ -730,7 +731,8 @@ static int aha1542_getconfig(int base_io, unsigned char *irq_level, unsigned cha };aha1542_out (base_io, inquiry_cmd,1 );aha1542_in (base_io, inquiry_result,3 ); -WAIT (INTRFLAGS (base_io),INTRMASK ,HACC ,0 ); +if (!wait_mask (INTRFLAGS (base_io),INTRMASK ,HACC ,0 ,0 )) + goto fail;while (0 ) { fail:printk (KERN_ERR "aha1542_detect: query board settings\n" );
@@ -800,7 +802,8 @@ static int aha1542_mbenable(int base)aha1542_out (base, mbenable_cmd,1 );if (aha1542_in1 (base, mbenable_result,2 ))return retval; -WAITd (INTRFLAGS (base),INTRMASK ,HACC ,0 ,100 ); +if (!wait_mask (INTRFLAGS (base),INTRMASK ,HACC ,0 ,100 )) + goto fail;aha1542_intr_reset (base);if ((mbenable_result[0 ] &0x08 ) || mbenable_result[1 ]) {
@@ -812,7 +815,8 @@ static int aha1542_mbenable(int base) retval =BIOS_TRANSLATION_25563 ;aha1542_out (base, mbenable_cmd,3 ); -WAIT (INTRFLAGS (base),INTRMASK ,HACC ,0 ); +if (!wait_mask (INTRFLAGS (base),INTRMASK ,HACC ,0 ,0 )) + goto fail; };while (0 ) { fail:
@@ -834,7 +838,8 @@ static int aha1542_query(int base_io, int *transl) };aha1542_out (base_io, inquiry_cmd,1 );aha1542_in (base_io, inquiry_result,4 ); -WAIT (INTRFLAGS (base_io),INTRMASK ,HACC ,0 ); +if (!wait_mask (INTRFLAGS (base_io),INTRMASK ,HACC ,0 ,0 )) + goto fail;while (0 ) { fail:printk (KERN_ERR "aha1542_detect: query card type\n" );
@@ -978,16 +983,19 @@ static struct Scsi_Host *aha1542_hw_init(struct scsi_host_template *tpnt, struct }aha1542_intr_reset (base_io);aha1542_out (base_io, oncmd,2 ); -WAIT (INTRFLAGS (base_io),INTRMASK ,HACC ,0 ); +if (!wait_mask (INTRFLAGS (base_io),INTRMASK ,HACC ,0 ,0 )) + goto fail;aha1542_intr_reset (base_io);aha1542_out (base_io, offcmd,2 ); -WAIT (INTRFLAGS (base_io),INTRMASK ,HACC ,0 ); +if (!wait_mask (INTRFLAGS (base_io),INTRMASK ,HACC ,0 ,0 )) + goto fail;if (setup_dmaspeed[indx] >=0 ) {u8 dmacmd[] = {CMD_DMASPEED ,0 }; dmacmd[1 ] = setup_dmaspeed[indx];aha1542_intr_reset (base_io);aha1542_out (base_io, dmacmd,2 ); -WAIT (INTRFLAGS (base_io),INTRMASK ,HACC ,0 ); +if (!wait_mask (INTRFLAGS (base_io),INTRMASK ,HACC ,0 ,0 )) + goto fail; }while (0 ) { fail:
@@ -1162,8 +1170,9 @@ static int aha1542_bus_reset(Scsi_Cmnd * SCpnt)spin_lock_irq (SCpnt->device->host->host_lock); -WAIT (STATUS (SCpnt->device->host->io_port), -STATMASK ,INIT |IDLE ,STST |DIAGF |INVDCMD |DF |CDF ); +if (!wait_mask (STATUS (SCpnt->device->host->io_port), +STATMASK ,INIT |IDLE ,STST |DIAGF |INVDCMD |DF |CDF ,0 )) + goto fail;/* * Now try to pick up the pieces. For all pending commands,
@@ -1226,8 +1235,9 @@ static int aha1542_host_reset(Scsi_Cmnd * SCpnt)ssleep (4 );spin_lock_irq (SCpnt->device->host->host_lock); -WAIT (STATUS (SCpnt->device->host->io_port), -STATMASK ,INIT |IDLE ,STST |DIAGF |INVDCMD |DF |CDF ); +if (!wait_mask (STATUS (SCpnt->device->host->io_port), +STATMASK ,INIT |IDLE ,STST |DIAGF |INVDCMD |DF |CDF ,0 )) + goto fail;/* * We need to do this too before the 1542 can interact with
Signature · 1 line
Ondrej Zary
PATCH 11/36 aha1542: Unify aha1542_in and aha1542_in1
In reply to Ondrej ZaryUnify aha1542_in and aha1542_in1 functions, they differ only in timeout and printk.
--- drivers/scsi/aha1542.c | 33 +++++++-------------------------- 1 file changed, 7 insertions(+), 26 deletions(-)
drivers/scsi/aha1542.c +7 -26
@@ -191,34 +191,13 @@ fail:/* Only used at boot time, so we do not need to worry about latency as much here */ -static int aha1542_in (unsigned int base,u8 *cmdp,int len) +static int aha1542_in (unsigned int base,u8 *cmdp,int len,int timeout) {unsigned long flags;spin_lock_irqsave (&aha1542_lock, flags);while (len--) { -if (!wait_mask (STATUS (base),DF ,DF ,0 ,0 )) - goto fail; - *cmdp++ =inb (DATA (base)); - } -spin_unlock_irqrestore (&aha1542_lock, flags); -return 0 ; -fail: -spin_unlock_irqrestore (&aha1542_lock, flags); -printk (KERN_ERR "aha1542_in failed(%d): " , len +1 ); -return 1 ; -} - -/* Similar to aha1542_in, except that we wait a very short period of time. -We use this if we know the board is alive and awake, but we are not sure -if the board will respond to the command we are about to send or not */ -static int aha1542_in1 (unsigned int base,u8 *cmdp,int len) -{ -unsigned long flags; - -spin_lock_irqsave (&aha1542_lock, flags); -while (len--) { -if (!wait_mask (STATUS (base),DF ,DF ,0 ,100 )) +if (!wait_mask (STATUS (base),DF ,DF ,0 , timeout)) goto fail; *cmdp++ =inb (DATA (base)); }
@@ -226,6 +205,8 @@ static int aha1542_in1(unsigned int base, u8 *cmdp, int len)return 0 ; fail:spin_unlock_irqrestore (&aha1542_lock, flags); +if (timeout ==0 ) +printk (KERN_ERR "aha1542_in failed(%d): " , len +1 );return 1 ; }
@@ -730,7 +711,7 @@ static int aha1542_getconfig(int base_io, unsigned char *irq_level, unsigned cha i =inb (DATA (base_io)); };aha1542_out (base_io, inquiry_cmd,1 ); -aha1542_in (base_io, inquiry_result,3 ); +aha1542_in (base_io, inquiry_result,3 ,0 );if (!wait_mask (INTRFLAGS (base_io),INTRMASK ,HACC ,0 ,0 )) goto fail;while (0 ) {
@@ -800,7 +781,7 @@ static int aha1542_mbenable(int base) mbenable_cmd[0 ] =CMD_EXTBIOS ;aha1542_out (base, mbenable_cmd,1 ); -if (aha1542_in1 (base, mbenable_result,2 )) +if (aha1542_in (base, mbenable_result,2 ,100 ))return retval;if (!wait_mask (INTRFLAGS (base),INTRMASK ,HACC ,0 ,100 )) goto fail;
@@ -837,7 +818,7 @@ static int aha1542_query(int base_io, int *transl) i =inb (DATA (base_io)); };aha1542_out (base_io, inquiry_cmd,1 ); -aha1542_in (base_io, inquiry_result,4 ); +aha1542_in (base_io, inquiry_result,4 ,0 );if (!wait_mask (INTRFLAGS (base_io),INTRMASK ,HACC ,0 ,0 )) goto fail;while (0 ) {
Signature · 1 line
Ondrej Zary
PATCH 12/36 aha1542: Split aha1542_out
In reply to Ondrej Zaryaha1542_out are in fact two separate functions.
Split them into aha1542_out and aha1542_outb to simplify the code.
--- drivers/scsi/aha1542.c | 75 ++++++++++++++++++++++-------------------------- 1 file changed, 35 insertions(+), 40 deletions(-)
drivers/scsi/aha1542.c +35 -40
@@ -151,41 +151,42 @@ static inline bool wait_mask(u16 port, u8 mask, u8 allof, u8 noneof, int timeoutroutine does not send something out while we are in the middle of this. Fortunately, it is only at boot time that multi-byte messages are ever sent. */ -static int aha1542_out (unsigned int base,u8 *cmdp,int len) +static int aha1542_outb (unsigned int base,u8 cmd) { -unsigned long flags =0 ; -int got_lock; - -if (len ==1 ) { - got_lock =0 ; -while (1 ==1 ) { -if (!wait_mask (STATUS (base),CDF ,0 ,CDF ,0 )) - goto fail; -spin_lock_irqsave (&aha1542_lock, flags); -if (inb (STATUS (base)) &CDF ) { -spin_unlock_irqrestore (&aha1542_lock, flags); -continue ; - } -outb (*cmdp,DATA (base)); -spin_unlock_irqrestore (&aha1542_lock, flags); -return 0 ; +unsigned long flags; + +while (1 ) { +if (!wait_mask (STATUS (base),CDF ,0 ,CDF ,0 )) { +printk (KERN_ERR "aha1542_outb failed" ); +return 1 ; } - }else {spin_lock_irqsave (&aha1542_lock, flags); - got_lock =1 ; -while (len--) { -if (!wait_mask (STATUS (base),CDF ,0 ,CDF ,0 )) - goto fail; -outb (*cmdp++,DATA (base)); +if (inb (STATUS (base)) &CDF ) { +spin_unlock_irqrestore (&aha1542_lock, flags); +continue ; } +outb (cmd,DATA (base));spin_unlock_irqrestore (&aha1542_lock, flags); +return 0 ; } +} + +static int aha1542_out (unsigned int base,u8 *cmdp,int len) +{ +unsigned long flags; + +spin_lock_irqsave (&aha1542_lock, flags); +while (len--) { +if (!wait_mask (STATUS (base),CDF ,0 ,CDF ,0 )) { +spin_unlock_irqrestore (&aha1542_lock, flags); +printk (KERN_ERR "aha1542_out failed(%d): " , len +1 ); +return 1 ; + } +outb (*cmdp++,DATA (base)); + } +spin_unlock_irqrestore (&aha1542_lock, flags); +return 0 ; -fail: -if (got_lock) -spin_unlock_irqrestore (&aha1542_lock, flags); -printk (KERN_ERR "aha1542_out failed(%d): " , len +1 ); -return 1 ; }/* Only used at boot time, so we do not need to worry about latency as much
@@ -268,7 +269,6 @@ static int makecode(unsigned hosterr, unsigned scsierr)static int aha1542_test_port (int bse,struct Scsi_Host *shpnt) { -u8 inquiry_cmd[] = {CMD_INQUIRY };u8 inquiry_result[4 ];u8 *cmdp;int len;
@@ -303,7 +303,7 @@ static int aha1542_test_port(int bse, struct Scsi_Host *shpnt)/* Perform a host adapter inquiry instead so we do not need to set up the mailboxes ahead of time */ -aha1542_out (bse, inquiry_cmd,1 ); +aha1542_outb (bse,CMD_INQUIRY ); debug =3 ; len =4 ;
@@ -527,7 +527,6 @@ static irqreturn_t do_aha1542_intr_handle(int dummy, void *dev_id)static int aha1542_queuecommand_lck (Scsi_Cmnd * SCpnt,void (*done) (Scsi_Cmnd *)) {struct aha1542_hostdata *aha1542 =shost_priv (SCpnt->device->host); -u8 ahacmd =CMD_START_SCSI ;u8 direction;u8 *cmd = (u8 *) SCpnt->cmnd;u8 target = SCpnt->device->id;
@@ -666,7 +665,7 @@ static int aha1542_queuecommand_lck(Scsi_Cmnd * SCpnt, void (*done) (Scsi_Cmnd *DEB (printk ("aha1542_queuecommand: now waiting for interrupt " )); SCpnt->scsi_done = done; mb[mbo].status =1 ; -aha1542_out (SCpnt->device->host->io_port, &ahacmd,1 );/* start scsi command */ +aha1542_outb (SCpnt->device->host->io_port,CMD_START_SCSI ); }else printk ("aha1542_queuecommand: done can't be NULL\n" );
@@ -703,14 +702,13 @@ fail:static int aha1542_getconfig (int base_io,unsigned char *irq_level,unsigned char *dma_chan,unsigned char *scsi_id) { -u8 inquiry_cmd[] = {CMD_RETCONF };u8 inquiry_result[3 ];int i; i =inb (STATUS (base_io));if (i &DF ) { i =inb (DATA (base_io)); }; -aha1542_out (base_io, inquiry_cmd,1 ); +aha1542_outb (base_io,CMD_RETCONF );aha1542_in (base_io, inquiry_result,3 ,0 );if (!wait_mask (INTRFLAGS (base_io),INTRMASK ,HACC ,0 ,0 )) goto fail;
@@ -779,8 +777,7 @@ static int aha1542_mbenable(int base) retval =BIOS_TRANSLATION_6432 ; - mbenable_cmd[0 ] =CMD_EXTBIOS ; -aha1542_out (base, mbenable_cmd,1 ); +aha1542_outb (base,CMD_EXTBIOS );if (aha1542_in (base, mbenable_result,2 ,100 ))return retval;if (!wait_mask (INTRFLAGS (base),INTRMASK ,HACC ,0 ,100 ))
@@ -810,14 +807,13 @@ fail:/* Query the board to find out if it is a 1542 or a 1740, or whatever. */ static int aha1542_query (int base_io,int *transl) { -u8 inquiry_cmd[] = {CMD_INQUIRY };u8 inquiry_result[4 ];int i; i =inb (STATUS (base_io));if (i &DF ) { i =inb (DATA (base_io)); }; -aha1542_out (base_io, inquiry_cmd,1 ); +aha1542_outb (base_io,CMD_INQUIRY );aha1542_in (base_io, inquiry_result,4 ,0 );if (!wait_mask (INTRFLAGS (base_io),INTRMASK ,HACC ,0 ,0 )) goto fail;
@@ -1079,7 +1075,6 @@ static int aha1542_dev_reset(Scsi_Cmnd * SCpnt)u8 lun = SCpnt->device->lun;int mbo;struct ccb *ccb = aha1542->ccb; -u8 ahacmd =CMD_START_SCSI ;spin_lock_irqsave (&aha1542_lock, flags); mbo = aha1542->aha1542_last_mbo_used +1 ;
@@ -1119,7 +1114,7 @@ static int aha1542_dev_reset(Scsi_Cmnd * SCpnt)* Now tell the 1542 to flush all pending commands for this * target */ -aha1542_out (SCpnt->device->host->io_port, &ahacmd,1 ); +aha1542_outb (SCpnt->device->host->io_port,CMD_START_SCSI );scmd_printk (KERN_WARNING , SCpnt,"Trying device reset for target\n" );
Signature · 1 line
Ondrej Zary
PATCH 13/36 aha1542: Remove unneeded gotos
In reply to Ondrej ZaryRemove gotos that are no longer needed.
--- drivers/scsi/aha1542.c | 58 ++++++++++++++++-------------------------------- 1 file changed, 19 insertions(+), 39 deletions(-)
drivers/scsi/aha1542.c +19 -39
@@ -198,17 +198,16 @@ static int aha1542_in(unsigned int base, u8 *cmdp, int len, int timeout)spin_lock_irqsave (&aha1542_lock, flags);while (len--) { -if (!wait_mask (STATUS (base),DF ,DF ,0 , timeout)) - goto fail; +if (!wait_mask (STATUS (base),DF ,DF ,0 , timeout)) { +spin_unlock_irqrestore (&aha1542_lock, flags); +if (timeout ==0 ) +printk (KERN_ERR "aha1542_in failed(%d): " , len +1 ); +return 1 ; + } *cmdp++ =inb (DATA (base)); }spin_unlock_irqrestore (&aha1542_lock, flags);return 0 ; -fail: -spin_unlock_irqrestore (&aha1542_lock, flags); -if (timeout ==0 ) -printk (KERN_ERR "aha1542_in failed(%d): " , len +1 ); -return 1 ; }static int makecode (unsigned hosterr,unsigned scsierr)
@@ -292,12 +291,12 @@ static int aha1542_test_port(int bse, struct Scsi_Host *shpnt) debug =1 ;/* Expect INIT and IDLE, any of the others are bad */ if (!wait_mask (STATUS (bse),STATMASK ,INIT |IDLE ,STST |DIAGF |INVDCMD |DF |CDF ,0 )) - goto fail; +return 0 ; debug =2 ;/* Shouldn't have generated any interrupts during reset */ if (inb (INTRFLAGS (bse)) &INTRMASK ) - goto fail; +return 0 ;/* Perform a host adapter inquiry instead so we do not need to set
@@ -311,19 +310,19 @@ static int aha1542_test_port(int bse, struct Scsi_Host *shpnt)while (len--) {if (!wait_mask (STATUS (bse),DF ,DF ,0 ,0 )) - goto fail; +return 0 ; *cmdp++ =inb (DATA (bse)); } debug =8 ;/* Reading port should reset DF */ if (inb (STATUS (bse)) &DF ) - goto fail; +return 0 ; debug =9 ;/* When HACC, command is completed, and we're though testing */ if (!wait_mask (INTRFLAGS (bse),HACC ,HACC ,0 ,0 )) - goto fail; +return 0 ;/* now initialize adapter */ debug =10 ;
@@ -333,8 +332,6 @@ static int aha1542_test_port(int bse, struct Scsi_Host *shpnt) debug =11 ;return debug;/* 1 = ok */ -fail: -return 0 ;/* 0 = not ok */ }static int aha1542_restart (struct Scsi_Host *shost)
@@ -692,11 +689,7 @@ static void setup_mailboxes(int bse, struct Scsi_Host *shpnt)any2scsi ((cmd +2 ),isa_virt_to_bus (mb));aha1542_out (bse, cmd,5 );if (!wait_mask (INTRFLAGS (bse),INTRMASK ,HACC ,0 ,0 )) - goto fail; -while (0 ) { -fail:printk (KERN_ERR "aha1542_detect: failed setting up mailboxes\n" ); - }aha1542_intr_reset (bse); }
@@ -711,11 +704,7 @@ static int aha1542_getconfig(int base_io, unsigned char *irq_level, unsigned chaaha1542_outb (base_io,CMD_RETCONF );aha1542_in (base_io, inquiry_result,3 ,0 );if (!wait_mask (INTRFLAGS (base_io),INTRMASK ,HACC ,0 ,0 )) - goto fail; -while (0 ) { -fail:printk (KERN_ERR "aha1542_detect: query board settings\n" ); - }aha1542_intr_reset (base_io);switch (inquiry_result[0 ]) {case 0x80 :
@@ -816,11 +805,7 @@ static int aha1542_query(int base_io, int *transl)aha1542_outb (base_io,CMD_INQUIRY );aha1542_in (base_io, inquiry_result,4 ,0 );if (!wait_mask (INTRFLAGS (base_io),INTRMASK ,HACC ,0 ,0 )) - goto fail; -while (0 ) { -fail:printk (KERN_ERR "aha1542_detect: query card type\n" ); - }aha1542_intr_reset (base_io); *transl =BIOS_TRANSLATION_6432 ;/* Default case */
@@ -1147,8 +1132,10 @@ static int aha1542_bus_reset(Scsi_Cmnd * SCpnt)spin_lock_irq (SCpnt->device->host->host_lock);if (!wait_mask (STATUS (SCpnt->device->host->io_port), -STATMASK ,INIT |IDLE ,STST |DIAGF |INVDCMD |DF |CDF ,0 )) - goto fail; +STATMASK ,INIT |IDLE ,STST |DIAGF |INVDCMD |DF |CDF ,0 )) { +spin_unlock_irq (SCpnt->device->host->host_lock); +return FAILED ; + }/* * Now try to pick up the pieces. For all pending commands,
@@ -1182,10 +1169,6 @@ static int aha1542_bus_reset(Scsi_Cmnd * SCpnt)spin_unlock_irq (SCpnt->device->host->host_lock);return SUCCESS ; - -fail: -spin_unlock_irq (SCpnt->device->host->host_lock); -return FAILED ; }static int aha1542_host_reset (Scsi_Cmnd * SCpnt)
@@ -1212,9 +1195,10 @@ static int aha1542_host_reset(Scsi_Cmnd * SCpnt)spin_lock_irq (SCpnt->device->host->host_lock);if (!wait_mask (STATUS (SCpnt->device->host->io_port), -STATMASK ,INIT |IDLE ,STST |DIAGF |INVDCMD |DF |CDF ,0 )) - goto fail; - +STATMASK ,INIT |IDLE ,STST |DIAGF |INVDCMD |DF |CDF ,0 )) { +spin_unlock_irq (SCpnt->device->host->host_lock); +return FAILED ; + }/* * We need to do this too before the 1542 can interact with * us again.
@@ -1252,10 +1236,6 @@ static int aha1542_host_reset(Scsi_Cmnd * SCpnt)spin_unlock_irq (SCpnt->device->host->host_lock);return SUCCESS ; - -fail: -spin_unlock_irq (SCpnt->device->host->host_lock); -return FAILED ; } static int aha1542_biosparam(struct scsi_device *sdev,
Signature · 1 line
Ondrej Zary
PATCH 14/36 aha1542: remove useless code from aha1542_test_port
In reply to Ondrej Zary--- drivers/scsi/aha1542.c | 15 +-------------- 1 file changed, 1 insertion(+), 14 deletions(-)
drivers/scsi/aha1542.c +1 -14
@@ -271,7 +271,6 @@ static int aha1542_test_port(int bse, struct Scsi_Host *shpnt)u8 inquiry_result[4 ];u8 *cmdp;int len; -volatile int debug =0 ;/* Quick and dirty test for presence of the card. */ if (inb (STATUS (bse)) ==0xff )
@@ -279,8 +278,6 @@ static int aha1542_test_port(int bse, struct Scsi_Host *shpnt)/* Reset the adapter. I ought to make a hard reset, but it's not really necessary */ -/* DEB(printk("aha1542_test_port called \n")); */ -/* In case some other card was probing here, reset interrupts */ aha1542_intr_reset (bse);/* reset interrupts, so they don't block */
@@ -288,23 +285,19 @@ static int aha1542_test_port(int bse, struct Scsi_Host *shpnt)mdelay (20 );/* Wait a little bit for things to settle down. */ - debug =1 ;/* Expect INIT and IDLE, any of the others are bad */ if (!wait_mask (STATUS (bse),STATMASK ,INIT |IDLE ,STST |DIAGF |INVDCMD |DF |CDF ,0 ))return 0 ; - debug =2 ;/* Shouldn't have generated any interrupts during reset */ if (inb (INTRFLAGS (bse)) &INTRMASK )return 0 ; -/* Perform a host adapter inquiry instead so we do not need to set up the mailboxes ahead of time */ aha1542_outb (bse,CMD_INQUIRY ); - debug =3 ; len =4 ; cmdp = &inquiry_result[0 ];
@@ -314,24 +307,18 @@ static int aha1542_test_port(int bse, struct Scsi_Host *shpnt) *cmdp++ =inb (DATA (bse)); } - debug =8 ;/* Reading port should reset DF */ if (inb (STATUS (bse)) &DF )return 0 ; - debug =9 ;/* When HACC, command is completed, and we're though testing */ if (!wait_mask (INTRFLAGS (bse),HACC ,HACC ,0 ,0 ))return 0 ; -/* now initialize adapter */ - debug =10 ;/* Clear interrupts */ outb (IRST ,CONTROL (bse)); - debug =11 ; - -return debug;/* 1 = ok */ +return 1 ; }static int aha1542_restart (struct Scsi_Host *shost)
Signature · 1 line
Ondrej Zary
PATCH 15/36 aha1542: Remove aha1542_restart
In reply to Ondrej Zaryaha1542_restart does nothing (except useless printk), remove it
--- drivers/scsi/aha1542.c | 28 ++-------------------------- 1 file changed, 2 insertions(+), 26 deletions(-)
drivers/scsi/aha1542.c +2 -26
@@ -321,22 +321,6 @@ static int aha1542_test_port(int bse, struct Scsi_Host *shpnt)return 1 ; } -static int aha1542_restart (struct Scsi_Host *shost) -{ -struct aha1542_hostdata *aha1542 =shost_priv (shost); -int i; -int count =0 ; - -for (i =0 ; i <AHA1542_MAILBOXES ; i++) -if (aha1542->SCint[i] && - !(aha1542->SCint[i]->device->soft_reset)) { - count++; - } -printk (KERN_DEBUG "Potential to restart %d stalled commands...\n" , count); - -return 0 ; -} -/* A "high" level interrupt handler */ static void aha1542_intr_handle (struct Scsi_Host *shost) {
@@ -347,7 +331,6 @@ static void aha1542_intr_handle(struct Scsi_Host *shost)unsigned long flags;Scsi_Cmnd *SCtmp;int flag; -int needs_restart;struct mailbox *mb = aha1542->mb;struct ccb *ccb = aha1542->ccb;
@@ -369,7 +352,6 @@ static void aha1542_intr_handle(struct Scsi_Host *shost) };#endif number_serviced =0 ; - needs_restart =0 ;while (1 ==1 ) { flag =inb (INTRFLAGS (shost->io_port));
@@ -383,10 +365,8 @@ static void aha1542_intr_handle(struct Scsi_Host *shost)printk ("MBOF " );if (flag &HACC )printk ("HACC " ); -if (flag &SCRD ) { - needs_restart =1 ; +if (flag &SCRD )printk ("SCRD " ); - } }aha1542_intr_reset (shost->io_port);
@@ -406,12 +386,8 @@ static void aha1542_intr_handle(struct Scsi_Host *shost)if (mb[mbi].status ==0 ) {spin_unlock_irqrestore (&aha1542_lock, flags);/* Hmm, no mail. Must have read it the last time around */ -if (!number_serviced && !needs_restart) +if (!number_serviced)printk (KERN_WARNING "aha1542.c: interrupt received, but no mail.\n" ); -/* We detected a reset. Restart all pending commands for -devices that use the hard reset option */ -if (needs_restart) -aha1542_restart (shost);return ; };
Signature · 1 line
Ondrej Zary
PATCH 16/36 aha1542: Merge aha1542_host_reset and aha1542_bus_reset
In reply to Ondrej Zaryaha1542_host_reset and aha1542_bus_reset are almost same, merge them into aha1542_reset
--- drivers/scsi/aha1542.c | 82 +++++++++--------------------------------------- 1 file changed, 14 insertions(+), 68 deletions(-)
drivers/scsi/aha1542.c +14 -68
@@ -1070,7 +1070,7 @@ static int aha1542_dev_reset(Scsi_Cmnd * SCpnt)return SUCCESS ; } -static int aha1542_bus_reset (Scsi_Cmnd * SCpnt) +static int aha1542_reset (Scsi_Cmnd *SCpnt,u8 reset_cmd) {struct aha1542_hostdata *aha1542 =shost_priv (SCpnt->device->host);int i;
@@ -1081,7 +1081,7 @@ static int aha1542_bus_reset(Scsi_Cmnd * SCpnt)* we do this? Try this first, and we can add that later * if it turns out to be useful. */ -outb (SCRST ,CONTROL (SCpnt->device->host->io_port)); +outb (reset_cmd,CONTROL (SCpnt->device->host->io_port));/* * Wait for the thing to settle down a bit. Unfortunately
@@ -1091,7 +1091,6 @@ static int aha1542_bus_reset(Scsi_Cmnd * SCpnt)* we are pretty desperate anyways. */ ssleep (4 ); -spin_lock_irq (SCpnt->device->host->host_lock); if (!wait_mask(STATUS(SCpnt->device->host->io_port),
@@ -1099,7 +1098,12 @@ static int aha1542_bus_reset(Scsi_Cmnd * SCpnt)spin_unlock_irq (SCpnt->device->host->host_lock);return FAILED ; } - +/* +* We need to do this too before the 1542 can interact with +* us again after host reset. +*/ +if (reset_cmd &HRST ) +setup_mailboxes (SCpnt->device->host->io_port, SCpnt->device->host);/* * Now try to pick up the pieces. For all pending commands, * free any internal data structures, and basically clear things
@@ -1113,7 +1117,6 @@ static int aha1542_bus_reset(Scsi_Cmnd * SCpnt)Scsi_Cmnd *SCtmp; SCtmp = aha1542->SCint[i]; -if (SCtmp->device->soft_reset) {/* * If this device implements the soft reset option,
@@ -1134,71 +1137,14 @@ static int aha1542_bus_reset(Scsi_Cmnd * SCpnt)return SUCCESS ; } -static int aha1542_host_reset (Scsi_Cmnd * SCpnt) +static int aha1542_bus_reset (Scsi_Cmnd *SCpnt) { -struct aha1542_hostdata *aha1542 =shost_priv (SCpnt->device->host); -int i; - -/* -* This does a scsi reset for all devices on the bus. -* In principle, we could also reset the 1542 - should -* we do this? Try this first, and we can add that later -* if it turns out to be useful. -*/ -outb (HRST |SCRST ,CONTROL (SCpnt->device->host->io_port)); - -/* -* Wait for the thing to settle down a bit. Unfortunately -* this is going to basically lock up the machine while we -* wait for this to complete. To be 100% correct, we need to -* check for timeout, and if we are doing something like this -* we are pretty desperate anyways. -*/ -ssleep (4 ); -spin_lock_irq (SCpnt->device->host->host_lock); - -if (!wait_mask (STATUS (SCpnt->device->host->io_port), -STATMASK ,INIT |IDLE ,STST |DIAGF |INVDCMD |DF |CDF ,0 )) { -spin_unlock_irq (SCpnt->device->host->host_lock); -return FAILED ; - } -/* -* We need to do this too before the 1542 can interact with -* us again. -*/ -setup_mailboxes (SCpnt->device->host->io_port, SCpnt->device->host); - -/* -* Now try to pick up the pieces. For all pending commands, -* free any internal data structures, and basically clear things -* out. We do not try and restart any commands or anything - -* the strategy handler takes care of that crap. -*/ -printk (KERN_WARNING "Sent BUS RESET to scsi host %d\n" , SCpnt->device->host->host_no); - -for (i =0 ; i <AHA1542_MAILBOXES ; i++) { -if (aha1542->SCint[i] !=NULL ) { -Scsi_Cmnd *SCtmp; - SCtmp = aha1542->SCint[i]; - -if (SCtmp->device->soft_reset) { -/* -* If this device implements the soft reset option, -* then it is still holding onto the command, and -* may yet complete it. In this case, we don't -* flush the data. -*/ -continue ; - } -kfree (SCtmp->host_scribble); - SCtmp->host_scribble =NULL ; - aha1542->SCint[i] =NULL ; - aha1542->mb[i].status =0 ; - } - } +return aha1542_reset (SCpnt,SCRST ); +} -spin_unlock_irq (SCpnt->device->host->host_lock); -return SUCCESS ; +static int aha1542_host_reset (Scsi_Cmnd *SCpnt) +{ +return aha1542_reset (SCpnt,HRST |SCRST ); } static int aha1542_biosparam(struct scsi_device *sdev,
Signature · 1 line
Ondrej Zary
PATCH 17/36 aha1542: split out code from aha1542_hw_init
In reply to Ondrej ZarySplit out bus times related block of aha1542_hw_init into separate function aha1542_set_bus_times.
--- drivers/scsi/aha1542.c | 65 ++++++++++++++++++++++++++---------------------- 1 file changed, 35 insertions(+), 30 deletions(-)
drivers/scsi/aha1542.c +35 -30
@@ -867,6 +867,40 @@ static int __init do_setup(char *str)__setup ("aha1542=" ,do_setup);#endif +/* Set the Bus on/off-times as not to ruin floppy performance */ +static void aha1542_set_bus_times (int indx) +{ +unsigned int base_io = bases[indx]; +u8 oncmd[] = {CMD_BUSON_TIME ,7 }; +u8 offcmd[] = {CMD_BUSOFF_TIME ,5 }; + +if (setup_called[indx]) { + oncmd[1 ] = setup_buson[indx]; + offcmd[1 ] = setup_busoff[indx]; + } +aha1542_intr_reset (base_io); +aha1542_out (base_io, oncmd,2 ); +if (!wait_mask (INTRFLAGS (base_io),INTRMASK ,HACC ,0 ,0 )) + goto fail; +aha1542_intr_reset (base_io); +aha1542_out (base_io, offcmd,2 ); +if (!wait_mask (INTRFLAGS (base_io),INTRMASK ,HACC ,0 ,0 )) + goto fail; +if (setup_dmaspeed[indx] >=0 ) { +u8 dmacmd[] = {CMD_DMASPEED ,0 }; + dmacmd[1 ] = setup_dmaspeed[indx]; +aha1542_intr_reset (base_io); +aha1542_out (base_io, dmacmd,2 ); +if (!wait_mask (INTRFLAGS (base_io),INTRMASK ,HACC ,0 ,0 )) + goto fail; + } +aha1542_intr_reset (base_io); +return ; +fail: +printk (KERN_ERR "setting bus on/off-time failed\n" ); +aha1542_intr_reset (base_io); +} +/* return non-zero on detection */ static struct Scsi_Host *aha1542_hw_init (struct scsi_host_template *tpnt,struct device *pdev,int indx) {
@@ -897,37 +931,8 @@ static struct Scsi_Host *aha1542_hw_init(struct scsi_host_template *tpnt, struct base_io = bases[indx]; -/* Set the Bus on/off-times as not to ruin floppy performance */ - { -u8 oncmd[] = {CMD_BUSON_TIME ,7 }; -u8 offcmd[] = {CMD_BUSOFF_TIME ,5 }; +aha1542_set_bus_times (indx); -if (setup_called[indx]) { - oncmd[1 ] = setup_buson[indx]; - offcmd[1 ] = setup_busoff[indx]; - } -aha1542_intr_reset (base_io); -aha1542_out (base_io, oncmd,2 ); -if (!wait_mask (INTRFLAGS (base_io),INTRMASK ,HACC ,0 ,0 )) - goto fail; -aha1542_intr_reset (base_io); -aha1542_out (base_io, offcmd,2 ); -if (!wait_mask (INTRFLAGS (base_io),INTRMASK ,HACC ,0 ,0 )) - goto fail; -if (setup_dmaspeed[indx] >=0 ) { -u8 dmacmd[] = {CMD_DMASPEED ,0 }; - dmacmd[1 ] = setup_dmaspeed[indx]; -aha1542_intr_reset (base_io); -aha1542_out (base_io, dmacmd,2 ); -if (!wait_mask (INTRFLAGS (base_io),INTRMASK ,HACC ,0 ,0 )) - goto fail; - } -while (0 ) { -fail: -printk (KERN_ERR "aha1542_detect: setting bus on/off-time failed\n" ); - } -aha1542_intr_reset (base_io); - }if (aha1542_query (base_io, &trans)) goto unregister;
Signature · 1 line
Ondrej Zary
PATCH 18/36 aha1542: Call wait_mask from aha1542_out
In reply to Ondrej Zaryaha1542_out call is always followed by wait_mask.
Move the call into aha1542_out to simplify code.
--- drivers/scsi/aha1542.c | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-)
drivers/scsi/aha1542.c +7 -10
@@ -185,6 +185,8 @@ static int aha1542_out(unsigned int base, u8 *cmdp, int len)outb (*cmdp++,DATA (base)); }spin_unlock_irqrestore (&aha1542_lock, flags); +if (!wait_mask (INTRFLAGS (base),INTRMASK ,HACC ,0 ,0 )) +return 1 ;return 0 ; }
@@ -650,8 +652,7 @@ static void setup_mailboxes(int bse, struct Scsi_Host *shpnt) };aha1542_intr_reset (bse);/* reset interrupts, so they don't block */ any2scsi ((cmd +2 ),isa_virt_to_bus (mb)); -aha1542_out (bse, cmd,5 ); -if (!wait_mask (INTRFLAGS (bse),INTRMASK ,HACC ,0 ,0 )) +if (aha1542_out (bse, cmd,5 ))printk (KERN_ERR "aha1542_detect: failed setting up mailboxes\n" );aha1542_intr_reset (bse); }
@@ -744,8 +745,7 @@ static int aha1542_mbenable(int base)if ((mbenable_result[0 ] &0x08 ) && (mbenable_result[1 ] &0x03 )) retval =BIOS_TRANSLATION_25563 ; -aha1542_out (base, mbenable_cmd,3 ); -if (!wait_mask (INTRFLAGS (base),INTRMASK ,HACC ,0 ,0 )) +if (aha1542_out (base, mbenable_cmd,3 )) goto fail; };while (0 ) {
@@ -879,19 +879,16 @@ static void aha1542_set_bus_times(int indx) offcmd[1 ] = setup_busoff[indx]; }aha1542_intr_reset (base_io); -aha1542_out (base_io, oncmd,2 ); -if (!wait_mask (INTRFLAGS (base_io),INTRMASK ,HACC ,0 ,0 )) +if (aha1542_out (base_io, oncmd,2 )) goto fail;aha1542_intr_reset (base_io); -aha1542_out (base_io, offcmd,2 ); -if (!wait_mask (INTRFLAGS (base_io),INTRMASK ,HACC ,0 ,0 )) +if (aha1542_out (base_io, offcmd,2 )) goto fail;if (setup_dmaspeed[indx] >=0 ) {u8 dmacmd[] = {CMD_DMASPEED ,0 }; dmacmd[1 ] = setup_dmaspeed[indx];aha1542_intr_reset (base_io); -aha1542_out (base_io, dmacmd,2 ); -if (!wait_mask (INTRFLAGS (base_io),INTRMASK ,HACC ,0 ,0 )) +if (aha1542_out (base_io, dmacmd,2 )) goto fail; }aha1542_intr_reset (base_io);
Signature · 1 line
Ondrej Zary
PATCH 19/36 aha1542: rework hw_init
In reply to Ondrej ZaryCleanup hw_init, use goto for error handling.
--- drivers/scsi/aha1542.c | 139 ++++++++++++++++++++---------------------------- drivers/scsi/aha1542.h | 1 + 2 files changed, 59 insertions(+), 81 deletions(-)
drivers/scsi/aha1542.c +58 -81
@@ -657,7 +657,7 @@ static void setup_mailboxes(int bse, struct Scsi_Host *shpnt)aha1542_intr_reset (bse); } -static int aha1542_getconfig (int base_io,unsigned char *irq_level,unsigned char *dma_chan,unsigned char *scsi_id) +static int aha1542_getconfig (int base_io,unsigned int *irq_level,unsigned char *dma_chan,unsigned int *scsi_id) {u8 inquiry_result[3 ];int i;
@@ -901,99 +901,76 @@ fail:/* return non-zero on detection */ static struct Scsi_Host *aha1542_hw_init (struct scsi_host_template *tpnt,struct device *pdev,int indx) { -unsigned char dma_chan; -unsigned char irq_level; -unsigned char scsi_id; -unsigned long flags; -unsigned int base_io; -int trans; -struct Scsi_Host *shpnt =NULL ; +unsigned int base_io = bases[indx]; +struct Scsi_Host *shpnt;struct aha1542_hostdata *aha1542; -DEB (printk ("aha1542_detect: \n" )); - - tpnt->proc_name ="aha1542" ; - -if (bases[indx] !=0 &&request_region (bases[indx],4 ,"aha1542" )) { - shpnt =scsi_host_alloc (tpnt, -sizeof (struct aha1542_hostdata )); - -if (shpnt==NULL ) { -release_region (bases[indx],4 ); -return NULL ; - } - aha1542 =shost_priv (shpnt); -if (!aha1542_test_port (bases[indx], shpnt)) - goto unregister; +if (base_io ==0 ) +return NULL ; - base_io = bases[indx]; +if (!request_region (base_io,AHA1542_REGION_SIZE ,"aha1542" )) +return NULL ; -aha1542_set_bus_times (indx); + shpnt =scsi_host_alloc (tpnt,sizeof (struct aha1542_hostdata )); +if (!shpnt) + goto release; + aha1542 =shost_priv (shpnt); -if (aha1542_query (base_io, &trans)) - goto unregister; +if (!aha1542_test_port (base_io, shpnt)) + goto unregister; -if (aha1542_getconfig (base_io, &irq_level, &dma_chan, &scsi_id) ==-1 ) - goto unregister; +aha1542_set_bus_times (indx); +if (aha1542_query (base_io, &aha1542->bios_translation)) + goto unregister; +if (aha1542_getconfig (base_io, &shpnt->irq, &shpnt->dma_channel, &shpnt->this_id) ==-1 ) + goto unregister; -printk (KERN_INFO "Configuring Adaptec (SCSI-ID %d) at IO:%x, IRQ %d" , scsi_id, base_io, irq_level); -if (dma_chan !=0xFF ) -printk (", DMA priority %d" , dma_chan); -printk ("\n" ); +printk (KERN_INFO "Adaptec AHA-1542 (SCSI-ID %d) at IO 0x%x, IRQ %d" , shpnt->this_id, base_io, shpnt->irq); +if (shpnt->dma_channel !=0xFF ) +printk (", DMA %d" , shpnt->dma_channel); +printk ("\n" ); +if (aha1542->bios_translation ==BIOS_TRANSLATION_25563 ) +printk (KERN_INFO "aha1542.c: Using extended bios translation\n" ); -setup_mailboxes (base_io, shpnt); +setup_mailboxes (base_io, shpnt); -DEB (printk ("aha1542_detect: enable interrupt channel %d\n" , irq_level)); -spin_lock_irqsave (&aha1542_lock, flags); -if (request_irq (irq_level, do_aha1542_intr_handle,0 , +if (request_irq (shpnt->irq, do_aha1542_intr_handle,0 ,"aha1542" , shpnt)) { -printk (KERN_ERR "Unable to allocate IRQ for adaptec controller.\n" ); -spin_unlock_irqrestore (&aha1542_lock, flags); - goto unregister; - } -if (dma_chan !=0xFF ) { -if (request_dma (dma_chan,"aha1542" )) { -printk (KERN_ERR "Unable to allocate DMA channel for Adaptec.\n" ); -free_irq (irq_level, shpnt); -spin_unlock_irqrestore (&aha1542_lock, flags); - goto unregister; - } -if (dma_chan ==0 || dma_chan >=5 ) { -set_dma_mode (dma_chan,DMA_MODE_CASCADE ); -enable_dma (dma_chan); - } - } +printk (KERN_ERR "Unable to allocate IRQ for adaptec controller.\n" ); + goto unregister; + } +if (shpnt->dma_channel !=0xFF ) { +if (request_dma (shpnt->dma_channel,"aha1542" )) { +printk (KERN_ERR "Unable to allocate DMA channel for Adaptec.\n" ); + goto free_irq; + } +if (shpnt->dma_channel ==0 || shpnt->dma_channel >=5 ) { +set_dma_mode (shpnt->dma_channel,DMA_MODE_CASCADE ); +enable_dma (shpnt->dma_channel); + } + } - shpnt->this_id = scsi_id; - shpnt->unique_id = base_io; - shpnt->io_port = base_io; - shpnt->n_io_port =4 ;/* Number of bytes of I/O space used */ - shpnt->dma_channel = dma_chan; - shpnt->irq = irq_level; - aha1542->bios_translation = trans; -if (trans ==BIOS_TRANSLATION_25563 ) -printk (KERN_INFO "aha1542.c: Using extended bios translation\n" ); - aha1542->aha1542_last_mbi_used = (2 *AHA1542_MAILBOXES -1 ); - aha1542->aha1542_last_mbo_used = (AHA1542_MAILBOXES -1 ); -memset (aha1542->SCint,0 ,sizeof (aha1542->SCint)); -spin_unlock_irqrestore (&aha1542_lock, flags); + shpnt->unique_id = base_io; + shpnt->io_port = base_io; + shpnt->n_io_port =AHA1542_REGION_SIZE ; + aha1542->aha1542_last_mbi_used =2 *AHA1542_MAILBOXES -1 ; + aha1542->aha1542_last_mbo_used =AHA1542_MAILBOXES -1 ; -if (scsi_add_host (shpnt, pdev)) { -if (shpnt->dma_channel !=0xff ) -free_dma (shpnt->dma_channel); -free_irq (irq_level, shpnt); - goto unregister; - } +if (scsi_add_host (shpnt, pdev)) + goto free_dma; -scsi_scan_host (shpnt); +scsi_scan_host (shpnt); -return shpnt; +return shpnt; +free_dma: +if (shpnt->dma_channel !=0xff ) +free_dma (shpnt->dma_channel); +free_irq: +free_irq (shpnt->irq, shpnt); unregister: -release_region (bases[indx],4 ); -scsi_host_put (shpnt); -return NULL ; - - }; +scsi_host_put (shpnt); +release: +release_region (base_io,AHA1542_REGION_SIZE );return NULL ; }
@@ -1001,10 +978,10 @@ unregister:static int aha1542_release (struct Scsi_Host *shost) {scsi_remove_host (shost); -if (shost->irq) -free_irq (shost->irq, shost);if (shost->dma_channel !=0xff )free_dma (shost->dma_channel); +if (shost->irq) +free_irq (shost->irq, shost);if (shost->io_port && shost->n_io_port)release_region (shost->io_port, shost->n_io_port);scsi_host_put (shost);
drivers/scsi/aha1542.h +1 -0
@@ -126,6 +126,7 @@ struct ccb { /* Command Control Block 5.3 */ /* REQUEST SENSE */ }; +#define AHA1542_REGION_SIZE 4#define AHA1542_MAILBOXES 8#endif
Signature · 1 line
Ondrej Zary
PATCH 20/36 aha1542: rework configuration parameters
In reply to Ondrej ZaryRemove __setup and introduce separate io, bus_on, bus_off and dma_speed module parameters.
--- drivers/scsi/aha1542.c | 213 ++++++++++++------------------------------------ 1 file changed, 54 insertions(+), 159 deletions(-)
drivers/scsi/aha1542.c +54 -159
@@ -53,56 +53,30 @@#else #define DEB (x)#endif +#define MAXBOARDS 4 -/* -static const char RCSid[] = "$Header: /usr/src/linux/kernel/blk_drv/scsi/RCS/aha1542.c,v 1.1 1992/07/24 06:27:38 root Exp root $"; -*/ - -/* The adaptec can be configured for quite a number of addresses, but -I generally do not want the card poking around at random. We allow -two addresses - this allows people to use the Adaptec with a Midi -card, which also used 0x330 -- can be overridden with LILO! */ - -#define MAXBOARDS 4/* Increase this and the sizes of the -arrays below, if you need more.. */ - -/* Boards 3,4 slots are reserved for ISAPnP scans */ - -static unsigned int bases[MAXBOARDS ] = {0x330 ,0x334 ,0 ,0 }; +static bool isapnp =1 ; +module_param (isapnp, bool,0 ); +MODULE_PARM_DESC (isapnp,"enable PnP support (default=1)" ); -/* set by aha1542_setup according to the command line; they also may -be marked __initdata, but require zero initializers then */ +static int io[MAXBOARDS ] = {0x330 ,0x334 ,0 ,0 }; +module_param_array (io, int,NULL ,0 ); +MODULE_PARM_DESC (io,"base IO address of controller (0x130,0x134,0x230,0x234,0x330,0x334, default=0x330,0x334)" ); -static int setup_called[MAXBOARDS ]; -static int setup_buson[MAXBOARDS ]; -static int setup_busoff[MAXBOARDS ]; -static int setup_dmaspeed[MAXBOARDS ] = {-1 ,-1 ,-1 ,-1 }; +/* time AHA spends on the AT-bus during data transfer */ +static int bus_on[MAXBOARDS ] = {-1 ,-1 ,-1 ,-1 };/* power-on default: 11us */ +module_param_array (bus_on, int,NULL ,0 ); +MODULE_PARM_DESC (bus_on,"bus on time [us] (2-15, default=-1 [HW default: 11])" ); -/* -* LILO/Module params: aha1542=<PORTBASE>[,<BUSON>,<BUSOFF>[,<DMASPEED>]] -* -* Where: <PORTBASE> is any of the valid AHA addresses: -* 0x130, 0x134, 0x230, 0x234, 0x330, 0x334 -* <BUSON> is the time (in microsecs) that AHA spends on the AT-bus -* when transferring data. 1542A power-on default is 11us, -* valid values are in range: 2..15 (decimal) -* <BUSOFF> is the time that AHA spends OFF THE BUS after while -* it is transferring data (not to monopolize the bus). -* Power-on default is 4us, valid range: 1..64 microseconds. -* <DMASPEED> Default is jumper selected (1542A: on the J1), -* but experimenter can alter it with this. -* Valid values: 5, 6, 7, 8, 10 (MB/s) -* Factory default is 5 MB/s. -*/ +/* time AHA spends off the bus (not to monopolize it) during data transfer */ +static int bus_off[MAXBOARDS ] = {-1 ,-1 ,-1 ,-1 };/* power-on default: 4us */ +module_param_array (bus_off, int,NULL ,0 ); +MODULE_PARM_DESC (bus_off,"bus off time [us] (1-64, default=-1 [HW default: 4])" ); -#if defined(MODULE ) -static bool isapnp =0 ; -static int aha1542[] = {0x330 ,11 ,4 ,-1 }; -module_param_array (aha1542, int,NULL ,0 ); -module_param (isapnp, bool,0 ); -#else -static int isapnp =1 ; -#endif +/* default is jumper selected (J1 on 1542A), factory default = 5 MB/s */ +static int dma_speed[MAXBOARDS ] = {-1 ,-1 ,-1 ,-1 }; +module_param_array (dma_speed, int,NULL ,0 ); +MODULE_PARM_DESC (dma_speed,"DMA speed [MB/s] (5,6,7,8,10, default=-1 [by jumper])" );#define BIOS_TRANSLATION_1632 0/* Used by some old 1542A boards */ #define BIOS_TRANSLATION_6432 1/* Default case these days */
@@ -792,101 +766,48 @@ static int aha1542_query(int base_io, int *transl)return 0 ; } -#ifndef MODULE -static char *setup_str[MAXBOARDS ]__initdata ; -static int setup_idx =0 ; - -static void __init aha1542_setup (char *str,int *ints) +static u8 dma_speed_hw (int dma_speed) { -const char *ahausage ="aha1542: usage: aha1542=<PORTBASE>[,<BUSON>,<BUSOFF>[,<DMASPEED>]]\n" ; -int setup_portbase; - -if (setup_idx >=MAXBOARDS ) { -printk (KERN_ERR "aha1542: aha1542_setup called too many times! Bad LILO params ?\n" ); -printk (KERN_ERR " Entryline 1: %s\n" , setup_str[0 ]); -printk (KERN_ERR " Entryline 2: %s\n" , setup_str[1 ]); -printk (KERN_ERR " This line: %s\n" , str); -return ; - } -if (ints[0 ] <1 || ints[0 ] >4 ) { -printk (KERN_ERR "aha1542: %s\n" , str); -printk (ahausage); -printk (KERN_ERR "aha1542: Wrong parameters may cause system malfunction.. We try anyway..\n" ); - } - setup_called[setup_idx] = ints[0 ]; - setup_str[setup_idx] = str; - - setup_portbase = ints[0 ] >=1 ? ints[1 ] :0 ;/* Preserve the default value.. */ - setup_buson[setup_idx] = ints[0 ] >=2 ? ints[2 ] :7 ; - setup_busoff[setup_idx] = ints[0 ] >=3 ? ints[3 ] :5 ; -if (ints[0 ] >=4 ) - { -int atbt =-1 ; -switch (ints[4 ]) { -case 5 : - atbt =0x00 ; -break ; -case 6 : - atbt =0x04 ; -break ; -case 7 : - atbt =0x01 ; -break ; -case 8 : - atbt =0x02 ; -break ; -case 10 : - atbt =0x03 ; -break ; -default : -printk (KERN_ERR "aha1542: %s\n" , str); -printk (ahausage); -printk (KERN_ERR "aha1542: Valid values for DMASPEED are 5-8, 10 MB/s. Using jumper defaults.\n" ); -break ; - } - setup_dmaspeed[setup_idx] = atbt; +switch (dma_speed) { +case 5 : +return 0x00 ; +case 6 : +return 0x04 ; +case 7 : +return 0x01 ; +case 8 : +return 0x02 ; +case 10 : +return 0x03 ; } -if (setup_portbase !=0 ) - bases[setup_idx] = setup_portbase; - ++setup_idx; +return 0xff ;/* invalid */ } -static int __init do_setup (char *str) +/* Set the Bus on/off-times as not to ruin floppy performance */ +static void aha1542_set_bus_times (int indx) { -int ints[5 ]; +unsigned int base_io = io[indx]; -int count=setup_idx; +if (bus_on[indx] >0 ) { +u8 oncmd[] = {CMD_BUSON_TIME ,clamp (bus_on[indx],2 ,15 ) }; -get_options (str,ARRAY_SIZE (ints), ints); -aha1542_setup (str,ints); +aha1542_intr_reset (base_io); +if (aha1542_out (base_io, oncmd,2 )) + goto fail; + } -return count<setup_idx; -} +if (bus_off[indx] >0 ) { +u8 offcmd[] = {CMD_BUSOFF_TIME ,clamp (bus_off[indx],1 ,64 ) }; -__setup ("aha1542=" ,do_setup); -#endif +aha1542_intr_reset (base_io); +if (aha1542_out (base_io, offcmd,2 )) + goto fail; + } -/* Set the Bus on/off-times as not to ruin floppy performance */ -static void aha1542_set_bus_times (int indx) -{ -unsigned int base_io = bases[indx]; -u8 oncmd[] = {CMD_BUSON_TIME ,7 }; -u8 offcmd[] = {CMD_BUSOFF_TIME ,5 }; +if (dma_speed_hw (dma_speed[indx]) !=0xff ) { +u8 dmacmd[] = {CMD_DMASPEED ,dma_speed_hw (dma_speed[indx]) }; -if (setup_called[indx]) { - oncmd[1 ] = setup_buson[indx]; - offcmd[1 ] = setup_busoff[indx]; - } -aha1542_intr_reset (base_io); -if (aha1542_out (base_io, oncmd,2 )) - goto fail; -aha1542_intr_reset (base_io); -if (aha1542_out (base_io, offcmd,2 )) - goto fail; -if (setup_dmaspeed[indx] >=0 ) { -u8 dmacmd[] = {CMD_DMASPEED ,0 }; - dmacmd[1 ] = setup_dmaspeed[indx];aha1542_intr_reset (base_io);if (aha1542_out (base_io, dmacmd,2 )) goto fail;
@@ -901,7 +822,7 @@ fail:/* return non-zero on detection */ static struct Scsi_Host *aha1542_hw_init (struct scsi_host_template *tpnt,struct device *pdev,int indx) { -unsigned int base_io = bases[indx]; +unsigned int base_io = io[indx];struct Scsi_Host *shpnt;struct aha1542_hostdata *aha1542;
@@ -1207,19 +1128,19 @@ static int aha1542_pnp_probe(struct pnp_dev *pdev, const struct pnp_device_id *iint indx;struct Scsi_Host *sh; -for (indx =0 ; indx <ARRAY_SIZE (bases); indx++) { -if (bases[indx]) +for (indx =0 ; indx <ARRAY_SIZE (io); indx++) { +if (io[indx])continue ;if (pnp_activate_dev (pdev) <0 )continue ; - bases[indx] =pnp_port_start (pdev,0 ); + io[indx] =pnp_port_start (pdev,0 );/* The card can be queried for its DMA, we have the DMA set up that is enough */ -printk (KERN_INFO "ISAPnP found an AHA1535 at I/O 0x%03X\n" , bases[indx]); +printk (KERN_INFO "ISAPnP found an AHA1535 at I/O 0x%03X\n" , io[indx]); } sh =aha1542_hw_init (&driver_template, &pdev->dev, indx);
@@ -1248,32 +1169,6 @@ static int pnp_registered;static int __init aha1542_init (void ) {int ret =0 ; -#ifdef MODULE -int atbt =-1 ; - - bases[0 ] = aha1542[0 ]; - setup_buson[0 ] = aha1542[1 ]; - setup_busoff[0 ] = aha1542[2 ]; - -switch (aha1542[3 ]) { -case 5 : - atbt =0x00 ; -break ; -case 6 : - atbt =0x04 ; -break ; -case 7 : - atbt =0x01 ; -break ; -case 8 : - atbt =0x02 ; -break ; -case 10 : - atbt =0x03 ; -break ; - }; - setup_dmaspeed[0 ] = atbt; -#endif #ifdef CONFIG_PNP if (isapnp) {
Signature · 1 line
Ondrej Zary
PATCH 21/36 aha1542: Simplify aha1542_biosparam
In reply to Ondrej ZarySimplify aha1542_biosparam, use sector_div, remove unused BIOS_TRANSLATION_1632.
--- drivers/scsi/aha1542.c | 21 ++++++++------------- 1 file changed, 8 insertions(+), 13 deletions(-)
drivers/scsi/aha1542.c +8 -13
@@ -78,7 +78,6 @@ static int dma_speed[MAXBOARDS] = { -1, -1, -1, -1 };module_param_array (dma_speed, int,NULL ,0 );MODULE_PARM_DESC (dma_speed,"DMA speed [MB/s] (5,6,7,8,10, default=-1 [by jumper])" ); -#define BIOS_TRANSLATION_1632 0/* Used by some old 1542A boards */ #define BIOS_TRANSLATION_6432 1/* Default case these days */ #define BIOS_TRANSLATION_25563 2/* Big disk case */
@@ -1048,24 +1047,20 @@ static int aha1542_host_reset(Scsi_Cmnd *SCpnt) }static int aha1542_biosparam (struct scsi_device *sdev, -struct block_device *bdev,sector_t capacity,int *ip) +struct block_device *bdev,sector_t capacity,int geom[]) {struct aha1542_hostdata *aha1542 =shost_priv (sdev->host); -int translation_algorithm; -int size = capacity; - translation_algorithm = aha1542->bios_translation; - -if ((size >>11 ) >1024 && translation_algorithm ==BIOS_TRANSLATION_25563 ) { +if (capacity >=0x200000 && + aha1542->bios_translation ==BIOS_TRANSLATION_25563 ) {/* Please verify that this is the same as what DOS returns */ - ip[0 ] =255 ; - ip[1 ] =63 ; - ip[2 ] = size /255 /63 ; + geom[0 ] =255 ;/* heads */ + geom[1 ] =63 ;/* sectors */ }else { - ip[0 ] =64 ; - ip[1 ] =32 ; - ip[2 ] = size >>11 ; + geom[0 ] =64 ;/* heads */ + geom[1 ] =32 ;/* sectors */ } + geom[2 ] =sector_div (capacity, geom[0 ] * geom[1 ]);/* cylinders */ return 0 ; }
Signature · 1 line
Ondrej Zary
PATCH 22/36 aha1542: clean up cmd variables
In reply to Ondrej ZaryMake sure that there's no variable named cmd
--- drivers/scsi/aha1542.c | 53 ++++++++++++++++++++++-------------------------- 1 file changed, 24 insertions(+), 29 deletions(-)
drivers/scsi/aha1542.c +24 -29
@@ -124,7 +124,7 @@ static inline bool wait_mask(u16 port, u8 mask, u8 allof, u8 noneof, int timeoutroutine does not send something out while we are in the middle of this. Fortunately, it is only at boot time that multi-byte messages are ever sent. */ -static int aha1542_outb (unsigned int base,u8 cmd) +static int aha1542_outb (unsigned int base,u8 val) {unsigned long flags;
@@ -138,13 +138,13 @@ static int aha1542_outb(unsigned int base, u8 cmd)spin_unlock_irqrestore (&aha1542_lock, flags);continue ; } -outb (cmd,DATA (base)); +outb (val,DATA (base));spin_unlock_irqrestore (&aha1542_lock, flags);return 0 ; } } -static int aha1542_out (unsigned int base,u8 *cmdp,int len) +static int aha1542_out (unsigned int base,u8 *buf,int len) {unsigned long flags;
@@ -155,7 +155,7 @@ static int aha1542_out(unsigned int base, u8 *cmdp, int len)printk (KERN_ERR "aha1542_out failed(%d): " , len +1 );return 1 ; } -outb (*cmdp++,DATA (base)); +outb (*buf++,DATA (base)); }spin_unlock_irqrestore (&aha1542_lock, flags);if (!wait_mask (INTRFLAGS (base),INTRMASK ,HACC ,0 ,0 ))
@@ -167,7 +167,7 @@ static int aha1542_out(unsigned int base, u8 *cmdp, int len)/* Only used at boot time, so we do not need to worry about latency as much here */ -static int aha1542_in (unsigned int base,u8 *cmdp,int len,int timeout) +static int aha1542_in (unsigned int base,u8 *buf,int len,int timeout) {unsigned long flags;
@@ -179,7 +179,7 @@ static int aha1542_in(unsigned int base, u8 *cmdp, int len, int timeout)printk (KERN_ERR "aha1542_in failed(%d): " , len +1 );return 1 ; } - *cmdp++ =inb (DATA (base)); + *buf++ =inb (DATA (base)); }spin_unlock_irqrestore (&aha1542_lock, flags);return 0 ;
@@ -244,8 +244,7 @@ static int makecode(unsigned hosterr, unsigned scsierr)static int aha1542_test_port (int bse,struct Scsi_Host *shpnt) {u8 inquiry_result[4 ]; -u8 *cmdp; -int len; +int i;/* Quick and dirty test for presence of the card. */ if (inb (STATUS (bse)) ==0xff )
@@ -273,13 +272,10 @@ static int aha1542_test_port(int bse, struct Scsi_Host *shpnt)aha1542_outb (bse,CMD_INQUIRY ); - len =4 ; - cmdp = &inquiry_result[0 ]; - -while (len--) { +for (i =0 ; i <4 ; i++) {if (!wait_mask (STATUS (bse),DF ,DF ,0 ,0 ))return 0 ; - *cmdp++ =inb (DATA (bse)); + inquiry_result[i] =inb (DATA (bse)); }/* Reading port should reset DF */
@@ -463,7 +459,6 @@ static int aha1542_queuecommand_lck(Scsi_Cmnd * SCpnt, void (*done) (Scsi_Cmnd * {struct aha1542_hostdata *aha1542 =shost_priv (SCpnt->device->host);u8 direction; -u8 *cmd = (u8 *) SCpnt->cmnd;u8 target = SCpnt->device->id;u8 lun = SCpnt->device->lun;unsigned long flags;
@@ -480,28 +475,28 @@ static int aha1542_queuecommand_lck(Scsi_Cmnd * SCpnt, void (*done) (Scsi_Cmnd * } ); -if (*cmd ==REQUEST_SENSE ) { +if (*SCpnt->cmnd ==REQUEST_SENSE ) {/* Don't do the command - we have the sense data already */ SCpnt->result =0 ;done (SCpnt);return 0 ; }#ifdef DEBUG -if (*cmd ==READ_10 || *cmd ==WRITE_10 ) - i =xscsi2int (cmd +2 ); -else if (*cmd ==READ_6 || *cmd ==WRITE_6 ) - i =scsi2int (cmd +2 ); +if (*SCpnt->cmnd ==READ_10 || *SCpnt->cmnd ==WRITE_10 ) + i =xscsi2int (SCpnt->cmnd +2 ); +else if (*SCpnt->cmnd ==READ_6 || *SCpnt->cmnd ==WRITE_6 ) + i =scsi2int (SCpnt->cmnd +2 );else i =-1 ;if (done) -printk (KERN_DEBUG "aha1542_queuecommand: dev %d cmd %02x pos %d len %d " , target, *cmd, i, bufflen); +printk (KERN_DEBUG "aha1542_queuecommand: dev %d cmd %02x pos %d len %d " , target, *SCpnt->cmnd, i, bufflen);else -printk (KERN_DEBUG "aha1542_command: dev %d cmd %02x pos %d len %d " , target, *cmd, i, bufflen); +printk (KERN_DEBUG "aha1542_command: dev %d cmd %02x pos %d len %d " , target, *SCpnt->cmnd, i, bufflen);printk (KERN_DEBUG "aha1542_queuecommand: dumping scsi cmd:" );for (i =0 ; i < SCpnt->cmd_len; i++) -printk ("%02x " , cmd[i]); +printk ("%02x " , SCpnt->cmnd[i]);printk ("\n" ); -if (*cmd ==WRITE_10 || *cmd ==WRITE_6 ) +if (*SCpnt->cmnd ==WRITE_10 || *SCpnt->cmnd ==WRITE_6 )return 0 ;/* we are still testing, so *don't* write */ #endif /* Use the outgoing mailboxes in a round-robin fashion, because this
@@ -540,12 +535,12 @@ static int aha1542_queuecommand_lck(Scsi_Cmnd * SCpnt, void (*done) (Scsi_Cmnd * ccb[mbo].cdblen = SCpnt->cmd_len; direction =0 ; -if (*cmd ==READ_10 || *cmd ==READ_6 ) +if (*SCpnt->cmnd ==READ_10 || *SCpnt->cmnd ==READ_6 ) direction =8 ; -else if (*cmd ==WRITE_10 || *cmd ==WRITE_6 ) +else if (*SCpnt->cmnd ==WRITE_10 || *SCpnt->cmnd ==WRITE_6 ) direction =16 ; -memcpy (ccb[mbo].cdb, cmd, ccb[mbo].cdblen); +memcpy (ccb[mbo].cdb, SCpnt->cmnd, ccb[mbo].cdblen);if (bufflen) {struct scatterlist *sg;
@@ -617,15 +612,15 @@ static void setup_mailboxes(int bse, struct Scsi_Host *shpnt)struct mailbox *mb = aha1542->mb;struct ccb *ccb = aha1542->ccb; -u8 cmd[5 ] = {CMD_MBINIT ,AHA1542_MAILBOXES ,0 ,0 ,0 }; +u8 mb_cmd[5 ] = {CMD_MBINIT ,AHA1542_MAILBOXES ,0 ,0 ,0 };for (i =0 ; i <AHA1542_MAILBOXES ; i++) { mb[i].status = mb[AHA1542_MAILBOXES + i].status =0 ;any2scsi (mb[i].ccbptr,isa_virt_to_bus (&ccb[i])); };aha1542_intr_reset (bse);/* reset interrupts, so they don't block */ -any2scsi ((cmd +2 ),isa_virt_to_bus (mb)); -if (aha1542_out (bse, cmd,5 )) +any2scsi ((mb_cmd +2 ),isa_virt_to_bus (mb)); +if (aha1542_out (bse, mb_cmd,5 ))printk (KERN_ERR "aha1542_detect: failed setting up mailboxes\n" );aha1542_intr_reset (bse); }
Signature · 1 line
Ondrej Zary
PATCH 23/36 aha1524: Use struct scsi_cmnd
In reply to Ondrej ZaryUse struct scsi_cmnd instead of Scsi_Cmnd and also rename the variables to get rid of SC prefix
--- drivers/scsi/aha1542.c | 150 ++++++++++++++++++++++++------------------------ 1 file changed, 75 insertions(+), 75 deletions(-)
drivers/scsi/aha1542.c +75 -75
@@ -86,7 +86,7 @@ struct aha1542_hostdata {int bios_translation;/* Mapping bios uses - for compatibility */ int aha1542_last_mbi_used;int aha1542_last_mbo_used; -Scsi_Cmnd *SCint[AHA1542_MAILBOXES ]; +struct scsi_cmnd *int_cmds[AHA1542_MAILBOXES ];struct mailbox mb[2 *AHA1542_MAILBOXES ];struct ccb ccb[AHA1542_MAILBOXES ]; };
@@ -296,11 +296,11 @@ static int aha1542_test_port(int bse, struct Scsi_Host *shpnt)static void aha1542_intr_handle (struct Scsi_Host *shost) {struct aha1542_hostdata *aha1542 =shost_priv (shost); -void (*my_done) (Scsi_Cmnd *) =NULL ; +void (*my_done)(struct scsi_cmnd *) =NULL ;int errstatus, mbi, mbo, mbistatus;int number_serviced;unsigned long flags; -Scsi_Cmnd *SCtmp; +struct scsi_cmnd *tmp_cmd;int flag;struct mailbox *mb = aha1542->mb;struct ccb *ccb = aha1542->ccb;
@@ -383,22 +383,22 @@ static void aha1542_intr_handle(struct Scsi_Host *shost)printk (KERN_DEBUG "...done %d %d\n" , mbo, mbi);#endif - SCtmp = aha1542->SCint[mbo]; + tmp_cmd = aha1542->int_cmds[mbo]; -if (!SCtmp || !SCtmp->scsi_done) { +if (!tmp_cmd || !tmp_cmd->scsi_done) {printk (KERN_WARNING "aha1542_intr_handle: Unexpected interrupt\n" );printk (KERN_WARNING "tarstat=%x, hastat=%x idlun=%x ccb#=%d \n" , ccb[mbo].tarstat, ccb[mbo].hastat, ccb[mbo].idlun, mbo);return ; } - my_done = SCtmp->scsi_done; -kfree (SCtmp->host_scribble); - SCtmp->host_scribble =NULL ; + my_done = tmp_cmd->scsi_done; +kfree (tmp_cmd->host_scribble); + tmp_cmd->host_scribble =NULL ;/* Fetch the sense data, and tuck it away, in the required slot. The Adaptec automatically fetches it, and there is no guarantee that we will still have it in the cdb when we come back */ if (ccb[mbo].tarstat ==2 ) -memcpy (SCtmp->sense_buffer, &ccb[mbo].cdb[ccb[mbo].cdblen], +memcpy (tmp_cmd->sense_buffer, &ccb[mbo].cdb[ccb[mbo].cdblen],SCSI_SENSE_BUFFERSIZE );
@@ -435,10 +435,10 @@ static void aha1542_intr_handle(struct Scsi_Host *shost)*/ } DEB(if (errstatus) printk("aha1542_intr_handle: returning %6x\n", errstatus)); - SCtmp->result = errstatus; - aha1542->SCint[mbo] =NULL ;/* This effectively frees up the mailbox slot, as + tmp_cmd->result = errstatus; + aha1542->int_cmds[mbo] =NULL ;/* This effectively frees up the mailbox slot, as far as queuecommand is concerned */ -my_done (SCtmp); +my_done (tmp_cmd); number_serviced++; }; }
@@ -455,14 +455,14 @@ static irqreturn_t do_aha1542_intr_handle(int dummy, void *dev_id)return IRQ_HANDLED ; } -static int aha1542_queuecommand_lck (Scsi_Cmnd * SCpnt,void (*done) (Scsi_Cmnd *)) +static int aha1542_queuecommand_lck (struct scsi_cmnd *cmd,void (*done) (struct scsi_cmnd *)) { -struct aha1542_hostdata *aha1542 =shost_priv (SCpnt->device->host); +struct aha1542_hostdata *aha1542 =shost_priv (cmd->device->host);u8 direction; -u8 target = SCpnt->device->id; -u8 lun = SCpnt->device->lun; +u8 target = cmd->device->id; +u8 lun = cmd->device->lun;unsigned long flags; -int bufflen =scsi_bufflen (SCpnt); +int bufflen =scsi_bufflen (cmd);int mbo;struct mailbox *mb = aha1542->mb;struct ccb *ccb = aha1542->ccb;
@@ -470,33 +470,33 @@ static int aha1542_queuecommand_lck(Scsi_Cmnd * SCpnt, void (*done) (Scsi_Cmnd * DEB(int i); DEB(if (target > 1) { - SCpnt->result =DID_TIME_OUT <<16 ; -done (SCpnt);return 0 ; + cmd->result =DID_TIME_OUT <<16 ; +done (cmd);return 0 ; } ); -if (*SCpnt->cmnd ==REQUEST_SENSE ) { +if (*cmd->cmnd ==REQUEST_SENSE ) {/* Don't do the command - we have the sense data already */ - SCpnt->result =0 ; -done (SCpnt); + cmd->result =0 ; +done (cmd);return 0 ; }#ifdef DEBUG -if (*SCpnt->cmnd ==READ_10 || *SCpnt->cmnd ==WRITE_10 ) - i =xscsi2int (SCpnt->cmnd +2 ); -else if (*SCpnt->cmnd ==READ_6 || *SCpnt->cmnd ==WRITE_6 ) - i =scsi2int (SCpnt->cmnd +2 ); +if (*cmd->cmnd ==READ_10 || *cmd->cmnd ==WRITE_10 ) + i =xscsi2int (cmd->cmnd +2 ); +else if (*cmd->cmnd ==READ_6 || *cmd->cmnd ==WRITE_6 ) + i =scsi2int (cmd->cmnd +2 );else i =-1 ;if (done) -printk (KERN_DEBUG "aha1542_queuecommand: dev %d cmd %02x pos %d len %d " , target, *SCpnt->cmnd, i, bufflen); +printk (KERN_DEBUG "aha1542_queuecommand: dev %d cmd %02x pos %d len %d " , target, *cmd->cmnd, i, bufflen);else -printk (KERN_DEBUG "aha1542_command: dev %d cmd %02x pos %d len %d " , target, *SCpnt->cmnd, i, bufflen); +printk (KERN_DEBUG "aha1542_command: dev %d cmd %02x pos %d len %d " , target, *cmd->cmnd, i, bufflen);printk (KERN_DEBUG "aha1542_queuecommand: dumping scsi cmd:" ); -for (i =0 ; i < SCpnt->cmd_len; i++) -printk ("%02x " , SCpnt->cmnd[i]); +for (i =0 ; i < cmd->cmd_len; i++) +printk ("%02x " , cmd->cmnd[i]);printk ("\n" ); -if (*SCpnt->cmnd ==WRITE_10 || *SCpnt->cmnd ==WRITE_6 ) +if (*cmd->cmnd ==WRITE_10 || *cmd->cmnd ==WRITE_6 )return 0 ;/* we are still testing, so *don't* write */ #endif /* Use the outgoing mailboxes in a round-robin fashion, because this
@@ -508,17 +508,17 @@ static int aha1542_queuecommand_lck(Scsi_Cmnd * SCpnt, void (*done) (Scsi_Cmnd * mbo =0 ;do { -if (mb[mbo].status ==0 && aha1542->SCint[mbo] ==NULL ) +if (mb[mbo].status ==0 && aha1542->int_cmds[mbo] ==NULL )break ; mbo++;if (mbo >=AHA1542_MAILBOXES ) mbo =0 ; }while (mbo != aha1542->aha1542_last_mbo_used); -if (mb[mbo].status || aha1542->SCint[mbo]) +if (mb[mbo].status || aha1542->int_cmds[mbo])panic ("Unable to find empty mailbox for aha1542.\n" ); - aha1542->SCint[mbo] = SCpnt;/* This will effectively prevent someone else from + aha1542->int_cmds[mbo] = cmd;/* This will effectively prevent someone else from screwing with this cdb. */ aha1542->aha1542_last_mbo_used = mbo;
@@ -532,15 +532,15 @@ static int aha1542_queuecommand_lck(Scsi_Cmnd * SCpnt, void (*done) (Scsi_Cmnd *memset (&ccb[mbo],0 ,sizeof (struct ccb )); - ccb[mbo].cdblen = SCpnt->cmd_len; + ccb[mbo].cdblen = cmd->cmd_len; direction =0 ; -if (*SCpnt->cmnd ==READ_10 || *SCpnt->cmnd ==READ_6 ) +if (*cmd->cmnd ==READ_10 || *cmd->cmnd ==READ_6 ) direction =8 ; -else if (*SCpnt->cmnd ==WRITE_10 || *SCpnt->cmnd ==WRITE_6 ) +else if (*cmd->cmnd ==WRITE_10 || *cmd->cmnd ==WRITE_6 ) direction =16 ; -memcpy (ccb[mbo].cdb, SCpnt->cmnd, ccb[mbo].cdblen); +memcpy (ccb[mbo].cdb, cmd->cmnd, ccb[mbo].cdblen);if (bufflen) {struct scatterlist *sg;
@@ -548,17 +548,17 @@ static int aha1542_queuecommand_lck(Scsi_Cmnd * SCpnt, void (*done) (Scsi_Cmnd *#ifdef DEBUG unsigned char *ptr;#endif -int i, sg_count =scsi_sg_count (SCpnt); +int i, sg_count =scsi_sg_count (cmd); ccb[mbo].op =2 ;/* SCSI Initiator Command w/scatter-gather */ - SCpnt->host_scribble =kmalloc (sizeof (*cptr)*sg_count, + cmd->host_scribble =kmalloc (sizeof (*cptr)*sg_count,GFP_KERNEL |GFP_DMA ); - cptr = (struct chain *) SCpnt->host_scribble; + cptr = (struct chain *) cmd->host_scribble;if (cptr ==NULL ) {/* free the claimed mailbox slot */ - aha1542->SCint[mbo] =NULL ; + aha1542->int_cmds[mbo] =NULL ;return SCSI_MLQUEUE_HOST_BUSY ; } -scsi_for_each_sg (SCpnt, sg, sg_count, i) { +scsi_for_each_sg (cmd, sg, sg_count, i) {any2scsi (cptr[i].dataptr,isa_page_to_bus (sg_page (sg)) + sg->offset);any2scsi (cptr[i].datalen, sg->length);
@@ -573,7 +573,7 @@ static int aha1542_queuecommand_lck(Scsi_Cmnd * SCpnt, void (*done) (Scsi_Cmnd *#endif }else { ccb[mbo].op =0 ;/* SCSI Initiator Command */ - SCpnt->host_scribble =NULL ; + cmd->host_scribble =NULL ;any2scsi (ccb[mbo].datalen,0 );any2scsi (ccb[mbo].dataptr,0 ); };
@@ -593,9 +593,9 @@ static int aha1542_queuecommand_lck(Scsi_Cmnd * SCpnt, void (*done) (Scsi_Cmnd *if (done) {DEB (printk ("aha1542_queuecommand: now waiting for interrupt " )); - SCpnt->scsi_done = done; + cmd->scsi_done = done; mb[mbo].status =1 ; -aha1542_outb (SCpnt->device->host->io_port,CMD_START_SCSI ); +aha1542_outb (cmd->device->host->io_port,CMD_START_SCSI ); }else printk ("aha1542_queuecommand: done can't be NULL\n" );
@@ -908,13 +908,13 @@ static int aha1542_release(struct Scsi_Host *shost)* This is a device reset. This is handled by sending a special command * to the device. */ -static int aha1542_dev_reset (Scsi_Cmnd * SCpnt) +static int aha1542_dev_reset (struct scsi_cmnd *cmd) { -struct aha1542_hostdata *aha1542 =shost_priv (SCpnt->device->host); +struct aha1542_hostdata *aha1542 =shost_priv (cmd->device->host);unsigned long flags;struct mailbox *mb = aha1542->mb; -u8 target = SCpnt->device->id; -u8 lun = SCpnt->device->lun; +u8 target = cmd->device->id; +u8 lun = cmd->device->lun;int mbo;struct ccb *ccb = aha1542->ccb;
@@ -924,17 +924,17 @@ static int aha1542_dev_reset(Scsi_Cmnd * SCpnt) mbo =0 ;do { -if (mb[mbo].status ==0 && aha1542->SCint[mbo] ==NULL ) +if (mb[mbo].status ==0 && aha1542->int_cmds[mbo] ==NULL )break ; mbo++;if (mbo >=AHA1542_MAILBOXES ) mbo =0 ; }while (mbo != aha1542->aha1542_last_mbo_used); -if (mb[mbo].status || aha1542->SCint[mbo]) +if (mb[mbo].status || aha1542->int_cmds[mbo])panic ("Unable to find empty mailbox for aha1542.\n" ); - aha1542->SCint[mbo] = SCpnt;/* This will effectively + aha1542->int_cmds[mbo] = cmd;/* This will effectively prevent someone else from screwing with this cdb. */
@@ -956,17 +956,17 @@ static int aha1542_dev_reset(Scsi_Cmnd * SCpnt)* Now tell the 1542 to flush all pending commands for this * target */ -aha1542_outb (SCpnt->device->host->io_port,CMD_START_SCSI ); +aha1542_outb (cmd->device->host->io_port,CMD_START_SCSI ); -scmd_printk (KERN_WARNING , SCpnt, +scmd_printk (KERN_WARNING , cmd,"Trying device reset for target\n" );return SUCCESS ; } -static int aha1542_reset (Scsi_Cmnd *SCpnt,u8 reset_cmd) +static int aha1542_reset (struct scsi_cmnd *cmd,u8 reset_cmd) { -struct aha1542_hostdata *aha1542 =shost_priv (SCpnt->device->host); +struct aha1542_hostdata *aha1542 =shost_priv (cmd->device->host);int i;/*
@@ -975,7 +975,7 @@ static int aha1542_reset(Scsi_Cmnd *SCpnt, u8 reset_cmd)* we do this? Try this first, and we can add that later * if it turns out to be useful. */ -outb (reset_cmd,CONTROL (SCpnt->device->host->io_port)); +outb (reset_cmd,CONTROL (cmd->device->host->io_port));/* * Wait for the thing to settle down a bit. Unfortunately
@@ -985,11 +985,11 @@ static int aha1542_reset(Scsi_Cmnd *SCpnt, u8 reset_cmd)* we are pretty desperate anyways. */ ssleep (4 ); -spin_lock_irq (SCpnt->device->host->host_lock); +spin_lock_irq (cmd->device->host->host_lock); -if (!wait_mask (STATUS (SCpnt->device->host->io_port), +if (!wait_mask (STATUS (cmd->device->host->io_port),STATMASK ,INIT |IDLE ,STST |DIAGF |INVDCMD |DF |CDF ,0 )) { -spin_unlock_irq (SCpnt->device->host->host_lock); +spin_unlock_irq (cmd->device->host->host_lock);return FAILED ; }/*
@@ -997,21 +997,21 @@ static int aha1542_reset(Scsi_Cmnd *SCpnt, u8 reset_cmd)* us again after host reset. */ if (reset_cmd &HRST ) -setup_mailboxes (SCpnt->device->host->io_port, SCpnt->device->host); +setup_mailboxes (cmd->device->host->io_port, cmd->device->host);/* * Now try to pick up the pieces. For all pending commands, * free any internal data structures, and basically clear things * out. We do not try and restart any commands or anything - * the strategy handler takes care of that crap. */ -printk (KERN_WARNING "Sent BUS RESET to scsi host %d\n" , SCpnt->device->host->host_no); +printk (KERN_WARNING "Sent BUS RESET to scsi host %d\n" , cmd->device->host->host_no);for (i =0 ; i <AHA1542_MAILBOXES ; i++) { -if (aha1542->SCint[i] !=NULL ) { -Scsi_Cmnd *SCtmp; - SCtmp = aha1542->SCint[i]; +if (aha1542->int_cmds[i] !=NULL ) { +struct scsi_cmnd *tmp_cmd; + tmp_cmd = aha1542->int_cmds[i]; -if (SCtmp->device->soft_reset) { +if (tmp_cmd->device->soft_reset) {/* * If this device implements the soft reset option, * then it is still holding onto the command, and
@@ -1020,25 +1020,25 @@ static int aha1542_reset(Scsi_Cmnd *SCpnt, u8 reset_cmd)*/ continue ; } -kfree (SCtmp->host_scribble); - SCtmp->host_scribble =NULL ; - aha1542->SCint[i] =NULL ; +kfree (tmp_cmd->host_scribble); + tmp_cmd->host_scribble =NULL ; + aha1542->int_cmds[i] =NULL ; aha1542->mb[i].status =0 ; } } -spin_unlock_irq (SCpnt->device->host->host_lock); +spin_unlock_irq (cmd->device->host->host_lock);return SUCCESS ; } -static int aha1542_bus_reset (Scsi_Cmnd *SCpnt) +static int aha1542_bus_reset (struct scsi_cmnd *cmd) { -return aha1542_reset (SCpnt,SCRST ); +return aha1542_reset (cmd,SCRST ); } -static int aha1542_host_reset (Scsi_Cmnd *SCpnt) +static int aha1542_host_reset (struct scsi_cmnd *cmd) { -return aha1542_reset (SCpnt,HRST |SCRST ); +return aha1542_reset (cmd,HRST |SCRST ); } static int aha1542_biosparam(struct scsi_device *sdev,
Signature · 1 line
Ondrej Zary
PATCH 24/36 aha1542: Always name Scsi_Host variables sh
In reply to Ondrej ZaryMake Scsi_Host variable names consistent - use sh everywhere.
--- drivers/scsi/aha1542.c | 98 ++++++++++++++++++++++++------------------------ 1 file changed, 49 insertions(+), 49 deletions(-)
drivers/scsi/aha1542.c +49 -49
@@ -241,7 +241,7 @@ static int makecode(unsigned hosterr, unsigned scsierr)return scsierr | (hosterr <<16 ); } -static int aha1542_test_port (int bse,struct Scsi_Host *shpnt) +static int aha1542_test_port (int bse,struct Scsi_Host *sh) {u8 inquiry_result[4 ];int i;
@@ -293,9 +293,9 @@ static int aha1542_test_port(int bse, struct Scsi_Host *shpnt) }/* A "high" level interrupt handler */ -static void aha1542_intr_handle (struct Scsi_Host *shost) +static void aha1542_intr_handle (struct Scsi_Host *sh) { -struct aha1542_hostdata *aha1542 =shost_priv (shost); +struct aha1542_hostdata *aha1542 =shost_priv (sh);void (*my_done)(struct scsi_cmnd *) =NULL ;int errstatus, mbi, mbo, mbistatus;int number_serviced;
@@ -307,7 +307,7 @@ static void aha1542_intr_handle(struct Scsi_Host *shost)#ifdef DEBUG { - flag =inb (INTRFLAGS (shost->io_port)); + flag =inb (INTRFLAGS (sh->io_port));printk (KERN_DEBUG "aha1542_intr_handle: " );if (!(flag &ANYINTR ))printk ("no interrupt?" );
@@ -319,13 +319,13 @@ static void aha1542_intr_handle(struct Scsi_Host *shost)printk ("HACC " );if (flag &SCRD )printk ("SCRD " ); - printk("status %02x\n", inb(STATUS(shost->io_port))); + printk("status %02x\n", inb(STATUS(sh->io_port))); };#endif number_serviced =0 ;while (1 ==1 ) { - flag =inb (INTRFLAGS (shost->io_port)); + flag =inb (INTRFLAGS (sh->io_port));/* Check for unusual interrupts. If any of these happen, we should probably do something special, but for now just printing a message
@@ -339,7 +339,7 @@ static void aha1542_intr_handle(struct Scsi_Host *shost)if (flag &SCRD )printk ("SCRD " ); } -aha1542_intr_reset (shost->io_port); +aha1542_intr_reset (sh->io_port);spin_lock_irqsave (&aha1542_lock, flags); mbi = aha1542->aha1542_last_mbi_used +1 ;
@@ -447,11 +447,11 @@ static void aha1542_intr_handle(struct Scsi_Host *shost)static irqreturn_t do_aha1542_intr_handle (int dummy,void *dev_id) {unsigned long flags; -struct Scsi_Host *shost = dev_id; +struct Scsi_Host *sh = dev_id; -spin_lock_irqsave (shost->host_lock, flags); -aha1542_intr_handle (shost); -spin_unlock_irqrestore (shost->host_lock, flags); +spin_lock_irqsave (sh->host_lock, flags); +aha1542_intr_handle (sh); +spin_unlock_irqrestore (sh->host_lock, flags);return IRQ_HANDLED ; }
@@ -605,9 +605,9 @@ static int aha1542_queuecommand_lck(struct scsi_cmnd *cmd, void (*done) (structstatic DEF_SCSI_QCMD (aha1542_queuecommand)/* Initialize mailboxes */ -static void setup_mailboxes(int bse, struct Scsi_Host *shpnt) +static void setup_mailboxes(int bse, struct Scsi_Host *sh) { -struct aha1542_hostdata *aha1542 =shost_priv (shpnt); +struct aha1542_hostdata *aha1542 =shost_priv (sh);int i;struct mailbox *mb = aha1542->mb;struct ccb *ccb = aha1542->ccb;
@@ -817,7 +817,7 @@ fail:static struct Scsi_Host *aha1542_hw_init (struct scsi_host_template *tpnt,struct device *pdev,int indx) {unsigned int base_io = io[indx]; -struct Scsi_Host *shpnt; +struct Scsi_Host *sh;struct aha1542_hostdata *aha1542;if (base_io ==0 )
@@ -826,80 +826,80 @@ static struct Scsi_Host *aha1542_hw_init(struct scsi_host_template *tpnt, structif (!request_region (base_io,AHA1542_REGION_SIZE ,"aha1542" ))return NULL ; - shpnt =scsi_host_alloc (tpnt,sizeof (struct aha1542_hostdata )); -if (!shpnt) + sh =scsi_host_alloc (tpnt,sizeof (struct aha1542_hostdata )); +if (!sh) goto release; - aha1542 =shost_priv (shpnt); + aha1542 =shost_priv (sh); -if (!aha1542_test_port (base_io, shpnt)) +if (!aha1542_test_port (base_io, sh)) goto unregister;aha1542_set_bus_times (indx);if (aha1542_query (base_io, &aha1542->bios_translation)) goto unregister; -if (aha1542_getconfig (base_io, &shpnt->irq, &shpnt->dma_channel, &shpnt->this_id) ==-1 ) +if (aha1542_getconfig (base_io, &sh->irq, &sh->dma_channel, &sh->this_id) ==-1 ) goto unregister; -printk (KERN_INFO "Adaptec AHA-1542 (SCSI-ID %d) at IO 0x%x, IRQ %d" , shpnt->this_id, base_io, shpnt->irq); -if (shpnt->dma_channel !=0xFF ) -printk (", DMA %d" , shpnt->dma_channel); +printk (KERN_INFO "Adaptec AHA-1542 (SCSI-ID %d) at IO 0x%x, IRQ %d" , sh->this_id, base_io, sh->irq); +if (sh->dma_channel !=0xFF ) +printk (", DMA %d" , sh->dma_channel);printk ("\n" );if (aha1542->bios_translation ==BIOS_TRANSLATION_25563 )printk (KERN_INFO "aha1542.c: Using extended bios translation\n" ); -setup_mailboxes (base_io, shpnt); +setup_mailboxes (base_io, sh); -if (request_irq (shpnt->irq, do_aha1542_intr_handle,0 , -"aha1542" , shpnt)) { +if (request_irq (sh->irq, do_aha1542_intr_handle,0 , +"aha1542" , sh)) {printk (KERN_ERR "Unable to allocate IRQ for adaptec controller.\n" ); goto unregister; } -if (shpnt->dma_channel !=0xFF ) { -if (request_dma (shpnt->dma_channel,"aha1542" )) { +if (sh->dma_channel !=0xFF ) { +if (request_dma (sh->dma_channel,"aha1542" )) {printk (KERN_ERR "Unable to allocate DMA channel for Adaptec.\n" ); goto free_irq; } -if (shpnt->dma_channel ==0 || shpnt->dma_channel >=5 ) { -set_dma_mode (shpnt->dma_channel,DMA_MODE_CASCADE ); -enable_dma (shpnt->dma_channel); +if (sh->dma_channel ==0 || sh->dma_channel >=5 ) { +set_dma_mode (sh->dma_channel,DMA_MODE_CASCADE ); +enable_dma (sh->dma_channel); } } - shpnt->unique_id = base_io; - shpnt->io_port = base_io; - shpnt->n_io_port =AHA1542_REGION_SIZE ; + sh->unique_id = base_io; + sh->io_port = base_io; + sh->n_io_port =AHA1542_REGION_SIZE ; aha1542->aha1542_last_mbi_used =2 *AHA1542_MAILBOXES -1 ; aha1542->aha1542_last_mbo_used =AHA1542_MAILBOXES -1 ; -if (scsi_add_host (shpnt, pdev)) +if (scsi_add_host (sh, pdev)) goto free_dma; -scsi_scan_host (shpnt); +scsi_scan_host (sh); -return shpnt; +return sh; free_dma: -if (shpnt->dma_channel !=0xff ) -free_dma (shpnt->dma_channel); +if (sh->dma_channel !=0xff ) +free_dma (sh->dma_channel); free_irq: -free_irq (shpnt->irq, shpnt); +free_irq (sh->irq, sh); unregister: -scsi_host_put (shpnt); +scsi_host_put (sh); release:release_region (base_io,AHA1542_REGION_SIZE );return NULL ; } -static int aha1542_release (struct Scsi_Host *shost) +static int aha1542_release (struct Scsi_Host *sh) { -scsi_remove_host (shost); -if (shost->dma_channel !=0xff ) -free_dma (shost->dma_channel); -if (shost->irq) -free_irq (shost->irq, shost); -if (shost->io_port && shost->n_io_port) -release_region (shost->io_port, shost->n_io_port); -scsi_host_put (shost); +scsi_remove_host (sh); +if (sh->dma_channel !=0xff ) +free_dma (sh->dma_channel); +if (sh->irq) +free_irq (sh->irq, sh); +if (sh->io_port && sh->n_io_port) +release_region (sh->io_port, sh->n_io_port); +scsi_host_put (sh);return 0 ; }
Signature · 1 line
Ondrej Zary
PATCH 25/36 aha1542: fix include guard and remove useless changelog
In reply to Ondrej ZaryFix include guard in header file and remove useless changelog
--- drivers/scsi/aha1542.h | 36 +++--------------------------------- 1 file changed, 3 insertions(+), 33 deletions(-)
drivers/scsi/aha1542.h +3 -33
@@ -1,35 +1,5 @@ -#ifndef _AHA1542_H - -/* $Id: aha1542.h,v 1.1 1992/07/24 06:27:38 root Exp root $ -* -* Header file for the adaptec 1542 driver for Linux -* -* $Log: aha1542.h,v $ -* Revision 1.1 1992/07/24 06:27:38 root -* Initial revision -* -* Revision 1.2 1992/07/04 18:41:49 root -* Replaced distribution with current drivers -* -* Revision 1.3 1992/06/23 23:58:20 root -* Fixes. -* -* Revision 1.2 1992/05/26 22:13:23 root -* Changed bug that prevented DMA above first 2 mbytes. -* -* Revision 1.1 1992/05/22 21:00:29 root -* Initial revision -* -* Revision 1.1 1992/04/24 18:01:50 root -* Initial revision -* -* Revision 1.1 1992/04/02 03:23:13 drew -* Initial revision -* -* Revision 1.3 1992/01/27 14:46:29 tthorn -* *** empty log message *** -* -*/ +#ifndef _AHA1542_H_ +#define _AHA1542_H_#include <linux/types.h>
@@ -129,4 +99,4 @@ struct ccb { /* Command Control Block 5.3 */#define AHA1542_REGION_SIZE 4#define AHA1542_MAILBOXES 8 -#endif +#endif /* _AHA1542_H_ */
Signature · 1 line
Ondrej Zary
PATCH 26/36 aha1542: remove useless changelog
In reply to Ondrej Zary--- drivers/scsi/aha1542.c | 25 +++---------------------- 1 file changed, 3 insertions(+), 22 deletions(-)
drivers/scsi/aha1542.c +3 -22
@@ -1,28 +1,9 @@ -/* $Id: aha1542.c,v 1.1 1992/07/24 06:27:38 root Exp root $ -* linux/kernel/aha1542.c +/* +* Driver for Adaptec AHA-1542 SCSI host adapters * * Copyright (C) 1992 Tommy Thorn * Copyright (C) 1993, 1994, 1995 Eric Youngdale -* -* Modified by Eric Youngdale -* Use request_irq and request_dma to help prevent unexpected conflicts -* Set up on-board DMA controller, such that we do not have to -* have the bios enabled to use the aha1542. -* Modified by David Gentzel -* Don't call request_dma if dma mask is 0 (for BusLogic BT-445S VL-Bus -* controller). -* Modified by Matti Aarnio -* Accept parameters from LILO cmd-line. -- 1-Oct-94 -* Modified by Mike McLagan <[email protected]> -* Recognise extended mode on AHA1542CP, different bit than 1542CF -* 1-Jan-97 -* Modified by Bjorn L. Thordarson and Einar Thor Einarsson -* Recognize that DMA0 is valid DMA channel -- 13-Jul-98 -* Modified by Chris Faulhaber <[email protected]> -* Added module command-line options -* 19-Jul-99 -* Modified by Adam Fritzler -* Added proper detection of the AHA-1640 (MCA, now deleted) +* Copyright (C) 2015 Ondrej Zary */ #include <linux/module.h>
Signature · 1 line
Ondrej Zary
PATCH 27/36 aha1542: cleanup includes
In reply to Ondrej Zary--- drivers/scsi/aha1542.c | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-)
drivers/scsi/aha1542.c +3 -8
@@ -11,23 +11,18 @@#include <linux/kernel.h> #include <linux/types.h> #include <linux/string.h> -#include <linux/ioport.h> #include <linux/delay.h> -#include <linux/proc_fs.h> #include <linux/init.h> #include <linux/spinlock.h> #include <linux/isa.h> #include <linux/pnp.h> -#include <linux/blkdev.h> #include <linux/slab.h> - +#include <linux/io.h> #include <asm/dma.h> -#include <asm/io.h> - -#include "scsi.h" +#include <scsi/scsi_cmnd.h> +#include <scsi/scsi_device.h> #include <scsi/scsi_host.h> #include "aha1542.h" -#include <linux/stat.h> #ifdef DEBUG #define DEB (x) x
Signature · 1 line
Ondrej Zary
PATCH 28/36 aha1542: Pass struct Scsi_Host * to functions
In reply to Ondrej ZaryPass struct Scsi_Host * to functions instead of base address. This reduces the number of parameters and is also required for printk conversion.
--- drivers/scsi/aha1542.c | 125 ++++++++++++++++++++++++------------------------ 1 file changed, 63 insertions(+), 62 deletions(-)
drivers/scsi/aha1542.c +63 -62
@@ -217,53 +217,53 @@ static int makecode(unsigned hosterr, unsigned scsierr)return scsierr | (hosterr <<16 ); } -static int aha1542_test_port (int bse,struct Scsi_Host *sh) +static int aha1542_test_port (struct Scsi_Host *sh) {u8 inquiry_result[4 ];int i;/* Quick and dirty test for presence of the card. */ -if (inb (STATUS (bse)) ==0xff ) +if (inb (STATUS (sh->io_port)) ==0xff )return 0 ;/* Reset the adapter. I ought to make a hard reset, but it's not really necessary */ /* In case some other card was probing here, reset interrupts */ -aha1542_intr_reset (bse);/* reset interrupts, so they don't block */ +aha1542_intr_reset (sh->io_port);/* reset interrupts, so they don't block */ -outb (SRST |IRST /*|SCRST */ ,CONTROL (bse)); +outb (SRST |IRST /*|SCRST */ ,CONTROL (sh->io_port));mdelay (20 );/* Wait a little bit for things to settle down. */ /* Expect INIT and IDLE, any of the others are bad */ -if (!wait_mask (STATUS (bse),STATMASK ,INIT |IDLE ,STST |DIAGF |INVDCMD |DF |CDF ,0 )) +if (!wait_mask (STATUS (sh->io_port),STATMASK ,INIT |IDLE ,STST |DIAGF |INVDCMD |DF |CDF ,0 ))return 0 ;/* Shouldn't have generated any interrupts during reset */ -if (inb (INTRFLAGS (bse)) &INTRMASK ) +if (inb (INTRFLAGS (sh->io_port)) &INTRMASK )return 0 ;/* Perform a host adapter inquiry instead so we do not need to set up the mailboxes ahead of time */ -aha1542_outb (bse,CMD_INQUIRY ); +aha1542_outb (sh->io_port,CMD_INQUIRY );for (i =0 ; i <4 ; i++) { -if (!wait_mask (STATUS (bse),DF ,DF ,0 ,0 )) +if (!wait_mask (STATUS (sh->io_port),DF ,DF ,0 ,0 ))return 0 ; - inquiry_result[i] =inb (DATA (bse)); + inquiry_result[i] =inb (DATA (sh->io_port)); }/* Reading port should reset DF */ -if (inb (STATUS (bse)) &DF ) +if (inb (STATUS (sh->io_port)) &DF )return 0 ;/* When HACC, command is completed, and we're though testing */ -if (!wait_mask (INTRFLAGS (bse),HACC ,HACC ,0 ,0 )) +if (!wait_mask (INTRFLAGS (sh->io_port),HACC ,HACC ,0 ,0 ))return 0 ;/* Clear interrupts */ -outb (IRST ,CONTROL (bse)); +outb (IRST ,CONTROL (sh->io_port));return 1 ; }
@@ -581,7 +581,7 @@ static int aha1542_queuecommand_lck(struct scsi_cmnd *cmd, void (*done) (structstatic DEF_SCSI_QCMD (aha1542_queuecommand)/* Initialize mailboxes */ -static void setup_mailboxes(int bse, struct Scsi_Host *sh) +static void setup_mailboxes(struct Scsi_Host *sh) {struct aha1542_hostdata *aha1542 =shost_priv (sh);int i;
@@ -594,43 +594,43 @@ static void setup_mailboxes(int bse, struct Scsi_Host *sh) mb[i].status = mb[AHA1542_MAILBOXES + i].status =0 ;any2scsi (mb[i].ccbptr,isa_virt_to_bus (&ccb[i])); }; -aha1542_intr_reset (bse);/* reset interrupts, so they don't block */ +aha1542_intr_reset (sh->io_port);/* reset interrupts, so they don't block */ any2scsi ((mb_cmd +2 ),isa_virt_to_bus (mb)); -if (aha1542_out (bse, mb_cmd,5 )) +if (aha1542_out (sh->io_port, mb_cmd,5 ))printk (KERN_ERR "aha1542_detect: failed setting up mailboxes\n" ); -aha1542_intr_reset (bse); +aha1542_intr_reset (sh->io_port); } -static int aha1542_getconfig (int base_io,unsigned int *irq_level,unsigned char *dma_chan,unsigned int *scsi_id) +static int aha1542_getconfig (struct Scsi_Host *sh) {u8 inquiry_result[3 ];int i; - i =inb (STATUS (base_io)); + i =inb (STATUS (sh->io_port));if (i &DF ) { - i =inb (DATA (base_io)); + i =inb (DATA (sh->io_port)); }; -aha1542_outb (base_io,CMD_RETCONF ); -aha1542_in (base_io, inquiry_result,3 ,0 ); -if (!wait_mask (INTRFLAGS (base_io),INTRMASK ,HACC ,0 ,0 )) +aha1542_outb (sh->io_port,CMD_RETCONF ); +aha1542_in (sh->io_port, inquiry_result,3 ,0 ); +if (!wait_mask (INTRFLAGS (sh->io_port),INTRMASK ,HACC ,0 ,0 ))printk (KERN_ERR "aha1542_detect: query board settings\n" ); -aha1542_intr_reset (base_io); +aha1542_intr_reset (sh->io_port);switch (inquiry_result[0 ]) {case 0x80 : - *dma_chan =7 ; + sh->dma_channel =7 ;break ;case 0x40 : - *dma_chan =6 ; + sh->dma_channel =6 ;break ;case 0x20 : - *dma_chan =5 ; + sh->dma_channel =5 ;break ;case 0x01 : - *dma_chan =0 ; + sh->dma_channel =0 ;break ;case 0 :/* This means that the adapter, although Adaptec 1542 compatible, doesn't use a DMA channel. Currently only aware of the BusLogic BT-445S VL-Bus adapter which needs this. */ - *dma_chan =0xFF ; + sh->dma_channel =0xFF ;break ;default :printk (KERN_ERR "Unable to determine Adaptec DMA priority. Disabling board\n" );
@@ -638,35 +638,35 @@ static int aha1542_getconfig(int base_io, unsigned int *irq_level, unsigned char };switch (inquiry_result[1 ]) {case 0x40 : - *irq_level =15 ; + sh->irq =15 ;break ;case 0x20 : - *irq_level =14 ; + sh->irq =14 ;break ;case 0x8 : - *irq_level =12 ; + sh->irq =12 ;break ;case 0x4 : - *irq_level =11 ; + sh->irq =11 ;break ;case 0x2 : - *irq_level =10 ; + sh->irq =10 ;break ;case 0x1 : - *irq_level =9 ; + sh->irq =9 ;break ;default :printk (KERN_ERR "Unable to determine Adaptec IRQ level. Disabling board\n" );return -1 ; }; - *scsi_id = inquiry_result[2 ] &7 ; + sh->this_id = inquiry_result[2 ] &7 ;return 0 ; }/* This function should only be called for 1542C boards - we can detect the special firmware settings and unlock the board */ -static int aha1542_mbenable (int base) +static int aha1542_mbenable (struct Scsi_Host *sh) {static u8 mbenable_cmd[3 ];static u8 mbenable_result[2 ];
@@ -674,12 +674,12 @@ static int aha1542_mbenable(int base) retval =BIOS_TRANSLATION_6432 ; -aha1542_outb (base,CMD_EXTBIOS ); -if (aha1542_in (base, mbenable_result,2 ,100 )) +aha1542_outb (sh->io_port,CMD_EXTBIOS ); +if (aha1542_in (sh->io_port, mbenable_result,2 ,100 ))return retval; -if (!wait_mask (INTRFLAGS (base),INTRMASK ,HACC ,0 ,100 )) +if (!wait_mask (INTRFLAGS (sh->io_port),INTRMASK ,HACC ,0 ,100 )) goto fail; -aha1542_intr_reset (base); +aha1542_intr_reset (sh->io_port);if ((mbenable_result[0 ] &0x08 ) || mbenable_result[1 ]) { mbenable_cmd[0 ] =CMD_MBENABLE ;
@@ -689,33 +689,34 @@ static int aha1542_mbenable(int base)if ((mbenable_result[0 ] &0x08 ) && (mbenable_result[1 ] &0x03 )) retval =BIOS_TRANSLATION_25563 ; -if (aha1542_out (base, mbenable_cmd,3 )) +if (aha1542_out (sh->io_port, mbenable_cmd,3 )) goto fail; };while (0 ) { fail:printk (KERN_ERR "aha1542_mbenable: Mailbox init failed\n" ); } -aha1542_intr_reset (base); +aha1542_intr_reset (sh->io_port);return retval; }/* Query the board to find out if it is a 1542 or a 1740, or whatever. */ -static int aha1542_query (int base_io,int *transl) +static int aha1542_query (struct Scsi_Host *sh) { +struct aha1542_hostdata *aha1542 =shost_priv (sh);u8 inquiry_result[4 ];int i; - i =inb (STATUS (base_io)); + i =inb (STATUS (sh->io_port));if (i &DF ) { - i =inb (DATA (base_io)); + i =inb (DATA (sh->io_port)); }; -aha1542_outb (base_io,CMD_INQUIRY ); -aha1542_in (base_io, inquiry_result,4 ,0 ); -if (!wait_mask (INTRFLAGS (base_io),INTRMASK ,HACC ,0 ,0 )) +aha1542_outb (sh->io_port,CMD_INQUIRY ); +aha1542_in (sh->io_port, inquiry_result,4 ,0 ); +if (!wait_mask (INTRFLAGS (sh->io_port),INTRMASK ,HACC ,0 ,0 ))printk (KERN_ERR "aha1542_detect: query card type\n" ); -aha1542_intr_reset (base_io); +aha1542_intr_reset (sh->io_port); - *transl =BIOS_TRANSLATION_6432 ;/* Default case */ + aha1542->bios_translation =BIOS_TRANSLATION_6432 ;/* Default case */ /* For an AHA1740 series board, we ignore the board since there is a hardware bug which can lead to wrong blocks being returned if the board
@@ -731,7 +732,7 @@ static int aha1542_query(int base_io, int *transl)/* Always call this - boards that do not support extended bios translation will ignore the command, and we will set the proper default */ - *transl =aha1542_mbenable (base_io); + aha1542->bios_translation =aha1542_mbenable (sh);return 0 ; }
@@ -807,13 +808,19 @@ static struct Scsi_Host *aha1542_hw_init(struct scsi_host_template *tpnt, struct goto release; aha1542 =shost_priv (sh); -if (!aha1542_test_port (base_io, sh)) + sh->unique_id = base_io; + sh->io_port = base_io; + sh->n_io_port =AHA1542_REGION_SIZE ; + aha1542->aha1542_last_mbi_used =2 *AHA1542_MAILBOXES -1 ; + aha1542->aha1542_last_mbo_used =AHA1542_MAILBOXES -1 ; + +if (!aha1542_test_port (sh)) goto unregister;aha1542_set_bus_times (indx); -if (aha1542_query (base_io, &aha1542->bios_translation)) +if (aha1542_query (sh)) goto unregister; -if (aha1542_getconfig (base_io, &sh->irq, &sh->dma_channel, &sh->this_id) ==-1 ) +if (aha1542_getconfig (sh) ==-1 ) goto unregister;printk (KERN_INFO "Adaptec AHA-1542 (SCSI-ID %d) at IO 0x%x, IRQ %d" , sh->this_id, base_io, sh->irq);
@@ -823,7 +830,7 @@ static struct Scsi_Host *aha1542_hw_init(struct scsi_host_template *tpnt, structif (aha1542->bios_translation ==BIOS_TRANSLATION_25563 )printk (KERN_INFO "aha1542.c: Using extended bios translation\n" ); -setup_mailboxes (base_io, sh); +setup_mailboxes (sh);if (request_irq (sh->irq, do_aha1542_intr_handle,0 ,"aha1542" , sh)) {
@@ -841,12 +848,6 @@ static struct Scsi_Host *aha1542_hw_init(struct scsi_host_template *tpnt, struct } } - sh->unique_id = base_io; - sh->io_port = base_io; - sh->n_io_port =AHA1542_REGION_SIZE ; - aha1542->aha1542_last_mbi_used =2 *AHA1542_MAILBOXES -1 ; - aha1542->aha1542_last_mbo_used =AHA1542_MAILBOXES -1 ; -if (scsi_add_host (sh, pdev)) goto free_dma;
@@ -973,7 +974,7 @@ static int aha1542_reset(struct scsi_cmnd *cmd, u8 reset_cmd)* us again after host reset. */ if (reset_cmd &HRST ) -setup_mailboxes (cmd->device->host->io_port, cmd->device->host); +setup_mailboxes (cmd->device->host);/* * Now try to pick up the pieces. For all pending commands, * free any internal data structures, and basically clear things
Signature · 1 line
Ondrej Zary
PATCH 29/36 aha1542: Change aha1542_set_bus_times parameters
In reply to Ondrej ZaryPass struct Scsi_Host *sh and dma parameters instead of index to aha1542_set_bus_times.
This is required for printk conversion.
--- drivers/scsi/aha1542.c | 34 ++++++++++++++++------------------ 1 file changed, 16 insertions(+), 18 deletions(-)
drivers/scsi/aha1542.c +16 -18
@@ -756,38 +756,36 @@ static u8 dma_speed_hw(int dma_speed) }/* Set the Bus on/off-times as not to ruin floppy performance */ -static void aha1542_set_bus_times (int indx) +static void aha1542_set_bus_times (struct Scsi_Host *sh,int bus_on,int bus_off,int dma_speed) { -unsigned int base_io = io[indx]; - -if (bus_on[indx] >0 ) { -u8 oncmd[] = {CMD_BUSON_TIME ,clamp (bus_on[indx],2 ,15 ) }; +if (bus_on >0 ) { +u8 oncmd[] = {CMD_BUSON_TIME ,clamp (bus_on,2 ,15 ) }; -aha1542_intr_reset (base_io); -if (aha1542_out (base_io, oncmd,2 )) +aha1542_intr_reset (sh->io_port); +if (aha1542_out (sh->io_port, oncmd,2 )) goto fail; } -if (bus_off[indx] >0 ) { -u8 offcmd[] = {CMD_BUSOFF_TIME ,clamp (bus_off[indx],1 ,64 ) }; +if (bus_off >0 ) { +u8 offcmd[] = {CMD_BUSOFF_TIME ,clamp (bus_off,1 ,64 ) }; -aha1542_intr_reset (base_io); -if (aha1542_out (base_io, offcmd,2 )) +aha1542_intr_reset (sh->io_port); +if (aha1542_out (sh->io_port, offcmd,2 )) goto fail; } -if (dma_speed_hw (dma_speed[indx]) !=0xff ) { -u8 dmacmd[] = {CMD_DMASPEED ,dma_speed_hw (dma_speed[indx]) }; +if (dma_speed_hw (dma_speed) !=0xff ) { +u8 dmacmd[] = {CMD_DMASPEED ,dma_speed_hw (dma_speed) }; -aha1542_intr_reset (base_io); -if (aha1542_out (base_io, dmacmd,2 )) +aha1542_intr_reset (sh->io_port); +if (aha1542_out (sh->io_port, dmacmd,2 )) goto fail; } -aha1542_intr_reset (base_io); +aha1542_intr_reset (sh->io_port);return ; fail:printk (KERN_ERR "setting bus on/off-time failed\n" ); -aha1542_intr_reset (base_io); +aha1542_intr_reset (sh->io_port); }/* return non-zero on detection */
@@ -817,7 +815,7 @@ static struct Scsi_Host *aha1542_hw_init(struct scsi_host_template *tpnt, structif (!aha1542_test_port (sh)) goto unregister; -aha1542_set_bus_times (indx); +aha1542_set_bus_times (sh, bus_on[indx], bus_off[indx], dma_speed[indx]);if (aha1542_query (sh)) goto unregister;if (aha1542_getconfig (sh) ==-1 )
Signature · 1 line
Ondrej Zary
PATCH 30/36 aha1542: Use shost_printk instead of printk
In reply to Ondrej Zary--- drivers/scsi/aha1542.c | 67 +++++++++++++++++++++++------------------------- 1 file changed, 32 insertions(+), 35 deletions(-)
drivers/scsi/aha1542.c +32 -35
@@ -105,10 +105,8 @@ static int aha1542_outb(unsigned int base, u8 val)unsigned long flags;while (1 ) { -if (!wait_mask (STATUS (base),CDF ,0 ,CDF ,0 )) { -printk (KERN_ERR "aha1542_outb failed" ); +if (!wait_mask (STATUS (base),CDF ,0 ,CDF ,0 ))return 1 ; - }spin_lock_irqsave (&aha1542_lock, flags);if (inb (STATUS (base)) &CDF ) {spin_unlock_irqrestore (&aha1542_lock, flags);
@@ -128,7 +126,6 @@ static int aha1542_out(unsigned int base, u8 *buf, int len)while (len--) {if (!wait_mask (STATUS (base),CDF ,0 ,CDF ,0 )) {spin_unlock_irqrestore (&aha1542_lock, flags); -printk (KERN_ERR "aha1542_out failed(%d): " , len +1 );return 1 ; }outb (*buf++,DATA (base));
@@ -151,8 +148,6 @@ static int aha1542_in(unsigned int base, u8 *buf, int len, int timeout)while (len--) {if (!wait_mask (STATUS (base),DF ,DF ,0 , timeout)) {spin_unlock_irqrestore (&aha1542_lock, flags); -if (timeout ==0 ) -printk (KERN_ERR "aha1542_in failed(%d): " , len +1 );return 1 ; } *buf++ =inb (DATA (base));
@@ -284,7 +279,7 @@ static void aha1542_intr_handle(struct Scsi_Host *sh)#ifdef DEBUG { flag =inb (INTRFLAGS (sh->io_port)); -printk (KERN_DEBUG "aha1542_intr_handle: " ); +shost_printk (KERN_DEBUG , sh,"aha1542_intr_handle: " );if (!(flag &ANYINTR ))printk ("no interrupt?" );if (flag &MBIF )
@@ -334,7 +329,7 @@ static void aha1542_intr_handle(struct Scsi_Host *sh)spin_unlock_irqrestore (&aha1542_lock, flags);/* Hmm, no mail. Must have read it the last time around */ if (!number_serviced) -printk (KERN_WARNING "aha1542.c: interrupt received, but no mail.\n" ); +shost_printk (KERN_WARNING , sh,"interrupt received, but no mail.\n" );return ; };
@@ -347,7 +342,7 @@ static void aha1542_intr_handle(struct Scsi_Host *sh)#ifdef DEBUG {if (ccb[mbo].tarstat | ccb[mbo].hastat) -printk (KERN_DEBUG "aha1542_command: returning %x (status %d)\n" , +shost_printk (KERN_DEBUG , sh,"aha1542_command: returning %x (status %d)\n" , ccb[mbo].tarstat + ((int ) ccb[mbo].hastat <<16 ), mb[mbi].status); };#endif
@@ -356,14 +351,14 @@ static void aha1542_intr_handle(struct Scsi_Host *sh)continue ;/* Aborted command not found */ #ifdef DEBUG -printk (KERN_DEBUG "...done %d %d\n" , mbo, mbi); +shost_printk (KERN_DEBUG , sh,"...done %d %d\n" , mbo, mbi);#endif tmp_cmd = aha1542->int_cmds[mbo];if (!tmp_cmd || !tmp_cmd->scsi_done) { -printk (KERN_WARNING "aha1542_intr_handle: Unexpected interrupt\n" ); -printk (KERN_WARNING "tarstat=%x, hastat=%x idlun=%x ccb#=%d \n" , ccb[mbo].tarstat, +shost_printk (KERN_WARNING , sh,"Unexpected interrupt\n" ); +shost_printk (KERN_WARNING , sh,"tarstat=%x, hastat=%x idlun=%x ccb#=%d\n" , ccb[mbo].tarstat, ccb[mbo].hastat, ccb[mbo].idlun, mbo);return ; }
@@ -389,7 +384,7 @@ static void aha1542_intr_handle(struct Scsi_Host *sh)#ifdef DEBUG if (errstatus) -printk (KERN_DEBUG "(aha1542 error:%x %x %x) " , errstatus, +shost_printk (KERN_DEBUG , sh,"(aha1542 error:%x %x %x) " , errstatus, ccb[mbo].hastat, ccb[mbo].tarstat);#endif
@@ -433,7 +428,8 @@ static irqreturn_t do_aha1542_intr_handle(int dummy, void *dev_id)static int aha1542_queuecommand_lck (struct scsi_cmnd *cmd,void (*done) (struct scsi_cmnd *)) { -struct aha1542_hostdata *aha1542 =shost_priv (cmd->device->host); +struct Scsi_Host *sh = cmd->device->host; +struct aha1542_hostdata *aha1542 =shost_priv (sh);u8 direction;u8 target = cmd->device->id;u8 lun = cmd->device->lun;
@@ -465,10 +461,10 @@ static int aha1542_queuecommand_lck(struct scsi_cmnd *cmd, void (*done) (structelse i =-1 ;if (done) -printk (KERN_DEBUG "aha1542_queuecommand: dev %d cmd %02x pos %d len %d " , target, *cmd->cmnd, i, bufflen); +shost_printk (KERN_DEBUG , sh,"aha1542_queuecommand: dev %d cmd %02x pos %d len %d " , target, *cmd->cmnd, i, bufflen);else -printk (KERN_DEBUG "aha1542_command: dev %d cmd %02x pos %d len %d " , target, *cmd->cmnd, i, bufflen); -printk (KERN_DEBUG "aha1542_queuecommand: dumping scsi cmd:" ); +shost_printk (KERN_DEBUG , sh,"aha1542_command: dev %d cmd %02x pos %d len %d " , target, *cmd->cmnd, i, bufflen); +shost_printk (KERN_DEBUG , sh,"aha1542_queuecommand: dumping scsi cmd:" );for (i =0 ; i < cmd->cmd_len; i++)printk ("%02x " , cmd->cmnd[i]);printk ("\n" );
@@ -501,7 +497,7 @@ static int aha1542_queuecommand_lck(struct scsi_cmnd *cmd, void (*done) (structspin_unlock_irqrestore (&aha1542_lock, flags);#ifdef DEBUG -printk (KERN_DEBUG "Sending command (%d %x)..." , mbo, done); +shost_printk (KERN_DEBUG , sh,"Sending command (%d %x)..." , mbo, done);#endif any2scsi (mb[mbo].ccbptr,isa_virt_to_bus (&ccb[mbo]));/* This gets trashed for some reason */
@@ -561,7 +557,7 @@ static int aha1542_queuecommand_lck(struct scsi_cmnd *cmd, void (*done) (struct#ifdef DEBUG {int i; -printk (KERN_DEBUG "aha1542_command: sending.. " ); +shost_printk (KERN_DEBUG , sh,"aha1542_command: sending.. " );for (i =0 ; i <sizeof (ccb[mbo]) -10 ; i++)printk ("%02x " , ((u8 *) &ccb[mbo])[i]); };
@@ -597,7 +593,7 @@ static void setup_mailboxes(struct Scsi_Host *sh)aha1542_intr_reset (sh->io_port);/* reset interrupts, so they don't block */ any2scsi ((mb_cmd +2 ),isa_virt_to_bus (mb));if (aha1542_out (sh->io_port, mb_cmd,5 )) -printk (KERN_ERR "aha1542_detect: failed setting up mailboxes\n" ); +shost_printk (KERN_ERR , sh,"failed setting up mailboxes\n" );aha1542_intr_reset (sh->io_port); }
@@ -612,7 +608,7 @@ static int aha1542_getconfig(struct Scsi_Host *sh)aha1542_outb (sh->io_port,CMD_RETCONF );aha1542_in (sh->io_port, inquiry_result,3 ,0 );if (!wait_mask (INTRFLAGS (sh->io_port),INTRMASK ,HACC ,0 ,0 )) -printk (KERN_ERR "aha1542_detect: query board settings\n" ); +shost_printk (KERN_ERR , sh,"error querying board settings\n" );aha1542_intr_reset (sh->io_port);switch (inquiry_result[0 ]) {case 0x80 :
@@ -633,7 +629,7 @@ static int aha1542_getconfig(struct Scsi_Host *sh) sh->dma_channel =0xFF ;break ;default : -printk (KERN_ERR "Unable to determine Adaptec DMA priority. Disabling board\n" ); +shost_printk (KERN_ERR , sh,"Unable to determine DMA channel.\n" );return -1 ; };switch (inquiry_result[1 ]) {
@@ -656,7 +652,7 @@ static int aha1542_getconfig(struct Scsi_Host *sh) sh->irq =9 ;break ;default : -printk (KERN_ERR "Unable to determine Adaptec IRQ level. Disabling board\n" ); +shost_printk (KERN_ERR , sh,"Unable to determine IRQ level.\n" );return -1 ; }; sh->this_id = inquiry_result[2 ] &7 ;
@@ -694,7 +690,7 @@ static int aha1542_mbenable(struct Scsi_Host *sh) };while (0 ) { fail: -printk (KERN_ERR "aha1542_mbenable: Mailbox init failed\n" ); +shost_printk (KERN_ERR , sh,"Mailbox init failed\n" ); }aha1542_intr_reset (sh->io_port);return retval;
@@ -713,7 +709,7 @@ static int aha1542_query(struct Scsi_Host *sh)aha1542_outb (sh->io_port,CMD_INQUIRY );aha1542_in (sh->io_port, inquiry_result,4 ,0 );if (!wait_mask (INTRFLAGS (sh->io_port),INTRMASK ,HACC ,0 ,0 )) -printk (KERN_ERR "aha1542_detect: query card type\n" ); +shost_printk (KERN_ERR , sh,"error querying card type\n" );aha1542_intr_reset (sh->io_port); aha1542->bios_translation =BIOS_TRANSLATION_6432 ;/* Default case */
@@ -725,7 +721,7 @@ static int aha1542_query(struct Scsi_Host *sh)*/ if (inquiry_result[0 ] ==0x43 ) { -printk (KERN_INFO "aha1542.c: Emulation mode not supported for AHA 174N hardware.\n" ); +shost_printk (KERN_INFO , sh,"Emulation mode not supported for AHA-1740 hardware, use aha1740 driver instead.\n" );return 1 ; };
@@ -784,7 +780,7 @@ static void aha1542_set_bus_times(struct Scsi_Host *sh, int bus_on, int bus_off,aha1542_intr_reset (sh->io_port);return ; fail: -printk (KERN_ERR "setting bus on/off-time failed\n" ); +shost_printk (KERN_ERR , sh,"setting bus on/off-time failed\n" );aha1542_intr_reset (sh->io_port); }
@@ -794,6 +790,7 @@ static struct Scsi_Host *aha1542_hw_init(struct scsi_host_template *tpnt, structunsigned int base_io = io[indx];struct Scsi_Host *sh;struct aha1542_hostdata *aha1542; +char dma_info[] ="no DMA" ;if (base_io ==0 )return NULL ;
@@ -821,23 +818,23 @@ static struct Scsi_Host *aha1542_hw_init(struct scsi_host_template *tpnt, structif (aha1542_getconfig (sh) ==-1 ) goto unregister; -printk (KERN_INFO "Adaptec AHA-1542 (SCSI-ID %d) at IO 0x%x, IRQ %d" , sh->this_id, base_io, sh->irq);if (sh->dma_channel !=0xFF ) -printk (", DMA %d" , sh->dma_channel); -printk ("\n" ); +snprintf (dma_info,sizeof (dma_info),"DMA %d" , sh->dma_channel); +shost_printk (KERN_INFO , sh,"Adaptec AHA-1542 (SCSI-ID %d) at IO 0x%x, IRQ %d, %s\n" , + sh->this_id, base_io, sh->irq, dma_info);if (aha1542->bios_translation ==BIOS_TRANSLATION_25563 ) -printk (KERN_INFO "aha1542.c: Using extended bios translation\n" ); +shost_printk (KERN_INFO , sh,"Using extended bios translation\n" );setup_mailboxes (sh);if (request_irq (sh->irq, do_aha1542_intr_handle,0 ,"aha1542" , sh)) { -printk (KERN_ERR "Unable to allocate IRQ for adaptec controller.\n" ); +shost_printk (KERN_ERR , sh,"Unable to allocate IRQ.\n" ); goto unregister; }if (sh->dma_channel !=0xFF ) {if (request_dma (sh->dma_channel,"aha1542" )) { -printk (KERN_ERR "Unable to allocate DMA channel for Adaptec.\n" ); +shost_printk (KERN_ERR , sh,"Unable to allocate DMA channel.\n" ); goto free_irq; }if (sh->dma_channel ==0 || sh->dma_channel >=5 ) {
@@ -979,7 +976,7 @@ static int aha1542_reset(struct scsi_cmnd *cmd, u8 reset_cmd)* out. We do not try and restart any commands or anything - * the strategy handler takes care of that crap. */ -printk (KERN_WARNING "Sent BUS RESET to scsi host %d\n" , cmd->device->host->host_no); +shost_printk (KERN_WARNING , cmd->device->host,"Sent BUS RESET to scsi host %d\n" , cmd->device->host->host_no);for (i =0 ; i <AHA1542_MAILBOXES ; i++) {if (aha1542->int_cmds[i] !=NULL ) {
@@ -1105,7 +1102,7 @@ static int aha1542_pnp_probe(struct pnp_dev *pdev, const struct pnp_device_id *i/* The card can be queried for its DMA, we have the DMA set up that is enough */ -printk (KERN_INFO "ISAPnP found an AHA1535 at I/O 0x%03X\n" , io[indx]); +dev_info (&pdev->dev,"ISAPnP found an AHA1535 at I/O 0x%03X" , io[indx]); } sh =aha1542_hw_init (&driver_template, &pdev->dev, indx);
Signature · 1 line
Ondrej Zary
PATCH 31/36 aha1542: remove DEB macro and simplify debug code
In reply to Ondrej ZaryRemove DEB macro and join ifdef DEBUG blocks
--- drivers/scsi/aha1542.c | 56 +++++++++++++++++++----------------------------- 1 file changed, 22 insertions(+), 34 deletions(-)
drivers/scsi/aha1542.c +22 -34
@@ -24,11 +24,6 @@#include <scsi/scsi_host.h> #include "aha1542.h" -#ifdef DEBUG -#define DEB (x) x -#else -#define DEB (x) -#endif #define MAXBOARDS 4static bool isapnp =1 ;
@@ -195,7 +190,9 @@ static int makecode(unsigned hosterr, unsigned scsierr)case 0x1a :/* Invalid CCB or Segment List Parameter-A segment list with a zero length segment or invalid segment list boundaries was received. A CCB parameter was invalid. */ -DEB (printk ("Aha1542: %x %x\n" , hosterr, scsierr)); +#ifdef DEBUG +printk ("Aha1542: %x %x\n" , hosterr, scsierr); +#endif hosterr =DID_ERROR ;/* Couldn't find any better */ break ;
@@ -340,11 +337,9 @@ static void aha1542_intr_handle(struct Scsi_Host *sh)spin_unlock_irqrestore (&aha1542_lock, flags);#ifdef DEBUG - { -if (ccb[mbo].tarstat | ccb[mbo].hastat) -shost_printk (KERN_DEBUG , sh,"aha1542_command: returning %x (status %d)\n" , - ccb[mbo].tarstat + ((int ) ccb[mbo].hastat <<16 ), mb[mbi].status); - }; +if (ccb[mbo].tarstat | ccb[mbo].hastat) +shost_printk (KERN_DEBUG , sh,"aha1542_command: returning %x (status %d)\n" , + ccb[mbo].tarstat + ((int ) ccb[mbo].hastat <<16 ), mb[mbi].status);#endif if (mbistatus ==3 )
@@ -386,26 +381,17 @@ static void aha1542_intr_handle(struct Scsi_Host *sh)if (errstatus)shost_printk (KERN_DEBUG , sh,"(aha1542 error:%x %x %x) " , errstatus, ccb[mbo].hastat, ccb[mbo].tarstat); -#endif -if (ccb[mbo].tarstat ==2 ) { -#ifdef DEBUG int i; -#endif -DEB (printk ("aha1542_intr_handle: sense:" )); -#ifdef DEBUG + +printk ("aha1542_intr_handle: sense:" );for (i =0 ; i <12 ; i++)printk ("%02x " , ccb[mbo].cdb[ccb[mbo].cdblen + i]);printk ("\n" ); -#endif -/* -DEB(printk("aha1542_intr_handle: buf:")); -for (i = 0; i < bufflen; i++) -printk("%02x ", ((unchar *)buff)[i]); -printk("\n"); -*/ } - DEB(if (errstatus) printk("aha1542_intr_handle: returning %6x\n", errstatus)); +if (errstatus) +printk ("aha1542_intr_handle: returning %6x\n" , errstatus); +#endif tmp_cmd->result = errstatus; aha1542->int_cmds[mbo] =NULL ;/* This effectively frees up the mailbox slot, as far as queuecommand is concerned */
@@ -438,15 +424,15 @@ static int aha1542_queuecommand_lck(struct scsi_cmnd *cmd, void (*done) (structint mbo;struct mailbox *mb = aha1542->mb;struct ccb *ccb = aha1542->ccb; +#ifdef DEBUG +int i; - DEB(int i); - - DEB(if (target > 1) { - cmd->result =DID_TIME_OUT <<16 ; -done (cmd);return 0 ; - } - ); - +if (target >1 ) { + cmd->result =DID_TIME_OUT <<16 ; +done (cmd); +return 0 ; + } +#endif if (*cmd->cmnd ==REQUEST_SENSE ) {/* Don't do the command - we have the sense data already */ cmd->result =0 ;
@@ -564,7 +550,9 @@ static int aha1542_queuecommand_lck(struct scsi_cmnd *cmd, void (*done) (struct#endif if (done) { -DEB (printk ("aha1542_queuecommand: now waiting for interrupt " )); +#ifdef DEBUG +printk ("aha1542_queuecommand: now waiting for interrupt " ); +#endif cmd->scsi_done = done; mb[mbo].status =1 ;aha1542_outb (cmd->device->host->io_port,CMD_START_SCSI );
Signature · 1 line
Ondrej Zary
PATCH 32/36 aha1542: Use print_hex_dump_bytes in debug code
In reply to Ondrej Zary--- drivers/scsi/aha1542.c | 34 ++++++++-------------------------- 1 file changed, 8 insertions(+), 26 deletions(-)
drivers/scsi/aha1542.c +8 -26
@@ -381,14 +381,8 @@ static void aha1542_intr_handle(struct Scsi_Host *sh)if (errstatus)shost_printk (KERN_DEBUG , sh,"(aha1542 error:%x %x %x) " , errstatus, ccb[mbo].hastat, ccb[mbo].tarstat); -if (ccb[mbo].tarstat ==2 ) { -int i; - -printk ("aha1542_intr_handle: sense:" ); -for (i =0 ; i <12 ; i++) -printk ("%02x " , ccb[mbo].cdb[ccb[mbo].cdblen + i]); -printk ("\n" ); - } +if (ccb[mbo].tarstat ==2 ) +print_hex_dump_bytes ("sense: " ,DUMP_PREFIX_NONE , &ccb[mbo].cdb[ccb[mbo].cdblen],12 );if (errstatus)printk ("aha1542_intr_handle: returning %6x\n" , errstatus);#endif
@@ -450,10 +444,7 @@ static int aha1542_queuecommand_lck(struct scsi_cmnd *cmd, void (*done) (structshost_printk (KERN_DEBUG , sh,"aha1542_queuecommand: dev %d cmd %02x pos %d len %d " , target, *cmd->cmnd, i, bufflen); else shost_printk(KERN_DEBUG, sh, "aha1542_command: dev %d cmd %02x pos %d len %d ", target, *cmd->cmnd, i, bufflen); -shost_printk (KERN_DEBUG , sh,"aha1542_queuecommand: dumping scsi cmd:" ); -for (i =0 ; i < cmd->cmd_len; i++) -printk ("%02x " , cmd->cmnd[i]); -printk ("\n" ); +print_hex_dump_bytes ("command: " ,DUMP_PREFIX_NONE , cmd->cmnd, cmd->cmd_len);if (*cmd->cmnd ==WRITE_10 || *cmd->cmnd ==WRITE_6 )return 0 ;/* we are still testing, so *don't* write */ #endif
@@ -483,7 +474,7 @@ static int aha1542_queuecommand_lck(struct scsi_cmnd *cmd, void (*done) (structspin_unlock_irqrestore (&aha1542_lock, flags);#ifdef DEBUG -shost_printk (KERN_DEBUG , sh,"Sending command (%d %x)..." , mbo, done); +shost_printk (KERN_DEBUG , sh,"Sending command (%d %p)..." , mbo, done);#endif any2scsi (mb[mbo].ccbptr,isa_virt_to_bus (&ccb[mbo]));/* This gets trashed for some reason */
@@ -503,10 +494,8 @@ static int aha1542_queuecommand_lck(struct scsi_cmnd *cmd, void (*done) (structif (bufflen) {struct scatterlist *sg;struct chain *cptr; -#ifdef DEBUG -unsigned char *ptr; -#endif int i, sg_count =scsi_sg_count (cmd); + ccb[mbo].op =2 ;/* SCSI Initiator Command w/scatter-gather */ cmd->host_scribble =kmalloc (sizeof (*cptr)*sg_count,GFP_KERNEL |GFP_DMA );
@@ -524,10 +513,8 @@ static int aha1542_queuecommand_lck(struct scsi_cmnd *cmd, void (*done) (structany2scsi (ccb[mbo].datalen, sg_count *sizeof (struct chain ));any2scsi (ccb[mbo].dataptr,isa_virt_to_bus (cptr));#ifdef DEBUG -printk ("cptr %x: " , cptr); - ptr = (unsigned char *) cptr; -for (i =0 ; i <18 ; i++) -printk ("%02x " , ptr[i]); +shost_printk (KERN_DEBUG , sh,"cptr %p: " , cptr); +print_hex_dump_bytes ("cptr: " ,DUMP_PREFIX_NONE , cptr,18 );#endif }else { ccb[mbo].op =0 ;/* SCSI Initiator Command */
@@ -541,12 +528,7 @@ static int aha1542_queuecommand_lck(struct scsi_cmnd *cmd, void (*done) (struct ccb[mbo].commlinkid =0 ;#ifdef DEBUG - { -int i; -shost_printk (KERN_DEBUG , sh,"aha1542_command: sending.. " ); -for (i =0 ; i <sizeof (ccb[mbo]) -10 ; i++) -printk ("%02x " , ((u8 *) &ccb[mbo])[i]); - }; +print_hex_dump_bytes ("sending: " ,DUMP_PREFIX_NONE , &ccb[mbo],sizeof (ccb[mbo]) -10 );#endif if (done) {
Signature · 1 line
Ondrej Zary
PATCH 33/36 aha1542: Don't reduce functionality with DEBUG enabled
In reply to Ondrej ZaryEnabling DEBUG disables write commands and devices with ID > 1. Remove this "feature" to allow real debugging.
--- drivers/scsi/aha1542.c | 31 ++++++++++--------------------- 1 file changed, 10 insertions(+), 21 deletions(-)
drivers/scsi/aha1542.c +10 -21
@@ -418,15 +418,7 @@ static int aha1542_queuecommand_lck(struct scsi_cmnd *cmd, void (*done) (structint mbo;struct mailbox *mb = aha1542->mb;struct ccb *ccb = aha1542->ccb; -#ifdef DEBUG -int i; -if (target >1 ) { - cmd->result =DID_TIME_OUT <<16 ; -done (cmd); -return 0 ; - } -#endif if (*cmd->cmnd ==REQUEST_SENSE ) {/* Don't do the command - we have the sense data already */ cmd->result =0 ;
@@ -434,19 +426,16 @@ static int aha1542_queuecommand_lck(struct scsi_cmnd *cmd, void (*done) (structreturn 0 ; }#ifdef DEBUG -if (*cmd->cmnd ==READ_10 || *cmd->cmnd ==WRITE_10 ) - i =xscsi2int (cmd->cmnd +2 ); -else if (*cmd->cmnd ==READ_6 || *cmd->cmnd ==WRITE_6 ) - i =scsi2int (cmd->cmnd +2 ); -else - i =-1 ; -if (done) -shost_printk (KERN_DEBUG , sh,"aha1542_queuecommand: dev %d cmd %02x pos %d len %d " , target, *cmd->cmnd, i, bufflen); -else -shost_printk (KERN_DEBUG , sh,"aha1542_command: dev %d cmd %02x pos %d len %d " , target, *cmd->cmnd, i, bufflen); -print_hex_dump_bytes ("command: " ,DUMP_PREFIX_NONE , cmd->cmnd, cmd->cmd_len); -if (*cmd->cmnd ==WRITE_10 || *cmd->cmnd ==WRITE_6 ) -return 0 ;/* we are still testing, so *don't* write */ + { +int i =-1 ; +if (*cmd->cmnd ==READ_10 || *cmd->cmnd ==WRITE_10 ) + i =xscsi2int (cmd->cmnd +2 ); +else if (*cmd->cmnd ==READ_6 || *cmd->cmnd ==WRITE_6 ) + i =scsi2int (cmd->cmnd +2 ); +shost_printk (KERN_DEBUG , sh,"aha1542_queuecommand: dev %d cmd %02x pos %d len %d" , + target, *cmd->cmnd, i, bufflen); +print_hex_dump_bytes ("command: " ,DUMP_PREFIX_NONE , cmd->cmnd, cmd->cmd_len); + }#endif /* Use the outgoing mailboxes in a round-robin fashion, because this is how the host adapter will scan for them */
Signature · 1 line
Ondrej Zary
PATCH 34/36 aha1542: rework locking
In reply to Ondrej ZaryRemove aha1542_lock and use host_lock instead.
Remove interrupt and queuecommand function wrappers.
Remove locking from lowlevel _out and _in functions, they now can onle be called (at runtime) with host_lock being held.
Remove ssleep(4) in aha1542_reset as we can't sleep while holding a spinlock. It's useless anyway as wait_mask will wait until the controller is idle and kernel waits for 10 seconds (HOST_RESET_SETTLE_TIME) after that.
--- drivers/scsi/aha1542.c | 118 ++++++++++++++---------------------------------- 1 file changed, 34 insertions(+), 84 deletions(-)
drivers/scsi/aha1542.c +34 -84
@@ -62,8 +62,6 @@ struct aha1542_hostdata {struct ccb ccb[AHA1542_MAILBOXES ]; }; -static DEFINE_SPINLOCK (aha1542_lock); -static inline void aha1542_intr_reset (u16 base) {outb (IRST ,CONTROL (base));
@@ -91,41 +89,25 @@ static inline bool wait_mask(u16 port, u8 mask, u8 allof, u8 noneof, int timeoutreturn true; } -/* This is a bit complicated, but we need to make sure that an interrupt -routine does not send something out while we are in the middle of this. -Fortunately, it is only at boot time that multi-byte messages -are ever sent. */ static int aha1542_outb (unsigned int base,u8 val) { -unsigned long flags; -while (1 ) {if (!wait_mask (STATUS (base),CDF ,0 ,CDF ,0 ))return 1 ; -spin_lock_irqsave (&aha1542_lock, flags); -if (inb (STATUS (base)) &CDF ) { -spin_unlock_irqrestore (&aha1542_lock, flags); +if (inb (STATUS (base)) &CDF )continue ; - }outb (val,DATA (base)); -spin_unlock_irqrestore (&aha1542_lock, flags);return 0 ; } }static int aha1542_out (unsigned int base,u8 *buf,int len) { -unsigned long flags; - -spin_lock_irqsave (&aha1542_lock, flags);while (len--) { -if (!wait_mask (STATUS (base),CDF ,0 ,CDF ,0 )) { -spin_unlock_irqrestore (&aha1542_lock, flags); +if (!wait_mask (STATUS (base),CDF ,0 ,CDF ,0 ))return 1 ; - }outb (*buf++,DATA (base)); } -spin_unlock_irqrestore (&aha1542_lock, flags);if (!wait_mask (INTRFLAGS (base),INTRMASK ,HACC ,0 ,0 ))return 1 ;
@@ -137,17 +119,11 @@ static int aha1542_out(unsigned int base, u8 *buf, int len)static int aha1542_in (unsigned int base,u8 *buf,int len,int timeout) { -unsigned long flags; - -spin_lock_irqsave (&aha1542_lock, flags);while (len--) { -if (!wait_mask (STATUS (base),DF ,DF ,0 , timeout)) { -spin_unlock_irqrestore (&aha1542_lock, flags); +if (!wait_mask (STATUS (base),DF ,DF ,0 , timeout))return 1 ; - } *buf++ =inb (DATA (base)); } -spin_unlock_irqrestore (&aha1542_lock, flags);return 0 ; }
@@ -260,9 +236,9 @@ static int aha1542_test_port(struct Scsi_Host *sh)return 1 ; } -/* A "high" level interrupt handler */ -static void aha1542_intr_handle (struct Scsi_Host *sh) +static irqreturn_t aha1542_interrupt (int irq,void *dev_id) { +struct Scsi_Host *sh = dev_id;struct aha1542_hostdata *aha1542 =shost_priv (sh);void (*my_done)(struct scsi_cmnd *) =NULL ;int errstatus, mbi, mbo, mbistatus;
@@ -292,7 +268,8 @@ static void aha1542_intr_handle(struct Scsi_Host *sh)#endif number_serviced =0 ; -while (1 ==1 ) { +spin_lock_irqsave (sh->host_lock, flags); +while (1 ) { flag =inb (INTRFLAGS (sh->io_port));/* Check for unusual interrupts. If any of these happen, we should
@@ -309,7 +286,6 @@ static void aha1542_intr_handle(struct Scsi_Host *sh) }aha1542_intr_reset (sh->io_port); -spin_lock_irqsave (&aha1542_lock, flags); mbi = aha1542->aha1542_last_mbi_used +1 ;if (mbi >=2 *AHA1542_MAILBOXES ) mbi =AHA1542_MAILBOXES ;
@@ -323,18 +299,17 @@ static void aha1542_intr_handle(struct Scsi_Host *sh) }while (mbi != aha1542->aha1542_last_mbi_used);if (mb[mbi].status ==0 ) { -spin_unlock_irqrestore (&aha1542_lock, flags); +spin_unlock_irqrestore (sh->host_lock, flags);/* Hmm, no mail. Must have read it the last time around */ if (!number_serviced)shost_printk (KERN_WARNING , sh,"interrupt received, but no mail.\n" ); -return ; +return IRQ_HANDLED ; }; mbo = (scsi2int (mb[mbi].ccbptr) - (isa_virt_to_bus (&ccb[0 ]))) /sizeof (struct ccb ); mbistatus = mb[mbi].status; mb[mbi].status =0 ; aha1542->aha1542_last_mbi_used = mbi; -spin_unlock_irqrestore (&aha1542_lock, flags);#ifdef DEBUG if (ccb[mbo].tarstat | ccb[mbo].hastat)
@@ -352,10 +327,11 @@ static void aha1542_intr_handle(struct Scsi_Host *sh) tmp_cmd = aha1542->int_cmds[mbo];if (!tmp_cmd || !tmp_cmd->scsi_done) { +spin_unlock_irqrestore (sh->host_lock, flags);shost_printk (KERN_WARNING , sh,"Unexpected interrupt\n" );shost_printk (KERN_WARNING , sh,"tarstat=%x, hastat=%x idlun=%x ccb#=%d\n" , ccb[mbo].tarstat, ccb[mbo].hastat, ccb[mbo].idlun, mbo); -return ; +return IRQ_HANDLED ; } my_done = tmp_cmd->scsi_done;kfree (tmp_cmd->host_scribble);
@@ -394,21 +370,8 @@ static void aha1542_intr_handle(struct Scsi_Host *sh) }; } -/* A quick wrapper for do_aha1542_intr_handle to grab the spin lock */ -static irqreturn_t do_aha1542_intr_handle (int dummy,void *dev_id) +static int aha1542_queuecommand (struct Scsi_Host *sh,struct scsi_cmnd *cmd) { -unsigned long flags; -struct Scsi_Host *sh = dev_id; - -spin_lock_irqsave (sh->host_lock, flags); -aha1542_intr_handle (sh); -spin_unlock_irqrestore (sh->host_lock, flags); -return IRQ_HANDLED ; -} - -static int aha1542_queuecommand_lck (struct scsi_cmnd *cmd,void (*done) (struct scsi_cmnd *)) -{ -struct Scsi_Host *sh = cmd->device->host;struct aha1542_hostdata *aha1542 =shost_priv (sh);u8 direction;u8 target = cmd->device->id;
@@ -422,7 +385,7 @@ static int aha1542_queuecommand_lck(struct scsi_cmnd *cmd, void (*done) (structif (*cmd->cmnd ==REQUEST_SENSE ) {/* Don't do the command - we have the sense data already */ cmd->result =0 ; -done (cmd); + cmd->scsi_done (cmd);return 0 ; }#ifdef DEBUG
@@ -440,7 +403,7 @@ static int aha1542_queuecommand_lck(struct scsi_cmnd *cmd, void (*done) (struct/* Use the outgoing mailboxes in a round-robin fashion, because this is how the host adapter will scan for them */ -spin_lock_irqsave (&aha1542_lock, flags); +spin_lock_irqsave (sh->host_lock, flags); mbo = aha1542->aha1542_last_mbo_used +1 ;if (mbo >=AHA1542_MAILBOXES ) mbo =0 ;
@@ -460,10 +423,9 @@ static int aha1542_queuecommand_lck(struct scsi_cmnd *cmd, void (*done) (structscrewing with this cdb. */ aha1542->aha1542_last_mbo_used = mbo; -spin_unlock_irqrestore (&aha1542_lock, flags);#ifdef DEBUG -shost_printk (KERN_DEBUG , sh,"Sending command (%d %p)..." , mbo, done); +shost_printk (KERN_DEBUG , sh,"Sending command (%d %p)..." , mbo, cmd->scsi_done);#endif any2scsi (mb[mbo].ccbptr,isa_virt_to_bus (&ccb[mbo]));/* This gets trashed for some reason */
@@ -492,6 +454,7 @@ static int aha1542_queuecommand_lck(struct scsi_cmnd *cmd, void (*done) (structif (cptr ==NULL ) {/* free the claimed mailbox slot */ aha1542->int_cmds[mbo] =NULL ; +spin_unlock_irqrestore (sh->host_lock, flags);return SCSI_MLQUEUE_HOST_BUSY ; }scsi_for_each_sg (cmd, sg, sg_count, i) {
@@ -518,23 +481,15 @@ static int aha1542_queuecommand_lck(struct scsi_cmnd *cmd, void (*done) (struct#ifdef DEBUG print_hex_dump_bytes ("sending: " ,DUMP_PREFIX_NONE , &ccb[mbo],sizeof (ccb[mbo]) -10 ); +printk ("aha1542_queuecommand: now waiting for interrupt " );#endif - -if (done) { -#ifdef DEBUG -printk ("aha1542_queuecommand: now waiting for interrupt " ); -#endif - cmd->scsi_done = done; - mb[mbo].status =1 ; -aha1542_outb (cmd->device->host->io_port,CMD_START_SCSI ); - }else -printk ("aha1542_queuecommand: done can't be NULL\n" ); + mb[mbo].status =1 ; +aha1542_outb (cmd->device->host->io_port,CMD_START_SCSI ); +spin_unlock_irqrestore (sh->host_lock, flags);return 0 ; } -static DEF_SCSI_QCMD (aha1542_queuecommand) -/* Initialize mailboxes */ static void setup_mailboxes (struct Scsi_Host *sh) {
@@ -786,8 +741,7 @@ static struct Scsi_Host *aha1542_hw_init(struct scsi_host_template *tpnt, structsetup_mailboxes (sh); -if (request_irq (sh->irq, do_aha1542_intr_handle,0 , -"aha1542" , sh)) { +if (request_irq (sh->irq, aha1542_interrupt,0 ,"aha1542" , sh)) {shost_printk (KERN_ERR , sh,"Unable to allocate IRQ.\n" ); goto unregister; }
@@ -841,7 +795,8 @@ static int aha1542_release(struct Scsi_Host *sh)*/ static int aha1542_dev_reset (struct scsi_cmnd *cmd) { -struct aha1542_hostdata *aha1542 =shost_priv (cmd->device->host); +struct Scsi_Host *sh = cmd->device->host; +struct aha1542_hostdata *aha1542 =shost_priv (sh);unsigned long flags;struct mailbox *mb = aha1542->mb;u8 target = cmd->device->id;
@@ -849,7 +804,7 @@ static int aha1542_dev_reset(struct scsi_cmnd *cmd)int mbo;struct ccb *ccb = aha1542->ccb; -spin_lock_irqsave (&aha1542_lock, flags); +spin_lock_irqsave (sh->host_lock, flags); mbo = aha1542->aha1542_last_mbo_used +1 ;if (mbo >=AHA1542_MAILBOXES ) mbo =0 ;
@@ -870,7 +825,6 @@ static int aha1542_dev_reset(struct scsi_cmnd *cmd)screwing with this cdb. */ aha1542->aha1542_last_mbo_used = mbo; -spin_unlock_irqrestore (&aha1542_lock, flags);any2scsi (mb[mbo].ccbptr,isa_virt_to_bus (&ccb[mbo]));/* This gets trashed for some reason */
@@ -887,7 +841,8 @@ static int aha1542_dev_reset(struct scsi_cmnd *cmd)* Now tell the 1542 to flush all pending commands for this * target */ -aha1542_outb (cmd->device->host->io_port,CMD_START_SCSI ); +aha1542_outb (sh->io_port,CMD_START_SCSI ); +spin_unlock_irqrestore (sh->host_lock, flags);scmd_printk (KERN_WARNING , cmd,"Trying device reset for target\n" );
@@ -897,9 +852,12 @@ static int aha1542_dev_reset(struct scsi_cmnd *cmd)static int aha1542_reset (struct scsi_cmnd *cmd,u8 reset_cmd) { -struct aha1542_hostdata *aha1542 =shost_priv (cmd->device->host); +struct Scsi_Host *sh = cmd->device->host; +struct aha1542_hostdata *aha1542 =shost_priv (sh); +unsigned long flags;int i; +spin_lock_irqsave (sh->host_lock, flags);/* * This does a scsi reset for all devices on the bus. * In principle, we could also reset the 1542 - should
@@ -908,27 +866,19 @@ static int aha1542_reset(struct scsi_cmnd *cmd, u8 reset_cmd)*/ outb (reset_cmd,CONTROL (cmd->device->host->io_port)); -/* -* Wait for the thing to settle down a bit. Unfortunately -* this is going to basically lock up the machine while we -* wait for this to complete. To be 100% correct, we need to -* check for timeout, and if we are doing something like this -* we are pretty desperate anyways. -*/ -ssleep (4 ); -spin_lock_irq (cmd->device->host->host_lock); -if (!wait_mask (STATUS (cmd->device->host->io_port),STATMASK ,INIT |IDLE ,STST |DIAGF |INVDCMD |DF |CDF ,0 )) { -spin_unlock_irq (cmd->device->host->host_lock); +spin_unlock_irqrestore (sh->host_lock, flags);return FAILED ; } +/* * We need to do this too before the 1542 can interact with * us again after host reset. */ if (reset_cmd &HRST )setup_mailboxes (cmd->device->host); +/* * Now try to pick up the pieces. For all pending commands, * free any internal data structures, and basically clear things
@@ -958,7 +908,7 @@ static int aha1542_reset(struct scsi_cmnd *cmd, u8 reset_cmd) } } -spin_unlock_irq (cmd->device->host->host_lock); +spin_unlock_irqrestore (sh->host_lock, flags);return SUCCESS ; }
Signature · 1 line
Ondrej Zary
PATCH 35/36 aha1542: Fix bus reset
In reply to Ondrej ZaryBus reset always fails because aha1542_reset waits for the controller to assert the INIT bit (Mailbox Initialization Required) which it never does. This bit is asserted only after host reset.
Remove the requirement for INIT bit (we really need only the IDLE bit).
--- drivers/scsi/aha1542.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/scsi/aha1542.c +1 -1
@@ -867,7 +867,7 @@ static int aha1542_reset(struct scsi_cmnd *cmd, u8 reset_cmd)outb (reset_cmd,CONTROL (cmd->device->host->io_port));if (!wait_mask (STATUS (cmd->device->host->io_port), -STATMASK ,INIT |IDLE ,STST |DIAGF |INVDCMD |DF |CDF ,0 )) { +STATMASK ,IDLE ,STST |DIAGF |INVDCMD |DF |CDF ,0 )) {spin_unlock_irqrestore (sh->host_lock, flags);return FAILED ; }
Signature · 1 line
Ondrej Zary
PATCH 36/36 aha1542: remove loop from aha1542_outb
In reply to Ondrej ZaryThe loop in aha1542_outb with double-check is no longer needed, remove it.
--- drivers/scsi/aha1542.c | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-)
drivers/scsi/aha1542.c +5 -8
@@ -91,14 +91,11 @@ static inline bool wait_mask(u16 port, u8 mask, u8 allof, u8 noneof, int timeoutstatic int aha1542_outb (unsigned int base,u8 val) { -while (1 ) { -if (!wait_mask (STATUS (base),CDF ,0 ,CDF ,0 )) -return 1 ; -if (inb (STATUS (base)) &CDF ) -continue ; -outb (val,DATA (base)); -return 0 ; - } +if (!wait_mask (STATUS (base),CDF ,0 ,CDF ,0 )) +return 1 ; +outb (val,DATA (base)); + +return 0 ; }static int aha1542_out (unsigned int base,u8 *buf,int len)
Signature · 1 line
Ondrej Zary
The whole series looks good to me, thanks a lot for bringing the driver into this century Ondrej!