atp870u: Major rework
cover atp870u: Major rework
This patch series removes the first level of crap from atp870u - the worst (in-tree) SCSI driver [1] and then cleans up the code a bit.
First the driver is converted to C from something that looks like a (bad) assembler code: use of tmport for all I/O accesses and gotos all over the code.
Then I/O access wrappers are introduced.
Finally, is870, is880 and is885 are unified and two of them removed.
After that, some cleanups are done. There's still a lot of work left to do.
Tested on AEC-6710D (ATP870IU-C).
[1] http://www.spinics.net/lists/linux-scsi/msg81142.html
atp870u.c | 3707 +++++++++++++++++--------------------------------------------- atp870u.h | 4 2 files changed, 1064 insertions(+), 2647 deletions(-)
PATCH 1/52 atp870u: Remove workport
Remove workport temporary variable to simplify the code.
--- drivers/scsi/atp870u.c | 59 +++++++++++++++++++++++------------------------- 1 file changed, 28 insertions(+), 31 deletions(-)
drivers/scsi/atp870u.c +28 -31
@@ -51,7 +51,7 @@ static irqreturn_t atp870u_intr_handle(int irq, void *dev_id)unsigned char i, j, c, target_id, lun,cmdp;unsigned char *prd;struct scsi_cmnd *workreq; -unsigned int workport, tmport, tmport1; +unsigned int tmport, tmport1;unsigned long adrcnt, k;#ifdef ED_DBGP unsigned long l;
@@ -76,10 +76,9 @@ ch_sel:#endif dev->in_int[c] =1 ; cmdp =inb (dev->ioport[c] +0x10 ); - workport = dev->ioport[c];if (dev->working[c] !=0 ) {if (dev->dev_id ==ATP885_DEVID ) { - tmport1 = workport +0x16 ; + tmport1 = dev->ioport[c] +0x16 ;if ((inb (tmport1) &0x80 ) ==0 )outb ((inb (tmport1) |0x80 ), tmport1); }
@@ -160,7 +159,7 @@ stop_dma:* Flip wide */ if (dev->wide_id[c] !=0 ) { - tmport = workport +0x1b ; + tmport = dev->ioport[c] +0x1b ;outb (0x01 , tmport);while ((inb (tmport) &0x01 ) !=0x01 ) {outb (0x01 , tmport);
@@ -276,9 +275,9 @@ stop_dma:if (dev->dev_id ==ATP885_DEVID ) { j =inb (dev->baseport +0x29 ) &0xfe ;outb (j, dev->baseport +0x29 ); - tmport = workport +0x16 ; + tmport = dev->ioport[c] +0x16 ; }else { - tmport = workport +0x10 ; + tmport = dev->ioport[c] +0x10 ;outb (0x45 , tmport); tmport +=0x06 ; }
@@ -293,7 +292,7 @@ stop_dma: target_id &=0x07 ; }if (dev->dev_id ==ATP885_DEVID ) { - tmport = workport +0x10 ; + tmport = dev->ioport[c] +0x10 ;outb (0x45 , tmport); } workreq = dev->id[c][target_id].curr_req;
@@ -304,7 +303,7 @@ stop_dma:printk ("\n" );#endif - tmport = workport +0x0f ; + tmport = dev->ioport[c] +0x0f ;outb (lun, tmport); tmport +=0x02 ;outb (dev->id[c][target_id].devsp, tmport++);
@@ -338,21 +337,21 @@ stop_dma:outb (i,tmpcip); }else if ((dev->dev_id ==ATP880_DEVID1 ) || (dev->dev_id ==ATP880_DEVID2 ) ) { - tmport = workport -0x05 ; + tmport = dev->ioport[c] -0x05 ;if ((workreq->cmnd[0 ] ==0x08 ) || (workreq->cmnd[0 ] ==0x28 ) || (workreq->cmnd[0 ] ==0x0a ) || (workreq->cmnd[0 ] ==0x2a )) {outb ((unsigned char ) ((inb (tmport) &0x3f ) |0xc0 ), tmport); }else {outb ((unsigned char ) (inb (tmport) &0x3f ), tmport); } }else { - tmport = workport +0x3a ; + tmport = dev->ioport[c] +0x3a ;if ((workreq->cmnd[0 ] ==0x08 ) || (workreq->cmnd[0 ] ==0x28 ) || (workreq->cmnd[0 ] ==0x0a ) || (workreq->cmnd[0 ] ==0x2a )) {outb ((unsigned char ) ((inb (tmport) &0xf3 ) |0x08 ), tmport); }else {outb ((unsigned char ) (inb (tmport) &0xf3 ), tmport); } } - tmport = workport +0x1b ; + tmport = dev->ioport[c] +0x1b ; j =0 ; id =1 ; id = id << target_id;
@@ -367,7 +366,7 @@ stop_dma:outb (j,tmport); }if (dev->id[c][target_id].last_len ==0 ) { - tmport = workport +0x18 ; + tmport = dev->ioport[c] +0x18 ;outb (0x08 , tmport); dev->in_int[c] =0 ;#ifdef ED_DBGP
@@ -414,7 +413,7 @@ stop_dma:outb (0x00 , tmpcip); tmpcip -=0x02 ; } - tmport = workport +0x18 ; + tmport = dev->ioport[c] +0x18 ;/* * Check transfer direction */
@@ -488,7 +487,7 @@ go_42:* Take it back wide */ if (dev->wide_id[c] !=0 ) { - tmport = workport +0x1b ; + tmport = dev->ioport[c] +0x1b ;outb (0x01 , tmport);while ((inb (tmport) &0x01 ) !=0x01 ) {outb (0x01 , tmport);
@@ -523,7 +522,7 @@ go_42:outb (0x06 , tmpcip);outb (0x00 , tmpcip); tmpcip = tmpcip -2 ; - tmport = workport +0x10 ; + tmport = dev->ioport[c] +0x10 ;outb (0x41 , tmport);if (dev->dev_id ==ATP885_DEVID ) { tmport +=2 ;
@@ -549,7 +548,7 @@ go_42:outb (0x06 , tmpcip);outb (0x00 , tmpcip); tmpcip = tmpcip -2 ; - tmport = workport +0x10 ; + tmport = dev->ioport[c] +0x10 ;outb (0x41 , tmport);if (dev->dev_id ==ATP885_DEVID ) { tmport +=2 ;
@@ -584,7 +583,7 @@ go_42: dev->in_int[c] =0 ; goto handled; }else { -// tmport = workport + 0x17; +// tmport = dev->ioport[c] + 0x17; // inb(tmport); // dev->working[c] = 0; dev->in_int[c] =0 ;
@@ -713,7 +712,6 @@ static void send_s870(struct atp_unit *dev,unsigned char c)unsigned char *prd;unsigned short int tmpcip, w;unsigned long l, bttl =0 ; -unsigned int workport;unsigned long sg_count;if (dev->in_snd[c] !=0 ) {
@@ -759,12 +757,11 @@ static void send_s870(struct atp_unit *dev,unsigned char c) dev->in_snd[c] =0 ;return ; cmd_subp: - workport = dev->ioport[c]; - tmport = workport +0x1f ; + tmport = dev->ioport[c] +0x1f ;if ((inb (tmport) &0xb0 ) !=0 ) { goto abortsnd; } - tmport = workport +0x1c ; + tmport = dev->ioport[c] +0x1c ;if (inb (tmport) ==0 ) { goto oktosend; }
@@ -800,7 +797,7 @@ oktosend: l =0 ; } - tmport = workport +0x1b ; + tmport = dev->ioport[c] +0x1b ; j =0 ; target_id =scmd_id (workreq);
@@ -823,7 +820,7 @@ oktosend:* Write the command */ - tmport = workport; + tmport = dev->ioport[c];outb (workreq->cmd_len, tmport++);outb (0x2c , tmport++);if (dev->dev_id ==ATP885_DEVID ) {
@@ -834,7 +831,7 @@ oktosend:for (i =0 ; i < workreq->cmd_len; i++) {outb (workreq->cmnd[i], tmport++); } - tmport = workport +0x0f ; + tmport = dev->ioport[c] +0x0f ;outb (workreq->device->lun, tmport); tmport +=0x02 ;/*
@@ -874,11 +871,11 @@ oktosend: }outb ((unsigned char ) (inb (tmport) |0x80 ), tmport);outb (0x80 , tmport); - tmport = workport +0x1c ; + tmport = dev->ioport[c] +0x1c ; dev->id[c][target_id].dirct =0 ;if (l ==0 ) {if (inb (tmport) ==0 ) { - tmport = workport +0x18 ; + tmport = dev->ioport[c] +0x18 ;#ifdef ED_DBGP printk ("change SCSI_CMD_REG 0x08\n" );#endif
@@ -947,7 +944,7 @@ oktosend: }else if ((dev->dev_id ==ATP880_DEVID1 ) || (dev->dev_id ==ATP880_DEVID2 )) { tmpcip =tmpcip -2 ; - tmport = workport -0x05 ; + tmport = dev->ioport[c] -0x05 ;if ((workreq->cmnd[0 ] ==0x08 ) || (workreq->cmnd[0 ] ==0x28 ) || (workreq->cmnd[0 ] ==0x0a ) || (workreq->cmnd[0 ] ==0x2a )) {outb ((unsigned char ) ((inb (tmport) &0x3f ) |0xc0 ), tmport); }else {
@@ -955,19 +952,19 @@ oktosend: } }else { tmpcip =tmpcip -2 ; - tmport = workport +0x3a ; + tmport = dev->ioport[c] +0x3a ;if ((workreq->cmnd[0 ] ==0x08 ) || (workreq->cmnd[0 ] ==0x28 ) || (workreq->cmnd[0 ] ==0x0a ) || (workreq->cmnd[0 ] ==0x2a )) {outb ((inb (tmport) &0xf3 ) |0x08 , tmport); }else {outb (inb (tmport) &0xf3 , tmport); } } - tmport = workport +0x1c ; + tmport = dev->ioport[c] +0x1c ;if (workreq->sc_data_direction ==DMA_TO_DEVICE ) { dev->id[c][target_id].dirct =0x20 ;if (inb (tmport) ==0 ) { - tmport = workport +0x18 ; + tmport = dev->ioport[c] +0x18 ;outb (0x08 , tmport);outb (0x01 , tmpcip);#ifdef ED_DBGP
@@ -980,7 +977,7 @@ oktosend:return ; }if (inb (tmport) ==0 ) { - tmport = workport +0x18 ; + tmport = dev->ioport[c] +0x18 ;outb (0x08 , tmport);outb (0x09 , tmpcip);#ifdef ED_DBGP
Signature · 1 line
Ondrej Zary
PATCH 2/52 atp870u: Remove tmport1
In reply to Ondrej ZaryRemove tmport1 temporary variable to simplify the code.
--- drivers/scsi/atp870u.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-)
drivers/scsi/atp870u.c +3 -4
@@ -51,7 +51,7 @@ static irqreturn_t atp870u_intr_handle(int irq, void *dev_id)unsigned char i, j, c, target_id, lun,cmdp;unsigned char *prd;struct scsi_cmnd *workreq; -unsigned int tmport, tmport1; +unsigned int tmport;unsigned long adrcnt, k;#ifdef ED_DBGP unsigned long l;
@@ -78,9 +78,8 @@ ch_sel: cmdp =inb (dev->ioport[c] +0x10 );if (dev->working[c] !=0 ) {if (dev->dev_id ==ATP885_DEVID ) { - tmport1 = dev->ioport[c] +0x16 ; -if ((inb (tmport1) &0x80 ) ==0 ) -outb ((inb (tmport1) |0x80 ), tmport1); +if ((inb (dev->ioport[c] +0x16 ) &0x80 ) ==0 ) +outb ((inb (dev->ioport[c] +0x16 ) |0x80 ), dev->ioport[c] +0x16 ); } tmpcip = dev->pciport[c];if ((inb (tmpcip) &0x08 ) !=0 )
Signature · 1 line
Ondrej Zary
PATCH 3/52 atp870u: Untangle tmport
In reply to Ondrej ZaryUntangle the tmport crap so it becomes obvious what ports are accessed.
--- drivers/scsi/atp870u.c | 186 ++++++++++++++++++------------------------------ 1 file changed, 71 insertions(+), 115 deletions(-)
drivers/scsi/atp870u.c +71 -115
@@ -51,7 +51,6 @@ static irqreturn_t atp870u_intr_handle(int irq, void *dev_id)unsigned char i, j, c, target_id, lun,cmdp;unsigned char *prd;struct scsi_cmnd *workreq; -unsigned int tmport;unsigned long adrcnt, k;#ifdef ED_DBGP unsigned long l;
@@ -61,8 +60,7 @@ static irqreturn_t atp870u_intr_handle(int irq, void *dev_id)struct atp_unit *dev = (struct atp_unit *)&host->hostdata;for (c =0 ; c <2 ; c++) { - tmport = dev->ioport[c] +0x1f ; - j =inb (tmport); + j =inb (dev->ioport[c] +0x1f );if ((j &0x80 ) !=0 ) { goto ch_sel;
@@ -97,9 +95,8 @@ ch_sel: stop_dma: tmpcip = dev->pciport[c];outb (0x00 , tmpcip); - tmport -=0x08 ; - i =inb (tmport); + i =inb (dev->ioport[c] +0x17 );if (dev->dev_id ==ATP885_DEVID ) { tmpcip +=2 ;
@@ -107,9 +104,7 @@ stop_dma: tmpcip -=2 ; } - tmport -=0x02 ; - target_id =inb (tmport); - tmport +=0x02 ; + target_id =inb (dev->ioport[c] +0x15 );/* * Remap wide devices onto id numbers
@@ -137,11 +132,10 @@ stop_dma: dev->last_cmd[c] =0xff ; }if (dev->dev_id ==ATP885_DEVID ) { - tmport -=0x05 ; adrcnt =0 ; - ((unsigned char *) &adrcnt)[2 ] =inb (tmport++); - ((unsigned char *) &adrcnt)[1 ] =inb (tmport++); - ((unsigned char *) &adrcnt)[0 ] =inb (tmport); + ((unsigned char *) &adrcnt)[2 ] =inb (dev->ioport[c] +0x12 ); + ((unsigned char *) &adrcnt)[1 ] =inb (dev->ioport[c] +0x13 ); + ((unsigned char *) &adrcnt)[0 ] =inb (dev->ioport[c] +0x14 );if (dev->id[c][target_id].last_len != adrcnt) { k = dev->id[c][target_id].last_len;
@@ -150,7 +144,7 @@ stop_dma: dev->id[c][target_id].last_len = adrcnt; }#ifdef ED_DBGP -printk ("tmport = %x dev->id[c][target_id].last_len = %d dev->id[c][target_id].tran_len = %d\n" ,tmport,dev->id[c][target_id].last_len,dev->id[c][target_id].tran_len); +printk ("dev->id[c][target_id].last_len = %d dev->id[c][target_id].tran_len = %d\n" ,dev->id[c][target_id].last_len,dev->id[c][target_id].tran_len);#endif }
@@ -158,10 +152,9 @@ stop_dma:* Flip wide */ if (dev->wide_id[c] !=0 ) { - tmport = dev->ioport[c] +0x1b ; -outb (0x01 , tmport); -while ((inb (tmport) &0x01 ) !=0x01 ) { -outb (0x01 , tmport); +outb (0x01 , dev->ioport[c] +0x1b ); +while ((inb (dev->ioport[c] +0x1b ) &0x01 ) !=0x01 ) { +outb (0x01 , dev->ioport[c] +0x1b ); } }/*
@@ -196,19 +189,16 @@ stop_dma:if ((dev->last_cmd[c] &0xf0 ) !=0x40 ) { dev->last_cmd[c] =0xff ; } - tmport -=0x05 ; adrcnt =0 ; - ((unsigned char *) &adrcnt)[2 ] =inb (tmport++); - ((unsigned char *) &adrcnt)[1 ] =inb (tmport++); - ((unsigned char *) &adrcnt)[0 ] =inb (tmport); + ((unsigned char *) &adrcnt)[2 ] =inb (dev->ioport[c] +0x12 ); + ((unsigned char *) &adrcnt)[1 ] =inb (dev->ioport[c] +0x13 ); + ((unsigned char *) &adrcnt)[0 ] =inb (dev->ioport[c] +0x14 ); k = dev->id[c][target_id].last_len; k -= adrcnt; dev->id[c][target_id].tran_len = k; dev->id[c][target_id].last_len = adrcnt; - tmport -=0x04 ; -outb (0x41 , tmport); - tmport +=0x08 ; -outb (0x08 , tmport); +outb (0x41 , dev->ioport[c] +0x10 ); +outb (0x08 , dev->ioport[c] +0x18 ); dev->in_int[c] =0 ; goto handled; }
@@ -227,10 +217,8 @@ stop_dma:printk (KERN_DEBUG "Device reselect\n" );#endif lun =0 ; - tmport -=0x07 ;if (cmdp ==0x44 || i==0x80 ) { - tmport +=0x0d ; - lun =inb (tmport) &0x07 ; + lun =inb (dev->ioport[c] +0x1d ) &0x07 ; }else {if ((dev->last_cmd[c] &0xf0 ) !=0x40 ) { dev->last_cmd[c] =0xff ;
@@ -239,31 +227,27 @@ stop_dma:#ifdef ED_DBGP printk ("cmdp = 0x41\n" );#endif - tmport +=0x02 ; adrcnt =0 ; - ((unsigned char *) &adrcnt)[2 ] =inb (tmport++); - ((unsigned char *) &adrcnt)[1 ] =inb (tmport++); - ((unsigned char *) &adrcnt)[0 ] =inb (tmport); + ((unsigned char *) &adrcnt)[2 ] =inb (dev->ioport[c] +0x12 ); + ((unsigned char *) &adrcnt)[1 ] =inb (dev->ioport[c] +0x13 ); + ((unsigned char *) &adrcnt)[0 ] =inb (dev->ioport[c] +0x14 ); k = dev->id[c][target_id].last_len; k -= adrcnt; dev->id[c][target_id].tran_len = k; dev->id[c][target_id].last_len = adrcnt; - tmport +=0x04 ; -outb (0x08 , tmport); +outb (0x08 , dev->ioport[c] +0x18 ); dev->in_int[c] =0 ; goto handled; }else {#ifdef ED_DBGP printk ("cmdp != 0x41\n" );#endif -outb (0x46 , tmport); +outb (0x46 , dev->ioport[c] +0x10 ); dev->id[c][target_id].dirct =0x00 ; - tmport +=0x02 ; -outb (0x00 , tmport++); -outb (0x00 , tmport++); -outb (0x00 , tmport++); - tmport +=0x03 ; -outb (0x08 , tmport); +outb (0x00 , dev->ioport[c] +0x12 ); +outb (0x00 , dev->ioport[c] +0x13 ); +outb (0x00 , dev->ioport[c] +0x14 ); +outb (0x08 , dev->ioport[c] +0x18 ); dev->in_int[c] =0 ; goto handled; }
@@ -274,14 +258,10 @@ stop_dma:if (dev->dev_id ==ATP885_DEVID ) { j =inb (dev->baseport +0x29 ) &0xfe ;outb (j, dev->baseport +0x29 ); - tmport = dev->ioport[c] +0x16 ; - }else { - tmport = dev->ioport[c] +0x10 ; -outb (0x45 , tmport); - tmport +=0x06 ; - } - - target_id =inb (tmport); + }else +outb (0x45 , dev->ioport[c] +0x10 ); + + target_id =inb (dev->ioport[c] +0x16 );/* * Remap wide identifiers */
@@ -290,10 +270,8 @@ stop_dma: }else { target_id &=0x07 ; } -if (dev->dev_id ==ATP885_DEVID ) { - tmport = dev->ioport[c] +0x10 ; -outb (0x45 , tmport); - } +if (dev->dev_id ==ATP885_DEVID ) +outb (0x45 , dev->ioport[c] +0x10 ); workreq = dev->id[c][target_id].curr_req;#ifdef ED_DBGP scmd_printk (KERN_DEBUG , workreq,"CDB" );
@@ -302,18 +280,16 @@ stop_dma:printk ("\n" );#endif - tmport = dev->ioport[c] +0x0f ; -outb (lun, tmport); - tmport +=0x02 ; -outb (dev->id[c][target_id].devsp, tmport++); +outb (lun, dev->ioport[c] +0x0f ); +outb (dev->id[c][target_id].devsp, dev->ioport[c] +0x11 ); adrcnt = dev->id[c][target_id].tran_len; k = dev->id[c][target_id].last_len; -outb (((unsigned char *) &k)[2 ], tmport++); -outb (((unsigned char *) &k)[1 ], tmport++); -outb (((unsigned char *) &k)[0 ], tmport++); +outb (((unsigned char *) &k)[2 ], dev->ioport[c] +0x12 ); +outb (((unsigned char *) &k)[1 ], dev->ioport[c] +0x13 ); +outb (((unsigned char *) &k)[0 ], dev->ioport[c] +0x14 );#ifdef ED_DBGP -printk ("k %x, k[0] 0x%x k[1] 0x%x k[2] 0x%x\n" , k,inb (tmport-1 ),inb (tmport-2 ),inb (tmport-3 )); +printk ("k %x, k[0] 0x%x k[1] 0x%x k[2] 0x%x\n" , k,inb (dev->ioport[c] +0x14 ),inb (dev->ioport[c] +0x13 ),inb (dev->ioport[c] +0x12 ));#endif /* Remap wide */ j = target_id;
@@ -322,8 +298,8 @@ stop_dma: }/* Add direction */ j |= dev->id[c][target_id].dirct; -outb (j, tmport++); -outb (0x80 ,tmport); +outb (j, dev->ioport[c] +0x15 ); +outb (0x80 , dev->ioport[c] +0x16 );/* enable 32 bit fifo transfer */ if (dev->dev_id ==ATP885_DEVID ) {
@@ -336,21 +312,18 @@ stop_dma:outb (i,tmpcip); }else if ((dev->dev_id ==ATP880_DEVID1 ) || (dev->dev_id ==ATP880_DEVID2 ) ) { - tmport = dev->ioport[c] -0x05 ;if ((workreq->cmnd[0 ] ==0x08 ) || (workreq->cmnd[0 ] ==0x28 ) || (workreq->cmnd[0 ] ==0x0a ) || (workreq->cmnd[0 ] ==0x2a )) { -outb ((unsigned char ) ((inb (tmport) &0x3f ) |0xc0 ), tmport); +outb ((unsigned char ) ((inb (dev->ioport[c] -0x05 ) &0x3f ) |0xc0 ), dev->ioport[c] -0x05 );///minus 0x05??? }else { -outb ((unsigned char ) (inb (tmport) &0x3f ), tmport); +outb ((unsigned char ) (inb (dev->ioport[c] -0x05 ) &0x3f ), dev->ioport[c] -0x05 );///minus 0x05??? } }else { - tmport = dev->ioport[c] +0x3a ;if ((workreq->cmnd[0 ] ==0x08 ) || (workreq->cmnd[0 ] ==0x28 ) || (workreq->cmnd[0 ] ==0x0a ) || (workreq->cmnd[0 ] ==0x2a )) { -outb ((unsigned char ) ((inb (tmport) &0xf3 ) |0x08 ), tmport); +outb ((unsigned char ) ((inb (dev->ioport[c] +0x3a ) &0xf3 ) |0x08 ), dev->ioport[c] +0x3a ); }else { -outb ((unsigned char ) (inb (tmport) &0xf3 ), tmport); +outb ((unsigned char ) (inb (dev->ioport[c] +0x3a ) &0xf3 ), dev->ioport[c] +0x3a ); } } - tmport = dev->ioport[c] +0x1b ; j =0 ; id =1 ; id = id << target_id;
@@ -360,13 +333,12 @@ stop_dma:if ((id & dev->wide_id[c]) !=0 ) { j |=0x01 ; } -outb (j, tmport); -while ((inb (tmport) &0x01 ) != j) { -outb (j,tmport); +outb (j, dev->ioport[c] +0x1b ); +while ((inb (dev->ioport[c] +0x1b ) &0x01 ) != j) { +outb (j,dev->ioport[c] +0x1b ); }if (dev->id[c][target_id].last_len ==0 ) { - tmport = dev->ioport[c] +0x18 ; -outb (0x08 , tmport); +outb (0x08 , dev->ioport[c] +0x18 ); dev->in_int[c] =0 ;#ifdef ED_DBGP printk ("dev->id[c][target_id].last_len = 0\n" );
@@ -412,12 +384,11 @@ stop_dma:outb (0x00 , tmpcip); tmpcip -=0x02 ; } - tmport = dev->ioport[c] +0x18 ;/* * Check transfer direction */ if (dev->id[c][target_id].dirct !=0 ) { -outb (0x08 , tmport); +outb (0x08 , dev->ioport[c] +0x18 );outb (0x01 , tmpcip); dev->in_int[c] =0 ;#ifdef ED_DBGP
@@ -425,7 +396,7 @@ stop_dma:#endif goto handled; } -outb (0x08 , tmport); +outb (0x08 , dev->ioport[c] +0x18 );outb (0x09 , tmpcip); dev->in_int[c] =0 ;#ifdef ED_DBGP
@@ -454,8 +425,7 @@ stop_dma: dev->last_cmd[c] =0xff ; } errstus =0 ; - tmport -=0x08 ; - errstus =inb (tmport); + errstus =inb (dev->ioport[c] +0x0f );if (((dev->r1f[c][target_id] &0x10 ) !=0 )&&(dev->dev_id==ATP885_DEVID )) {printk (KERN_WARNING "AEC67162 CRC ERROR !\n" ); errstus =0x02 ;
@@ -486,10 +456,9 @@ go_42:* Take it back wide */ if (dev->wide_id[c] !=0 ) { - tmport = dev->ioport[c] +0x1b ; -outb (0x01 , tmport); -while ((inb (tmport) &0x01 ) !=0x01 ) { -outb (0x01 , tmport); +outb (0x01 , dev->ioport[c] +0x1b ); +while ((inb (dev->ioport[c] +0x1b ) &0x01 ) !=0x01 ) { +outb (0x01 , dev->ioport[c] +0x1b ); } }/*
@@ -521,21 +490,17 @@ go_42:outb (0x06 , tmpcip);outb (0x00 , tmpcip); tmpcip = tmpcip -2 ; - tmport = dev->ioport[c] +0x10 ; -outb (0x41 , tmport); +outb (0x41 , dev->ioport[c] +0x10 );if (dev->dev_id ==ATP885_DEVID ) { - tmport +=2 ; k = dev->id[c][target_id].last_len; -outb ((unsigned char ) (((unsigned char *) (&k))[2 ]), tmport++); -outb ((unsigned char ) (((unsigned char *) (&k))[1 ]), tmport++); -outb ((unsigned char ) (((unsigned char *) (&k))[0 ]), tmport); +outb ((unsigned char ) (((unsigned char *) (&k))[2 ]), dev->ioport[c] +0x12 ); +outb ((unsigned char ) (((unsigned char *) (&k))[1 ]), dev->ioport[c] +0x13 ); +outb ((unsigned char ) (((unsigned char *) (&k))[0 ]), dev->ioport[c] +0x14 ); dev->id[c][target_id].dirct =0x00 ; - tmport +=0x04 ; }else { dev->id[c][target_id].dirct =0x00 ; - tmport +=0x08 ; } -outb (0x08 , tmport); +outb (0x08 , dev->ioport[c] +0x18 );outb (0x09 , tmpcip); dev->in_int[c] =0 ; goto handled;
@@ -547,43 +512,34 @@ go_42:outb (0x06 , tmpcip);outb (0x00 , tmpcip); tmpcip = tmpcip -2 ; - tmport = dev->ioport[c] +0x10 ; -outb (0x41 , tmport); +outb (0x41 , dev->ioport[c] +0x10 );if (dev->dev_id ==ATP885_DEVID ) { - tmport +=2 ; k = dev->id[c][target_id].last_len; -outb ((unsigned char ) (((unsigned char *) (&k))[2 ]), tmport++); -outb ((unsigned char ) (((unsigned char *) (&k))[1 ]), tmport++); -outb ((unsigned char ) (((unsigned char *) (&k))[0 ]), tmport++); - }else { - tmport +=5 ; +outb ((unsigned char ) (((unsigned char *) (&k))[2 ]), dev->ioport[c] +0x12 ); +outb ((unsigned char ) (((unsigned char *) (&k))[1 ]), dev->ioport[c] +0x13 ); +outb ((unsigned char ) (((unsigned char *) (&k))[0 ]), dev->ioport[c] +0x14 ); } -outb ((unsigned char ) (inb (tmport) |0x20 ), tmport); +outb ((unsigned char ) (inb (dev->ioport[c] +0x15 ) |0x20 ), dev->ioport[c] +0x15 ); dev->id[c][target_id].dirct =0x20 ; - tmport +=0x03 ; -outb (0x08 , tmport); +outb (0x08 , dev->ioport[c] +0x18 );outb (0x01 , tmpcip); dev->in_int[c] =0 ; goto handled; } - tmport -=0x07 ;if (i ==0x0a ) { -outb (0x30 , tmport); +outb (0x30 , dev->ioport[c] +0x10 ); }else { -outb (0x46 , tmport); +outb (0x46 , dev->ioport[c] +0x10 ); } dev->id[c][target_id].dirct =0x00 ; - tmport +=0x02 ; -outb (0x00 , tmport++); -outb (0x00 , tmport++); -outb (0x00 , tmport++); - tmport +=0x03 ; -outb (0x08 , tmport); +outb (0x00 , dev->ioport[c] +0x12 ); +outb (0x00 , dev->ioport[c] +0x13 ); +outb (0x00 , dev->ioport[c] +0x14 ); +outb (0x08 , dev->ioport[c] +0x18 ); dev->in_int[c] =0 ; goto handled; }else { -// tmport = dev->ioport[c] + 0x17; -// inb(tmport); +// inb(dev->ioport[c] + 0x17); // dev->working[c] = 0; dev->in_int[c] =0 ; goto handled;
Signature · 1 line
Ondrej Zary
PATCH 4/52 atp870u: Untangle tmport #2
In reply to Ondrej ZaryUntangle the tmport crap so it becomes obvious what ports are accessed.
--- drivers/scsi/atp870u.c | 79 ++++++++++++++++++++---------------------------- 1 file changed, 32 insertions(+), 47 deletions(-)
drivers/scsi/atp870u.c +32 -47
@@ -562,7 +562,7 @@ static int atp870u_queuecommand_lck(struct scsi_cmnd *req_p, void (*done) (struct scsi_cmnd *)) {unsigned char c; -unsigned int tmport,m; +unsigned int m;struct atp_unit *dev;struct Scsi_Host *host;
@@ -631,11 +631,10 @@ static int atp870u_queuecommand_lck(struct scsi_cmnd *req_p,return 0 ; } dev->quereq[c][dev->quend[c]] = req_p; - tmport = dev->ioport[c] +0x1c ;#ifdef ED_DBGP -printk ("dev->ioport[c] = %x inb(tmport) = %x dev->in_int[%d] = %d dev->in_snd[%d] = %d\n" ,dev->ioport[c],inb (tmport),c,dev->in_int[c],c,dev->in_snd[c]); +printk ("dev->ioport[c] = %x inb(dev->ioport[c] + 0x1c) = %x dev->in_int[%d] = %d dev->in_snd[%d] = %d\n" ,dev->ioport[c],inb (dev->ioport[c] +0x1c ),c,dev->in_int[c],c,dev->in_snd[c]);#endif -if ((inb (tmport) ==0 ) && (dev->in_int[c] ==0 ) && (dev->in_snd[c] ==0 )) { +if ((inb (dev->ioport[c] +0x1c ) ==0 ) && (dev->in_int[c] ==0 ) && (dev->in_snd[c] ==0 )) {#ifdef ED_DBGP printk ("Call sent_s870(atp870u_queuecommand)\n" );#endif
@@ -660,7 +659,6 @@ static DEF_SCSI_QCMD(atp870u_queuecommand)*/ static void send_s870 (struct atp_unit *dev,unsigned char c) { -unsigned int tmport;struct scsi_cmnd *workreq;unsigned int i;//,k; unsigned char j, target_id;
@@ -712,12 +710,10 @@ static void send_s870(struct atp_unit *dev,unsigned char c) dev->in_snd[c] =0 ;return ; cmd_subp: - tmport = dev->ioport[c] +0x1f ; -if ((inb (tmport) &0xb0 ) !=0 ) { +if ((inb (dev->ioport[c] +0x1f ) &0xb0 ) !=0 ) { goto abortsnd; } - tmport = dev->ioport[c] +0x1c ; -if (inb (tmport) ==0 ) { +if (inb (dev->ioport[c] +0x1c ) ==0 ) { goto oktosend; } abortsnd:
@@ -752,7 +748,6 @@ oktosend: l =0 ; } - tmport = dev->ioport[c] +0x1b ; j =0 ; target_id =scmd_id (workreq);
@@ -764,9 +759,9 @@ oktosend:if ((w & dev->wide_id[c]) !=0 ) { j |=0x01 ; } -outb (j, tmport); -while ((inb (tmport) &0x01 ) != j) { -outb (j,tmport); +outb (j, dev->ioport[c] +0x1b ); +while ((inb (dev->ioport[c] +0x1b ) &0x01 ) != j) { +outb (j,dev->ioport[c] +0x1b );#ifdef ED_DBGP printk ("send_s870 while loop 1\n" );#endif
@@ -775,24 +770,21 @@ oktosend:* Write the command */ - tmport = dev->ioport[c]; -outb (workreq->cmd_len, tmport++); -outb (0x2c , tmport++); +outb (workreq->cmd_len, dev->ioport[c] +0x00 ); +outb (0x2c , dev->ioport[c] +0x01 );if (dev->dev_id ==ATP885_DEVID ) { -outb (0x7f , tmport++); +outb (0x7f , dev->ioport[c] +0x02 ); }else { -outb (0xcf , tmport++); +outb (0xcf , dev->ioport[c] +0x02 ); }for (i =0 ; i < workreq->cmd_len; i++) { -outb (workreq->cmnd[i], tmport++); +outb (workreq->cmnd[i], dev->ioport[c] +0x03 + i); } - tmport = dev->ioport[c] +0x0f ; -outb (workreq->device->lun, tmport); - tmport +=0x02 ; +outb (workreq->device->lun, dev->ioport[c] +0x0f );/* * Write the target */ -outb (dev->id[c][target_id].devsp, tmport++); +outb (dev->id[c][target_id].devsp, dev->ioport[c] +0x11 );#ifdef ED_DBGP printk ("dev->id[%d][%d].devsp = %2x\n" ,c,target_id,dev->id[c][target_id].devsp);#endif
@@ -801,9 +793,9 @@ oktosend:/* * Write transfer size */ -outb ((unsigned char ) (((unsigned char *) (&l))[2 ]), tmport++); -outb ((unsigned char ) (((unsigned char *) (&l))[1 ]), tmport++); -outb ((unsigned char ) (((unsigned char *) (&l))[0 ]), tmport++); +outb ((unsigned char ) (((unsigned char *) (&l))[2 ]), dev->ioport[c] +0x12 ); +outb ((unsigned char ) (((unsigned char *) (&l))[1 ]), dev->ioport[c] +0x13 ); +outb ((unsigned char ) (((unsigned char *) (&l))[0 ]), dev->ioport[c] +0x14 ); j = target_id; dev->id[c][j].last_len = l; dev->id[c][j].tran_len =0 ;
@@ -820,21 +812,19 @@ oktosend:* Check transfer direction */ if (workreq->sc_data_direction ==DMA_TO_DEVICE ) { -outb ((unsigned char ) (j |0x20 ), tmport++); +outb ((unsigned char ) (j |0x20 ), dev->ioport[c] +0x15 ); }else { -outb (j, tmport++); +outb (j, dev->ioport[c] +0x15 ); } -outb ((unsigned char ) (inb (tmport) |0x80 ), tmport); -outb (0x80 , tmport); - tmport = dev->ioport[c] +0x1c ; +outb ((unsigned char ) (inb (dev->ioport[c] +0x16 ) |0x80 ), dev->ioport[c] +0x16 ); +outb (0x80 , dev->ioport[c] +0x16 ); dev->id[c][target_id].dirct =0 ;if (l ==0 ) { -if (inb (tmport) ==0 ) { - tmport = dev->ioport[c] +0x18 ; +if (inb (dev->ioport[c] +0x1c ) ==0 ) {#ifdef ED_DBGP printk ("change SCSI_CMD_REG 0x08\n" );#endif -outb (0x08 , tmport); +outb (0x08 , dev->ioport[c] +0x18 ); }else { dev->last_cmd[c] |=0x40 ; }
@@ -899,28 +889,24 @@ oktosend: }else if ((dev->dev_id ==ATP880_DEVID1 ) || (dev->dev_id ==ATP880_DEVID2 )) { tmpcip =tmpcip -2 ; - tmport = dev->ioport[c] -0x05 ;if ((workreq->cmnd[0 ] ==0x08 ) || (workreq->cmnd[0 ] ==0x28 ) || (workreq->cmnd[0 ] ==0x0a ) || (workreq->cmnd[0 ] ==0x2a )) { -outb ((unsigned char ) ((inb (tmport) &0x3f ) |0xc0 ), tmport); +outb ((unsigned char ) ((inb (dev->ioport[c] -0x05 ) &0x3f ) |0xc0 ), dev->ioport[c] -0x05 ); }else { -outb ((unsigned char ) (inb (tmport) &0x3f ), tmport); +outb ((unsigned char ) (inb (dev->ioport[c] -0x05 ) &0x3f ), dev->ioport[c] -0x05 ); } }else { tmpcip =tmpcip -2 ; - tmport = dev->ioport[c] +0x3a ;if ((workreq->cmnd[0 ] ==0x08 ) || (workreq->cmnd[0 ] ==0x28 ) || (workreq->cmnd[0 ] ==0x0a ) || (workreq->cmnd[0 ] ==0x2a )) { -outb ((inb (tmport) &0xf3 ) |0x08 , tmport); +outb ((inb (dev->ioport[c] +0x3a ) &0xf3 ) |0x08 , dev->ioport[c] +0x3a ); }else { -outb (inb (tmport) &0xf3 , tmport); +outb (inb (dev->ioport[c] +0x3a ) &0xf3 , dev->ioport[c] +0x3a ); } } - tmport = dev->ioport[c] +0x1c ;if (workreq->sc_data_direction ==DMA_TO_DEVICE ) { dev->id[c][target_id].dirct =0x20 ; -if (inb (tmport) ==0 ) { - tmport = dev->ioport[c] +0x18 ; -outb (0x08 , tmport); +if (inb (dev->ioport[c] +0x1c ) ==0 ) { +outb (0x08 , dev->ioport[c] +0x18 );outb (0x01 , tmpcip);#ifdef ED_DBGP printk ("start DMA(to target)\n" );
@@ -931,9 +917,8 @@ oktosend: dev->in_snd[c] =0 ;return ; } -if (inb (tmport) ==0 ) { - tmport = dev->ioport[c] +0x18 ; -outb (0x08 , tmport); +if (inb (dev->ioport[c] +0x1c ) ==0 ) { +outb (0x08 , dev->ioport[c] +0x18 );outb (0x09 , tmpcip);#ifdef ED_DBGP printk ("start DMA(to host)\n" );
Signature · 1 line
Ondrej Zary
PATCH 5/52 atp870u: Untangle tmport #3
In reply to Ondrej ZaryUntangle the tmport crap so it becomes obvious what ports are accessed.
--- drivers/scsi/atp870u.c | 118 ++++++++++++++++++++---------------------------- 1 file changed, 49 insertions(+), 69 deletions(-)
drivers/scsi/atp870u.c +49 -69
@@ -933,38 +933,36 @@ oktosend:static unsigned char fun_scam (struct atp_unit *dev,unsigned short int *val) { -unsigned int tmport;unsigned short int i, k;unsigned char j; - tmport = dev->ioport[0 ] +0x1c ; -outw (*val, tmport); +outw (*val, dev->ioport[0 ] +0x1c ); FUN_D7:for (i =0 ; i <10 ; i++) {/* stable >= bus settle delay(400 ns) */ - k =inw (tmport); + k =inw (dev->ioport[0 ] +0x1c ); j = (unsigned char ) (k >>8 );if ((k &0x8000 ) !=0 ) {/* DB7 all release? */ goto FUN_D7; } } *val |=0x4000 ;/* assert DB6 */ -outw (*val, tmport); +outw (*val, dev->ioport[0 ] +0x1c ); *val &=0xdfff ;/* assert DB5 */ -outw (*val, tmport); +outw (*val, dev->ioport[0 ] +0x1c ); FUN_D5:for (i =0 ; i <10 ; i++) {/* stable >= bus settle delay(400 ns) */ -if ((inw (tmport) &0x2000 ) !=0 ) {/* DB5 all release? */ +if ((inw (dev->ioport[0 ] +0x1c ) &0x2000 ) !=0 ) {/* DB5 all release? */ goto FUN_D5; } } *val |=0x8000 ;/* no DB4-0, assert DB7 */ *val &=0xe0ff ; -outw (*val, tmport); +outw (*val, dev->ioport[0 ] +0x1c ); *val &=0xbfff ;/* release DB6 */ -outw (*val, tmport); +outw (*val, dev->ioport[0 ] +0x1c ); FUN_D6:for (i =0 ; i <10 ; i++) {/* stable >= bus settle delay(400 ns) */ -if ((inw (tmport) &0x4000 ) !=0 ) {/* DB6 all release? */ +if ((inw (dev->ioport[0 ] +0x1c ) &0x4000 ) !=0 ) {/* DB6 all release? */ goto FUN_D6; } }
@@ -975,7 +973,6 @@ FUN_D6:static void tscam (struct Scsi_Host *host) { -unsigned int tmport;unsigned char i, j, k;unsigned long n;unsigned short int m, assignid_map, val;
@@ -992,11 +989,9 @@ static void tscam(struct Scsi_Host *host)} */ - tmport = dev->ioport[0 ] +1 ; -outb (0x08 , tmport++); -outb (0x7f , tmport); - tmport = dev->ioport[0 ] +0x11 ; -outb (0x20 , tmport); +outb (0x08 , dev->ioport[0 ] +1 ); +outb (0x7f , dev->ioport[0 ] +2 ); +outb (0x20 , dev->ioport[0 ] +0x11 );if ((dev->scam_on &0x40 ) ==0 ) {return ;
@@ -1009,14 +1004,13 @@ static void tscam(struct Scsi_Host *host) j =8 ; } assignid_map = m; - tmport = dev->ioport[0 ] +0x02 ; -outb (0x02 , tmport++);/* 2*2=4ms,3EH 2/32*3E=3.9ms */ -outb (0 , tmport++); -outb (0 , tmport++); -outb (0 , tmport++); -outb (0 , tmport++); -outb (0 , tmport++); -outb (0 , tmport++); +outb (0x02 , dev->ioport[0 ] +0x02 );/* 2*2=4ms,3EH 2/32*3E=3.9ms */ +outb (0 , dev->ioport[0 ] +0x03 ); +outb (0 , dev->ioport[0 ] +0x04 ); +outb (0 , dev->ioport[0 ] +0x05 ); +outb (0 , dev->ioport[0 ] +0x06 ); +outb (0 , dev->ioport[0 ] +0x07 ); +outb (0 , dev->ioport[0 ] +0x08 );for (i =0 ; i < j; i++) { m =1 ;
@@ -1024,79 +1018,69 @@ static void tscam(struct Scsi_Host *host)if ((m & assignid_map) !=0 ) {continue ; } - tmport = dev->ioport[0 ] +0x0f ; -outb (0 , tmport++); - tmport +=0x02 ; -outb (0 , tmport++); -outb (0 , tmport++); -outb (0 , tmport++); +outb (0 , dev->ioport[0 ] +0x0f ); +outb (0 , dev->ioport[0 ] +0x12 ); +outb (0 , dev->ioport[0 ] +0x13 ); +outb (0 , dev->ioport[0 ] +0x14 );if (i >7 ) { k = (i &0x07 ) |0x40 ; }else { k = i; } -outb (k, tmport++); - tmport = dev->ioport[0 ] +0x1b ; +outb (k, dev->ioport[0 ] +0x15 );if (dev->chip_ver ==4 ) { -outb (0x01 , tmport); +outb (0x01 , dev->ioport[0 ] +0x1b ); }else { -outb (0x00 , tmport); +outb (0x00 , dev->ioport[0 ] +0x1b ); } wait_rdyok: - tmport = dev->ioport[0 ] +0x18 ; -outb (0x09 , tmport); - tmport +=0x07 ; +outb (0x09 , dev->ioport[0 ] +0x18 ); -while ((inb (tmport) &0x80 ) ==0x00 ) +while ((inb (dev->ioport[0 ] +0x1f ) &0x80 ) ==0x00 )cpu_relax (); - tmport -=0x08 ; - k =inb (tmport); + k =inb (dev->ioport[0 ] +0x17 );if (k !=0x16 ) {if ((k ==0x85 ) || (k ==0x42 )) {continue ; } - tmport = dev->ioport[0 ] +0x10 ; -outb (0x41 , tmport); +outb (0x41 , dev->ioport[0 ] +0x10 ); goto wait_rdyok; } assignid_map |= m; } - tmport = dev->ioport[0 ] +0x02 ; -outb (0x7f , tmport); - tmport = dev->ioport[0 ] +0x1b ; -outb (0x02 , tmport); +outb (0x7f , dev->ioport[0 ] +0x02 ); +outb (0x02 , dev->ioport[0 ] +0x1b );outb (0 ,0x80 ); val =0x0080 ;/* bsy */ - tmport = dev->ioport[0 ] +0x1c ; -outw (val, tmport); +outw (val, dev->ioport[0 ] +0x1c ); val |=0x0040 ;/* sel */ -outw (val, tmport); +outw (val, dev->ioport[0 ] +0x1c ); val |=0x0004 ;/* msg */ -outw (val, tmport); +outw (val, dev->ioport[0 ] +0x1c );inb (0x80 );/* 2 deskew delay(45ns*2=90ns) */ val &=0x007f ;/* no bsy */ -outw (val, tmport); +outw (val, dev->ioport[0 ] +0x1c );mdelay (128 ); val &=0x00fb ;/* after 1ms no msg */ -outw (val, tmport); +outw (val, dev->ioport[0 ] +0x1c ); wait_nomsg: -if ((inb (tmport) &0x04 ) !=0 ) { +if ((inb (dev->ioport[0 ] +0x1c ) &0x04 ) !=0 ) { goto wait_nomsg; }outb (1 ,0x80 );udelay (100 );for (n =0 ; n <0x30000 ; n++) { -if ((inb (tmport) &0x80 ) !=0 ) {/* bsy ? */ +if ((inb (dev->ioport[0 ] +0x1c ) &0x80 ) !=0 ) {/* bsy ? */ goto wait_io; } } goto TCM_SYNC; wait_io:for (n =0 ; n <0x30000 ; n++) { -if ((inb (tmport) &0x81 ) ==0x0081 ) { +if ((inb (dev->ioport[0 ] +0x1c ) &0x81 ) ==0x0081 ) { goto wait_io1; } }
@@ -1104,10 +1088,10 @@ wait_io: wait_io1:inb (0x80 ); val |=0x8003 ;/* io,cd,db7 */ -outw (val, tmport); +outw (val, dev->ioport[0 ] +0x1c );inb (0x80 ); val &=0x00bf ;/* no sel */ -outw (val, tmport); +outw (val, dev->ioport[0 ] +0x1c );outb (2 ,0x80 ); TCM_SYNC:/*
@@ -1120,18 +1104,14 @@ TCM_SYNC:*/ mdelay (2 );udelay (48 ); -if ((inb (tmport) &0x80 ) ==0x00 ) {/* bsy ? */ -outw (0 , tmport--); -outb (0 , tmport); - tmport = dev->ioport[0 ] +0x15 ; -outb (0 , tmport); - tmport +=0x03 ; -outb (0x09 , tmport); - tmport +=0x07 ; -while ((inb (tmport) &0x80 ) ==0 ) +if ((inb (dev->ioport[0 ] +0x1c ) &0x80 ) ==0x00 ) {/* bsy ? */ +outw (0 , dev->ioport[0 ] +0x1c ); +outb (0 , dev->ioport[0 ] +0x1b ); +outb (0 , dev->ioport[0 ] +0x15 ); +outb (0x09 , dev->ioport[0 ] +0x18 ); +while ((inb (dev->ioport[0 ] +0x1f ) &0x80 ) ==0 )cpu_relax (); - tmport -=0x08 ; -inb (tmport); +inb (dev->ioport[0 ] +0x17 );return ; } val &=0x00ff ;/* synchronization */
@@ -1145,7 +1125,7 @@ TCM_SYNC: i =8 ; j =0 ; TCM_ID: -if ((inw (tmport) &0x2000 ) ==0 ) { +if ((inw (dev->ioport[0 ] +0x1c ) &0x2000 ) ==0 ) { goto TCM_ID; }outb (5 ,0x80 );
Signature · 1 line
Ondrej Zary
PATCH 6/52 atp870u: Untangle tmport #4
In reply to Ondrej ZaryUntangle the tmport crap so it becomes obvious what ports are accessed.
--- drivers/scsi/atp870u.c | 370 ++++++++++++++++++------------------------------ 1 file changed, 138 insertions(+), 232 deletions(-)
drivers/scsi/atp870u.c +138 -232
@@ -1207,7 +1207,6 @@ G2Q_QUIN: /* k=binID#, */static void is870 (struct atp_unit *dev,unsigned int wkport) { -unsigned int tmport;unsigned char i, j, k, rmb, n;unsigned short int m;static unsigned char mbuf[512 ];
@@ -1218,8 +1217,7 @@ static void is870(struct atp_unit *dev, unsigned int wkport)static unsigned char synw[6 ] = {0x80 ,1 ,3 ,1 ,0x0c ,0x07 };static unsigned char wide[6 ] = {0x80 ,1 ,2 ,3 ,1 ,0 }; - tmport = wkport +0x3a ; -outb ((unsigned char ) (inb (tmport) |0x10 ), tmport); +outb ((unsigned char ) (inb (wkport +0x3a ) |0x10 ), wkport +0x3a );for (i =0 ; i <16 ; i++) {if ((dev->chip_ver !=4 ) && (i >7 )) {
@@ -1234,135 +1232,105 @@ static void is870(struct atp_unit *dev, unsigned int wkport)printk (KERN_INFO " ID: %2d Host Adapter\n" , dev->host_id[0 ]);continue ; } - tmport = wkport +0x1b ;if (dev->chip_ver ==4 ) { -outb (0x01 , tmport); +outb (0x01 , wkport +0x1b ); }else { -outb (0x00 , tmport); - } - tmport = wkport +1 ; -outb (0x08 , tmport++); -outb (0x7f , tmport++); -outb (satn[0 ], tmport++); -outb (satn[1 ], tmport++); -outb (satn[2 ], tmport++); -outb (satn[3 ], tmport++); -outb (satn[4 ], tmport++); -outb (satn[5 ], tmport++); - tmport +=0x06 ; -outb (0 , tmport); - tmport +=0x02 ; -outb (dev->id[0 ][i].devsp, tmport++); -outb (0 , tmport++); -outb (satn[6 ], tmport++); -outb (satn[7 ], tmport++); +outb (0x00 , wkport +0x1b ); + } +outb (0x08 , wkport +1 ); +outb (0x7f , wkport +2 ); +outb (satn[0 ], wkport +3 ); +outb (satn[1 ], wkport +4 ); +outb (satn[2 ], wkport +5 ); +outb (satn[3 ], wkport +6 ); +outb (satn[4 ], wkport +7 ); +outb (satn[5 ], wkport +8 ); +outb (0 , wkport +0x0f ); +outb (dev->id[0 ][i].devsp, wkport +0x11 ); +outb (0 , wkport +0x12 ); +outb (satn[6 ], wkport +0x13 ); +outb (satn[7 ], wkport +0x14 ); j = i;if ((j &0x08 ) !=0 ) { j = (j &0x07 ) |0x40 ; } -outb (j, tmport); - tmport +=0x03 ; -outb (satn[8 ], tmport); - tmport +=0x07 ; +outb (j, wkport +0x15 ); +outb (satn[8 ], wkport +0x18 ); -while ((inb (tmport) &0x80 ) ==0x00 ) +while ((inb (wkport +0x1f ) &0x80 ) ==0x00 )cpu_relax (); - tmport -=0x08 ; -if (inb (tmport) !=0x11 &&inb (tmport) !=0x8e ) +if (inb (wkport +0x17 ) !=0x11 &&inb (wkport +0x17 ) !=0x8e )continue ; -while (inb (tmport) !=0x8e ) +while (inb (wkport +0x17 ) !=0x8e )cpu_relax (); dev->active_id[0 ] |= m; - tmport = wkport +0x10 ; -outb (0x30 , tmport); - tmport = wkport +0x04 ; -outb (0x00 , tmport); +outb (0x30 , wkport +0x10 ); +outb (0x00 , wkport +0x04 ); phase_cmd: - tmport = wkport +0x18 ; -outb (0x08 , tmport); - tmport +=0x07 ; -while ((inb (tmport) &0x80 ) ==0x00 ) +outb (0x08 , wkport +0x18 ); +while ((inb (wkport +0x1f ) &0x80 ) ==0x00 )cpu_relax (); - tmport -=0x08 ; - j =inb (tmport); + j =inb (wkport +0x17 );if (j !=0x16 ) { - tmport = wkport +0x10 ; -outb (0x41 , tmport); +outb (0x41 , wkport +0x10 ); goto phase_cmd; } sel_ok: - tmport = wkport +3 ; -outb (inqd[0 ], tmport++); -outb (inqd[1 ], tmport++); -outb (inqd[2 ], tmport++); -outb (inqd[3 ], tmport++); -outb (inqd[4 ], tmport++); -outb (inqd[5 ], tmport); - tmport +=0x07 ; -outb (0 , tmport); - tmport +=0x02 ; -outb (dev->id[0 ][i].devsp, tmport++); -outb (0 , tmport++); -outb (inqd[6 ], tmport++); -outb (inqd[7 ], tmport++); - tmport +=0x03 ; -outb (inqd[8 ], tmport); - tmport +=0x07 ; - -while ((inb (tmport) &0x80 ) ==0x00 ) +outb (inqd[0 ], wkport +3 ); +outb (inqd[1 ], wkport +4 ); +outb (inqd[2 ], wkport +5 ); +outb (inqd[3 ], wkport +6 ); +outb (inqd[4 ], wkport +7 ); +outb (inqd[5 ], wkport +8 ); +outb (0 , wkport +0x0f ); +outb (dev->id[0 ][i].devsp, wkport +0x11 ); +outb (0 , wkport +0x12 ); +outb (inqd[6 ], wkport +0x13 ); +outb (inqd[7 ], wkport +0x14 ); +outb (inqd[8 ], wkport +0x18 ); + +while ((inb (wkport +0x1f ) &0x80 ) ==0x00 )cpu_relax (); - tmport -=0x08 ; -if (inb (tmport) !=0x11 &&inb (tmport) !=0x8e ) +if (inb (wkport +0x17 ) !=0x11 &&inb (wkport +0x17 ) !=0x8e )continue ; -while (inb (tmport) !=0x8e ) +while (inb (wkport +0x17 ) !=0x8e )cpu_relax (); - tmport = wkport +0x1b ;if (dev->chip_ver ==4 ) -outb (0x00 , tmport); +outb (0x00 , wkport +0x1b ); - tmport = wkport +0x18 ; -outb (0x08 , tmport); - tmport +=0x07 ; +outb (0x08 , wkport +0x18 ); j =0 ; rd_inq_data: - k =inb (tmport); + k =inb (wkport +0x1f );if ((k &0x01 ) !=0 ) { - tmport -=0x06 ; - mbuf[j++] =inb (tmport); - tmport +=0x06 ; + mbuf[j++] =inb (wkport +0x19 ); goto rd_inq_data; }if ((k &0x80 ) ==0 ) { goto rd_inq_data; } - tmport -=0x08 ; - j =inb (tmport); + j =inb (wkport +0x17 );if (j ==0x16 ) { goto inq_ok; } - tmport = wkport +0x10 ; -outb (0x46 , tmport); - tmport +=0x02 ; -outb (0 , tmport++); -outb (0 , tmport++); -outb (0 , tmport++); - tmport +=0x03 ; -outb (0x08 , tmport); - tmport +=0x07 ; +outb (0x46 , wkport +0x10 ); +outb (0 , wkport +0x12 ); +outb (0 , wkport +0x13 ); +outb (0 , wkport +0x14 ); +outb (0x08 , wkport +0x18 ); -while ((inb (tmport) &0x80 ) ==0x00 ) +while ((inb (wkport +0x1f ) &0x80 ) ==0x00 )cpu_relax (); - tmport -=0x08 ; -if (inb (tmport) !=0x16 ) { +if (inb (wkport +0x17 ) !=0x16 ) { goto sel_ok; } inq_ok:
@@ -1380,57 +1348,43 @@ inq_ok:if ((dev->global_map[0 ] &0x20 ) ==0 ) { goto not_wide; } - tmport = wkport +0x1b ; -outb (0x01 , tmport); - tmport = wkport +3 ; -outb (satn[0 ], tmport++); -outb (satn[1 ], tmport++); -outb (satn[2 ], tmport++); -outb (satn[3 ], tmport++); -outb (satn[4 ], tmport++); -outb (satn[5 ], tmport++); - tmport +=0x06 ; -outb (0 , tmport); - tmport +=0x02 ; -outb (dev->id[0 ][i].devsp, tmport++); -outb (0 , tmport++); -outb (satn[6 ], tmport++); -outb (satn[7 ], tmport++); - tmport +=0x03 ; -outb (satn[8 ], tmport); - tmport +=0x07 ; - -while ((inb (tmport) &0x80 ) ==0x00 ) +outb (0x01 , wkport +0x1b ); +outb (satn[0 ], wkport +3 ); +outb (satn[1 ], wkport +4 ); +outb (satn[2 ], wkport +5 ); +outb (satn[3 ], wkport +6 ); +outb (satn[4 ], wkport +7 ); +outb (satn[5 ], wkport +8 ); +outb (0 , wkport +0x0f ); +outb (dev->id[0 ][i].devsp, wkport +0x11 ); +outb (0 , wkport +0x12 ); +outb (satn[6 ], wkport +0x13 ); +outb (satn[7 ], wkport +0x14 ); +outb (satn[8 ], wkport +0x18 ); + +while ((inb (wkport +0x1f ) &0x80 ) ==0x00 )cpu_relax (); - tmport -=0x08 ; -if (inb (tmport) !=0x11 &&inb (tmport) !=0x8e ) +if (inb (wkport +0x17 ) !=0x11 &&inb (wkport +0x17 ) !=0x8e )continue ; -while (inb (tmport) !=0x8e ) +while (inb (wkport +0x17 ) !=0x8e )cpu_relax (); try_wide: j =0 ; - tmport = wkport +0x14 ; -outb (0x05 , tmport); - tmport +=0x04 ; -outb (0x20 , tmport); - tmport +=0x07 ; +outb (0x05 , wkport +0x14 ); +outb (0x20 , wkport +0x18 ); -while ((inb (tmport) &0x80 ) ==0 ) { -if ((inb (tmport) &0x01 ) !=0 ) { - tmport -=0x06 ; -outb (wide[j++], tmport); - tmport +=0x06 ; - } +while ((inb (wkport +0x1f ) &0x80 ) ==0 ) { +if ((inb (wkport +0x1f ) &0x01 ) !=0 ) +outb (wide[j++], wkport +0x19 ); } - tmport -=0x08 ; -while ((inb (tmport) &0x80 ) ==0x00 ) +while ((inb (wkport +0x17 ) &0x80 ) ==0x00 )cpu_relax (); - j =inb (tmport) &0x0f ; + j =inb (wkport +0x17 ) &0x0f ;if (j ==0x0f ) { goto widep_in; }
@@ -1442,18 +1396,12 @@ try_wide: }continue ; widep_out: - tmport = wkport +0x18 ; -outb (0x20 , tmport); - tmport +=0x07 ; -while ((inb (tmport) &0x80 ) ==0 ) { -if ((inb (tmport) &0x01 ) !=0 ) { - tmport -=0x06 ; -outb (0 , tmport); - tmport +=0x06 ; - } +outb (0x20 , wkport +0x18 ); +while ((inb (wkport +0x1f ) &0x80 ) ==0 ) { +if ((inb (wkport +0x1f ) &0x01 ) !=0 ) +outb (0 , wkport +0x19 ); } - tmport -=0x08 ; - j =inb (tmport) &0x0f ; + j =inb (wkport +0x17 ) &0x0f ;if (j ==0x0f ) { goto widep_in; }
@@ -1465,25 +1413,19 @@ widep_out: }continue ; widep_in: - tmport = wkport +0x14 ; -outb (0xff , tmport); - tmport +=0x04 ; -outb (0x20 , tmport); - tmport +=0x07 ; +outb (0xff , wkport +0x14 ); +outb (0x20 , wkport +0x18 ); k =0 ; widep_in1: - j =inb (tmport); + j =inb (wkport +0x1f );if ((j &0x01 ) !=0 ) { - tmport -=0x06 ; - mbuf[k++] =inb (tmport); - tmport +=0x06 ; + mbuf[k++] =inb (wkport +0x19 ); goto widep_in1; }if ((j &0x80 ) ==0x00 ) { goto widep_in1; } - tmport -=0x08 ; - j =inb (tmport) &0x0f ; + j =inb (wkport +0x17 ) &0x0f ;if (j ==0x0f ) { goto widep_in; }
@@ -1495,19 +1437,14 @@ widep_in1: }continue ; widep_cmd: - tmport = wkport +0x10 ; -outb (0x30 , tmport); - tmport = wkport +0x14 ; -outb (0x00 , tmport); - tmport +=0x04 ; -outb (0x08 , tmport); - tmport +=0x07 ; +outb (0x30 , wkport +0x10 ); +outb (0x00 , wkport +0x14 ); +outb (0x08 , wkport +0x18 ); -while ((inb (tmport) &0x80 ) ==0x00 ) +while ((inb (wkport +0x1f ) &0x80 ) ==0x00 )cpu_relax (); - tmport -=0x08 ; - j =inb (tmport); + j =inb (wkport +0x17 );if (j !=0x16 ) {if (j ==0x4e ) { goto widep_out;
@@ -1535,69 +1472,56 @@ not_wide: }continue ; set_sync: - tmport = wkport +0x1b ; j =0 ;if ((m & dev->wide_id[0 ]) !=0 ) { j |=0x01 ; } -outb (j, tmport); - tmport = wkport +3 ; -outb (satn[0 ], tmport++); -outb (satn[1 ], tmport++); -outb (satn[2 ], tmport++); -outb (satn[3 ], tmport++); -outb (satn[4 ], tmport++); -outb (satn[5 ], tmport++); - tmport +=0x06 ; -outb (0 , tmport); - tmport +=0x02 ; -outb (dev->id[0 ][i].devsp, tmport++); -outb (0 , tmport++); -outb (satn[6 ], tmport++); -outb (satn[7 ], tmport++); - tmport +=0x03 ; -outb (satn[8 ], tmport); - tmport +=0x07 ; - -while ((inb (tmport) &0x80 ) ==0x00 ) +outb (j, wkport +0x1b ); +outb (satn[0 ], wkport +3 ); +outb (satn[1 ], wkport +4 ); +outb (satn[2 ], wkport +5 ); +outb (satn[3 ], wkport +6 ); +outb (satn[4 ], wkport +7 ); +outb (satn[5 ], wkport +8 ); +outb (0 , wkport +0x0f ); +outb (dev->id[0 ][i].devsp, wkport +0x11 ); +outb (0 , wkport +0x12 ); +outb (satn[6 ], wkport +0x13 ); +outb (satn[7 ], wkport +0x14 ); +outb (satn[8 ], wkport +0x18 ); + +while ((inb (wkport +0x1f ) &0x80 ) ==0x00 )cpu_relax (); - tmport -=0x08 ; -if (inb (tmport) !=0x11 &&inb (tmport) !=0x8e ) +if (inb (wkport +0x17 ) !=0x11 &&inb (wkport +0x17 ) !=0x8e )continue ; -while (inb (tmport) !=0x8e ) +while (inb (wkport +0x17 ) !=0x8e )cpu_relax (); try_sync: j =0 ; - tmport = wkport +0x14 ; -outb (0x06 , tmport); - tmport +=0x04 ; -outb (0x20 , tmport); - tmport +=0x07 ; +outb (0x06 , wkport +0x14 ); +outb (0x20 , wkport +0x18 ); -while ((inb (tmport) &0x80 ) ==0 ) { -if ((inb (tmport) &0x01 ) !=0 ) { - tmport -=0x06 ; +while ((inb (wkport +0x1f ) &0x80 ) ==0 ) { +if ((inb (wkport +0x1f ) &0x01 ) !=0 ) {if ((m & dev->wide_id[0 ]) !=0 ) { -outb (synw[j++], tmport); +outb (synw[j++], wkport +0x19 ); }else {if ((m & dev->ultra_map[0 ]) !=0 ) { -outb (synu[j++], tmport); +outb (synu[j++], wkport +0x19 ); }else { -outb (synn[j++], tmport); +outb (synn[j++], wkport +0x19 ); } } - tmport +=0x06 ; } } - tmport -=0x08 ; -while ((inb (tmport) &0x80 ) ==0x00 ) +while ((inb (wkport +0x17 ) &0x80 ) ==0x00 )cpu_relax (); - j =inb (tmport) &0x0f ; + j =inb (wkport +0x17 ) &0x0f ;if (j ==0x0f ) { goto phase_ins; }
@@ -1609,18 +1533,12 @@ try_sync: }continue ; phase_outs: - tmport = wkport +0x18 ; -outb (0x20 , tmport); - tmport +=0x07 ; -while ((inb (tmport) &0x80 ) ==0x00 ) { -if ((inb (tmport) &0x01 ) !=0x00 ) { - tmport -=0x06 ; -outb (0x00 , tmport); - tmport +=0x06 ; - } +outb (0x20 , wkport +0x18 ); +while ((inb (wkport +0x1f ) &0x80 ) ==0x00 ) { +if ((inb (wkport +0x1f ) &0x01 ) !=0x00 ) +outb (0x00 , wkport +0x19 ); } - tmport -=0x08 ; - j =inb (tmport); + j =inb (wkport +0x17 );if (j ==0x85 ) { goto tar_dcons; }
@@ -1636,29 +1554,23 @@ phase_outs: }continue ; phase_ins: - tmport = wkport +0x14 ; -outb (0xff , tmport); - tmport +=0x04 ; -outb (0x20 , tmport); - tmport +=0x07 ; +outb (0xff , wkport +0x14 ); +outb (0x20 , wkport +0x18 ); k =0 ; phase_ins1: - j =inb (tmport); + j =inb (wkport +0x1f );if ((j &0x01 ) !=0x00 ) { - tmport -=0x06 ; - mbuf[k++] =inb (tmport); - tmport +=0x06 ; + mbuf[k++] =inb (wkport +0x19 ); goto phase_ins1; }if ((j &0x80 ) ==0x00 ) { goto phase_ins1; } - tmport -=0x08 ; -while ((inb (tmport) &0x80 ) ==0x00 ) +while ((inb (wkport +0x17 ) &0x80 ) ==0x00 )cpu_relax (); - j =inb (tmport); + j =inb (wkport +0x17 );if (j ==0x85 ) { goto tar_dcons; }
@@ -1674,20 +1586,15 @@ phase_ins1: }continue ; phase_cmds: - tmport = wkport +0x10 ; -outb (0x30 , tmport); +outb (0x30 , wkport +0x10 ); tar_dcons: - tmport = wkport +0x14 ; -outb (0x00 , tmport); - tmport +=0x04 ; -outb (0x08 , tmport); - tmport +=0x07 ; +outb (0x00 , wkport +0x14 ); +outb (0x08 , wkport +0x18 ); -while ((inb (tmport) &0x80 ) ==0x00 ) +while ((inb (wkport +0x1f ) &0x80 ) ==0x00 )cpu_relax (); - tmport -=0x08 ; - j =inb (tmport); + j =inb (wkport +0x17 );if (j !=0x16 ) {continue ; }
@@ -1727,8 +1634,7 @@ tar_dcons: set_syn_ok: dev->id[0 ][i].devsp = (dev->id[0 ][i].devsp &0x0f ) | j; } - tmport = wkport +0x3a ; -outb ((unsigned char ) (inb (tmport) &0xef ), tmport); +outb ((unsigned char ) (inb (wkport +0x3a ) &0xef ), wkport +0x3a ); }static void is880 (struct atp_unit *dev,unsigned int wkport)
Signature · 1 line
Ondrej Zary
PATCH 7/52 atp870u: Untangle tmport #5
In reply to Ondrej ZaryUntangle the tmport crap so it becomes obvious what ports are accessed.
--- drivers/scsi/atp870u.c | 470 ++++++++++++++++++------------------------------ 1 file changed, 173 insertions(+), 297 deletions(-)
drivers/scsi/atp870u.c +173 -297
@@ -1639,7 +1639,6 @@ set_syn_ok:static void is880 (struct atp_unit *dev,unsigned int wkport) { -unsigned int tmport;unsigned char i, j, k, rmb, n, lvdmode;unsigned short int m;static unsigned char mbuf[512 ];
@@ -1664,130 +1663,100 @@ static void is880(struct atp_unit *dev, unsigned int wkport)printk (KERN_INFO " ID: %2d Host Adapter\n" , dev->host_id[0 ]);continue ; } - tmport = wkport +0x5b ; -outb (0x01 , tmport); - tmport = wkport +0x41 ; -outb (0x08 , tmport++); -outb (0x7f , tmport++); -outb (satn[0 ], tmport++); -outb (satn[1 ], tmport++); -outb (satn[2 ], tmport++); -outb (satn[3 ], tmport++); -outb (satn[4 ], tmport++); -outb (satn[5 ], tmport++); - tmport +=0x06 ; -outb (0 , tmport); - tmport +=0x02 ; -outb (dev->id[0 ][i].devsp, tmport++); -outb (0 , tmport++); -outb (satn[6 ], tmport++); -outb (satn[7 ], tmport++); +outb (0x01 , wkport +0x5b ); +outb (0x08 , wkport +0x41 ); +outb (0x7f , wkport +0x42 ); +outb (satn[0 ], wkport +0x43 ); +outb (satn[1 ], wkport +0x44 ); +outb (satn[2 ], wkport +0x45 ); +outb (satn[3 ], wkport +0x46 ); +outb (satn[4 ], wkport +0x47 ); +outb (satn[5 ], wkport +0x48 ); +outb (0 , wkport +0x4f ); +outb (dev->id[0 ][i].devsp, wkport +0x51 ); +outb (0 , wkport +0x52 ); +outb (satn[6 ], wkport +0x53 ); +outb (satn[7 ], wkport +0x54 ); j = i;if ((j &0x08 ) !=0 ) { j = (j &0x07 ) |0x40 ; } -outb (j, tmport); - tmport +=0x03 ; -outb (satn[8 ], tmport); - tmport +=0x07 ; +outb (j, wkport +0x55 ); +outb (satn[8 ], wkport +0x58 ); -while ((inb (tmport) &0x80 ) ==0x00 ) +while ((inb (wkport +0x5f ) &0x80 ) ==0x00 )cpu_relax (); - tmport -=0x08 ; -if (inb (tmport) !=0x11 &&inb (tmport) !=0x8e ) +if (inb (wkport +0x57 ) !=0x11 &&inb (wkport +0x57 ) !=0x8e )continue ; -while (inb (tmport) !=0x8e ) +while (inb (wkport +0x57 ) !=0x8e )cpu_relax (); dev->active_id[0 ] |= m; - tmport = wkport +0x50 ; -outb (0x30 , tmport); - tmport = wkport +0x54 ; -outb (0x00 , tmport); +outb (0x30 , wkport +0x50 ); +outb (0x00 , wkport +0x54 ); phase_cmd: - tmport = wkport +0x58 ; -outb (0x08 , tmport); - tmport +=0x07 ; +outb (0x08 , wkport +0x58 ); -while ((inb (tmport) &0x80 ) ==0x00 ) +while ((inb (wkport +0x5f ) &0x80 ) ==0x00 )cpu_relax (); - tmport -=0x08 ; - j =inb (tmport); + j =inb (wkport +0x57 );if (j !=0x16 ) { - tmport = wkport +0x50 ; -outb (0x41 , tmport); +outb (0x41 , wkport +0x50 ); goto phase_cmd; } sel_ok: - tmport = wkport +0x43 ; -outb (inqd[0 ], tmport++); -outb (inqd[1 ], tmport++); -outb (inqd[2 ], tmport++); -outb (inqd[3 ], tmport++); -outb (inqd[4 ], tmport++); -outb (inqd[5 ], tmport); - tmport +=0x07 ; -outb (0 , tmport); - tmport +=0x02 ; -outb (dev->id[0 ][i].devsp, tmport++); -outb (0 , tmport++); -outb (inqd[6 ], tmport++); -outb (inqd[7 ], tmport++); - tmport +=0x03 ; -outb (inqd[8 ], tmport); - tmport +=0x07 ; +outb (inqd[0 ], wkport +0x43 ); +outb (inqd[1 ], wkport +0x44 ); +outb (inqd[2 ], wkport +0x45 ); +outb (inqd[3 ], wkport +0x46 ); +outb (inqd[4 ], wkport +0x47 ); +outb (inqd[5 ], wkport +0x48 ); +outb (0 , wkport +0x4f ); +outb (dev->id[0 ][i].devsp, wkport +0x51 ); +outb (0 , wkport +0x52 ); +outb (inqd[6 ], wkport +0x53 ); +outb (inqd[7 ], wkport +0x54 ); +outb (inqd[8 ], wkport +0x58 ); -while ((inb (tmport) &0x80 ) ==0x00 ) +while ((inb (wkport +0x5f ) &0x80 ) ==0x00 )cpu_relax (); - tmport -=0x08 ; -if (inb (tmport) !=0x11 &&inb (tmport) !=0x8e ) +if (inb (wkport +0x57 ) !=0x11 &&inb (wkport +0x57 ) !=0x8e )continue ; -while (inb (tmport) !=0x8e ) +while (inb (wkport +0x57 ) !=0x8e )cpu_relax (); - tmport = wkport +0x5b ; -outb (0x00 , tmport); - tmport = wkport +0x58 ; -outb (0x08 , tmport); - tmport +=0x07 ; +outb (0x00 , wkport +0x5b ); +outb (0x08 , wkport +0x58 ); j =0 ; rd_inq_data: - k =inb (tmport); + k =inb (wkport +0x5f );if ((k &0x01 ) !=0 ) { - tmport -=0x06 ; - mbuf[j++] =inb (tmport); - tmport +=0x06 ; + mbuf[j++] =inb (wkport +0x59 ); goto rd_inq_data; }if ((k &0x80 ) ==0 ) { goto rd_inq_data; } - tmport -=0x08 ; - j =inb (tmport); + j =inb (wkport +0x57 );if (j ==0x16 ) { goto inq_ok; } - tmport = wkport +0x50 ; -outb (0x46 , tmport); - tmport +=0x02 ; -outb (0 , tmport++); -outb (0 , tmport++); -outb (0 , tmport++); - tmport +=0x03 ; -outb (0x08 , tmport); - tmport +=0x07 ; -while ((inb (tmport) &0x80 ) ==0x00 ) +outb (0x46 , wkport +0x50 ); +outb (0 , wkport +0x52 ); +outb (0 , wkport +0x53 ); +outb (0 , wkport +0x54 ); +outb (0x08 , wkport +0x58 ); +while ((inb (wkport +0x5f ) &0x80 ) ==0x00 )cpu_relax (); - tmport -=0x08 ; -if (inb (tmport) !=0x16 ) +if (inb (wkport +0x57 ) !=0x16 ) goto sel_ok; inq_ok:
@@ -1810,58 +1779,43 @@ inq_ok: goto chg_wide; } - tmport = wkport +0x5b ; -outb (0x01 , tmport); - tmport = wkport +0x43 ; -outb (satn[0 ], tmport++); -outb (satn[1 ], tmport++); -outb (satn[2 ], tmport++); -outb (satn[3 ], tmport++); -outb (satn[4 ], tmport++); -outb (satn[5 ], tmport++); - tmport +=0x06 ; -outb (0 , tmport); - tmport +=0x02 ; -outb (dev->id[0 ][i].devsp, tmport++); -outb (0 , tmport++); -outb (satn[6 ], tmport++); -outb (satn[7 ], tmport++); - tmport +=0x03 ; -outb (satn[8 ], tmport); - tmport +=0x07 ; - -while ((inb (tmport) &0x80 ) ==0x00 ) +outb (0x01 , wkport +0x5b ); +outb (satn[0 ], wkport +0x43 ); +outb (satn[1 ], wkport +0x44 ); +outb (satn[2 ], wkport +0x45 ); +outb (satn[3 ], wkport +0x46 ); +outb (satn[4 ], wkport +0x47 ); +outb (satn[5 ], wkport +0x48 ); +outb (0 , wkport +0x4f ); +outb (dev->id[0 ][i].devsp, wkport +0x51 ); +outb (0 , wkport +0x52 ); +outb (satn[6 ], wkport +0x53 ); +outb (satn[7 ], wkport +0x54 ); +outb (satn[8 ], wkport +0x58 ); + +while ((inb (wkport +0x5f ) &0x80 ) ==0x00 )cpu_relax (); - tmport -=0x08 ; - -if (inb (tmport) !=0x11 &&inb (tmport) !=0x8e ) +if (inb (wkport +0x57 ) !=0x11 &&inb (wkport +0x57 ) !=0x8e )continue ; -while (inb (tmport) !=0x8e ) +while (inb (wkport +0x57 ) !=0x8e )cpu_relax (); try_u3: j =0 ; - tmport = wkport +0x54 ; -outb (0x09 , tmport); - tmport +=0x04 ; -outb (0x20 , tmport); - tmport +=0x07 ; +outb (0x09 , wkport +0x54 ); +outb (0x20 , wkport +0x58 ); -while ((inb (tmport) &0x80 ) ==0 ) { -if ((inb (tmport) &0x01 ) !=0 ) { - tmport -=0x06 ; -outb (u3[j++], tmport); - tmport +=0x06 ; - } +while ((inb (wkport +0x5f ) &0x80 ) ==0 ) { +if ((inb (wkport +0x5f ) &0x01 ) !=0 ) +outb (u3[j++], wkport +0x59 ); } - tmport -=0x08 ; -while ((inb (tmport) &0x80 ) ==0x00 ) +while ((inb (wkport +0x57 ) &0x80 ) ==0x00 )cpu_relax (); - j =inb (tmport) &0x0f ; + j =inb (wkport +0x57 ) &0x0f ;if (j ==0x0f ) { goto u3p_in; }
@@ -1873,18 +1827,12 @@ try_u3: }continue ; u3p_out: - tmport = wkport +0x58 ; -outb (0x20 , tmport); - tmport +=0x07 ; -while ((inb (tmport) &0x80 ) ==0 ) { -if ((inb (tmport) &0x01 ) !=0 ) { - tmport -=0x06 ; -outb (0 , tmport); - tmport +=0x06 ; - } +outb (0x20 , wkport +0x58 ); +while ((inb (wkport +0x5f ) &0x80 ) ==0 ) { +if ((inb (wkport +0x5f ) &0x01 ) !=0 ) +outb (0 , wkport +0x59 ); } - tmport -=0x08 ; - j =inb (tmport) &0x0f ; + j =inb (wkport +0x57 ) &0x0f ;if (j ==0x0f ) { goto u3p_in; }
@@ -1896,25 +1844,19 @@ u3p_out: }continue ; u3p_in: - tmport = wkport +0x54 ; -outb (0x09 , tmport); - tmport +=0x04 ; -outb (0x20 , tmport); - tmport +=0x07 ; +outb (0x09 , wkport +0x54 ); +outb (0x20 , wkport +0x58 ); k =0 ; u3p_in1: - j =inb (tmport); + j =inb (wkport +0x5f );if ((j &0x01 ) !=0 ) { - tmport -=0x06 ; - mbuf[k++] =inb (tmport); - tmport +=0x06 ; + mbuf[k++] =inb (wkport +0x59 ); goto u3p_in1; }if ((j &0x80 ) ==0x00 ) { goto u3p_in1; } - tmport -=0x08 ; - j =inb (tmport) &0x0f ; + j =inb (wkport +0x57 ) &0x0f ;if (j ==0x0f ) { goto u3p_in; }
@@ -1926,19 +1868,14 @@ u3p_in1: }continue ; u3p_cmd: - tmport = wkport +0x50 ; -outb (0x30 , tmport); - tmport = wkport +0x54 ; -outb (0x00 , tmport); - tmport +=0x04 ; -outb (0x08 , tmport); - tmport +=0x07 ; +outb (0x30 , wkport +0x50 ); +outb (0x00 , wkport +0x54 ); +outb (0x08 , wkport +0x58 ); -while ((inb (tmport) &0x80 ) ==0x00 ) +while ((inb (wkport +0x5f ) &0x80 ) ==0x00 )cpu_relax (); - tmport -=0x08 ; - j =inb (tmport); + j =inb (wkport +0x57 );if (j !=0x16 ) {if (j ==0x4e ) { goto u3p_out;
@@ -1962,56 +1899,42 @@ u3p_cmd:continue ; } chg_wide: - tmport = wkport +0x5b ; -outb (0x01 , tmport); - tmport = wkport +0x43 ; -outb (satn[0 ], tmport++); -outb (satn[1 ], tmport++); -outb (satn[2 ], tmport++); -outb (satn[3 ], tmport++); -outb (satn[4 ], tmport++); -outb (satn[5 ], tmport++); - tmport +=0x06 ; -outb (0 , tmport); - tmport +=0x02 ; -outb (dev->id[0 ][i].devsp, tmport++); -outb (0 , tmport++); -outb (satn[6 ], tmport++); -outb (satn[7 ], tmport++); - tmport +=0x03 ; -outb (satn[8 ], tmport); - tmport +=0x07 ; - -while ((inb (tmport) &0x80 ) ==0x00 ) +outb (0x01 , wkport +0x5b ); +outb (satn[0 ], wkport +0x43 ); +outb (satn[1 ], wkport +0x44 ); +outb (satn[2 ], wkport +0x45 ); +outb (satn[3 ], wkport +0x46 ); +outb (satn[4 ], wkport +0x47 ); +outb (satn[5 ], wkport +0x48 ); +outb (0 , wkport +0x4f ); +outb (dev->id[0 ][i].devsp, wkport +0x51 ); +outb (0 , wkport +0x52 ); +outb (satn[6 ], wkport +0x53 ); +outb (satn[7 ], wkport +0x54 ); +outb (satn[8 ], wkport +0x58 ); + +while ((inb (wkport +0x5f ) &0x80 ) ==0x00 )cpu_relax (); - tmport -=0x08 ; -if (inb (tmport) !=0x11 &&inb (tmport) !=0x8e ) +if (inb (wkport +0x57 ) !=0x11 &&inb (wkport +0x57 ) !=0x8e )continue ; -while (inb (tmport) !=0x8e ) +while (inb (wkport +0x57 ) !=0x8e )cpu_relax (); try_wide: j =0 ; - tmport = wkport +0x54 ; -outb (0x05 , tmport); - tmport +=0x04 ; -outb (0x20 , tmport); - tmport +=0x07 ; +outb (0x05 , wkport +0x54 ); +outb (0x20 , wkport +0x58 ); -while ((inb (tmport) &0x80 ) ==0 ) { -if ((inb (tmport) &0x01 ) !=0 ) { - tmport -=0x06 ; -outb (wide[j++], tmport); - tmport +=0x06 ; - } +while ((inb (wkport +0x5f ) &0x80 ) ==0 ) { +if ((inb (wkport +0x5f ) &0x01 ) !=0 ) +outb (wide[j++], wkport +0x59 ); } - tmport -=0x08 ; -while ((inb (tmport) &0x80 ) ==0x00 ) +while ((inb (wkport +0x57 ) &0x80 ) ==0x00 )cpu_relax (); - j =inb (tmport) &0x0f ; + j =inb (wkport +0x57 ) &0x0f ;if (j ==0x0f ) { goto widep_in; }
@@ -2023,18 +1946,12 @@ try_wide: }continue ; widep_out: - tmport = wkport +0x58 ; -outb (0x20 , tmport); - tmport +=0x07 ; -while ((inb (tmport) &0x80 ) ==0 ) { -if ((inb (tmport) &0x01 ) !=0 ) { - tmport -=0x06 ; -outb (0 , tmport); - tmport +=0x06 ; - } +outb (0x20 , wkport +0x58 ); +while ((inb (wkport +0x5f ) &0x80 ) ==0 ) { +if ((inb (wkport +0x5f ) &0x01 ) !=0 ) +outb (0 , wkport +0x59 ); } - tmport -=0x08 ; - j =inb (tmport) &0x0f ; + j =inb (wkport +0x57 ) &0x0f ;if (j ==0x0f ) { goto widep_in; }
@@ -2046,25 +1963,19 @@ widep_out: }continue ; widep_in: - tmport = wkport +0x54 ; -outb (0xff , tmport); - tmport +=0x04 ; -outb (0x20 , tmport); - tmport +=0x07 ; +outb (0xff , wkport +0x54 ); +outb (0x20 , wkport +0x58 ); k =0 ; widep_in1: - j =inb (tmport); + j =inb (wkport +0x5f );if ((j &0x01 ) !=0 ) { - tmport -=0x06 ; - mbuf[k++] =inb (tmport); - tmport +=0x06 ; + mbuf[k++] =inb (wkport +0x59 ); goto widep_in1; }if ((j &0x80 ) ==0x00 ) { goto widep_in1; } - tmport -=0x08 ; - j =inb (tmport) &0x0f ; + j =inb (wkport +0x57 ) &0x0f ;if (j ==0x0f ) { goto widep_in; }
@@ -2076,19 +1987,14 @@ widep_in1: }continue ; widep_cmd: - tmport = wkport +0x50 ; -outb (0x30 , tmport); - tmport = wkport +0x54 ; -outb (0x00 , tmport); - tmport +=0x04 ; -outb (0x08 , tmport); - tmport +=0x07 ; +outb (0x30 , wkport +0x50 ); +outb (0x00 , wkport +0x54 ); +outb (0x08 , wkport +0x58 ); -while ((inb (tmport) &0x80 ) ==0x00 ) +while ((inb (wkport +0x5f ) &0x80 ) ==0x00 )cpu_relax (); - tmport -=0x08 ; - j =inb (tmport); + j =inb (wkport +0x57 );if (j !=0x16 ) {if (j ==0x4e ) { goto widep_out;
@@ -2129,73 +2035,60 @@ set_sync: synuw[4 ] =0x0a ; } } - tmport = wkport +0x5b ; j =0 ;if ((m & dev->wide_id[0 ]) !=0 ) { j |=0x01 ; } -outb (j, tmport); - tmport = wkport +0x43 ; -outb (satn[0 ], tmport++); -outb (satn[1 ], tmport++); -outb (satn[2 ], tmport++); -outb (satn[3 ], tmport++); -outb (satn[4 ], tmport++); -outb (satn[5 ], tmport++); - tmport +=0x06 ; -outb (0 , tmport); - tmport +=0x02 ; -outb (dev->id[0 ][i].devsp, tmport++); -outb (0 , tmport++); -outb (satn[6 ], tmport++); -outb (satn[7 ], tmport++); - tmport +=0x03 ; -outb (satn[8 ], tmport); - tmport +=0x07 ; - -while ((inb (tmport) &0x80 ) ==0x00 ) +outb (j, wkport +0x5b ); +outb (satn[0 ], wkport +0x43 ); +outb (satn[1 ], wkport +0x44 ); +outb (satn[2 ], wkport +0x45 ); +outb (satn[3 ], wkport +0x46 ); +outb (satn[4 ], wkport +0x47 ); +outb (satn[5 ], wkport +0x48 ); +outb (0 , wkport +0x4f ); +outb (dev->id[0 ][i].devsp, wkport +0x51 ); +outb (0 , wkport +0x52 ); +outb (satn[6 ], wkport +0x53 ); +outb (satn[7 ], wkport +0x54 ); +outb (satn[8 ], wkport +0x58 ); + +while ((inb (wkport +0x5f ) &0x80 ) ==0x00 )cpu_relax (); - tmport -=0x08 ; -if ((inb (tmport) !=0x11 ) && (inb (tmport) !=0x8e )) { +if ((inb (wkport +0x57 ) !=0x11 ) && (inb (wkport +0x57 ) !=0x8e )) {continue ; } -while (inb (tmport) !=0x8e ) +while (inb (wkport +0x57 ) !=0x8e )cpu_relax (); try_sync: j =0 ; - tmport = wkport +0x54 ; -outb (0x06 , tmport); - tmport +=0x04 ; -outb (0x20 , tmport); - tmport +=0x07 ; +outb (0x06 , wkport +0x54 ); +outb (0x20 , wkport +0x58 ); -while ((inb (tmport) &0x80 ) ==0 ) { -if ((inb (tmport) &0x01 ) !=0 ) { - tmport -=0x06 ; +while ((inb (wkport +0x5f ) &0x80 ) ==0 ) { +if ((inb (wkport +0x5f ) &0x01 ) !=0 ) {if ((m & dev->wide_id[0 ]) !=0 ) {if ((m & dev->ultra_map[0 ]) !=0 ) { -outb (synuw[j++], tmport); +outb (synuw[j++], wkport +0x59 ); }else { -outb (synw[j++], tmport); +outb (synw[j++], wkport +0x59 ); } }else {if ((m & dev->ultra_map[0 ]) !=0 ) { -outb (synu[j++], tmport); +outb (synu[j++], wkport +0x59 ); }else { -outb (synn[j++], tmport); +outb (synn[j++], wkport +0x59 ); } } - tmport +=0x06 ; } } - tmport -=0x08 ; -while ((inb (tmport) &0x80 ) ==0x00 ) +while ((inb (wkport +0x57 ) &0x80 ) ==0x00 )cpu_relax (); - j =inb (tmport) &0x0f ; + j =inb (wkport +0x57 ) &0x0f ;if (j ==0x0f ) { goto phase_ins; }
@@ -2207,18 +2100,12 @@ try_sync: }continue ; phase_outs: - tmport = wkport +0x58 ; -outb (0x20 , tmport); - tmport +=0x07 ; -while ((inb (tmport) &0x80 ) ==0x00 ) { -if ((inb (tmport) &0x01 ) !=0x00 ) { - tmport -=0x06 ; -outb (0x00 , tmport); - tmport +=0x06 ; - } +outb (0x20 , wkport +0x58 ); +while ((inb (wkport +0x5f ) &0x80 ) ==0x00 ) { +if ((inb (wkport +0x5f ) &0x01 ) !=0x00 ) +outb (0x00 , wkport +0x59 ); } - tmport -=0x08 ; - j =inb (tmport); + j =inb (wkport +0x57 );if (j ==0x85 ) { goto tar_dcons; }
@@ -2234,29 +2121,23 @@ phase_outs: }continue ; phase_ins: - tmport = wkport +0x54 ; -outb (0x06 , tmport); - tmport +=0x04 ; -outb (0x20 , tmport); - tmport +=0x07 ; +outb (0x06 , wkport +0x54 ); +outb (0x20 , wkport +0x58 ); k =0 ; phase_ins1: - j =inb (tmport); + j =inb (wkport +0x5f );if ((j &0x01 ) !=0x00 ) { - tmport -=0x06 ; - mbuf[k++] =inb (tmport); - tmport +=0x06 ; + mbuf[k++] =inb (wkport +0x59 ); goto phase_ins1; }if ((j &0x80 ) ==0x00 ) { goto phase_ins1; } - tmport -=0x08 ; -while ((inb (tmport) &0x80 ) ==0x00 ) +while ((inb (wkport +0x57 ) &0x80 ) ==0x00 )cpu_relax (); - j =inb (tmport); + j =inb (wkport +0x57 );if (j ==0x85 ) { goto tar_dcons; }
@@ -2272,20 +2153,15 @@ phase_ins1: }continue ; phase_cmds: - tmport = wkport +0x50 ; -outb (0x30 , tmport); +outb (0x30 , wkport +0x50 ); tar_dcons: - tmport = wkport +0x54 ; -outb (0x00 , tmport); - tmport +=0x04 ; -outb (0x08 , tmport); - tmport +=0x07 ; +outb (0x00 , wkport +0x54 ); +outb (0x08 , wkport +0x58 ); -while ((inb (tmport) &0x80 ) ==0x00 ) +while ((inb (wkport +0x5f ) &0x80 ) ==0x00 )cpu_relax (); - tmport -=0x08 ; - j =inb (tmport); + j =inb (wkport +0x57 );if (j !=0x16 ) {continue ; }
Signature · 1 line
Ondrej Zary
PATCH 8/52 atp870u: Untangle tmport #6
In reply to Ondrej ZaryUntangle the tmport crap so it becomes obvious what ports are accessed.
--- drivers/scsi/atp870u.c | 136 +++++++++++++++++------------------------------- 1 file changed, 49 insertions(+), 87 deletions(-)
drivers/scsi/atp870u.c +49 -87
@@ -2264,7 +2264,7 @@ static int atp870u_probe(struct pci_dev *pdev, const struct pci_device_id *ent) {unsigned char k, m, c;unsigned long flags; -unsigned int base_io, tmport, error,n; +unsigned int base_io, error,n;unsigned char host_id;struct Scsi_Host *shpnt =NULL ;struct atp_unit *atpdev, *p;
@@ -2322,12 +2322,9 @@ static int atp870u_probe(struct pci_dev *pdev, const struct pci_device_id *ent) atpdev->dev_id = ent->device; atpdev->host_id[0 ] = host_id; - tmport = base_io +0x22 ; - atpdev->scam_on =inb (tmport); - tmport +=0x13 ; - atpdev->global_map[0 ] =inb (tmport); - tmport +=0x07 ; - atpdev->ultra_map[0 ] =inw (tmport); + atpdev->scam_on =inb (base_io +0x22 ); + atpdev->global_map[0 ] =inb (base_io +0x35 ); + atpdev->ultra_map[0 ] =inw (base_io +0x3c ); n =0x3f09 ; next_fblk_880:
@@ -2402,37 +2399,26 @@ flash_ok_880: }spin_lock_irqsave (shpnt->host_lock, flags); - tmport = base_io +0x38 ; - k =inb (tmport) &0x80 ; -outb (k, tmport); - tmport +=0x03 ; -outb (0x20 , tmport); + k =inb (base_io +0x38 ) &0x80 ; +outb (k, base_io +0x38 ); +outb (0x20 , base_io +0x3b );mdelay (32 ); -outb (0 , tmport); +outb (0 , base_io +0x3b );mdelay (32 ); - tmport = base_io +0x5b ; -inb (tmport); - tmport -=0x04 ; -inb (tmport); - tmport = base_io +0x40 ; -outb ((host_id |0x08 ), tmport); - tmport +=0x18 ; -outb (0 , tmport); - tmport +=0x07 ; -while ((inb (tmport) &0x80 ) ==0 ) +inb (base_io +0x5b ); +inb (base_io +0x57 ); +outb ((host_id |0x08 ), base_io +0x40 ); +outb (0 , base_io +0x58 ); +while ((inb (base_io +0x5f ) &0x80 ) ==0 )mdelay (1 ); - tmport -=0x08 ; -inb (tmport); - tmport = base_io +0x41 ; -outb (8 , tmport++); -outb (0x7f , tmport); - tmport = base_io +0x51 ; -outb (0x20 , tmport); +inb (base_io +0x57 ); +outb (8 , base_io +0x41 ); +outb (0x7f , base_io +0x42 ); +outb (0x20 , base_io +0x51 );tscam (shpnt);is880 (p, base_io); - tmport = base_io +0x38 ; -outb (0xb0 , tmport); +outb (0xb0 , base_io +0x38 ); shpnt->max_id =16 ; shpnt->this_id = host_id; shpnt->unique_id = base_io;
@@ -2546,47 +2532,35 @@ flash_ok_885:inb (base_io +0x97 );inb (base_io +0xdb );inb (base_io +0xd7 ); - tmport = base_io +0x80 ; k=p->host_id[0 ];if (k >7 ) k = (k &0x07 ) |0x40 ; k |=0x08 ; -outb (k, tmport); - tmport +=0x18 ; -outb (0 , tmport); - tmport +=0x07 ; +outb (k, base_io +0x80 ); +outb (0 , base_io +0x98 ); -while ((inb (tmport) &0x80 ) ==0 ) +while ((inb (base_io +0x9f ) &0x80 ) ==0 )cpu_relax (); - tmport -=0x08 ; -inb (tmport); - tmport = base_io +0x81 ; -outb (8 , tmport++); -outb (0x7f , tmport); - tmport = base_io +0x91 ; -outb (0x20 , tmport); +inb (base_io +0x97 ); +outb (8 , base_io +0x81 ); +outb (0x7f , base_io +0x82 ); +outb (0x20 , base_io +0x91 ); - tmport = base_io +0xc0 ; k=p->host_id[1 ];if (k >7 ) k = (k &0x07 ) |0x40 ; k |=0x08 ; -outb (k, tmport); - tmport +=0x18 ; -outb (0 , tmport); - tmport +=0x07 ; +outb (k, base_io +0xc0 ); +outb (0 , base_io +0xd8 ); -while ((inb (tmport) &0x80 ) ==0 ) +while ((inb (base_io +0xdf ) &0x80 ) ==0 )cpu_relax (); - tmport -=0x08 ; -inb (tmport); - tmport = base_io +0xc1 ; -outb (8 , tmport++); -outb (0x7f , tmport); - tmport = base_io +0xd1 ; -outb (0x20 , tmport); +inb (base_io +0xd7 ); +outb (8 , base_io +0xc1 ); +outb (0x7f , base_io +0xc2 ); +outb (0x20 , base_io +0xd1 );tscam_885 ();printk (KERN_INFO " Scanning Channel A SCSI Device ...\n" );
@@ -2624,11 +2598,9 @@ flash_ok_885: atpdev->dev_id = ent->device; host_id &=0x07 ; atpdev->host_id[0 ] = host_id; - tmport = base_io +0x22 ; - atpdev->scam_on =inb (tmport); - tmport +=0x0b ; - atpdev->global_map[0 ] =inb (tmport++); - atpdev->ultra_map[0 ] =inw (tmport); + atpdev->scam_on =inb (base_io +0x22 ); + atpdev->global_map[0 ] =inb (base_io +0x2d ); + atpdev->ultra_map[0 ] =inw (base_io +0x2e );if (atpdev->ultra_map[0 ] ==0 ) { atpdev->scam_on =0x00 ;
@@ -2656,39 +2628,29 @@ flash_ok_885:spin_lock_irqsave (shpnt->host_lock, flags);if (atpdev->chip_ver >0x07 ) {/* check if atp876 chip then enable terminator */ - tmport = base_io +0x3e ; -outb (0x00 , tmport); +outb (0x00 , base_io +0x3e ); } - tmport = base_io +0x3a ; - k = (inb (tmport) &0xf3 ) |0x10 ; -outb (k, tmport); -outb ((k &0xdf ), tmport); + k = (inb (base_io +0x3a ) &0xf3 ) |0x10 ; +outb (k, base_io +0x3a ); +outb ((k &0xdf ), base_io +0x3a );mdelay (32 ); -outb (k, tmport); +outb (k, base_io +0x3a );mdelay (32 ); - tmport = base_io; -outb ((host_id |0x08 ), tmport); - tmport +=0x18 ; -outb (0 , tmport); - tmport +=0x07 ; -while ((inb (tmport) &0x80 ) ==0 ) +outb ((host_id |0x08 ), base_io +0 ); +outb (0 , base_io +0x18 ); +while ((inb (base_io +0x1f ) &0x80 ) ==0 )mdelay (1 ); - tmport -=0x08 ; -inb (tmport); - tmport = base_io +1 ; -outb (8 , tmport++); -outb (0x7f , tmport); - tmport = base_io +0x11 ; -outb (0x20 , tmport); +inb (base_io +0x17 ); +outb (8 , base_io +1 ); +outb (0x7f , base_io +2 ); +outb (0x20 , base_io +0x11 );tscam (shpnt);is870 (p, base_io); - tmport = base_io +0x3a ; -outb ((inb (tmport) &0xef ), tmport); - tmport++; -outb ((inb (tmport) |0x20 ), tmport); +outb ((inb (base_io +0x3a ) &0xef ), base_io +0x3a ); +outb ((inb (base_io +0x3b ) |0x20 ), base_io +0x3b );if (atpdev->chip_ver ==4 ) shpnt->max_id =16 ;else
Signature · 1 line
Ondrej Zary
PATCH 9/52 atp870u: Untangle tmport #7
In reply to Ondrej ZaryUntangle the tmport crap so it becomes obvious what ports are accessed.
--- drivers/scsi/atp870u.c | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-)
drivers/scsi/atp870u.c +5 -11
@@ -2716,7 +2716,6 @@ static int atp870u_abort(struct scsi_cmnd * SCpnt) {unsigned char j, k, c;struct scsi_cmnd *workrequ; -unsigned int tmport;struct atp_unit *dev;struct Scsi_Host *host; host = SCpnt->device->host;
@@ -2726,18 +2725,13 @@ static int atp870u_abort(struct scsi_cmnd * SCpnt)printk (" atp870u: abort Channel = %x \n" , c);printk ("working=%x last_cmd=%x " , dev->working[c], dev->last_cmd[c]);printk (" quhdu=%x quendu=%x " , dev->quhd[c], dev->quend[c]); - tmport = dev->ioport[c];for (j =0 ; j <0x18 ; j++) { -printk (" r%2x=%2x" , j,inb (tmport++)); +printk (" r%2x=%2x" , j,inb (dev->ioport[c] + j)); } - tmport +=0x04 ; -printk (" r1c=%2x" ,inb (tmport)); - tmport +=0x03 ; -printk (" r1f=%2x in_snd=%2x " ,inb (tmport), dev->in_snd[c]); - tmport= dev->pciport[c]; -printk (" d00=%2x" ,inb (tmport)); - tmport +=0x02 ; -printk (" d02=%2x" ,inb (tmport)); +printk (" r1c=%2x" ,inb (dev->ioport[c] +0x1c )); +printk (" r1f=%2x in_snd=%2x " ,inb (dev->ioport[c] +0x1f ), dev->in_snd[c]); +printk (" d00=%2x" ,inb (dev->pciport[c])); +printk (" d02=%2x" ,inb (dev->pciport[c] +0x02 ));for (j=0 ;j<16 ;j++) {if (dev->id[c][j].curr_req !=NULL ) { workrequ = dev->id[c][j].curr_req;
Signature · 1 line
Ondrej Zary
PATCH 10/52 atp870u: Untangle tmport #8
In reply to Ondrej ZaryUntangle the tmport crap so it becomes obvious what ports are accessed.
--- drivers/scsi/atp870u.c | 478 ++++++++++++++++++------------------------------ 1 file changed, 177 insertions(+), 301 deletions(-)
drivers/scsi/atp870u.c +177 -301
@@ -2870,7 +2870,6 @@ static void tscam_885(void)static void is885 (struct atp_unit *dev,unsigned int wkport,unsigned char c) { -unsigned int tmport;unsigned char i, j, k, rmb, n, lvdmode;unsigned short int m;static unsigned char mbuf[512 ];
@@ -2895,123 +2894,93 @@ static void is885(struct atp_unit *dev, unsigned int wkport,unsigned char c)printk (KERN_INFO " ID: %2d Host Adapter\n" , dev->host_id[c]);continue ; } - tmport = wkport +0x1b ; -outb (0x01 , tmport); - tmport = wkport +0x01 ; -outb (0x08 , tmport++); -outb (0x7f , tmport++); -outb (satn[0 ], tmport++); -outb (satn[1 ], tmport++); -outb (satn[2 ], tmport++); -outb (satn[3 ], tmport++); -outb (satn[4 ], tmport++); -outb (satn[5 ], tmport++); - tmport +=0x06 ; -outb (0 , tmport); - tmport +=0x02 ; -outb (dev->id[c][i].devsp, tmport++); +outb (0x01 , wkport +0x1b ); +outb (0x08 , wkport +0x01 ); +outb (0x7f , wkport +0x02 ); +outb (satn[0 ], wkport +0x03 ); +outb (satn[1 ], wkport +0x04 ); +outb (satn[2 ], wkport +0x05 ); +outb (satn[3 ], wkport +0x06 ); +outb (satn[4 ], wkport +0x07 ); +outb (satn[5 ], wkport +0x08 ); +outb (0 , wkport +0x0f ); +outb (dev->id[c][i].devsp, wkport +0x11 ); -outb (0 , tmport++); -outb (satn[6 ], tmport++); -outb (satn[7 ], tmport++); +outb (0 , wkport +0x12 ); +outb (satn[6 ], wkport +0x13 ); +outb (satn[7 ], wkport +0x14 ); j = i;if ((j &0x08 ) !=0 ) { j = (j &0x07 ) |0x40 ; } -outb (j, tmport); - tmport +=0x03 ; -outb (satn[8 ], tmport); - tmport +=0x07 ; +outb (j, wkport +0x15 ); +outb (satn[8 ], wkport +0x18 ); -while ((inb (tmport) &0x80 ) ==0x00 ) +while ((inb (wkport +0x1f ) &0x80 ) ==0x00 )cpu_relax (); - tmport -=0x08 ; -if ((inb (tmport) !=0x11 ) && (inb (tmport) !=0x8e )) { +if ((inb (wkport +0x17 ) !=0x11 ) && (inb (wkport +0x17 ) !=0x8e )) {continue ; } -while (inb (tmport) !=0x8e ) +while (inb (wkport +0x17 ) !=0x8e )cpu_relax (); dev->active_id[c] |= m; - tmport = wkport +0x10 ; -outb (0x30 , tmport); - tmport = wkport +0x14 ; -outb (0x00 , tmport); +outb (0x30 , wkport +0x10 ); +outb (0x00 , wkport +0x14 ); phase_cmd: - tmport = wkport +0x18 ; -outb (0x08 , tmport); - tmport +=0x07 ; -while ((inb (tmport) &0x80 ) ==0x00 ) +outb (0x08 , wkport +0x18 ); +while ((inb (wkport +0x1f ) &0x80 ) ==0x00 )cpu_relax (); - tmport -=0x08 ; - j =inb (tmport); + j =inb (wkport +0x17 );if (j !=0x16 ) { - tmport = wkport +0x10 ; -outb (0x41 , tmport); +outb (0x41 , wkport +0x10 ); goto phase_cmd; } sel_ok: - tmport = wkport +0x03 ; -outb (inqd[0 ], tmport++); -outb (inqd[1 ], tmport++); -outb (inqd[2 ], tmport++); -outb (inqd[3 ], tmport++); -outb (inqd[4 ], tmport++); -outb (inqd[5 ], tmport); - tmport +=0x07 ; -outb (0 , tmport); - tmport +=0x02 ; -outb (dev->id[c][i].devsp, tmport++); -outb (0 , tmport++); -outb (inqd[6 ], tmport++); -outb (inqd[7 ], tmport++); - tmport +=0x03 ; -outb (inqd[8 ], tmport); - tmport +=0x07 ; -while ((inb (tmport) &0x80 ) ==0x00 ) +outb (inqd[0 ], wkport +0x03 ); +outb (inqd[1 ], wkport +0x04 ); +outb (inqd[2 ], wkport +0x05 ); +outb (inqd[3 ], wkport +0x06 ); +outb (inqd[4 ], wkport +0x07 ); +outb (inqd[5 ], wkport +0x08 ); +outb (0 , wkport +0x0f ); +outb (dev->id[c][i].devsp, wkport +0x11 ); +outb (0 , wkport +0x12 ); +outb (inqd[6 ], wkport +0x13 ); +outb (inqd[7 ], wkport +0x14 ); +outb (inqd[8 ], wkport +0x18 ); +while ((inb (wkport +0x1f ) &0x80 ) ==0x00 )cpu_relax (); - tmport -=0x08 ; -if ((inb (tmport) !=0x11 ) && (inb (tmport) !=0x8e )) { +if ((inb (wkport +0x17 ) !=0x11 ) && (inb (wkport +0x17 ) !=0x8e )) {continue ; } -while (inb (tmport) !=0x8e ) +while (inb (wkport +0x17 ) !=0x8e )cpu_relax (); - tmport = wkport +0x1b ; -outb (0x00 , tmport); - tmport = wkport +0x18 ; -outb (0x08 , tmport); - tmport +=0x07 ; +outb (0x00 , wkport +0x1b ); +outb (0x08 , wkport +0x18 ); j =0 ; rd_inq_data: - k =inb (tmport); + k =inb (wkport +0x1f );if ((k &0x01 ) !=0 ) { - tmport -=0x06 ; - mbuf[j++] =inb (tmport); - tmport +=0x06 ; + mbuf[j++] =inb (wkport +0x19 ); goto rd_inq_data; }if ((k &0x80 ) ==0 ) { goto rd_inq_data; } - tmport -=0x08 ; - j =inb (tmport); + j =inb (wkport +0x17 );if (j ==0x16 ) { goto inq_ok; } - tmport = wkport +0x10 ; -outb (0x46 , tmport); - tmport +=0x02 ; -outb (0 , tmport++); -outb (0 , tmport++); -outb (0 , tmport++); - tmport +=0x03 ; -outb (0x08 , tmport); - tmport +=0x07 ; -while ((inb (tmport) &0x80 ) ==0x00 ) +outb (0x46 , wkport +0x10 ); +outb (0 , wkport +0x12 ); +outb (0 , wkport +0x13 ); +outb (0 , wkport +0x14 ); +outb (0x08 , wkport +0x18 ); +while ((inb (wkport +0x1f ) &0x80 ) ==0x00 )cpu_relax (); - tmport -=0x08 ; -if (inb (tmport) !=0x16 ) { +if (inb (wkport +0x17 ) !=0x16 ) { goto sel_ok; } inq_ok:
@@ -3033,54 +3002,40 @@ inq_ok: goto chg_wide; } - tmport = wkport +0x1b ; -outb (0x01 , tmport); - tmport = wkport +0x03 ; -outb (satn[0 ], tmport++); -outb (satn[1 ], tmport++); -outb (satn[2 ], tmport++); -outb (satn[3 ], tmport++); -outb (satn[4 ], tmport++); -outb (satn[5 ], tmport++); - tmport +=0x06 ; -outb (0 , tmport); - tmport +=0x02 ; -outb (dev->id[c][i].devsp, tmport++); -outb (0 , tmport++); -outb (satn[6 ], tmport++); -outb (satn[7 ], tmport++); - tmport +=0x03 ; -outb (satn[8 ], tmport); - tmport +=0x07 ; - -while ((inb (tmport) &0x80 ) ==0x00 ) +outb (0x01 , wkport +0x1b ); +outb (satn[0 ], wkport +0x03 ); +outb (satn[1 ], wkport +0x04 ); +outb (satn[2 ], wkport +0x05 ); +outb (satn[3 ], wkport +0x06 ); +outb (satn[4 ], wkport +0x07 ); +outb (satn[5 ], wkport +0x08 ); +outb (0 , wkport +0x0f ); +outb (dev->id[c][i].devsp, wkport +0x11 ); +outb (0 , wkport +0x12 ); +outb (satn[6 ], wkport +0x13 ); +outb (satn[7 ], wkport +0x14 ); +outb (satn[8 ], wkport +0x18 ); + +while ((inb (wkport +0x1f ) &0x80 ) ==0x00 )cpu_relax (); - tmport -=0x08 ; -if ((inb (tmport) !=0x11 ) && (inb (tmport) !=0x8e )) { +if ((inb (wkport +0x17 ) !=0x11 ) && (inb (wkport +0x17 ) !=0x8e )) {continue ; } -while (inb (tmport) !=0x8e ) +while (inb (wkport +0x17 ) !=0x8e )cpu_relax (); try_u3: j =0 ; - tmport = wkport +0x14 ; -outb (0x09 , tmport); - tmport +=0x04 ; -outb (0x20 , tmport); - tmport +=0x07 ; - -while ((inb (tmport) &0x80 ) ==0 ) { -if ((inb (tmport) &0x01 ) !=0 ) { - tmport -=0x06 ; -outb (u3[j++], tmport); - tmport +=0x06 ; - } +outb (0x09 , wkport +0x14 ); +outb (0x20 , wkport +0x18 ); + +while ((inb (wkport +0x1f ) &0x80 ) ==0 ) { +if ((inb (wkport +0x1f ) &0x01 ) !=0 ) +outb (u3[j++], wkport +0x19 );cpu_relax (); } - tmport -=0x08 ; -while ((inb (tmport) &0x80 ) ==0x00 ) +while ((inb (wkport +0x17 ) &0x80 ) ==0x00 )cpu_relax (); - j =inb (tmport) &0x0f ; + j =inb (wkport +0x17 ) &0x0f ;if (j ==0x0f ) { goto u3p_in; }
@@ -3092,19 +3047,13 @@ try_u3: }continue ; u3p_out: - tmport = wkport +0x18 ; -outb (0x20 , tmport); - tmport +=0x07 ; -while ((inb (tmport) &0x80 ) ==0 ) { -if ((inb (tmport) &0x01 ) !=0 ) { - tmport -=0x06 ; -outb (0 , tmport); - tmport +=0x06 ; - } +outb (0x20 , wkport +0x18 ); +while ((inb (wkport +0x1f ) &0x80 ) ==0 ) { +if ((inb (wkport +0x1f ) &0x01 ) !=0 ) +outb (0 , wkport +0x19 );cpu_relax (); } - tmport -=0x08 ; - j =inb (tmport) &0x0f ; + j =inb (wkport +0x17 ) &0x0f ;if (j ==0x0f ) { goto u3p_in; }
@@ -3116,25 +3065,19 @@ u3p_out: }continue ; u3p_in: - tmport = wkport +0x14 ; -outb (0x09 , tmport); - tmport +=0x04 ; -outb (0x20 , tmport); - tmport +=0x07 ; +outb (0x09 , wkport +0x14 ); +outb (0x20 , wkport +0x18 ); k =0 ; u3p_in1: - j =inb (tmport); + j =inb (wkport +0x1f );if ((j &0x01 ) !=0 ) { - tmport -=0x06 ; - mbuf[k++] =inb (tmport); - tmport +=0x06 ; + mbuf[k++] =inb (wkport +0x19 ); goto u3p_in1; }if ((j &0x80 ) ==0x00 ) { goto u3p_in1; } - tmport -=0x08 ; - j =inb (tmport) &0x0f ; + j =inb (wkport +0x17 ) &0x0f ;if (j ==0x0f ) { goto u3p_in; }
@@ -3146,16 +3089,11 @@ u3p_in1: }continue ; u3p_cmd: - tmport = wkport +0x10 ; -outb (0x30 , tmport); - tmport = wkport +0x14 ; -outb (0x00 , tmport); - tmport +=0x04 ; -outb (0x08 , tmport); - tmport +=0x07 ; -while ((inb (tmport) &0x80 ) ==0x00 ); - tmport -=0x08 ; - j =inb (tmport); +outb (0x30 , wkport +0x10 ); +outb (0x00 , wkport +0x14 ); +outb (0x08 , wkport +0x18 ); +while ((inb (wkport +0x1f ) &0x80 ) ==0x00 ); + j =inb (wkport +0x17 );if (j !=0x16 ) {if (j ==0x4e ) { goto u3p_out;
@@ -3182,54 +3120,40 @@ u3p_cmd:continue ; } chg_wide: - tmport = wkport +0x1b ; -outb (0x01 , tmport); - tmport = wkport +0x03 ; -outb (satn[0 ], tmport++); -outb (satn[1 ], tmport++); -outb (satn[2 ], tmport++); -outb (satn[3 ], tmport++); -outb (satn[4 ], tmport++); -outb (satn[5 ], tmport++); - tmport +=0x06 ; -outb (0 , tmport); - tmport +=0x02 ; -outb (dev->id[c][i].devsp, tmport++); -outb (0 , tmport++); -outb (satn[6 ], tmport++); -outb (satn[7 ], tmport++); - tmport +=0x03 ; -outb (satn[8 ], tmport); - tmport +=0x07 ; - -while ((inb (tmport) &0x80 ) ==0x00 ) +outb (0x01 , wkport +0x1b ); +outb (satn[0 ], wkport +0x03 ); +outb (satn[1 ], wkport +0x04 ); +outb (satn[2 ], wkport +0x05 ); +outb (satn[3 ], wkport +0x06 ); +outb (satn[4 ], wkport +0x07 ); +outb (satn[5 ], wkport +0x08 ); +outb (0 , wkport +0x0f ); +outb (dev->id[c][i].devsp, wkport +0x11 ); +outb (0 , wkport +0x12 ); +outb (satn[6 ], wkport +0x13 ); +outb (satn[7 ], wkport +0x14 ); +outb (satn[8 ], wkport +0x18 ); + +while ((inb (wkport +0x1f ) &0x80 ) ==0x00 )cpu_relax (); - tmport -=0x08 ; -if ((inb (tmport) !=0x11 ) && (inb (tmport) !=0x8e )) { +if ((inb (wkport +0x17 ) !=0x11 ) && (inb (wkport +0x17 ) !=0x8e )) {continue ; } -while (inb (tmport) !=0x8e ) +while (inb (wkport +0x17 ) !=0x8e )cpu_relax (); try_wide: j =0 ; - tmport = wkport +0x14 ; -outb (0x05 , tmport); - tmport +=0x04 ; -outb (0x20 , tmport); - tmport +=0x07 ; - -while ((inb (tmport) &0x80 ) ==0 ) { -if ((inb (tmport) &0x01 ) !=0 ) { - tmport -=0x06 ; -outb (wide[j++], tmport); - tmport +=0x06 ; - } +outb (0x05 , wkport +0x14 ); +outb (0x20 , wkport +0x18 ); + +while ((inb (wkport +0x1f ) &0x80 ) ==0 ) { +if ((inb (wkport +0x1f ) &0x01 ) !=0 ) +outb (wide[j++], wkport +0x19 );cpu_relax (); } - tmport -=0x08 ; -while ((inb (tmport) &0x80 ) ==0x00 ) +while ((inb (wkport +0x17 ) &0x80 ) ==0x00 )cpu_relax (); - j =inb (tmport) &0x0f ; + j =inb (wkport +0x17 ) &0x0f ;if (j ==0x0f ) { goto widep_in; }
@@ -3241,19 +3165,13 @@ try_wide: }continue ; widep_out: - tmport = wkport +0x18 ; -outb (0x20 , tmport); - tmport +=0x07 ; -while ((inb (tmport) &0x80 ) ==0 ) { -if ((inb (tmport) &0x01 ) !=0 ) { - tmport -=0x06 ; -outb (0 , tmport); - tmport +=0x06 ; - } +outb (0x20 , wkport +0x18 ); +while ((inb (wkport +0x1f ) &0x80 ) ==0 ) { +if ((inb (wkport +0x1f ) &0x01 ) !=0 ) +outb (0 , wkport +0x19 );cpu_relax (); } - tmport -=0x08 ; - j =inb (tmport) &0x0f ; + j =inb (wkport +0x17 ) &0x0f ;if (j ==0x0f ) { goto widep_in; }
@@ -3265,25 +3183,19 @@ widep_out: }continue ; widep_in: - tmport = wkport +0x14 ; -outb (0xff , tmport); - tmport +=0x04 ; -outb (0x20 , tmport); - tmport +=0x07 ; +outb (0xff , wkport +0x14 ); +outb (0x20 , wkport +0x18 ); k =0 ; widep_in1: - j =inb (tmport); + j =inb (wkport +0x1f );if ((j &0x01 ) !=0 ) { - tmport -=0x06 ; - mbuf[k++] =inb (tmport); - tmport +=0x06 ; + mbuf[k++] =inb (wkport +0x19 ); goto widep_in1; }if ((j &0x80 ) ==0x00 ) { goto widep_in1; } - tmport -=0x08 ; - j =inb (tmport) &0x0f ; + j =inb (wkport +0x17 ) &0x0f ;if (j ==0x0f ) { goto widep_in; }
@@ -3295,17 +3207,12 @@ widep_in1: }continue ; widep_cmd: - tmport = wkport +0x10 ; -outb (0x30 , tmport); - tmport = wkport +0x14 ; -outb (0x00 , tmport); - tmport +=0x04 ; -outb (0x08 , tmport); - tmport +=0x07 ; -while ((inb (tmport) &0x80 ) ==0x00 ) +outb (0x30 , wkport +0x10 ); +outb (0x00 , wkport +0x14 ); +outb (0x08 , wkport +0x18 ); +while ((inb (wkport +0x1f ) &0x80 ) ==0x00 )cpu_relax (); - tmport -=0x08 ; - j =inb (tmport); + j =inb (wkport +0x17 );if (j !=0x16 ) {if (j ==0x4e ) { goto widep_out;
@@ -3347,69 +3254,56 @@ set_sync: synuw[4 ]=0x0a ; } } - tmport = wkport +0x1b ; j =0 ;if ((m & dev->wide_id[c]) !=0 ) { j |=0x01 ; } -outb (j, tmport); - tmport = wkport +0x03 ; -outb (satn[0 ], tmport++); -outb (satn[1 ], tmport++); -outb (satn[2 ], tmport++); -outb (satn[3 ], tmport++); -outb (satn[4 ], tmport++); -outb (satn[5 ], tmport++); - tmport +=0x06 ; -outb (0 , tmport); - tmport +=0x02 ; -outb (dev->id[c][i].devsp, tmport++); -outb (0 , tmport++); -outb (satn[6 ], tmport++); -outb (satn[7 ], tmport++); - tmport +=0x03 ; -outb (satn[8 ], tmport); - tmport +=0x07 ; - -while ((inb (tmport) &0x80 ) ==0x00 ) +outb (j, wkport +0x1b ); +outb (satn[0 ], wkport +0x03 ); +outb (satn[1 ], wkport +0x04 ); +outb (satn[2 ], wkport +0x05 ); +outb (satn[3 ], wkport +0x06 ); +outb (satn[4 ], wkport +0x07 ); +outb (satn[5 ], wkport +0x08 ); +outb (0 , wkport +0x0f ); +outb (dev->id[c][i].devsp, wkport +0x11 ); +outb (0 , wkport +0x12 ); +outb (satn[6 ], wkport +0x13 ); +outb (satn[7 ], wkport +0x14 ); +outb (satn[8 ], wkport +0x18 ); + +while ((inb (wkport +0x1f ) &0x80 ) ==0x00 )cpu_relax (); - tmport -=0x08 ; -if ((inb (tmport) !=0x11 ) && (inb (tmport) !=0x8e )) { +if ((inb (wkport +0x17 ) !=0x11 ) && (inb (wkport +0x17 ) !=0x8e )) {continue ; } -while (inb (tmport) !=0x8e ) +while (inb (wkport +0x17 ) !=0x8e )cpu_relax (); try_sync: j =0 ; - tmport = wkport +0x14 ; -outb (0x06 , tmport); - tmport +=0x04 ; -outb (0x20 , tmport); - tmport +=0x07 ; - -while ((inb (tmport) &0x80 ) ==0 ) { -if ((inb (tmport) &0x01 ) !=0 ) { - tmport -=0x06 ; +outb (0x06 , wkport +0x14 ); +outb (0x20 , wkport +0x18 ); + +while ((inb (wkport +0x1f ) &0x80 ) ==0 ) { +if ((inb (wkport +0x1f ) &0x01 ) !=0 ) {if ((m & dev->wide_id[c]) !=0 ) {if ((m & dev->ultra_map[c]) !=0 ) { -outb (synuw[j++], tmport); +outb (synuw[j++], wkport +0x19 ); }else { -outb (synw[j++], tmport); +outb (synw[j++], wkport +0x19 ); } }else {if ((m & dev->ultra_map[c]) !=0 ) { -outb (synu[j++], tmport); +outb (synu[j++], wkport +0x19 ); }else { -outb (synn[j++], tmport); +outb (synn[j++], wkport +0x19 ); } } - tmport +=0x06 ; } } - tmport -=0x08 ; -while ((inb (tmport) &0x80 ) ==0x00 ) +while ((inb (wkport +0x17 ) &0x80 ) ==0x00 )cpu_relax (); - j =inb (tmport) &0x0f ; + j =inb (wkport +0x17 ) &0x0f ;if (j ==0x0f ) { goto phase_ins; }
@@ -3421,19 +3315,13 @@ try_sync: }continue ; phase_outs: - tmport = wkport +0x18 ; -outb (0x20 , tmport); - tmport +=0x07 ; -while ((inb (tmport) &0x80 ) ==0x00 ) { -if ((inb (tmport) &0x01 ) !=0x00 ) { - tmport -=0x06 ; -outb (0x00 , tmport); - tmport +=0x06 ; - } +outb (0x20 , wkport +0x18 ); +while ((inb (wkport +0x1f ) &0x80 ) ==0x00 ) { +if ((inb (wkport +0x1f ) &0x01 ) !=0x00 ) +outb (0x00 , wkport +0x19 );cpu_relax (); } - tmport -=0x08 ; - j =inb (tmport); + j =inb (wkport +0x17 );if (j ==0x85 ) { goto tar_dcons; }
@@ -3449,26 +3337,20 @@ phase_outs: }continue ; phase_ins: - tmport = wkport +0x14 ; -outb (0x06 , tmport); - tmport +=0x04 ; -outb (0x20 , tmport); - tmport +=0x07 ; +outb (0x06 , wkport +0x14 ); +outb (0x20 , wkport +0x18 ); k =0 ; phase_ins1: - j =inb (tmport); + j =inb (wkport +0x1f );if ((j &0x01 ) !=0x00 ) { - tmport -=0x06 ; - mbuf[k++] =inb (tmport); - tmport +=0x06 ; + mbuf[k++] =inb (wkport +0x19 ); goto phase_ins1; }if ((j &0x80 ) ==0x00 ) { goto phase_ins1; } - tmport -=0x08 ; -while ((inb (tmport) &0x80 ) ==0x00 ); - j =inb (tmport); +while ((inb (wkport +0x17 ) &0x80 ) ==0x00 ); + j =inb (wkport +0x17 );if (j ==0x85 ) { goto tar_dcons; }
@@ -3484,18 +3366,13 @@ phase_ins1: }continue ; phase_cmds: - tmport = wkport +0x10 ; -outb (0x30 , tmport); +outb (0x30 , wkport +0x10 ); tar_dcons: - tmport = wkport +0x14 ; -outb (0x00 , tmport); - tmport +=0x04 ; -outb (0x08 , tmport); - tmport +=0x07 ; -while ((inb (tmport) &0x80 ) ==0x00 ) +outb (0x00 , wkport +0x14 ); +outb (0x08 , wkport +0x18 ); +while ((inb (wkport +0x1f ) &0x80 ) ==0x00 )cpu_relax (); - tmport -=0x08 ; - j =inb (tmport); + j =inb (wkport +0x17 );if (j !=0x16 ) {continue ; }
@@ -3542,8 +3419,7 @@ tar_dcons:printk ("dev->id[%2d][%2d].devsp = %2x\n" ,c,i,dev->id[c][i].devsp);#endif } - tmport = wkport +0x16 ; -outb (0x80 , tmport); +outb (0x80 , wkport +0x16 ); }module_init (atp870u_init);
Signature · 1 line
Ondrej Zary
PATCH 11/52 atp870u: Untangle tmpcip
In reply to Ondrej ZaryUntangle the tmpcip crap so it becomes obvious what ports are accessed.
--- drivers/scsi/atp870u.c | 64 +++++++++++++++++------------------------------- 1 file changed, 23 insertions(+), 41 deletions(-)
drivers/scsi/atp870u.c +23 -41
@@ -47,7 +47,7 @@ static void tscam_885(void);static irqreturn_t atp870u_intr_handle (int irq,void *dev_id) {unsigned long flags; -unsigned short int tmpcip, id; +unsigned short int id;unsigned char i, j, c, target_id, lun,cmdp;unsigned char *prd;struct scsi_cmnd *workreq;
@@ -79,30 +79,24 @@ ch_sel:if ((inb (dev->ioport[c] +0x16 ) &0x80 ) ==0 )outb ((inb (dev->ioport[c] +0x16 ) |0x80 ), dev->ioport[c] +0x16 ); } - tmpcip = dev->pciport[c]; -if ((inb (tmpcip) &0x08 ) !=0 ) +if ((inb (dev->pciport[c]) &0x08 ) !=0 ) { - tmpcip +=0x2 ;for (k=0 ; k <1000 ; k++) { -if ((inb (tmpcip) &0x08 ) ==0 ) { +if ((inb (dev->pciport[c] +2 ) &0x08 ) ==0 ) { goto stop_dma; } -if ((inb (tmpcip) &0x01 ) ==0 ) { +if ((inb (dev->pciport[c] +2 ) &0x01 ) ==0 ) { goto stop_dma; } } } stop_dma: - tmpcip = dev->pciport[c]; -outb (0x00 , tmpcip); +outb (0x00 , dev->pciport[c]); i =inb (dev->ioport[c] +0x17 ); -if (dev->dev_id ==ATP885_DEVID ) { - tmpcip +=2 ; -outb (0x06 , tmpcip); - tmpcip -=2 ; - } +if (dev->dev_id ==ATP885_DEVID ) +outb (0x06 , dev->pciport[c] +2 ); target_id =inb (dev->ioport[c] +0x15 );
@@ -303,13 +297,12 @@ stop_dma:/* enable 32 bit fifo transfer */ if (dev->dev_id ==ATP885_DEVID ) { - tmpcip = dev->pciport[c] +1 ; - i=inb (tmpcip) &0xf3 ; + i=inb (dev->pciport[c] +1 ) &0xf3 ;//j=workreq->cmnd[0]; if ((workreq->cmnd[0 ] ==0x08 ) || (workreq->cmnd[0 ] ==0x28 ) || (workreq->cmnd[0 ] ==0x0a ) || (workreq->cmnd[0 ] ==0x2a )) { i |=0x0c ; } -outb (i,tmpcip); +outb (i, dev->pciport[c] +1 ); }else if ((dev->dev_id ==ATP880_DEVID1 ) || (dev->dev_id ==ATP880_DEVID2 ) ) {if ((workreq->cmnd[0 ] ==0x08 ) || (workreq->cmnd[0 ] ==0x28 ) || (workreq->cmnd[0 ] ==0x0a ) || (workreq->cmnd[0 ] ==0x2a )) {
@@ -371,25 +364,20 @@ stop_dma: } } } - tmpcip = dev->pciport[c] +0x04 ; -outl (dev->id[c][target_id].prdaddr, tmpcip); +outl (dev->id[c][target_id].prdaddr, dev->pciport[c] +0x04 );#ifdef ED_DBGP printk ("dev->id[%d][%d].prdaddr 0x%8x\n" , c, target_id, dev->id[c][target_id].prdaddr);#endif -if (dev->dev_id ==ATP885_DEVID ) { - tmpcip -=0x04 ; - }else { - tmpcip -=0x02 ; -outb (0x06 , tmpcip); -outb (0x00 , tmpcip); - tmpcip -=0x02 ; +if (dev->dev_id !=ATP885_DEVID ) { +outb (0x06 , dev->pciport[c] +2 ); +outb (0x00 , dev->pciport[c] +2 ); }/* * Check transfer direction */ if (dev->id[c][target_id].dirct !=0 ) {outb (0x08 , dev->ioport[c] +0x18 ); -outb (0x01 , tmpcip); +outb (0x01 , dev->pciport[c]); dev->in_int[c] =0 ;#ifdef ED_DBGP printk ("status 0x80 return dirct != 0\n" );
@@ -397,7 +385,7 @@ stop_dma: goto handled; }outb (0x08 , dev->ioport[c] +0x18 ); -outb (0x09 , tmpcip); +outb (0x09 , dev->pciport[c]); dev->in_int[c] =0 ;#ifdef ED_DBGP printk ("status 0x80 return dirct = 0\n" );
@@ -484,12 +472,9 @@ go_42: } i &=0x0f ;if (i ==0x09 ) { - tmpcip +=4 ; -outl (dev->id[c][target_id].prdaddr, tmpcip); - tmpcip = tmpcip -2 ; -outb (0x06 , tmpcip); -outb (0x00 , tmpcip); - tmpcip = tmpcip -2 ; +outl (dev->id[c][target_id].prdaddr, dev->pciport[c] +4 ); +outb (0x06 , dev->pciport[c] +2 ); +outb (0x00 , dev->pciport[c] +2 );outb (0x41 , dev->ioport[c] +0x10 );if (dev->dev_id ==ATP885_DEVID ) { k = dev->id[c][target_id].last_len;
@@ -501,17 +486,14 @@ go_42: dev->id[c][target_id].dirct =0x00 ; }outb (0x08 , dev->ioport[c] +0x18 ); -outb (0x09 , tmpcip); +outb (0x09 , dev->pciport[c]); dev->in_int[c] =0 ; goto handled; }if (i ==0x08 ) { - tmpcip +=4 ; -outl (dev->id[c][target_id].prdaddr, tmpcip); - tmpcip = tmpcip -2 ; -outb (0x06 , tmpcip); -outb (0x00 , tmpcip); - tmpcip = tmpcip -2 ; +outl (dev->id[c][target_id].prdaddr, dev->pciport[c] +4 ); +outb (0x06 , dev->pciport[c] +2 ); +outb (0x00 , dev->pciport[c] +2 );outb (0x41 , dev->ioport[c] +0x10 );if (dev->dev_id ==ATP885_DEVID ) { k = dev->id[c][target_id].last_len;
@@ -522,7 +504,7 @@ go_42:outb ((unsigned char ) (inb (dev->ioport[c] +0x15 ) |0x20 ), dev->ioport[c] +0x15 ); dev->id[c][target_id].dirct =0x20 ;outb (0x08 , dev->ioport[c] +0x18 ); -outb (0x01 , tmpcip); +outb (0x01 , dev->pciport[c]); dev->in_int[c] =0 ; goto handled; }
Signature · 1 line
Ondrej Zary
PATCH 12/52 atp870u: Untangle tmpcip #2
In reply to Ondrej ZaryUntangle the tmpcip crap so it becomes obvious what ports are accessed.
--- drivers/scsi/atp870u.c | 25 +++++++++---------------- 1 file changed, 9 insertions(+), 16 deletions(-)
drivers/scsi/atp870u.c +9 -16
@@ -645,7 +645,7 @@ static void send_s870(struct atp_unit *dev,unsigned char c)unsigned int i;//,k; unsigned char j, target_id;unsigned char *prd; -unsigned short int tmpcip, w; +unsigned short int w;unsigned long l, bttl =0 ;unsigned long sg_count;
@@ -813,7 +813,6 @@ oktosend: dev->in_snd[c] =0 ;return ; } - tmpcip = dev->pciport[c]; prd = dev->id[c][target_id].prd_table; dev->id[c][target_id].prd_pos = prd;
@@ -850,34 +849,28 @@ oktosend:printk ("2. bttl %x, l %x\n" ,bttl, l);#endif } - tmpcip +=4 ;#ifdef ED_DBGP -printk ("send_s870: prdaddr_2 0x%8x tmpcip %x target_id %d\n" , dev->id[c][target_id].prdaddr,tmpcip,target_id); +printk ("send_s870: prdaddr_2 0x%8x target_id %d\n" , dev->id[c][target_id].prdaddr,target_id);#endif dev->id[c][target_id].prdaddr = dev->id[c][target_id].prd_bus; -outl (dev->id[c][target_id].prdaddr, tmpcip); - tmpcip = tmpcip -2 ; -outb (0x06 , tmpcip); -outb (0x00 , tmpcip); +outl (dev->id[c][target_id].prdaddr, dev->pciport[c] +4 ); +outb (0x06 , dev->pciport[c] +2 ); +outb (0x00 , dev->pciport[c] +2 );if (dev->dev_id ==ATP885_DEVID ) { - tmpcip--; - j=inb (tmpcip) &0xf3 ; + j =inb (dev->pciport[c] +1 ) &0xf3 ;if ((workreq->cmnd[0 ] ==0x08 ) || (workreq->cmnd[0 ] ==0x28 ) || (workreq->cmnd[0 ] ==0x0a ) || (workreq->cmnd[0 ] ==0x2a )) { j |=0x0c ; } -outb (j,tmpcip); - tmpcip--; +outb (j, dev->pciport[c] +1 ); }else if ((dev->dev_id ==ATP880_DEVID1 ) || (dev->dev_id ==ATP880_DEVID2 )) { - tmpcip =tmpcip -2 ;if ((workreq->cmnd[0 ] ==0x08 ) || (workreq->cmnd[0 ] ==0x28 ) || (workreq->cmnd[0 ] ==0x0a ) || (workreq->cmnd[0 ] ==0x2a )) {outb ((unsigned char ) ((inb (dev->ioport[c] -0x05 ) &0x3f ) |0xc0 ), dev->ioport[c] -0x05 ); }else {outb ((unsigned char ) (inb (dev->ioport[c] -0x05 ) &0x3f ), dev->ioport[c] -0x05 ); } }else { - tmpcip =tmpcip -2 ;if ((workreq->cmnd[0 ] ==0x08 ) || (workreq->cmnd[0 ] ==0x28 ) || (workreq->cmnd[0 ] ==0x0a ) || (workreq->cmnd[0 ] ==0x2a )) {outb ((inb (dev->ioport[c] +0x3a ) &0xf3 ) |0x08 , dev->ioport[c] +0x3a ); }else {
@@ -889,7 +882,7 @@ oktosend: dev->id[c][target_id].dirct =0x20 ;if (inb (dev->ioport[c] +0x1c ) ==0 ) {outb (0x08 , dev->ioport[c] +0x18 ); -outb (0x01 , tmpcip); +outb (0x01 , dev->pciport[c]);#ifdef ED_DBGP printk ("start DMA(to target)\n" );#endif
@@ -901,7 +894,7 @@ oktosend: }if (inb (dev->ioport[c] +0x1c ) ==0 ) {outb (0x08 , dev->ioport[c] +0x18 ); -outb (0x09 , tmpcip); +outb (0x09 , dev->pciport[c]);#ifdef ED_DBGP printk ("start DMA(to host)\n" );#endif
Signature · 1 line
Ondrej Zary
PATCH 13/52 atp870u: Remove ugly gotos
In reply to Ondrej Zary--- drivers/scsi/atp870u.c | 84 +++++++++++++++++------------------------------- 1 file changed, 30 insertions(+), 54 deletions(-)
drivers/scsi/atp870u.c +30 -54
@@ -55,20 +55,17 @@ static irqreturn_t atp870u_intr_handle(int irq, void *dev_id)#ifdef ED_DBGP unsigned long l;#endif -int errstus;struct Scsi_Host *host = dev_id;struct atp_unit *dev = (struct atp_unit *)&host->hostdata;for (c =0 ; c <2 ; c++) { j =inb (dev->ioport[c] +0x1f );if ((j &0x80 ) !=0 ) - { - goto ch_sel; - } +break ; dev->in_int[c] =0 ; } -return IRQ_NONE ; -ch_sel: +if ((j &0x80 ) ==0 ) +return IRQ_NONE ;#ifdef ED_DBGP printk ("atp870u_intr_handle enter\n" );#endif
@@ -82,15 +79,12 @@ ch_sel:if ((inb (dev->pciport[c]) &0x08 ) !=0 ) {for (k=0 ; k <1000 ; k++) { -if ((inb (dev->pciport[c] +2 ) &0x08 ) ==0 ) { - goto stop_dma; - } -if ((inb (dev->pciport[c] +2 ) &0x01 ) ==0 ) { - goto stop_dma; - } +if ((inb (dev->pciport[c] +2 ) &0x08 ) ==0 ) +break ; +if ((inb (dev->pciport[c] +2 ) &0x01 ) ==0 ) +break ; } } -stop_dma:outb (0x00 , dev->pciport[c]); i =inb (dev->ioport[c] +0x17 );
@@ -170,13 +164,13 @@ stop_dma:#ifdef ED_DBGP printk ("Status 0x85 return\n" );#endif - goto handled; +return IRQ_HANDLED ; }if (i ==0x40 ) { dev->last_cmd[c] |=0x40 ; dev->in_int[c] =0 ; - goto handled; +return IRQ_HANDLED ; }if (i ==0x21 ) {
@@ -194,7 +188,7 @@ stop_dma:outb (0x41 , dev->ioport[c] +0x10 );outb (0x08 , dev->ioport[c] +0x18 ); dev->in_int[c] =0 ; - goto handled; +return IRQ_HANDLED ; }if (dev->dev_id ==ATP885_DEVID ) {
@@ -231,7 +225,7 @@ stop_dma: dev->id[c][target_id].last_len = adrcnt;outb (0x08 , dev->ioport[c] +0x18 ); dev->in_int[c] =0 ; - goto handled; +return IRQ_HANDLED ; }else {#ifdef ED_DBGP printk ("cmdp != 0x41\n" );
@@ -243,7 +237,7 @@ stop_dma:outb (0x00 , dev->ioport[c] +0x14 );outb (0x08 , dev->ioport[c] +0x18 ); dev->in_int[c] =0 ; - goto handled; +return IRQ_HANDLED ; } }if (dev->last_cmd[c] !=0xff ) {
@@ -336,7 +330,7 @@ stop_dma:#ifdef ED_DBGP printk ("dev->id[c][target_id].last_len = 0\n" );#endif - goto handled; +return IRQ_HANDLED ; }#ifdef ED_DBGP printk ("target_id = %d adrcnt = %d\n" ,target_id,adrcnt);
@@ -382,7 +376,7 @@ stop_dma:#ifdef ED_DBGP printk ("status 0x80 return dirct != 0\n" );#endif - goto handled; +return IRQ_HANDLED ; }outb (0x08 , dev->ioport[c] +0x18 );outb (0x09 , dev->pciport[c]);
@@ -390,7 +384,7 @@ stop_dma:#ifdef ED_DBGP printk ("status 0x80 return dirct = 0\n" );#endif - goto handled; +return IRQ_HANDLED ; }/*
@@ -399,27 +393,19 @@ stop_dma: workreq = dev->id[c][target_id].curr_req; -if (i ==0x42 ) { -if ((dev->last_cmd[c] &0xf0 ) !=0x40 ) - { - dev->last_cmd[c] =0xff ; - } - errstus =0x02 ; - workreq->result = errstus; - goto go_42; - } -if (i ==0x16 ) { +if (i ==0x42 || i ==0x16 ) {if ((dev->last_cmd[c] &0xf0 ) !=0x40 ) { dev->last_cmd[c] =0xff ; } - errstus =0 ; - errstus =inb (dev->ioport[c] +0x0f ); -if (((dev->r1f[c][target_id] &0x10 ) !=0 )&&(dev->dev_id==ATP885_DEVID )) { -printk (KERN_WARNING "AEC67162 CRC ERROR !\n" ); - errstus =0x02 ; - } - workreq->result = errstus; -go_42: +if (i ==0x16 ) { + workreq->result =inb (dev->ioport[c] +0x0f ); +if (((dev->r1f[c][target_id] &0x10 ) !=0 )&&(dev->dev_id==ATP885_DEVID )) { +printk (KERN_WARNING "AEC67162 CRC ERROR !\n" ); + workreq->result =0x02 ; + } + }else + workreq->result =0x02 ; +if (dev->dev_id ==ATP885_DEVID ) { j =inb (dev->baseport +0x29 ) |0x01 ;outb (j, dev->baseport +0x29 );
@@ -462,7 +448,7 @@ go_42: }spin_unlock_irqrestore (dev->host->host_lock, flags); dev->in_int[c] =0 ; - goto handled; +return IRQ_HANDLED ; }if ((dev->last_cmd[c] &0xf0 ) !=0x40 ) { dev->last_cmd[c] =0xff ;
@@ -488,7 +474,7 @@ go_42:outb (0x08 , dev->ioport[c] +0x18 );outb (0x09 , dev->pciport[c]); dev->in_int[c] =0 ; - goto handled; +return IRQ_HANDLED ; }if (i ==0x08 ) {outl (dev->id[c][target_id].prdaddr, dev->pciport[c] +4 );
@@ -506,7 +492,7 @@ go_42:outb (0x08 , dev->ioport[c] +0x18 );outb (0x01 , dev->pciport[c]); dev->in_int[c] =0 ; - goto handled; +return IRQ_HANDLED ; }if (i ==0x0a ) {outb (0x30 , dev->ioport[c] +0x10 );
@@ -518,19 +504,9 @@ go_42:outb (0x00 , dev->ioport[c] +0x13 );outb (0x00 , dev->ioport[c] +0x14 );outb (0x08 , dev->ioport[c] +0x18 ); - dev->in_int[c] =0 ; - goto handled; - }else { -// inb(dev->ioport[c] + 0x17); -// dev->working[c] = 0; - dev->in_int[c] =0 ; - goto handled; } - -handled: -#ifdef ED_DBGP -printk ("atp870u_intr_handle exit\n" ); -#endif + dev->in_int[c] =0 ; +return IRQ_HANDLED ; }/**
Signature · 1 line
Ondrej Zary
PATCH 14/52 atp870u: Remove ugly gotos #2
In reply to Ondrej Zary--- drivers/scsi/atp870u.c | 68 +++++++++++++++++++++--------------------------- 1 file changed, 30 insertions(+), 38 deletions(-)
drivers/scsi/atp870u.c +30 -38
@@ -617,7 +617,7 @@ static DEF_SCSI_QCMD(atp870u_queuecommand)*/ static void send_s870 (struct atp_unit *dev,unsigned char c) { -struct scsi_cmnd *workreq; +struct scsi_cmnd *workreq =NULL ;unsigned int i;//,k; unsigned char j, target_id;unsigned char *prd;
@@ -638,50 +638,42 @@ static void send_s870(struct atp_unit *dev,unsigned char c)if ((dev->last_cmd[c] !=0xff ) && ((dev->last_cmd[c] &0x40 ) !=0 )) { dev->last_cmd[c] &=0x0f ; workreq = dev->id[c][dev->last_cmd[c]].curr_req; -if (workreq !=NULL ) {/* check NULL pointer */ - goto cmd_subp; - } - dev->last_cmd[c] =0xff ; -if (dev->quhd[c] == dev->quend[c]) { - dev->in_snd[c] =0 ; -return ; +if (!workreq) { + dev->last_cmd[c] =0xff ; +if (dev->quhd[c] == dev->quend[c]) { + dev->in_snd[c] =0 ; +return ; + } } } -if ((dev->last_cmd[c] !=0xff ) && (dev->working[c] !=0 )) { - dev->in_snd[c] =0 ; -return ; - } - dev->working[c]++; - j = dev->quhd[c]; - dev->quhd[c]++; -if (dev->quhd[c] >= qcnt) { - dev->quhd[c] =0 ; - } - workreq = dev->quereq[c][dev->quhd[c]]; -if (dev->id[c][scmd_id (workreq)].curr_req ==NULL ) { +if (!workreq) { +if ((dev->last_cmd[c] !=0xff ) && (dev->working[c] !=0 )) { + dev->in_snd[c] =0 ; +return ; + } + dev->working[c]++; + j = dev->quhd[c]; + dev->quhd[c]++; +if (dev->quhd[c] >= qcnt) + dev->quhd[c] =0 ; + workreq = dev->quereq[c][dev->quhd[c]]; +if (dev->id[c][scmd_id (workreq)].curr_req !=NULL ) { + dev->quhd[c] = j; + dev->working[c]--; + dev->in_snd[c] =0 ; +return ; + } dev->id[c][scmd_id (workreq)].curr_req = workreq; dev->last_cmd[c] =scmd_id (workreq); - goto cmd_subp; - } - dev->quhd[c] = j; - dev->working[c]--; - dev->in_snd[c] =0 ; -return ; -cmd_subp: -if ((inb (dev->ioport[c] +0x1f ) &0xb0 ) !=0 ) { - goto abortsnd; - } -if (inb (dev->ioport[c] +0x1c ) ==0 ) { - goto oktosend; } -abortsnd: +if ((inb (dev->ioport[c] +0x1f ) &0xb0 ) !=0 ||inb (dev->ioport[c] +0x1c ) !=0 ) {#ifdef ED_DBGP -printk ("Abort to Send\n" ); +printk ("Abort to Send\n" );#endif - dev->last_cmd[c] |=0x40 ; - dev->in_snd[c] =0 ; -return ; -oktosend: + dev->last_cmd[c] |=0x40 ; + dev->in_snd[c] =0 ; +return ; + }#ifdef ED_DBGP printk ("OK to Send\n" );scmd_printk (KERN_DEBUG , workreq,"CDB" );
Signature · 1 line
Ondrej Zary
PATCH 15/52 atp870u: Remove ugly gotos #3
In reply to Ondrej Zary--- drivers/scsi/atp870u.c | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-)
drivers/scsi/atp870u.c +6 -12
@@ -880,34 +880,28 @@ static unsigned char fun_scam(struct atp_unit *dev, unsigned short int *val)unsigned char j;outw (*val, dev->ioport[0 ] +0x1c ); -FUN_D7:for (i =0 ; i <10 ; i++) {/* stable >= bus settle delay(400 ns) */ k =inw (dev->ioport[0 ] +0x1c ); j = (unsigned char ) (k >>8 ); -if ((k &0x8000 ) !=0 ) {/* DB7 all release? */ - goto FUN_D7; - } +if ((k &0x8000 ) !=0 )/* DB7 all release? */ + i =0 ; } *val |=0x4000 ;/* assert DB6 */ outw (*val, dev->ioport[0 ] +0x1c ); *val &=0xdfff ;/* assert DB5 */ outw (*val, dev->ioport[0 ] +0x1c ); -FUN_D5:for (i =0 ; i <10 ; i++) {/* stable >= bus settle delay(400 ns) */ -if ((inw (dev->ioport[0 ] +0x1c ) &0x2000 ) !=0 ) {/* DB5 all release? */ - goto FUN_D5; - } +if ((inw (dev->ioport[0 ] +0x1c ) &0x2000 ) !=0 )/* DB5 all release? */ + i =0 ; } *val |=0x8000 ;/* no DB4-0, assert DB7 */ *val &=0xe0ff ;outw (*val, dev->ioport[0 ] +0x1c ); *val &=0xbfff ;/* release DB6 */ outw (*val, dev->ioport[0 ] +0x1c ); -FUN_D6:for (i =0 ; i <10 ; i++) {/* stable >= bus settle delay(400 ns) */ -if ((inw (dev->ioport[0 ] +0x1c ) &0x4000 ) !=0 ) {/* DB6 all release? */ - goto FUN_D6; - } +if ((inw (dev->ioport[0 ] +0x1c ) &0x4000 ) !=0 )/* DB6 all release? */ + i =0 ; }return j;
Signature · 1 line
Ondrej Zary
PATCH 16/52 atp870u: Remove ugly gotos #4
In reply to Ondrej Zary--- drivers/scsi/atp870u.c | 32 +++++++++++++++----------------- 1 file changed, 15 insertions(+), 17 deletions(-)
drivers/scsi/atp870u.c +15 -17
@@ -970,19 +970,19 @@ static void tscam(struct Scsi_Host *host) }else {outb (0x00 , dev->ioport[0 ] +0x1b ); } -wait_rdyok: -outb (0x09 , dev->ioport[0 ] +0x18 ); - -while ((inb (dev->ioport[0 ] +0x1f ) &0x80 ) ==0x00 ) -cpu_relax (); - k =inb (dev->ioport[0 ] +0x17 ); -if (k !=0x16 ) { -if ((k ==0x85 ) || (k ==0x42 )) { -continue ; - } -outb (0x41 , dev->ioport[0 ] +0x10 ); - goto wait_rdyok; - } +do { +outb (0x09 , dev->ioport[0 ] +0x18 ); + +while ((inb (dev->ioport[0 ] +0x1f ) &0x80 ) ==0x00 ) +cpu_relax (); + k =inb (dev->ioport[0 ] +0x17 ); +if ((k ==0x85 ) || (k ==0x42 )) +break ; +if (k !=0x16 ) +outb (0x41 , dev->ioport[0 ] +0x10 ); + }while (k !=0x16 ); +if ((k ==0x85 ) || (k ==0x42 )) +continue ; assignid_map |= m; }
@@ -1003,10 +1003,8 @@ wait_rdyok:mdelay (128 ); val &=0x00fb ;/* after 1ms no msg */ outw (val, dev->ioport[0 ] +0x1c ); -wait_nomsg: -if ((inb (dev->ioport[0 ] +0x1c ) &0x04 ) !=0 ) { - goto wait_nomsg; - } +while ((inb (dev->ioport[0 ] +0x1c ) &0x04 ) !=0 ) + ;outb (1 ,0x80 );udelay (100 );for (n =0 ; n <0x30000 ; n++) {
Signature · 1 line
Ondrej Zary
PATCH 17/52 atp870u: Remove ugly gotos #5
In reply to Ondrej Zary--- drivers/scsi/atp870u.c | 134 ++++++++++++++++++++++-------------------------- 1 file changed, 62 insertions(+), 72 deletions(-)
drivers/scsi/atp870u.c +62 -72
@@ -1007,28 +1007,22 @@ static void tscam(struct Scsi_Host *host) ;outb (1 ,0x80 );udelay (100 ); -for (n =0 ; n <0x30000 ; n++) { -if ((inb (dev->ioport[0 ] +0x1c ) &0x80 ) !=0 ) {/* bsy ? */ - goto wait_io; - } - } - goto TCM_SYNC; -wait_io: -for (n =0 ; n <0x30000 ; n++) { -if ((inb (dev->ioport[0 ] +0x1c ) &0x81 ) ==0x0081 ) { - goto wait_io1; - } - } - goto TCM_SYNC; -wait_io1: -inb (0x80 ); - val |=0x8003 ;/* io,cd,db7 */ -outw (val, dev->ioport[0 ] +0x1c ); -inb (0x80 ); - val &=0x00bf ;/* no sel */ -outw (val, dev->ioport[0 ] +0x1c ); -outb (2 ,0x80 ); -TCM_SYNC: +for (n =0 ; n <0x30000 ; n++) +if ((inb (dev->ioport[0 ] +0x1c ) &0x80 ) !=0 )/* bsy ? */ +break ; +if (n <0x30000 ) +for (n =0 ; n <0x30000 ; n++) +if ((inb (dev->ioport[0 ] +0x1c ) &0x81 ) ==0x0081 ) { +inb (0x80 ); + val |=0x8003 ;/* io,cd,db7 */ +outw (val, dev->ioport[0 ] +0x1c ); +inb (0x80 ); + val &=0x00bf ;/* no sel */ +outw (val, dev->ioport[0 ] +0x1c ); +outb (2 ,0x80 ); +break ; + } +while (1 ) {/* * The funny division into multiple delays is to accomodate * arches like ARM where udelay() multiplies its argument by
@@ -1059,31 +1053,28 @@ TCM_SYNC:outb (4 ,0x80 ); i =8 ; j =0 ; -TCM_ID: -if ((inw (dev->ioport[0 ] +0x1c ) &0x2000 ) ==0 ) { - goto TCM_ID; - } -outb (5 ,0x80 ); - val &=0x00ff ;/* get ID_STRING */ - val |=0x2000 ; - k =fun_scam (dev, &val); -if ((k &0x03 ) ==0 ) { - goto TCM_5; - } - mbuf[j] <<=0x01 ; - mbuf[j] &=0xfe ; -if ((k &0x02 ) !=0 ) { - mbuf[j] |=0x01 ; - } - i--; -if (i >0 ) { - goto TCM_ID; + +while (1 ) { +if ((inw (dev->ioport[0 ] +0x1c ) &0x2000 ) ==0 ) +continue ; +outb (5 ,0x80 ); + val &=0x00ff ;/* get ID_STRING */ + val |=0x2000 ; + k =fun_scam (dev, &val); +if ((k &0x03 ) ==0 ) +break ; + mbuf[j] <<=0x01 ; + mbuf[j] &=0xfe ; +if ((k &0x02 ) !=0 ) + mbuf[j] |=0x01 ; + i--; +if (i >0 ) +continue ; + j++; + i =8 ; } - j++; - i =8 ; - goto TCM_ID; -TCM_5:/* isolation complete.. */ +/* isolation complete.. */ /* mbuf[32]=0; printk(" \n%x %x %x %s\n ",assignid_map,mbuf[0],mbuf[1],&mbuf[2]); */ i =15 ;
@@ -1091,33 +1082,33 @@ TCM_5: /* isolation complete.. */if ((j &0x20 ) !=0 ) {/* bit5=1:ID up to 7 */ i =7 ; } -if ((j &0x06 ) ==0 ) {/* IDvalid? */ - goto G2Q5; - } - k = mbuf[1 ]; -small_id: - m =1 ; - m <<= k; -if ((m & assignid_map) ==0 ) { - goto G2Q_QUIN; - } -if (k >0 ) { - k--; - goto small_id; - } -G2Q5:/* srch from max acceptable ID# */ - k = i;/* max acceptable ID# */ -G2Q_LP: - m =1 ; - m <<= k; -if ((m & assignid_map) ==0 ) { - goto G2Q_QUIN; +if ((j &0x06 ) !=0 ) {/* IDvalid? */ + k = mbuf[1 ]; +while (1 ) { + m =1 ; + m <<= k; +if ((m & assignid_map) ==0 ) +break ; +if (k >0 ) + k--; +else +break ; + } } -if (k >0 ) { - k--; - goto G2Q_LP; +if ((m & assignid_map) !=0 ) {/* srch from max acceptable ID# */ + k = i;/* max acceptable ID# */ +while (1 ) { + m =1 ; + m <<= k; +if ((m & assignid_map) ==0 ) +break ; +if (k >0 ) + k--; +else +break ; + } } -G2Q_QUIN:/* k=binID#, */ +/* k=binID#, */ assignid_map |= m;if (k <8 ) { quintet[0 ] =0x38 ;/* 1st dft ID<8 */
@@ -1136,8 +1127,7 @@ G2Q_QUIN: /* k=binID#, */ val |= m;fun_scam (dev, &val); - goto TCM_SYNC; - + } }static void is870 (struct atp_unit *dev,unsigned int wkport)
Signature · 1 line
Ondrej Zary
PATCH 18/52 atp870u: Introduce HW access wrappers
In reply to Ondrej ZaryIntroduce *_read? and *_write? wrappers to improve code readability. Also make sure that baseport is always initialized, not only for ATP880.
--- drivers/scsi/atp870u.c | 472 ++++++++++++++++++++++++++---------------------- 1 file changed, 252 insertions(+), 220 deletions(-)
drivers/scsi/atp870u.c +252 -220
@@ -44,6 +44,51 @@ static void send_s870(struct atp_unit *dev,unsigned char c);static void is885 (struct atp_unit *dev,unsigned int wkport,unsigned char c);static void tscam_885 (void ); +static inline void atp_writeb_base (struct atp_unit *atp,u8 reg,u8 val) +{ +outb (val, atp->baseport + reg); +} + +static inline void atp_writeb_io (struct atp_unit *atp,u8 channel,u8 reg,u8 val) +{ +outb (val, atp->ioport[channel] + reg); +} + +static inline void atp_writew_io (struct atp_unit *atp,u8 channel,u8 reg,u16 val) +{ +outw (val, atp->ioport[channel] + reg); +} + +static inline void atp_writeb_pci (struct atp_unit *atp,u8 channel,u8 reg,u8 val) +{ +outb (val, atp->pciport[channel] + reg); +} + +static inline void atp_writel_pci (struct atp_unit *atp,u8 channel,u8 reg,u32 val) +{ +outl (val, atp->pciport[channel] + reg); +} + +static inline u8 atp_readb_base (struct atp_unit *atp,u8 reg) +{ +return inb (atp->baseport + reg); +} + +static inline u8 atp_readb_io (struct atp_unit *atp,u8 channel,u8 reg) +{ +return inb (atp->ioport[channel] + reg); +} + +static inline u16 atp_readw_io (struct atp_unit *atp,u8 channel,u8 reg) +{ +return inw (atp->ioport[channel] + reg); +} + +static inline u8 atp_readb_pci (struct atp_unit *atp,u8 channel,u8 reg) +{ +return inb (atp->pciport[channel] + reg); +} +static irqreturn_t atp870u_intr_handle (int irq,void *dev_id) {unsigned long flags;
@@ -59,7 +104,7 @@ static irqreturn_t atp870u_intr_handle(int irq, void *dev_id)struct atp_unit *dev = (struct atp_unit *)&host->hostdata;for (c =0 ; c <2 ; c++) { - j =inb (dev->ioport[c] +0x1f ); + j =atp_readb_io (dev, c,0x1f );if ((j &0x80 ) !=0 )break ; dev->in_int[c] =0 ;
@@ -70,29 +115,29 @@ static irqreturn_t atp870u_intr_handle(int irq, void *dev_id)printk ("atp870u_intr_handle enter\n" );#endif dev->in_int[c] =1 ; - cmdp =inb (dev->ioport[c] +0x10 ); + cmdp =atp_readb_io (dev, c,0x10 );if (dev->working[c] !=0 ) {if (dev->dev_id ==ATP885_DEVID ) { -if ((inb (dev->ioport[c] +0x16 ) &0x80 ) ==0 ) -outb ((inb (dev->ioport[c] +0x16 ) |0x80 ), dev->ioport[c] +0x16 ); +if ((atp_readb_io (dev, c,0x16 ) &0x80 ) ==0 ) +atp_writeb_io (dev, c,0x16 , (atp_readb_io (dev, c,0x16 ) |0x80 )); } -if ((inb (dev->pciport[c]) &0x08 ) !=0 ) +if ((atp_readb_pci (dev, c,0x00 ) &0x08 ) !=0 ) {for (k=0 ; k <1000 ; k++) { -if ((inb (dev->pciport[c] +2 ) &0x08 ) ==0 ) +if ((atp_readb_pci (dev, c,2 ) &0x08 ) ==0 )break ; -if ((inb (dev->pciport[c] +2 ) &0x01 ) ==0 ) +if ((atp_readb_pci (dev, c,2 ) &0x01 ) ==0 )break ; } } -outb (0x00 , dev->pciport[c]); +atp_writeb_pci (dev, c,0 ,0x00 ); - i =inb (dev->ioport[c] +0x17 ); + i =atp_readb_io (dev, c,0x17 );if (dev->dev_id ==ATP885_DEVID ) -outb (0x06 , dev->pciport[c] +2 ); +atp_writeb_pci (dev, c,2 ,0x06 ); - target_id =inb (dev->ioport[c] +0x15 ); + target_id =atp_readb_io (dev, c,0x15 );/* * Remap wide devices onto id numbers
@@ -121,9 +166,9 @@ static irqreturn_t atp870u_intr_handle(int irq, void *dev_id) }if (dev->dev_id ==ATP885_DEVID ) { adrcnt =0 ; - ((unsigned char *) &adrcnt)[2 ] =inb (dev->ioport[c] +0x12 ); - ((unsigned char *) &adrcnt)[1 ] =inb (dev->ioport[c] +0x13 ); - ((unsigned char *) &adrcnt)[0 ] =inb (dev->ioport[c] +0x14 ); + ((unsigned char *) &adrcnt)[2 ] =atp_readb_io (dev, c,0x12 ); + ((unsigned char *) &adrcnt)[1 ] =atp_readb_io (dev, c,0x13 ); + ((unsigned char *) &adrcnt)[0 ] =atp_readb_io (dev, c,0x14 );if (dev->id[c][target_id].last_len != adrcnt) { k = dev->id[c][target_id].last_len;
@@ -140,10 +185,9 @@ static irqreturn_t atp870u_intr_handle(int irq, void *dev_id)* Flip wide */ if (dev->wide_id[c] !=0 ) { -outb (0x01 , dev->ioport[c] +0x1b ); -while ((inb (dev->ioport[c] +0x1b ) &0x01 ) !=0x01 ) { -outb (0x01 , dev->ioport[c] +0x1b ); - } +atp_writeb_io (dev, c,0x1b ,0x01 ); +while ((atp_readb_io (dev, c,0x1b ) &0x01 ) !=0x01 ) +atp_writeb_io (dev, c,0x1b ,0x01 ); }/* * Issue more commands
@@ -178,15 +222,15 @@ static irqreturn_t atp870u_intr_handle(int irq, void *dev_id) dev->last_cmd[c] =0xff ; } adrcnt =0 ; - ((unsigned char *) &adrcnt)[2 ] =inb (dev->ioport[c] +0x12 ); - ((unsigned char *) &adrcnt)[1 ] =inb (dev->ioport[c] +0x13 ); - ((unsigned char *) &adrcnt)[0 ] =inb (dev->ioport[c] +0x14 ); + ((unsigned char *) &adrcnt)[2 ] =atp_readb_io (dev, c,0x12 ); + ((unsigned char *) &adrcnt)[1 ] =atp_readb_io (dev, c,0x13 ); + ((unsigned char *) &adrcnt)[0 ] =atp_readb_io (dev, c,0x14 ); k = dev->id[c][target_id].last_len; k -= adrcnt; dev->id[c][target_id].tran_len = k; dev->id[c][target_id].last_len = adrcnt; -outb (0x41 , dev->ioport[c] +0x10 ); -outb (0x08 , dev->ioport[c] +0x18 ); +atp_writeb_io (dev, c,0x10 ,0x41 ); +atp_writeb_io (dev, c,0x18 ,0x08 ); dev->in_int[c] =0 ;return IRQ_HANDLED ; }
@@ -205,9 +249,9 @@ static irqreturn_t atp870u_intr_handle(int irq, void *dev_id)printk (KERN_DEBUG "Device reselect\n" );#endif lun =0 ; -if (cmdp ==0x44 || i==0x80 ) { - lun =inb (dev->ioport[c] +0x1d ) &0x07 ; - }else { +if (cmdp ==0x44 || i ==0x80 ) + lun =atp_readb_io (dev, c,0x1d ) &0x07 ; +else {if ((dev->last_cmd[c] &0xf0 ) !=0x40 ) { dev->last_cmd[c] =0xff ; }
@@ -216,26 +260,26 @@ static irqreturn_t atp870u_intr_handle(int irq, void *dev_id)printk ("cmdp = 0x41\n" );#endif adrcnt =0 ; - ((unsigned char *) &adrcnt)[2 ] =inb (dev->ioport[c] +0x12 ); - ((unsigned char *) &adrcnt)[1 ] =inb (dev->ioport[c] +0x13 ); - ((unsigned char *) &adrcnt)[0 ] =inb (dev->ioport[c] +0x14 ); + ((unsigned char *) &adrcnt)[2 ] =atp_readb_io (dev, c,0x12 ); + ((unsigned char *) &adrcnt)[1 ] =atp_readb_io (dev, c,0x13 ); + ((unsigned char *) &adrcnt)[0 ] =atp_readb_io (dev, c,0x14 ); k = dev->id[c][target_id].last_len; k -= adrcnt; dev->id[c][target_id].tran_len = k; dev->id[c][target_id].last_len = adrcnt; -outb (0x08 , dev->ioport[c] +0x18 ); +atp_writeb_io (dev, c,0x18 ,0x08 ); dev->in_int[c] =0 ;return IRQ_HANDLED ; }else {#ifdef ED_DBGP printk ("cmdp != 0x41\n" );#endif -outb (0x46 , dev->ioport[c] +0x10 ); +atp_writeb_io (dev, c,0x10 ,0x46 ); dev->id[c][target_id].dirct =0x00 ; -outb (0x00 , dev->ioport[c] +0x12 ); -outb (0x00 , dev->ioport[c] +0x13 ); -outb (0x00 , dev->ioport[c] +0x14 ); -outb (0x08 , dev->ioport[c] +0x18 ); +atp_writeb_io (dev, c,0x12 ,0x00 ); +atp_writeb_io (dev, c,0x13 ,0x00 ); +atp_writeb_io (dev, c,0x14 ,0x00 ); +atp_writeb_io (dev, c,0x18 ,0x08 ); dev->in_int[c] =0 ;return IRQ_HANDLED ; }
@@ -244,12 +288,12 @@ static irqreturn_t atp870u_intr_handle(int irq, void *dev_id) dev->last_cmd[c] |=0x40 ; }if (dev->dev_id ==ATP885_DEVID ) { - j =inb (dev->baseport +0x29 ) &0xfe ; -outb (j, dev->baseport +0x29 ); + j =atp_readb_base (dev,0x29 ) &0xfe ; +atp_writeb_base (dev,0x29 , j); }else -outb (0x45 , dev->ioport[c] +0x10 ); +atp_writeb_io (dev, c,0x10 ,0x45 ); - target_id =inb (dev->ioport[c] +0x16 ); + target_id =atp_readb_io (dev, c,0x16 );/* * Remap wide identifiers */
@@ -259,7 +303,7 @@ static irqreturn_t atp870u_intr_handle(int irq, void *dev_id) target_id &=0x07 ; }if (dev->dev_id ==ATP885_DEVID ) -outb (0x45 , dev->ioport[c] +0x10 ); +atp_writeb_io (dev, c,0x10 ,0x45 ); workreq = dev->id[c][target_id].curr_req;#ifdef ED_DBGP scmd_printk (KERN_DEBUG , workreq,"CDB" );
@@ -268,16 +312,16 @@ static irqreturn_t atp870u_intr_handle(int irq, void *dev_id)printk ("\n" );#endif -outb (lun, dev->ioport[c] +0x0f ); -outb (dev->id[c][target_id].devsp, dev->ioport[c] +0x11 ); +atp_writeb_io (dev, c,0x0f , lun); +atp_writeb_io (dev, c,0x11 , dev->id[c][target_id].devsp); adrcnt = dev->id[c][target_id].tran_len; k = dev->id[c][target_id].last_len; -outb (((unsigned char *) &k)[2 ], dev->ioport[c] +0x12 ); -outb (((unsigned char *) &k)[1 ], dev->ioport[c] +0x13 ); -outb (((unsigned char *) &k)[0 ], dev->ioport[c] +0x14 ); +atp_writeb_io (dev, c,0x12 , ((unsigned char *) &k)[2 ]); +atp_writeb_io (dev, c,0x13 , ((unsigned char *) &k)[1 ]); +atp_writeb_io (dev, c,0x14 , ((unsigned char *) &k)[0 ]);#ifdef ED_DBGP -printk ("k %x, k[0] 0x%x k[1] 0x%x k[2] 0x%x\n" , k,inb (dev->ioport[c] +0x14 ),inb (dev->ioport[c] +0x13 ),inb (dev->ioport[c] +0x12 )); +printk ("k %x, k[0] 0x%x k[1] 0x%x k[2] 0x%x\n" , k,atp_readb_io (dev, c,0x14 ),atp_readb_io (dev, c,0x13 ),atp_readb_io (dev, c,0x12 ));#endif /* Remap wide */ j = target_id;
@@ -286,30 +330,28 @@ static irqreturn_t atp870u_intr_handle(int irq, void *dev_id) }/* Add direction */ j |= dev->id[c][target_id].dirct; -outb (j, dev->ioport[c] +0x15 ); -outb (0x80 , dev->ioport[c] +0x16 ); +atp_writeb_io (dev, c,0x15 , j); +atp_writeb_io (dev, c,0x16 ,0x80 );/* enable 32 bit fifo transfer */ if (dev->dev_id ==ATP885_DEVID ) { - i=inb (dev->pciport[c] +1 ) &0xf3 ; + i =atp_readb_pci (dev, c,1 ) &0xf3 ;//j=workreq->cmnd[0]; if ((workreq->cmnd[0 ] ==0x08 ) || (workreq->cmnd[0 ] ==0x28 ) || (workreq->cmnd[0 ] ==0x0a ) || (workreq->cmnd[0 ] ==0x2a )) { i |=0x0c ; } -outb (i, dev->pciport[c] +1 ); +atp_writeb_pci (dev, c,1 , i); }else if ((dev->dev_id ==ATP880_DEVID1 ) || (dev->dev_id ==ATP880_DEVID2 ) ) { -if ((workreq->cmnd[0 ] ==0x08 ) || (workreq->cmnd[0 ] ==0x28 ) || (workreq->cmnd[0 ] ==0x0a ) || (workreq->cmnd[0 ] ==0x2a )) { -outb ((unsigned char ) ((inb (dev->ioport[c] -0x05 ) &0x3f ) |0xc0 ), dev->ioport[c] -0x05 );///minus 0x05??? - }else { -outb ((unsigned char ) (inb (dev->ioport[c] -0x05 ) &0x3f ), dev->ioport[c] -0x05 );///minus 0x05??? - } +if ((workreq->cmnd[0 ] ==0x08 ) || (workreq->cmnd[0 ] ==0x28 ) || (workreq->cmnd[0 ] ==0x0a ) || (workreq->cmnd[0 ] ==0x2a )) +atp_writeb_base (dev,0x3b , (atp_readb_base (dev,0x3b ) &0x3f ) |0xc0 ); +else +atp_writeb_base (dev,0x3b ,atp_readb_base (dev,0x3b ) &0x3f ); }else { -if ((workreq->cmnd[0 ] ==0x08 ) || (workreq->cmnd[0 ] ==0x28 ) || (workreq->cmnd[0 ] ==0x0a ) || (workreq->cmnd[0 ] ==0x2a )) { -outb ((unsigned char ) ((inb (dev->ioport[c] +0x3a ) &0xf3 ) |0x08 ), dev->ioport[c] +0x3a ); - }else { -outb ((unsigned char ) (inb (dev->ioport[c] +0x3a ) &0xf3 ), dev->ioport[c] +0x3a ); - } +if ((workreq->cmnd[0 ] ==0x08 ) || (workreq->cmnd[0 ] ==0x28 ) || (workreq->cmnd[0 ] ==0x0a ) || (workreq->cmnd[0 ] ==0x2a )) +atp_writeb_io (dev, c,0x3a , (atp_readb_io (dev, c,0x3a ) &0xf3 ) |0x08 ); +else +atp_writeb_io (dev, c,0x3a ,atp_readb_io (dev, c,0x3a ) &0xf3 ); } j =0 ; id =1 ;
@@ -320,12 +362,11 @@ static irqreturn_t atp870u_intr_handle(int irq, void *dev_id)if ((id & dev->wide_id[c]) !=0 ) { j |=0x01 ; } -outb (j, dev->ioport[c] +0x1b ); -while ((inb (dev->ioport[c] +0x1b ) &0x01 ) != j) { -outb (j,dev->ioport[c] +0x1b ); - } +atp_writeb_io (dev, c,0x1b , j); +while ((atp_readb_io (dev, c,0x1b ) &0x01 ) != j) +atp_writeb_io (dev, c,0x1b , j);if (dev->id[c][target_id].last_len ==0 ) { -outb (0x08 , dev->ioport[c] +0x18 ); +atp_writeb_io (dev, c,0x18 ,0x08 ); dev->in_int[c] =0 ;#ifdef ED_DBGP printk ("dev->id[c][target_id].last_len = 0\n" );
@@ -358,28 +399,28 @@ static irqreturn_t atp870u_intr_handle(int irq, void *dev_id) } } } -outl (dev->id[c][target_id].prdaddr, dev->pciport[c] +0x04 ); +atp_writel_pci (dev, c,0x04 , dev->id[c][target_id].prdaddr);#ifdef ED_DBGP printk ("dev->id[%d][%d].prdaddr 0x%8x\n" , c, target_id, dev->id[c][target_id].prdaddr);#endif if (dev->dev_id !=ATP885_DEVID ) { -outb (0x06 , dev->pciport[c] +2 ); -outb (0x00 , dev->pciport[c] +2 ); +atp_writeb_pci (dev, c,2 ,0x06 ); +atp_writeb_pci (dev, c,2 ,0x00 ); }/* * Check transfer direction */ if (dev->id[c][target_id].dirct !=0 ) { -outb (0x08 , dev->ioport[c] +0x18 ); -outb (0x01 , dev->pciport[c]); +atp_writeb_io (dev, c,0x18 ,0x08 ); +atp_writeb_pci (dev, c,0 ,0x01 ); dev->in_int[c] =0 ;#ifdef ED_DBGP printk ("status 0x80 return dirct != 0\n" );#endif return IRQ_HANDLED ; } -outb (0x08 , dev->ioport[c] +0x18 ); -outb (0x09 , dev->pciport[c]); +atp_writeb_io (dev, c,0x18 ,0x08 ); +atp_writeb_pci (dev, c,0 ,0x09 ); dev->in_int[c] =0 ;#ifdef ED_DBGP printk ("status 0x80 return dirct = 0\n" );
@@ -398,7 +439,7 @@ static irqreturn_t atp870u_intr_handle(int irq, void *dev_id) dev->last_cmd[c] =0xff ; }if (i ==0x16 ) { - workreq->result =inb (dev->ioport[c] +0x0f ); + workreq->result =atp_readb_io (dev, c,0x0f );if (((dev->r1f[c][target_id] &0x10 ) !=0 )&&(dev->dev_id==ATP885_DEVID )) {printk (KERN_WARNING "AEC67162 CRC ERROR !\n" ); workreq->result =0x02 ;
@@ -407,8 +448,8 @@ static irqreturn_t atp870u_intr_handle(int irq, void *dev_id) workreq->result =0x02 ;if (dev->dev_id ==ATP885_DEVID ) { - j =inb (dev->baseport +0x29 ) |0x01 ; -outb (j, dev->baseport +0x29 ); + j =atp_readb_base (dev,0x29 ) |0x01 ; +atp_writeb_base (dev,0x29 , j); }/* * Complete the command
@@ -430,10 +471,9 @@ static irqreturn_t atp870u_intr_handle(int irq, void *dev_id)* Take it back wide */ if (dev->wide_id[c] !=0 ) { -outb (0x01 , dev->ioport[c] +0x1b ); -while ((inb (dev->ioport[c] +0x1b ) &0x01 ) !=0x01 ) { -outb (0x01 , dev->ioport[c] +0x1b ); - } +atp_writeb_io (dev, c,0x1b ,0x01 ); +while ((atp_readb_io (dev, c,0x1b ) &0x01 ) !=0x01 ) +atp_writeb_io (dev, c,0x1b ,0x01 ); }/* * If there is stuff to send and nothing going then send it
@@ -458,52 +498,51 @@ static irqreturn_t atp870u_intr_handle(int irq, void *dev_id) } i &=0x0f ;if (i ==0x09 ) { -outl (dev->id[c][target_id].prdaddr, dev->pciport[c] +4 ); -outb (0x06 , dev->pciport[c] +2 ); -outb (0x00 , dev->pciport[c] +2 ); -outb (0x41 , dev->ioport[c] +0x10 ); +atp_writel_pci (dev, c,4 , dev->id[c][target_id].prdaddr); +atp_writeb_pci (dev, c,2 ,0x06 ); +atp_writeb_pci (dev, c,2 ,0x00 ); +atp_writeb_io (dev, c,0x10 ,0x41 );if (dev->dev_id ==ATP885_DEVID ) { k = dev->id[c][target_id].last_len; -outb ((unsigned char ) (((unsigned char *) (&k))[2 ]), dev->ioport[c] +0x12 ); -outb ((unsigned char ) (((unsigned char *) (&k))[1 ]), dev->ioport[c] +0x13 ); -outb ((unsigned char ) (((unsigned char *) (&k))[0 ]), dev->ioport[c] +0x14 ); +atp_writeb_io (dev, c,0x12 , ((unsigned char *) (&k))[2 ]); +atp_writeb_io (dev, c,0x13 , ((unsigned char *) (&k))[1 ]); +atp_writeb_io (dev, c,0x14 , ((unsigned char *) (&k))[0 ]); dev->id[c][target_id].dirct =0x00 ; }else { dev->id[c][target_id].dirct =0x00 ; } -outb (0x08 , dev->ioport[c] +0x18 ); -outb (0x09 , dev->pciport[c]); +atp_writeb_io (dev, c,0x18 ,0x08 ); +atp_writeb_pci (dev, c,0 ,0x09 ); dev->in_int[c] =0 ;return IRQ_HANDLED ; }if (i ==0x08 ) { -outl (dev->id[c][target_id].prdaddr, dev->pciport[c] +4 ); -outb (0x06 , dev->pciport[c] +2 ); -outb (0x00 , dev->pciport[c] +2 ); -outb (0x41 , dev->ioport[c] +0x10 ); +atp_writel_pci (dev, c,4 , dev->id[c][target_id].prdaddr); +atp_writeb_pci (dev, c,2 ,0x06 ); +atp_writeb_pci (dev, c,2 ,0x00 ); +atp_writeb_io (dev, c,0x10 ,0x41 );if (dev->dev_id ==ATP885_DEVID ) { k = dev->id[c][target_id].last_len; -outb ((unsigned char ) (((unsigned char *) (&k))[2 ]), dev->ioport[c] +0x12 ); -outb ((unsigned char ) (((unsigned char *) (&k))[1 ]), dev->ioport[c] +0x13 ); -outb ((unsigned char ) (((unsigned char *) (&k))[0 ]), dev->ioport[c] +0x14 ); +atp_writeb_io (dev, c,0x12 , ((unsigned char *) (&k))[2 ]); +atp_writeb_io (dev, c,0x13 , ((unsigned char *) (&k))[1 ]); +atp_writeb_io (dev, c,0x14 , ((unsigned char *) (&k))[0 ]); } -outb ((unsigned char ) (inb (dev->ioport[c] +0x15 ) |0x20 ), dev->ioport[c] +0x15 ); +atp_writeb_io (dev, c,0x15 ,atp_readb_io (dev, c,0x15 ) |0x20 ); dev->id[c][target_id].dirct =0x20 ; -outb (0x08 , dev->ioport[c] +0x18 ); -outb (0x01 , dev->pciport[c]); +atp_writeb_io (dev, c,0x18 ,0x08 ); +atp_writeb_pci (dev, c,0 ,0x01 ); dev->in_int[c] =0 ;return IRQ_HANDLED ; } -if (i ==0x0a ) { -outb (0x30 , dev->ioport[c] +0x10 ); - }else { -outb (0x46 , dev->ioport[c] +0x10 ); - } +if (i ==0x0a ) +atp_writeb_io (dev, c,0x10 ,0x30 ); +else +atp_writeb_io (dev, c,0x10 ,0x46 ); dev->id[c][target_id].dirct =0x00 ; -outb (0x00 , dev->ioport[c] +0x12 ); -outb (0x00 , dev->ioport[c] +0x13 ); -outb (0x00 , dev->ioport[c] +0x14 ); -outb (0x08 , dev->ioport[c] +0x18 ); +atp_writeb_io (dev, c,0x12 ,0x00 ); +atp_writeb_io (dev, c,0x13 ,0x00 ); +atp_writeb_io (dev, c,0x14 ,0x00 ); +atp_writeb_io (dev, c,0x18 ,0x08 ); } dev->in_int[c] =0 ;
@@ -590,9 +629,9 @@ static int atp870u_queuecommand_lck(struct scsi_cmnd *req_p, } dev->quereq[c][dev->quend[c]] = req_p;#ifdef ED_DBGP -printk ("dev->ioport[c] = %x inb(dev->ioport[c] + 0x1c) = %x dev->in_int[%d] = %d dev->in_snd[%d] = %d\n" ,dev->ioport[c],inb (dev->ioport[c] +0x1c ),c,dev->in_int[c],c,dev->in_snd[c]); +printk ("dev->ioport[c] = %x atp_readb_io(dev, c, 0x1c) = %x dev->in_int[%d] = %d dev->in_snd[%d] = %d\n" ,dev->ioport[c],atp_readb_io (dev, c,0x1c ),c,dev->in_int[c],c,dev->in_snd[c]);#endif -if ((inb (dev->ioport[c] +0x1c ) ==0 ) && (dev->in_int[c] ==0 ) && (dev->in_snd[c] ==0 )) { +if ((atp_readb_io (dev, c,0x1c ) ==0 ) && (dev->in_int[c] ==0 ) && (dev->in_snd[c] ==0 )) {#ifdef ED_DBGP printk ("Call sent_s870(atp870u_queuecommand)\n" );#endif
@@ -666,7 +705,7 @@ static void send_s870(struct atp_unit *dev,unsigned char c) dev->id[c][scmd_id (workreq)].curr_req = workreq; dev->last_cmd[c] =scmd_id (workreq); } -if ((inb (dev->ioport[c] +0x1f ) &0xb0 ) !=0 ||inb (dev->ioport[c] +0x1c ) !=0 ) { +if ((atp_readb_io (dev, c,0x1f ) &0xb0 ) !=0 ||atp_readb_io (dev, c,0x1c ) !=0 ) {#ifdef ED_DBGP printk ("Abort to Send\n" );#endif
@@ -685,8 +724,8 @@ static void send_s870(struct atp_unit *dev,unsigned char c) l =scsi_bufflen (workreq);if (dev->dev_id ==ATP885_DEVID ) { - j =inb (dev->baseport +0x29 ) &0xfe ; -outb (j, dev->baseport +0x29 ); + j =atp_readb_base (dev,0x29 ) &0xfe ; +atp_writeb_base (dev,0x29 , j); dev->r1f[c][scmd_id (workreq)] =0 ; }
@@ -709,9 +748,9 @@ static void send_s870(struct atp_unit *dev,unsigned char c)if ((w & dev->wide_id[c]) !=0 ) { j |=0x01 ; } -outb (j, dev->ioport[c] +0x1b ); -while ((inb (dev->ioport[c] +0x1b ) &0x01 ) != j) { -outb (j,dev->ioport[c] +0x1b ); +atp_writeb_io (dev, c,0x1b , j); +while ((atp_readb_io (dev, c,0x1b ) &0x01 ) != j) { +atp_writeb_pci (dev, c,0x1b , j);#ifdef ED_DBGP printk ("send_s870 while loop 1\n" );#endif
@@ -720,21 +759,19 @@ static void send_s870(struct atp_unit *dev,unsigned char c)* Write the command */ -outb (workreq->cmd_len, dev->ioport[c] +0x00 ); -outb (0x2c , dev->ioport[c] +0x01 ); -if (dev->dev_id ==ATP885_DEVID ) { -outb (0x7f , dev->ioport[c] +0x02 ); - }else { -outb (0xcf , dev->ioport[c] +0x02 ); - } -for (i =0 ; i < workreq->cmd_len; i++) { -outb (workreq->cmnd[i], dev->ioport[c] +0x03 + i); - } -outb (workreq->device->lun, dev->ioport[c] +0x0f ); +atp_writeb_io (dev, c,0x00 , workreq->cmd_len); +atp_writeb_io (dev, c,0x01 ,0x2c ); +if (dev->dev_id ==ATP885_DEVID ) +atp_writeb_io (dev, c,0x02 ,0x7f ); +else +atp_writeb_io (dev, c,0x02 ,0xcf ); +for (i =0 ; i < workreq->cmd_len; i++) +atp_writeb_io (dev, c,0x03 + i, workreq->cmnd[i]); +atp_writeb_io (dev, c,0x0f , workreq->device->lun);/* * Write the target */ -outb (dev->id[c][target_id].devsp, dev->ioport[c] +0x11 ); +atp_writeb_io (dev, c,0x11 , dev->id[c][target_id].devsp);#ifdef ED_DBGP printk ("dev->id[%d][%d].devsp = %2x\n" ,c,target_id,dev->id[c][target_id].devsp);#endif
@@ -743,9 +780,9 @@ static void send_s870(struct atp_unit *dev,unsigned char c)/* * Write transfer size */ -outb ((unsigned char ) (((unsigned char *) (&l))[2 ]), dev->ioport[c] +0x12 ); -outb ((unsigned char ) (((unsigned char *) (&l))[1 ]), dev->ioport[c] +0x13 ); -outb ((unsigned char ) (((unsigned char *) (&l))[0 ]), dev->ioport[c] +0x14 ); +atp_writeb_io (dev, c,0x12 , ((unsigned char *) (&l))[2 ]); +atp_writeb_io (dev, c,0x13 , ((unsigned char *) (&l))[1 ]); +atp_writeb_io (dev, c,0x14 , ((unsigned char *) (&l))[0 ]); j = target_id; dev->id[c][j].last_len = l; dev->id[c][j].tran_len =0 ;
@@ -761,23 +798,21 @@ static void send_s870(struct atp_unit *dev,unsigned char c)/* * Check transfer direction */ -if (workreq->sc_data_direction ==DMA_TO_DEVICE ) { -outb ((unsigned char ) (j |0x20 ), dev->ioport[c] +0x15 ); - }else { -outb (j, dev->ioport[c] +0x15 ); - } -outb ((unsigned char ) (inb (dev->ioport[c] +0x16 ) |0x80 ), dev->ioport[c] +0x16 ); -outb (0x80 , dev->ioport[c] +0x16 ); +if (workreq->sc_data_direction ==DMA_TO_DEVICE ) +atp_writeb_io (dev, c,0x15 , j |0x20 ); +else +atp_writeb_io (dev, c,0x15 , j); +atp_writeb_io (dev, c,0x16 ,atp_readb_io (dev, c,0x16 ) |0x80 ); +atp_writeb_io (dev, c,0x16 ,0x80 ); dev->id[c][target_id].dirct =0 ;if (l ==0 ) { -if (inb (dev->ioport[c] +0x1c ) ==0 ) { +if (atp_readb_io (dev, c,0x1c ) ==0 ) {#ifdef ED_DBGP printk ("change SCSI_CMD_REG 0x08\n" );#endif -outb (0x08 , dev->ioport[c] +0x18 ); - }else { +atp_writeb_io (dev, c,0x18 ,0x08 ); + }else dev->last_cmd[c] |=0x40 ; - } dev->in_snd[c] =0 ;return ; }
@@ -821,36 +856,34 @@ static void send_s870(struct atp_unit *dev,unsigned char c)printk ("send_s870: prdaddr_2 0x%8x target_id %d\n" , dev->id[c][target_id].prdaddr,target_id);#endif dev->id[c][target_id].prdaddr = dev->id[c][target_id].prd_bus; -outl (dev->id[c][target_id].prdaddr, dev->pciport[c] +4 ); -outb (0x06 , dev->pciport[c] +2 ); -outb (0x00 , dev->pciport[c] +2 ); +atp_writel_pci (dev, c,4 , dev->id[c][target_id].prdaddr); +atp_writeb_pci (dev, c,2 ,0x06 ); +atp_writeb_pci (dev, c,2 ,0x00 );if (dev->dev_id ==ATP885_DEVID ) { - j =inb (dev->pciport[c] +1 ) &0xf3 ; + j =atp_readb_pci (dev, c,1 ) &0xf3 ;if ((workreq->cmnd[0 ] ==0x08 ) || (workreq->cmnd[0 ] ==0x28 ) || (workreq->cmnd[0 ] ==0x0a ) || (workreq->cmnd[0 ] ==0x2a )) { j |=0x0c ; } -outb (j, dev->pciport[c] +1 ); +atp_writeb_pci (dev, c,1 , j); }else if ((dev->dev_id ==ATP880_DEVID1 ) || (dev->dev_id ==ATP880_DEVID2 )) { -if ((workreq->cmnd[0 ] ==0x08 ) || (workreq->cmnd[0 ] ==0x28 ) || (workreq->cmnd[0 ] ==0x0a ) || (workreq->cmnd[0 ] ==0x2a )) { -outb ((unsigned char ) ((inb (dev->ioport[c] -0x05 ) &0x3f ) |0xc0 ), dev->ioport[c] -0x05 ); - }else { -outb ((unsigned char ) (inb (dev->ioport[c] -0x05 ) &0x3f ), dev->ioport[c] -0x05 ); - } +if ((workreq->cmnd[0 ] ==0x08 ) || (workreq->cmnd[0 ] ==0x28 ) || (workreq->cmnd[0 ] ==0x0a ) || (workreq->cmnd[0 ] ==0x2a )) +atp_writeb_base (dev,0x3b , (atp_readb_base (dev,0x3b ) &0x3f ) |0xc0 ); +else +atp_writeb_base (dev,0x3b ,atp_readb_base (dev,0x3b ) &0x3f ); }else { -if ((workreq->cmnd[0 ] ==0x08 ) || (workreq->cmnd[0 ] ==0x28 ) || (workreq->cmnd[0 ] ==0x0a ) || (workreq->cmnd[0 ] ==0x2a )) { -outb ((inb (dev->ioport[c] +0x3a ) &0xf3 ) |0x08 , dev->ioport[c] +0x3a ); - }else { -outb (inb (dev->ioport[c] +0x3a ) &0xf3 , dev->ioport[c] +0x3a ); - } +if ((workreq->cmnd[0 ] ==0x08 ) || (workreq->cmnd[0 ] ==0x28 ) || (workreq->cmnd[0 ] ==0x0a ) || (workreq->cmnd[0 ] ==0x2a )) +atp_writeb_io (dev, c,0x3a , (atp_readb_io (dev, c,0x3a ) &0xf3 ) |0x08 ); +else +atp_writeb_io (dev, c,0x3a ,atp_readb_io (dev, c,0x3a ) &0xf3 ); }if (workreq->sc_data_direction ==DMA_TO_DEVICE ) { dev->id[c][target_id].dirct =0x20 ; -if (inb (dev->ioport[c] +0x1c ) ==0 ) { -outb (0x08 , dev->ioport[c] +0x18 ); -outb (0x01 , dev->pciport[c]); +if (atp_readb_io (dev, c,0x1c ) ==0 ) { +atp_writeb_io (dev, c,0x18 ,0x08 ); +atp_writeb_pci (dev, c,0 ,0x01 );#ifdef ED_DBGP printk ("start DMA(to target)\n" );#endif
@@ -860,9 +893,9 @@ static void send_s870(struct atp_unit *dev,unsigned char c) dev->in_snd[c] =0 ;return ; } -if (inb (dev->ioport[c] +0x1c ) ==0 ) { -outb (0x08 , dev->ioport[c] +0x18 ); -outb (0x09 , dev->pciport[c]); +if (atp_readb_io (dev, c,0x1c ) ==0 ) { +atp_writeb_io (dev, c,0x18 ,0x08 ); +atp_writeb_pci (dev, c,0 ,0x09 );#ifdef ED_DBGP printk ("start DMA(to host)\n" );#endif
@@ -879,28 +912,28 @@ static unsigned char fun_scam(struct atp_unit *dev, unsigned short int *val)unsigned short int i, k;unsigned char j; -outw (*val, dev->ioport[0 ] +0x1c ); +atp_writew_io (dev,0 ,0x1c , *val);for (i =0 ; i <10 ; i++) {/* stable >= bus settle delay(400 ns) */ - k =inw (dev->ioport[0 ] +0x1c ); + k =atp_readw_io (dev,0 ,0x1c ); j = (unsigned char ) (k >>8 );if ((k &0x8000 ) !=0 )/* DB7 all release? */ i =0 ; } *val |=0x4000 ;/* assert DB6 */ -outw (*val, dev->ioport[0 ] +0x1c ); +atp_writew_io (dev,0 ,0x1c , *val); *val &=0xdfff ;/* assert DB5 */ -outw (*val, dev->ioport[0 ] +0x1c ); +atp_writew_io (dev,0 ,0x1c , *val);for (i =0 ; i <10 ; i++) {/* stable >= bus settle delay(400 ns) */ -if ((inw (dev->ioport[0 ] +0x1c ) &0x2000 ) !=0 )/* DB5 all release? */ +if ((atp_readw_io (dev,0 ,0x1c ) &0x2000 ) !=0 )/* DB5 all release? */ i =0 ; } *val |=0x8000 ;/* no DB4-0, assert DB7 */ *val &=0xe0ff ; -outw (*val, dev->ioport[0 ] +0x1c ); +atp_writew_io (dev,0 ,0x1c , *val); *val &=0xbfff ;/* release DB6 */ -outw (*val, dev->ioport[0 ] +0x1c ); +atp_writew_io (dev,0 ,0x1c , *val);for (i =0 ; i <10 ; i++) {/* stable >= bus settle delay(400 ns) */ -if ((inw (dev->ioport[0 ] +0x1c ) &0x4000 ) !=0 )/* DB6 all release? */ +if ((atp_readw_io (dev,0 ,0x1c ) &0x4000 ) !=0 )/* DB6 all release? */ i =0 ; }
@@ -926,9 +959,9 @@ static void tscam(struct Scsi_Host *host)} */ -outb (0x08 , dev->ioport[0 ] +1 ); -outb (0x7f , dev->ioport[0 ] +2 ); -outb (0x20 , dev->ioport[0 ] +0x11 ); +atp_writeb_io (dev,0 ,1 ,0x08 ); +atp_writeb_io (dev,0 ,2 ,0x7f ); +atp_writeb_io (dev,0 ,0x11 ,0x20 );if ((dev->scam_on &0x40 ) ==0 ) {return ;
@@ -941,13 +974,13 @@ static void tscam(struct Scsi_Host *host) j =8 ; } assignid_map = m; -outb (0x02 , dev->ioport[0 ] +0x02 );/* 2*2=4ms,3EH 2/32*3E=3.9ms */ -outb (0 , dev->ioport[0 ] +0x03 ); -outb (0 , dev->ioport[0 ] +0x04 ); -outb (0 , dev->ioport[0 ] +0x05 ); -outb (0 , dev->ioport[0 ] +0x06 ); -outb (0 , dev->ioport[0 ] +0x07 ); -outb (0 , dev->ioport[0 ] +0x08 ); +atp_writeb_io (dev,0 ,0x02 ,0x02 );/* 2*2=4ms,3EH 2/32*3E=3.9ms */ +atp_writeb_io (dev,0 ,0x03 ,0 ); +atp_writeb_io (dev,0 ,0x04 ,0 ); +atp_writeb_io (dev,0 ,0x05 ,0 ); +atp_writeb_io (dev,0 ,0x06 ,0 ); +atp_writeb_io (dev,0 ,0x07 ,0 ); +atp_writeb_io (dev,0 ,0x08 ,0 );for (i =0 ; i < j; i++) { m =1 ;
@@ -955,70 +988,69 @@ static void tscam(struct Scsi_Host *host)if ((m & assignid_map) !=0 ) {continue ; } -outb (0 , dev->ioport[0 ] +0x0f ); -outb (0 , dev->ioport[0 ] +0x12 ); -outb (0 , dev->ioport[0 ] +0x13 ); -outb (0 , dev->ioport[0 ] +0x14 ); +atp_writeb_io (dev,0 ,0x0f ,0 ); +atp_writeb_io (dev,0 ,0x12 ,0 ); +atp_writeb_io (dev,0 ,0x13 ,0 ); +atp_writeb_io (dev,0 ,0x14 ,0 );if (i >7 ) { k = (i &0x07 ) |0x40 ; }else { k = i; } -outb (k, dev->ioport[0 ] +0x15 ); -if (dev->chip_ver ==4 ) { -outb (0x01 , dev->ioport[0 ] +0x1b ); - }else { -outb (0x00 , dev->ioport[0 ] +0x1b ); - } +atp_writeb_io (dev,0 ,0x15 , k); +if (dev->chip_ver ==4 ) +atp_writeb_io (dev,0 ,0x1b ,0x01 ); +else +atp_writeb_io (dev,0 ,0x1b ,0x00 );do { -outb (0x09 , dev->ioport[0 ] +0x18 ); +atp_writeb_io (dev,0 ,0x18 ,0x09 ); -while ((inb (dev->ioport[0 ] +0x1f ) &0x80 ) ==0x00 ) +while ((atp_readb_io (dev,0 ,0x1f ) &0x80 ) ==0x00 )cpu_relax (); - k =inb (dev->ioport[0 ] +0x17 ); + k =atp_readb_io (dev,0 ,0x17 );if ((k ==0x85 ) || (k ==0x42 ))break ;if (k !=0x16 ) -outb (0x41 , dev->ioport[0 ] +0x10 ); +atp_writeb_io (dev,0 ,0x10 ,0x41 ); }while (k !=0x16 );if ((k ==0x85 ) || (k ==0x42 ))continue ; assignid_map |= m; } -outb (0x7f , dev->ioport[0 ] +0x02 ); -outb (0x02 , dev->ioport[0 ] +0x1b ); +atp_writeb_io (dev,0 ,0x02 ,0x7f ); +atp_writeb_io (dev,0 ,0x1b ,0x02 );outb (0 ,0x80 ); val =0x0080 ;/* bsy */ -outw (val, dev->ioport[0 ] +0x1c ); +atp_writew_io (dev,0 ,0x1c , val); val |=0x0040 ;/* sel */ -outw (val, dev->ioport[0 ] +0x1c ); +atp_writew_io (dev,0 ,0x1c , val); val |=0x0004 ;/* msg */ -outw (val, dev->ioport[0 ] +0x1c ); +atp_writew_io (dev,0 ,0x1c , val);inb (0x80 );/* 2 deskew delay(45ns*2=90ns) */ val &=0x007f ;/* no bsy */ -outw (val, dev->ioport[0 ] +0x1c ); +atp_writew_io (dev,0 ,0x1c , val);mdelay (128 ); val &=0x00fb ;/* after 1ms no msg */ -outw (val, dev->ioport[0 ] +0x1c ); -while ((inb (dev->ioport[0 ] +0x1c ) &0x04 ) !=0 ) +atp_writew_io (dev,0 ,0x1c , val); +while ((atp_readb_io (dev,0 ,0x1c ) &0x04 ) !=0 ) ;outb (1 ,0x80 );udelay (100 );for (n =0 ; n <0x30000 ; n++) -if ((inb (dev->ioport[0 ] +0x1c ) &0x80 ) !=0 )/* bsy ? */ +if ((atp_readb_io (dev,0 ,0x1c ) &0x80 ) !=0 )/* bsy ? */ break ;if (n <0x30000 )for (n =0 ; n <0x30000 ; n++) -if ((inb (dev->ioport[0 ] +0x1c ) &0x81 ) ==0x0081 ) { +if ((atp_readb_io (dev,0 ,0x1c ) &0x81 ) ==0x0081 ) {inb (0x80 ); val |=0x8003 ;/* io,cd,db7 */ -outw (val, dev->ioport[0 ] +0x1c ); +atp_writew_io (dev,0 ,0x1c , val);inb (0x80 ); val &=0x00bf ;/* no sel */ -outw (val, dev->ioport[0 ] +0x1c ); +atp_writew_io (dev,0 ,0x1c , val);outb (2 ,0x80 );break ; }
@@ -1033,14 +1065,14 @@ static void tscam(struct Scsi_Host *host)*/ mdelay (2 );udelay (48 ); -if ((inb (dev->ioport[0 ] +0x1c ) &0x80 ) ==0x00 ) {/* bsy ? */ -outw (0 , dev->ioport[0 ] +0x1c ); -outb (0 , dev->ioport[0 ] +0x1b ); -outb (0 , dev->ioport[0 ] +0x15 ); -outb (0x09 , dev->ioport[0 ] +0x18 ); -while ((inb (dev->ioport[0 ] +0x1f ) &0x80 ) ==0 ) +if ((atp_readb_io (dev,0 ,0x1c ) &0x80 ) ==0x00 ) {/* bsy ? */ +atp_writew_io (dev,0 ,0x1c ,0 ); +atp_writeb_io (dev,0 ,0x1b ,0 ); +atp_writeb_io (dev,0 ,0x15 ,0 ); +atp_writeb_io (dev,0 ,0x18 ,0x09 ); +while ((atp_readb_io (dev,0 ,0x1f ) &0x80 ) ==0 )cpu_relax (); -inb (dev->ioport[0 ] +0x17 ); +atp_readb_io (dev,0 ,0x17 );return ; } val &=0x00ff ;/* synchronization */
@@ -1055,7 +1087,7 @@ static void tscam(struct Scsi_Host *host) j =0 ;while (1 ) { -if ((inw (dev->ioport[0 ] +0x1c ) &0x2000 ) ==0 ) +if ((atp_readw_io (dev,0 ,0x1c ) &0x2000 ) ==0 )continue ;outb (5 ,0x80 ); val &=0x00ff ;/* get ID_STRING */
@@ -2232,6 +2264,7 @@ static int atp870u_probe(struct pci_dev *pdev, const struct pci_device_id *ent) } base_io =pci_resource_start (pdev,0 ); base_io &=0xfffffff8 ; + atpdev->baseport = base_io;if ((ent->device ==ATP880_DEVID1 )||(ent->device ==ATP880_DEVID2 )) { atpdev->chip_ver = pdev->revision;
@@ -2356,7 +2389,6 @@ flash_ok_880: atpdev->pdev = pdev; atpdev->dev_id = ent->device; - atpdev->baseport = base_io; atpdev->ioport[0 ] = base_io +0x80 ; atpdev->ioport[1 ] = base_io +0xc0 ; atpdev->pciport[0 ] = base_io +0x40 ;
@@ -2651,12 +2683,12 @@ static int atp870u_abort(struct scsi_cmnd * SCpnt)printk ("working=%x last_cmd=%x " , dev->working[c], dev->last_cmd[c]);printk (" quhdu=%x quendu=%x " , dev->quhd[c], dev->quend[c]);for (j =0 ; j <0x18 ; j++) { -printk (" r%2x=%2x" , j,inb (dev->ioport[c] + j)); +printk (" r%2x=%2x" , j,atp_readb_io (dev, c, j)); } -printk (" r1c=%2x" ,inb (dev->ioport[c] +0x1c )); -printk (" r1f=%2x in_snd=%2x " ,inb (dev->ioport[c] +0x1f ), dev->in_snd[c]); -printk (" d00=%2x" ,inb (dev->pciport[c])); -printk (" d02=%2x" ,inb (dev->pciport[c] +0x02 )); +printk (" r1c=%2x" ,atp_readb_io (dev, c,0x1c )); +printk (" r1f=%2x in_snd=%2x " ,atp_readb_io (dev, c,0x1f ), dev->in_snd[c]); +printk (" d00=%2x" ,atp_readb_pci (dev, c,0x00 )); +printk (" d02=%2x" ,atp_readb_pci (dev, c,0x02 ));for (j=0 ;j<16 ;j++) {if (dev->id[c][j].curr_req !=NULL ) { workrequ = dev->id[c][j].curr_req;
Signature · 1 line
Ondrej Zary
PATCH 19/52 atp870u: Convert is870() to use wrappers
In reply to Ondrej Zary--- drivers/scsi/atp870u.c | 276 ++++++++++++++++++++++++------------------------ 1 file changed, 138 insertions(+), 138 deletions(-)
drivers/scsi/atp870u.c +138 -138
@@ -1162,7 +1162,7 @@ static void tscam(struct Scsi_Host *host) } } -static void is870 (struct atp_unit *dev,unsigned int wkport) +static void is870 (struct atp_unit *dev) {unsigned char i, j, k, rmb, n;unsigned short int m;
@@ -1174,7 +1174,7 @@ static void is870(struct atp_unit *dev, unsigned int wkport)static unsigned char synw[6 ] = {0x80 ,1 ,3 ,1 ,0x0c ,0x07 };static unsigned char wide[6 ] = {0x80 ,1 ,2 ,3 ,1 ,0 }; -outb ((unsigned char ) (inb (wkport +0x3a ) |0x10 ), wkport +0x3a ); +atp_writeb_io (dev,0 ,0x3a ,atp_readb_io (dev,0 ,0x3a ) |0x10 );for (i =0 ; i <16 ; i++) {if ((dev->chip_ver !=4 ) && (i >7 )) {
@@ -1190,104 +1190,104 @@ static void is870(struct atp_unit *dev, unsigned int wkport)continue ; }if (dev->chip_ver ==4 ) { -outb (0x01 , wkport +0x1b ); +atp_writeb_io (dev,0 ,0x1b ,0x01 ); }else { -outb (0x00 , wkport +0x1b ); - } -outb (0x08 , wkport +1 ); -outb (0x7f , wkport +2 ); -outb (satn[0 ], wkport +3 ); -outb (satn[1 ], wkport +4 ); -outb (satn[2 ], wkport +5 ); -outb (satn[3 ], wkport +6 ); -outb (satn[4 ], wkport +7 ); -outb (satn[5 ], wkport +8 ); -outb (0 , wkport +0x0f ); -outb (dev->id[0 ][i].devsp, wkport +0x11 ); -outb (0 , wkport +0x12 ); -outb (satn[6 ], wkport +0x13 ); -outb (satn[7 ], wkport +0x14 ); +atp_writeb_io (dev,0 ,0x1b ,0x00 ); + } +atp_writeb_io (dev,0 ,1 ,0x08 ); +atp_writeb_io (dev,0 ,2 ,0x7f ); +atp_writeb_io (dev,0 ,3 , satn[0 ]); +atp_writeb_io (dev,0 ,4 , satn[1 ]); +atp_writeb_io (dev,0 ,5 , satn[2 ]); +atp_writeb_io (dev,0 ,6 , satn[3 ]); +atp_writeb_io (dev,0 ,7 , satn[4 ]); +atp_writeb_io (dev,0 ,8 , satn[5 ]); +atp_writeb_io (dev,0 ,0x0f ,0 ); +atp_writeb_io (dev,0 ,0x11 , dev->id[0 ][i].devsp); +atp_writeb_io (dev,0 ,0x12 ,0 ); +atp_writeb_io (dev,0 ,0x13 , satn[6 ]); +atp_writeb_io (dev,0 ,0x14 , satn[7 ]); j = i;if ((j &0x08 ) !=0 ) { j = (j &0x07 ) |0x40 ; } -outb (j, wkport +0x15 ); -outb (satn[8 ], wkport +0x18 ); +atp_writeb_io (dev,0 ,0x15 , j); +atp_writeb_io (dev,0 ,0x18 , satn[8 ]); -while ((inb (wkport +0x1f ) &0x80 ) ==0x00 ) +while ((atp_readb_io (dev,0 ,0x1f ) &0x80 ) ==0x00 )cpu_relax (); -if (inb (wkport +0x17 ) !=0x11 &&inb (wkport +0x17 ) !=0x8e ) +if (atp_readb_io (dev,0 ,0x17 ) !=0x11 &&atp_readb_io (dev,0 ,0x17 ) !=0x8e )continue ; -while (inb (wkport +0x17 ) !=0x8e ) +while (atp_readb_io (dev,0 ,0x17 ) !=0x8e )cpu_relax (); dev->active_id[0 ] |= m; -outb (0x30 , wkport +0x10 ); -outb (0x00 , wkport +0x04 ); +atp_writeb_io (dev,0 ,0x10 ,0x30 ); +atp_writeb_io (dev,0 ,0x04 ,0x00 ); phase_cmd: -outb (0x08 , wkport +0x18 ); -while ((inb (wkport +0x1f ) &0x80 ) ==0x00 ) +atp_writeb_io (dev,0 ,0x18 ,0x08 ); +while ((atp_readb_io (dev,0 ,0x1f ) &0x80 ) ==0x00 )cpu_relax (); - j =inb (wkport +0x17 ); + j =atp_readb_io (dev,0 ,0x17 );if (j !=0x16 ) { -outb (0x41 , wkport +0x10 ); +atp_writeb_io (dev,0 ,0x10 ,0x41 ); goto phase_cmd; } sel_ok: -outb (inqd[0 ], wkport +3 ); -outb (inqd[1 ], wkport +4 ); -outb (inqd[2 ], wkport +5 ); -outb (inqd[3 ], wkport +6 ); -outb (inqd[4 ], wkport +7 ); -outb (inqd[5 ], wkport +8 ); -outb (0 , wkport +0x0f ); -outb (dev->id[0 ][i].devsp, wkport +0x11 ); -outb (0 , wkport +0x12 ); -outb (inqd[6 ], wkport +0x13 ); -outb (inqd[7 ], wkport +0x14 ); -outb (inqd[8 ], wkport +0x18 ); +atp_writeb_io (dev,0 ,3 , inqd[0 ]); +atp_writeb_io (dev,0 ,4 , inqd[1 ]); +atp_writeb_io (dev,0 ,5 , inqd[2 ]); +atp_writeb_io (dev,0 ,6 , inqd[3 ]); +atp_writeb_io (dev,0 ,7 , inqd[4 ]); +atp_writeb_io (dev,0 ,8 , inqd[5 ]); +atp_writeb_io (dev,0 ,0x0f ,0 ); +atp_writeb_io (dev,0 ,0x11 , dev->id[0 ][i].devsp); +atp_writeb_io (dev,0 ,0x12 ,0 ); +atp_writeb_io (dev,0 ,0x13 , inqd[6 ]); +atp_writeb_io (dev,0 ,0x14 , inqd[7 ]); +atp_writeb_io (dev,0 ,0x18 , inqd[8 ]); -while ((inb (wkport +0x1f ) &0x80 ) ==0x00 ) +while ((atp_readb_io (dev,0 ,0x1f ) &0x80 ) ==0x00 )cpu_relax (); -if (inb (wkport +0x17 ) !=0x11 &&inb (wkport +0x17 ) !=0x8e ) +if (atp_readb_io (dev,0 ,0x17 ) !=0x11 &&atp_readb_io (dev,0 ,0x17 ) !=0x8e )continue ; -while (inb (wkport +0x17 ) !=0x8e ) +while (atp_readb_io (dev,0 ,0x17 ) !=0x8e )cpu_relax ();if (dev->chip_ver ==4 ) -outb (0x00 , wkport +0x1b ); +atp_writeb_io (dev,0 ,0x1b ,0x00 ); -outb (0x08 , wkport +0x18 ); +atp_writeb_io (dev,0 ,0x18 ,0x08 ); j =0 ; rd_inq_data: - k =inb (wkport +0x1f ); + k =atp_readb_io (dev,0 ,0x1f );if ((k &0x01 ) !=0 ) { - mbuf[j++] =inb (wkport +0x19 ); + mbuf[j++] =atp_readb_io (dev,0 ,0x19 ); goto rd_inq_data; }if ((k &0x80 ) ==0 ) { goto rd_inq_data; } - j =inb (wkport +0x17 ); + j =atp_readb_io (dev,0 ,0x17 );if (j ==0x16 ) { goto inq_ok; } -outb (0x46 , wkport +0x10 ); -outb (0 , wkport +0x12 ); -outb (0 , wkport +0x13 ); -outb (0 , wkport +0x14 ); -outb (0x08 , wkport +0x18 ); +atp_writeb_io (dev,0 ,0x10 ,0x46 ); +atp_writeb_io (dev,0 ,0x12 ,0 ); +atp_writeb_io (dev,0 ,0x13 ,0 ); +atp_writeb_io (dev,0 ,0x14 ,0 ); +atp_writeb_io (dev,0 ,0x18 ,0x08 ); -while ((inb (wkport +0x1f ) &0x80 ) ==0x00 ) +while ((atp_readb_io (dev,0 ,0x1f ) &0x80 ) ==0x00 )cpu_relax (); -if (inb (wkport +0x17 ) !=0x16 ) { +if (atp_readb_io (dev,0 ,0x17 ) !=0x16 ) { goto sel_ok; } inq_ok:
@@ -1305,43 +1305,43 @@ inq_ok:if ((dev->global_map[0 ] &0x20 ) ==0 ) { goto not_wide; } -outb (0x01 , wkport +0x1b ); -outb (satn[0 ], wkport +3 ); -outb (satn[1 ], wkport +4 ); -outb (satn[2 ], wkport +5 ); -outb (satn[3 ], wkport +6 ); -outb (satn[4 ], wkport +7 ); -outb (satn[5 ], wkport +8 ); -outb (0 , wkport +0x0f ); -outb (dev->id[0 ][i].devsp, wkport +0x11 ); -outb (0 , wkport +0x12 ); -outb (satn[6 ], wkport +0x13 ); -outb (satn[7 ], wkport +0x14 ); -outb (satn[8 ], wkport +0x18 ); +atp_writeb_io (dev,0 ,0x1b ,0x01 ); +atp_writeb_io (dev,0 ,3 , satn[0 ]); +atp_writeb_io (dev,0 ,4 , satn[1 ]); +atp_writeb_io (dev,0 ,5 , satn[2 ]); +atp_writeb_io (dev,0 ,6 , satn[3 ]); +atp_writeb_io (dev,0 ,7 , satn[4 ]); +atp_writeb_io (dev,0 ,8 , satn[5 ]); +atp_writeb_io (dev,0 ,0x0f ,0 ); +atp_writeb_io (dev,0 ,0x11 , dev->id[0 ][i].devsp); +atp_writeb_io (dev,0 ,0x12 ,0 ); +atp_writeb_io (dev,0 ,0x13 , satn[6 ]); +atp_writeb_io (dev,0 ,0x14 , satn[7 ]); +atp_writeb_io (dev,0 ,0x18 , satn[8 ]); -while ((inb (wkport +0x1f ) &0x80 ) ==0x00 ) +while ((atp_readb_io (dev,0 ,0x1f ) &0x80 ) ==0x00 )cpu_relax (); -if (inb (wkport +0x17 ) !=0x11 &&inb (wkport +0x17 ) !=0x8e ) +if (atp_readb_io (dev,0 ,0x17 ) !=0x11 &&atp_readb_io (dev,0 ,0x17 ) !=0x8e )continue ; -while (inb (wkport +0x17 ) !=0x8e ) +while (atp_readb_io (dev,0 ,0x17 ) !=0x8e )cpu_relax (); try_wide: j =0 ; -outb (0x05 , wkport +0x14 ); -outb (0x20 , wkport +0x18 ); +atp_writeb_io (dev,0 ,0x14 ,0x05 ); +atp_writeb_io (dev,0 ,0x18 ,0x20 ); -while ((inb (wkport +0x1f ) &0x80 ) ==0 ) { -if ((inb (wkport +0x1f ) &0x01 ) !=0 ) -outb (wide[j++], wkport +0x19 ); +while ((atp_readb_io (dev,0 ,0x1f ) &0x80 ) ==0 ) { +if ((atp_readb_io (dev,0 ,0x1f ) &0x01 ) !=0 ) +atp_writeb_io (dev,0 ,0x19 , wide[j++]); } -while ((inb (wkport +0x17 ) &0x80 ) ==0x00 ) +while ((atp_readb_io (dev,0 ,0x17 ) &0x80 ) ==0x00 )cpu_relax (); - j =inb (wkport +0x17 ) &0x0f ; + j =atp_readb_io (dev,0 ,0x17 ) &0x0f ;if (j ==0x0f ) { goto widep_in; }
@@ -1353,12 +1353,12 @@ try_wide: }continue ; widep_out: -outb (0x20 , wkport +0x18 ); -while ((inb (wkport +0x1f ) &0x80 ) ==0 ) { -if ((inb (wkport +0x1f ) &0x01 ) !=0 ) -outb (0 , wkport +0x19 ); +atp_writeb_io (dev,0 ,0x18 ,0x20 ); +while ((atp_readb_io (dev,0 ,0x1f ) &0x80 ) ==0 ) { +if ((atp_readb_io (dev,0 ,0x1f ) &0x01 ) !=0 ) +atp_writeb_io (dev,0 ,0x19 ,0 ); } - j =inb (wkport +0x17 ) &0x0f ; + j =atp_readb_io (dev,0 ,0x17 ) &0x0f ;if (j ==0x0f ) { goto widep_in; }
@@ -1370,19 +1370,19 @@ widep_out: }continue ; widep_in: -outb (0xff , wkport +0x14 ); -outb (0x20 , wkport +0x18 ); +atp_writeb_io (dev,0 ,0x14 ,0xff ); +atp_writeb_io (dev,0 ,0x18 ,0x20 ); k =0 ; widep_in1: - j =inb (wkport +0x1f ); + j =atp_readb_io (dev,0 ,0x1f );if ((j &0x01 ) !=0 ) { - mbuf[k++] =inb (wkport +0x19 ); + mbuf[k++] =atp_readb_io (dev,0 ,0x19 ); goto widep_in1; }if ((j &0x80 ) ==0x00 ) { goto widep_in1; } - j =inb (wkport +0x17 ) &0x0f ; + j =atp_readb_io (dev,0 ,0x17 ) &0x0f ;if (j ==0x0f ) { goto widep_in; }
@@ -1394,14 +1394,14 @@ widep_in1: }continue ; widep_cmd: -outb (0x30 , wkport +0x10 ); -outb (0x00 , wkport +0x14 ); -outb (0x08 , wkport +0x18 ); - -while ((inb (wkport +0x1f ) &0x80 ) ==0x00 ) +atp_writeb_io (dev,0 ,0x10 ,0x30 ); +atp_writeb_io (dev,0 ,0x14 ,0x00 ); +atp_writeb_io (dev,0 ,0x18 ,0x08 ); + +while ((atp_readb_io (dev,0 ,0x1f ) &0x80 ) ==0x00 )cpu_relax (); - j =inb (wkport +0x17 ); + j =atp_readb_io (dev,0 ,0x17 );if (j !=0x16 ) {if (j ==0x4e ) { goto widep_out;
@@ -1433,52 +1433,52 @@ set_sync:if ((m & dev->wide_id[0 ]) !=0 ) { j |=0x01 ; } -outb (j, wkport +0x1b ); -outb (satn[0 ], wkport +3 ); -outb (satn[1 ], wkport +4 ); -outb (satn[2 ], wkport +5 ); -outb (satn[3 ], wkport +6 ); -outb (satn[4 ], wkport +7 ); -outb (satn[5 ], wkport +8 ); -outb (0 , wkport +0x0f ); -outb (dev->id[0 ][i].devsp, wkport +0x11 ); -outb (0 , wkport +0x12 ); -outb (satn[6 ], wkport +0x13 ); -outb (satn[7 ], wkport +0x14 ); -outb (satn[8 ], wkport +0x18 ); +atp_writeb_io (dev,0 ,0x1b , j); +atp_writeb_io (dev,0 ,3 , satn[0 ]); +atp_writeb_io (dev,0 ,4 , satn[1 ]); +atp_writeb_io (dev,0 ,5 , satn[2 ]); +atp_writeb_io (dev,0 ,6 , satn[3 ]); +atp_writeb_io (dev,0 ,7 , satn[4 ]); +atp_writeb_io (dev,0 ,8 , satn[5 ]); +atp_writeb_io (dev,0 ,0x0f ,0 ); +atp_writeb_io (dev,0 ,0x11 , dev->id[0 ][i].devsp); +atp_writeb_io (dev,0 ,0x12 ,0 ); +atp_writeb_io (dev,0 ,0x13 , satn[6 ]); +atp_writeb_io (dev,0 ,0x14 , satn[7 ]); +atp_writeb_io (dev,0 ,0x18 , satn[8 ]); -while ((inb (wkport +0x1f ) &0x80 ) ==0x00 ) +while ((atp_readb_io (dev,0 ,0x1f ) &0x80 ) ==0x00 )cpu_relax (); -if (inb (wkport +0x17 ) !=0x11 &&inb (wkport +0x17 ) !=0x8e ) +if (atp_readb_io (dev,0 ,0x17 ) !=0x11 &&atp_readb_io (dev,0 ,0x17 ) !=0x8e )continue ; -while (inb (wkport +0x17 ) !=0x8e ) +while (atp_readb_io (dev,0 ,0x17 ) !=0x8e )cpu_relax (); try_sync: j =0 ; -outb (0x06 , wkport +0x14 ); -outb (0x20 , wkport +0x18 ); +atp_writeb_io (dev,0 ,0x14 ,0x06 ); +atp_writeb_io (dev,0 ,0x18 ,0x20 ); -while ((inb (wkport +0x1f ) &0x80 ) ==0 ) { -if ((inb (wkport +0x1f ) &0x01 ) !=0 ) { +while ((atp_readb_io (dev,0 ,0x1f ) &0x80 ) ==0 ) { +if ((atp_readb_io (dev,0 ,0x1f ) &0x01 ) !=0 ) {if ((m & dev->wide_id[0 ]) !=0 ) { -outb (synw[j++], wkport +0x19 ); +atp_writeb_io (dev,0 ,0x19 , synw[j++]); }else {if ((m & dev->ultra_map[0 ]) !=0 ) { -outb (synu[j++], wkport +0x19 ); +atp_writeb_io (dev,0 ,0x19 , synu[j++]); }else { -outb (synn[j++], wkport +0x19 ); +atp_writeb_io (dev,0 ,0x19 , synn[j++]); } } } } -while ((inb (wkport +0x17 ) &0x80 ) ==0x00 ) +while ((atp_readb_io (dev,0 ,0x17 ) &0x80 ) ==0x00 )cpu_relax (); - j =inb (wkport +0x17 ) &0x0f ; + j =atp_readb_io (dev,0 ,0x17 ) &0x0f ;if (j ==0x0f ) { goto phase_ins; }
@@ -1490,12 +1490,12 @@ try_sync: }continue ; phase_outs: -outb (0x20 , wkport +0x18 ); -while ((inb (wkport +0x1f ) &0x80 ) ==0x00 ) { -if ((inb (wkport +0x1f ) &0x01 ) !=0x00 ) -outb (0x00 , wkport +0x19 ); +atp_writeb_io (dev,0 ,0x18 ,0x20 ); +while ((atp_readb_io (dev,0 ,0x1f ) &0x80 ) ==0x00 ) { +if ((atp_readb_io (dev,0 ,0x1f ) &0x01 ) !=0x00 ) +atp_writeb_io (dev,0 ,0x19 ,0x00 ); } - j =inb (wkport +0x17 ); + j =atp_readb_io (dev,0 ,0x17 );if (j ==0x85 ) { goto tar_dcons; }
@@ -1511,23 +1511,23 @@ phase_outs: }continue ; phase_ins: -outb (0xff , wkport +0x14 ); -outb (0x20 , wkport +0x18 ); +atp_writeb_io (dev,0 ,0x14 ,0xff ); +atp_writeb_io (dev,0 ,0x18 ,0x20 ); k =0 ; phase_ins1: - j =inb (wkport +0x1f ); + j =atp_readb_io (dev,0 ,0x1f );if ((j &0x01 ) !=0x00 ) { - mbuf[k++] =inb (wkport +0x19 ); + mbuf[k++] =atp_readb_io (dev,0 ,0x19 ); goto phase_ins1; }if ((j &0x80 ) ==0x00 ) { goto phase_ins1; } -while ((inb (wkport +0x17 ) &0x80 ) ==0x00 ) +while ((atp_readb_io (dev,0 ,0x17 ) &0x80 ) ==0x00 )cpu_relax (); - j =inb (wkport +0x17 ); + j =atp_readb_io (dev,0 ,0x17 );if (j ==0x85 ) { goto tar_dcons; }
@@ -1543,15 +1543,15 @@ phase_ins1: }continue ; phase_cmds: -outb (0x30 , wkport +0x10 ); +atp_writeb_io (dev,0 ,0x10 ,0x30 ); tar_dcons: -outb (0x00 , wkport +0x14 ); -outb (0x08 , wkport +0x18 ); +atp_writeb_io (dev,0 ,0x14 ,0x00 ); +atp_writeb_io (dev,0 ,0x18 ,0x08 ); -while ((inb (wkport +0x1f ) &0x80 ) ==0x00 ) +while ((atp_readb_io (dev,0 ,0x1f ) &0x80 ) ==0x00 )cpu_relax (); - j =inb (wkport +0x17 ); + j =atp_readb_io (dev,0 ,0x17 );if (j !=0x16 ) {continue ; }
@@ -1591,7 +1591,7 @@ tar_dcons: set_syn_ok: dev->id[0 ][i].devsp = (dev->id[0 ][i].devsp &0x0f ) | j; } -outb ((unsigned char ) (inb (wkport +0x3a ) &0xef ), wkport +0x3a ); +atp_writeb_io (dev,0 ,0x3a ,atp_readb_io (dev,0 ,0x3a ) &0xef ); }static void is880 (struct atp_unit *dev,unsigned int wkport)
@@ -2605,7 +2605,7 @@ flash_ok_885:outb (0x20 , base_io +0x11 );tscam (shpnt); -is870 (p, base_io); +is870 (p);outb ((inb (base_io +0x3a ) &0xef ), base_io +0x3a );outb ((inb (base_io +0x3b ) |0x20 ), base_io +0x3b );if (atpdev->chip_ver ==4 )
Signature · 1 line
Ondrej Zary
PATCH 20/52 atp870u: Convert is880() to use wrappers
In reply to Ondrej ZarySubtract 0x40 to use _io access wrappers.
Now it's obvious that is870() and is880() are very similar.
--- drivers/scsi/atp870u.c | 352 ++++++++++++++++++++++++------------------------ 1 file changed, 176 insertions(+), 176 deletions(-)
drivers/scsi/atp870u.c +176 -176
@@ -1594,7 +1594,7 @@ set_syn_ok:atp_writeb_io (dev,0 ,0x3a ,atp_readb_io (dev,0 ,0x3a ) &0xef ); } -static void is880 (struct atp_unit *dev,unsigned int wkport) +static void is880 (struct atp_unit *dev) {unsigned char i, j, k, rmb, n, lvdmode;unsigned short int m;
@@ -1608,7 +1608,7 @@ static void is880(struct atp_unit *dev, unsigned int wkport)static unsigned char wide[6 ] = {0x80 ,1 ,2 ,3 ,1 ,0 };static unsigned char u3[9 ] = {0x80 ,1 ,6 ,4 ,0x09 ,00 ,0x0e ,0x01 ,0x02 }; - lvdmode =inb (wkport +0x3f ) &0x40 ; + lvdmode =atp_readb_base (dev,0x3f ) &0x40 ;for (i =0 ; i <16 ; i++) { m =1 ;
@@ -1620,100 +1620,100 @@ static void is880(struct atp_unit *dev, unsigned int wkport)printk (KERN_INFO " ID: %2d Host Adapter\n" , dev->host_id[0 ]);continue ; } -outb (0x01 , wkport +0x5b ); -outb (0x08 , wkport +0x41 ); -outb (0x7f , wkport +0x42 ); -outb (satn[0 ], wkport +0x43 ); -outb (satn[1 ], wkport +0x44 ); -outb (satn[2 ], wkport +0x45 ); -outb (satn[3 ], wkport +0x46 ); -outb (satn[4 ], wkport +0x47 ); -outb (satn[5 ], wkport +0x48 ); -outb (0 , wkport +0x4f ); -outb (dev->id[0 ][i].devsp, wkport +0x51 ); -outb (0 , wkport +0x52 ); -outb (satn[6 ], wkport +0x53 ); -outb (satn[7 ], wkport +0x54 ); +atp_writeb_io (dev,0 ,0x1b ,0x01 ); +atp_writeb_io (dev,0 ,1 ,0x08 ); +atp_writeb_io (dev,0 ,2 ,0x7f ); +atp_writeb_io (dev,0 ,3 , satn[0 ]); +atp_writeb_io (dev,0 ,4 , satn[1 ]); +atp_writeb_io (dev,0 ,5 , satn[2 ]); +atp_writeb_io (dev,0 ,6 , satn[3 ]); +atp_writeb_io (dev,0 ,7 , satn[4 ]); +atp_writeb_io (dev,0 ,8 , satn[5 ]); +atp_writeb_io (dev,0 ,0x0f ,0 ); +atp_writeb_io (dev,0 ,0x11 , dev->id[0 ][i].devsp); +atp_writeb_io (dev,0 ,0x12 ,0 ); +atp_writeb_io (dev,0 ,0x13 , satn[6 ]); +atp_writeb_io (dev,0 ,0x14 , satn[7 ]); j = i;if ((j &0x08 ) !=0 ) { j = (j &0x07 ) |0x40 ; } -outb (j, wkport +0x55 ); -outb (satn[8 ], wkport +0x58 ); +atp_writeb_io (dev,0 ,0x15 , j); +atp_writeb_io (dev,0 ,0x18 , satn[8 ]); -while ((inb (wkport +0x5f ) &0x80 ) ==0x00 ) +while ((atp_readb_io (dev,0 ,0x1f ) &0x80 ) ==0x00 )cpu_relax (); -if (inb (wkport +0x57 ) !=0x11 &&inb (wkport +0x57 ) !=0x8e ) +if (atp_readb_io (dev,0 ,0x17 ) !=0x11 &&atp_readb_io (dev,0 ,0x17 ) !=0x8e )continue ; -while (inb (wkport +0x57 ) !=0x8e ) +while (atp_readb_io (dev,0 ,0x17 ) !=0x8e )cpu_relax (); dev->active_id[0 ] |= m; -outb (0x30 , wkport +0x50 ); -outb (0x00 , wkport +0x54 ); +atp_writeb_io (dev,0 ,0x10 ,0x30 ); +atp_writeb_io (dev,0 ,0x14 ,0x00 ); phase_cmd: -outb (0x08 , wkport +0x58 ); +atp_writeb_io (dev,0 ,0x18 ,0x08 ); -while ((inb (wkport +0x5f ) &0x80 ) ==0x00 ) +while ((atp_readb_io (dev,0 ,0x1f ) &0x80 ) ==0x00 )cpu_relax (); - j =inb (wkport +0x57 ); + j =atp_readb_io (dev,0 ,0x17 );if (j !=0x16 ) { -outb (0x41 , wkport +0x50 ); +atp_writeb_io (dev,0 ,0x10 ,0x41 ); goto phase_cmd; } sel_ok: -outb (inqd[0 ], wkport +0x43 ); -outb (inqd[1 ], wkport +0x44 ); -outb (inqd[2 ], wkport +0x45 ); -outb (inqd[3 ], wkport +0x46 ); -outb (inqd[4 ], wkport +0x47 ); -outb (inqd[5 ], wkport +0x48 ); -outb (0 , wkport +0x4f ); -outb (dev->id[0 ][i].devsp, wkport +0x51 ); -outb (0 , wkport +0x52 ); -outb (inqd[6 ], wkport +0x53 ); -outb (inqd[7 ], wkport +0x54 ); -outb (inqd[8 ], wkport +0x58 ); +atp_writeb_io (dev,0 ,3 , inqd[0 ]); +atp_writeb_io (dev,0 ,4 , inqd[1 ]); +atp_writeb_io (dev,0 ,5 , inqd[2 ]); +atp_writeb_io (dev,0 ,6 , inqd[3 ]); +atp_writeb_io (dev,0 ,7 , inqd[4 ]); +atp_writeb_io (dev,0 ,8 , inqd[5 ]); +atp_writeb_io (dev,0 ,0x0f ,0 ); +atp_writeb_io (dev,0 ,0x11 , dev->id[0 ][i].devsp); +atp_writeb_io (dev,0 ,0x12 ,0 ); +atp_writeb_io (dev,0 ,0x13 , inqd[6 ]); +atp_writeb_io (dev,0 ,0x14 , inqd[7 ]); +atp_writeb_io (dev,0 ,0x18 , inqd[8 ]); -while ((inb (wkport +0x5f ) &0x80 ) ==0x00 ) +while ((atp_readb_io (dev,0 ,0x1f ) &0x80 ) ==0x00 )cpu_relax (); -if (inb (wkport +0x57 ) !=0x11 &&inb (wkport +0x57 ) !=0x8e ) +if (atp_readb_io (dev,0 ,0x17 ) !=0x11 &&atp_readb_io (dev,0 ,0x17 ) !=0x8e )continue ; -while (inb (wkport +0x57 ) !=0x8e ) +while (atp_readb_io (dev,0 ,0x17 ) !=0x8e )cpu_relax (); -outb (0x00 , wkport +0x5b ); -outb (0x08 , wkport +0x58 ); +atp_writeb_io (dev,0 ,0x1b ,0x00 ); +atp_writeb_io (dev,0 ,0x18 ,0x08 ); j =0 ; rd_inq_data: - k =inb (wkport +0x5f ); + k =atp_readb_io (dev,0 ,0x1f );if ((k &0x01 ) !=0 ) { - mbuf[j++] =inb (wkport +0x59 ); + mbuf[j++] =atp_readb_io (dev,0 ,0x19 ); goto rd_inq_data; }if ((k &0x80 ) ==0 ) { goto rd_inq_data; } - j =inb (wkport +0x57 ); + j =atp_readb_io (dev,0 ,0x17 );if (j ==0x16 ) { goto inq_ok; } -outb (0x46 , wkport +0x50 ); -outb (0 , wkport +0x52 ); -outb (0 , wkport +0x53 ); -outb (0 , wkport +0x54 ); -outb (0x08 , wkport +0x58 ); -while ((inb (wkport +0x5f ) &0x80 ) ==0x00 ) +atp_writeb_io (dev,0 ,0x10 ,0x46 ); +atp_writeb_io (dev,0 ,0x12 ,0 ); +atp_writeb_io (dev,0 ,0x13 ,0 ); +atp_writeb_io (dev,0 ,0x14 ,0 ); +atp_writeb_io (dev,0 ,0x18 ,0x08 ); +while ((atp_readb_io (dev,0 ,0x1f ) &0x80 ) ==0x00 )cpu_relax (); -if (inb (wkport +0x57 ) !=0x16 ) +if (atp_readb_io (dev,0 ,0x17 ) !=0x16 ) goto sel_ok; inq_ok:
@@ -1736,43 +1736,43 @@ inq_ok: goto chg_wide; } -outb (0x01 , wkport +0x5b ); -outb (satn[0 ], wkport +0x43 ); -outb (satn[1 ], wkport +0x44 ); -outb (satn[2 ], wkport +0x45 ); -outb (satn[3 ], wkport +0x46 ); -outb (satn[4 ], wkport +0x47 ); -outb (satn[5 ], wkport +0x48 ); -outb (0 , wkport +0x4f ); -outb (dev->id[0 ][i].devsp, wkport +0x51 ); -outb (0 , wkport +0x52 ); -outb (satn[6 ], wkport +0x53 ); -outb (satn[7 ], wkport +0x54 ); -outb (satn[8 ], wkport +0x58 ); - -while ((inb (wkport +0x5f ) &0x80 ) ==0x00 ) +atp_writeb_io (dev,0 ,0x1b ,0x01 ); +atp_writeb_io (dev,0 ,3 , satn[0 ]); +atp_writeb_io (dev,0 ,4 , satn[1 ]); +atp_writeb_io (dev,0 ,5 , satn[2 ]); +atp_writeb_io (dev,0 ,6 , satn[3 ]); +atp_writeb_io (dev,0 ,7 , satn[4 ]); +atp_writeb_io (dev,0 ,8 , satn[5 ]); +atp_writeb_io (dev,0 ,0x0f ,0 ); +atp_writeb_io (dev,0 ,0x11 , dev->id[0 ][i].devsp); +atp_writeb_io (dev,0 ,0x12 ,0 ); +atp_writeb_io (dev,0 ,0x13 , satn[6 ]); +atp_writeb_io (dev,0 ,0x14 , satn[7 ]); +atp_writeb_io (dev,0 ,0x18 , satn[8 ]); + +while ((atp_readb_io (dev,0 ,0x1f ) &0x80 ) ==0x00 )cpu_relax (); -if (inb (wkport +0x57 ) !=0x11 &&inb (wkport +0x57 ) !=0x8e ) +if (atp_readb_io (dev,0 ,0x17 ) !=0x11 &&atp_readb_io (dev,0 ,0x17 ) !=0x8e )continue ; -while (inb (wkport +0x57 ) !=0x8e ) +while (atp_readb_io (dev,0 ,0x17 ) !=0x8e )cpu_relax (); try_u3: j =0 ; -outb (0x09 , wkport +0x54 ); -outb (0x20 , wkport +0x58 ); +atp_writeb_io (dev,0 ,0x14 ,0x09 ); +atp_writeb_io (dev,0 ,0x18 ,0x20 ); -while ((inb (wkport +0x5f ) &0x80 ) ==0 ) { -if ((inb (wkport +0x5f ) &0x01 ) !=0 ) -outb (u3[j++], wkport +0x59 ); +while ((atp_readb_io (dev,0 ,0x1f ) &0x80 ) ==0 ) { +if ((atp_readb_io (dev,0 ,0x1f ) &0x01 ) !=0 ) +atp_writeb_io (dev,0 ,0x19 , u3[j++]); } -while ((inb (wkport +0x57 ) &0x80 ) ==0x00 ) +while ((atp_readb_io (dev,0 ,0x17 ) &0x80 ) ==0x00 )cpu_relax (); - j =inb (wkport +0x57 ) &0x0f ; + j =atp_readb_io (dev,0 ,0x17 ) &0x0f ;if (j ==0x0f ) { goto u3p_in; }
@@ -1784,12 +1784,12 @@ try_u3: }continue ; u3p_out: -outb (0x20 , wkport +0x58 ); -while ((inb (wkport +0x5f ) &0x80 ) ==0 ) { -if ((inb (wkport +0x5f ) &0x01 ) !=0 ) -outb (0 , wkport +0x59 ); +atp_writeb_io (dev,0 ,0x18 ,0x20 ); +while ((atp_readb_io (dev,0 ,0x1f ) &0x80 ) ==0 ) { +if ((atp_readb_io (dev,0 ,0x1f ) &0x01 ) !=0 ) +atp_writeb_io (dev,0 ,0x19 ,0 ); } - j =inb (wkport +0x57 ) &0x0f ; + j =atp_readb_io (dev,0 ,0x17 ) &0x0f ;if (j ==0x0f ) { goto u3p_in; }
@@ -1801,19 +1801,19 @@ u3p_out: }continue ; u3p_in: -outb (0x09 , wkport +0x54 ); -outb (0x20 , wkport +0x58 ); +atp_writeb_io (dev,0 ,0x14 ,0x09 ); +atp_writeb_io (dev,0 ,0x18 ,0x20 ); k =0 ; u3p_in1: - j =inb (wkport +0x5f ); + j =atp_readb_io (dev,0 ,0x1f );if ((j &0x01 ) !=0 ) { - mbuf[k++] =inb (wkport +0x59 ); + mbuf[k++] =atp_readb_io (dev,0 ,0x19 ); goto u3p_in1; }if ((j &0x80 ) ==0x00 ) { goto u3p_in1; } - j =inb (wkport +0x57 ) &0x0f ; + j =atp_readb_io (dev,0 ,0x17 ) &0x0f ;if (j ==0x0f ) { goto u3p_in; }
@@ -1825,14 +1825,14 @@ u3p_in1: }continue ; u3p_cmd: -outb (0x30 , wkport +0x50 ); -outb (0x00 , wkport +0x54 ); -outb (0x08 , wkport +0x58 ); +atp_writeb_io (dev,0 ,0x10 ,0x30 ); +atp_writeb_io (dev,0 ,0x14 ,0x00 ); +atp_writeb_io (dev,0 ,0x18 ,0x08 ); -while ((inb (wkport +0x5f ) &0x80 ) ==0x00 ) +while ((atp_readb_io (dev,0 ,0x1f ) &0x80 ) ==0x00 )cpu_relax (); - j =inb (wkport +0x57 ); + j =atp_readb_io (dev,0 ,0x17 );if (j !=0x16 ) {if (j ==0x4e ) { goto u3p_out;
@@ -1856,42 +1856,42 @@ u3p_cmd:continue ; } chg_wide: -outb (0x01 , wkport +0x5b ); -outb (satn[0 ], wkport +0x43 ); -outb (satn[1 ], wkport +0x44 ); -outb (satn[2 ], wkport +0x45 ); -outb (satn[3 ], wkport +0x46 ); -outb (satn[4 ], wkport +0x47 ); -outb (satn[5 ], wkport +0x48 ); -outb (0 , wkport +0x4f ); -outb (dev->id[0 ][i].devsp, wkport +0x51 ); -outb (0 , wkport +0x52 ); -outb (satn[6 ], wkport +0x53 ); -outb (satn[7 ], wkport +0x54 ); -outb (satn[8 ], wkport +0x58 ); - -while ((inb (wkport +0x5f ) &0x80 ) ==0x00 ) +atp_writeb_io (dev,0 ,0x1b ,0x01 ); +atp_writeb_io (dev,0 ,3 , satn[0 ]); +atp_writeb_io (dev,0 ,4 , satn[1 ]); +atp_writeb_io (dev,0 ,5 , satn[2 ]); +atp_writeb_io (dev,0 ,6 , satn[3 ]); +atp_writeb_io (dev,0 ,7 , satn[4 ]); +atp_writeb_io (dev,0 ,8 , satn[5 ]); +atp_writeb_io (dev,0 ,0x0f ,0 ); +atp_writeb_io (dev,0 ,0x11 , dev->id[0 ][i].devsp); +atp_writeb_io (dev,0 ,0x12 ,0 ); +atp_writeb_io (dev,0 ,0x13 , satn[6 ]); +atp_writeb_io (dev,0 ,0x14 , satn[7 ]); +atp_writeb_io (dev,0 ,0x18 , satn[8 ]); + +while ((atp_readb_io (dev,0 ,0x1f ) &0x80 ) ==0x00 )cpu_relax (); -if (inb (wkport +0x57 ) !=0x11 &&inb (wkport +0x57 ) !=0x8e ) +if (atp_readb_io (dev,0 ,0x17 ) !=0x11 &&atp_readb_io (dev,0 ,0x17 ) !=0x8e )continue ; -while (inb (wkport +0x57 ) !=0x8e ) +while (atp_readb_io (dev,0 ,0x17 ) !=0x8e )cpu_relax (); try_wide: j =0 ; -outb (0x05 , wkport +0x54 ); -outb (0x20 , wkport +0x58 ); +atp_writeb_io (dev,0 ,0x14 ,0x05 ); +atp_writeb_io (dev,0 ,0x18 ,0x20 ); -while ((inb (wkport +0x5f ) &0x80 ) ==0 ) { -if ((inb (wkport +0x5f ) &0x01 ) !=0 ) -outb (wide[j++], wkport +0x59 ); +while ((atp_readb_io (dev,0 ,0x1f ) &0x80 ) ==0 ) { +if ((atp_readb_io (dev,0 ,0x1f ) &0x01 ) !=0 ) +atp_writeb_io (dev,0 ,0x19 , wide[j++]); } -while ((inb (wkport +0x57 ) &0x80 ) ==0x00 ) +while ((atp_readb_io (dev,0 ,0x17 ) &0x80 ) ==0x00 )cpu_relax (); - j =inb (wkport +0x57 ) &0x0f ; + j =atp_readb_io (dev,0 ,0x17 ) &0x0f ;if (j ==0x0f ) { goto widep_in; }
@@ -1903,12 +1903,12 @@ try_wide: }continue ; widep_out: -outb (0x20 , wkport +0x58 ); -while ((inb (wkport +0x5f ) &0x80 ) ==0 ) { -if ((inb (wkport +0x5f ) &0x01 ) !=0 ) -outb (0 , wkport +0x59 ); +atp_writeb_io (dev,0 ,0x18 ,0x20 ); +while ((atp_readb_io (dev,0 ,0x1f ) &0x80 ) ==0 ) { +if ((atp_readb_io (dev,0 ,0x1f ) &0x01 ) !=0 ) +atp_writeb_io (dev,0 ,0x19 ,0 ); } - j =inb (wkport +0x57 ) &0x0f ; + j =atp_readb_io (dev,0 ,0x17 ) &0x0f ;if (j ==0x0f ) { goto widep_in; }
@@ -1920,19 +1920,19 @@ widep_out: }continue ; widep_in: -outb (0xff , wkport +0x54 ); -outb (0x20 , wkport +0x58 ); +atp_writeb_io (dev,0 ,0x14 ,0xff ); +atp_writeb_io (dev,0 ,0x18 ,0x20 ); k =0 ; widep_in1: - j =inb (wkport +0x5f ); + j =atp_readb_io (dev,0 ,0x1f );if ((j &0x01 ) !=0 ) { - mbuf[k++] =inb (wkport +0x59 ); + mbuf[k++] =atp_readb_io (dev,0 ,0x19 ); goto widep_in1; }if ((j &0x80 ) ==0x00 ) { goto widep_in1; } - j =inb (wkport +0x57 ) &0x0f ; + j =atp_readb_io (dev,0 ,0x17 ) &0x0f ;if (j ==0x0f ) { goto widep_in; }
@@ -1944,14 +1944,14 @@ widep_in1: }continue ; widep_cmd: -outb (0x30 , wkport +0x50 ); -outb (0x00 , wkport +0x54 ); -outb (0x08 , wkport +0x58 ); +atp_writeb_io (dev,0 ,0x10 ,0x30 ); +atp_writeb_io (dev,0 ,0x14 ,0x00 ); +atp_writeb_io (dev,0 ,0x18 ,0x08 ); -while ((inb (wkport +0x5f ) &0x80 ) ==0x00 ) +while ((atp_readb_io (dev,0 ,0x1f ) &0x80 ) ==0x00 )cpu_relax (); - j =inb (wkport +0x57 ); + j =atp_readb_io (dev,0 ,0x17 );if (j !=0x16 ) {if (j ==0x4e ) { goto widep_out;
@@ -1996,56 +1996,56 @@ set_sync:if ((m & dev->wide_id[0 ]) !=0 ) { j |=0x01 ; } -outb (j, wkport +0x5b ); -outb (satn[0 ], wkport +0x43 ); -outb (satn[1 ], wkport +0x44 ); -outb (satn[2 ], wkport +0x45 ); -outb (satn[3 ], wkport +0x46 ); -outb (satn[4 ], wkport +0x47 ); -outb (satn[5 ], wkport +0x48 ); -outb (0 , wkport +0x4f ); -outb (dev->id[0 ][i].devsp, wkport +0x51 ); -outb (0 , wkport +0x52 ); -outb (satn[6 ], wkport +0x53 ); -outb (satn[7 ], wkport +0x54 ); -outb (satn[8 ], wkport +0x58 ); - -while ((inb (wkport +0x5f ) &0x80 ) ==0x00 ) +atp_writeb_io (dev,0 ,0x1b , j); +atp_writeb_io (dev,0 ,3 , satn[0 ]); +atp_writeb_io (dev,0 ,4 , satn[1 ]); +atp_writeb_io (dev,0 ,5 , satn[2 ]); +atp_writeb_io (dev,0 ,6 , satn[3 ]); +atp_writeb_io (dev,0 ,7 , satn[4 ]); +atp_writeb_io (dev,0 ,8 , satn[5 ]); +atp_writeb_io (dev,0 ,0x0f ,0 ); +atp_writeb_io (dev,0 ,0x11 , dev->id[0 ][i].devsp); +atp_writeb_io (dev,0 ,0x12 ,0 ); +atp_writeb_io (dev,0 ,0x13 , satn[6 ]); +atp_writeb_io (dev,0 ,0x14 , satn[7 ]); +atp_writeb_io (dev,0 ,0x18 , satn[8 ]); + +while ((atp_readb_io (dev,0 ,0x1f ) &0x80 ) ==0x00 )cpu_relax (); -if ((inb (wkport +0x57 ) !=0x11 ) && (inb (wkport +0x57 ) !=0x8e )) { +if (atp_readb_io (dev,0 ,0x17 ) !=0x11 &&atp_readb_io (dev,0 ,0x17 ) !=0x8e ) {continue ; } -while (inb (wkport +0x57 ) !=0x8e ) +while (atp_readb_io (dev,0 ,0x17 ) !=0x8e )cpu_relax (); try_sync: j =0 ; -outb (0x06 , wkport +0x54 ); -outb (0x20 , wkport +0x58 ); +atp_writeb_io (dev,0 ,0x14 ,0x06 ); +atp_writeb_io (dev,0 ,0x18 ,0x20 ); -while ((inb (wkport +0x5f ) &0x80 ) ==0 ) { -if ((inb (wkport +0x5f ) &0x01 ) !=0 ) { +while ((atp_readb_io (dev,0 ,0x1f ) &0x80 ) ==0 ) { +if ((atp_readb_io (dev,0 ,0x1f ) &0x01 ) !=0 ) {if ((m & dev->wide_id[0 ]) !=0 ) {if ((m & dev->ultra_map[0 ]) !=0 ) { -outb (synuw[j++], wkport +0x59 ); +atp_writeb_io (dev,0 ,0x19 , synuw[j++]); }else { -outb (synw[j++], wkport +0x59 ); +atp_writeb_io (dev,0 ,0x19 , synw[j++]); } }else {if ((m & dev->ultra_map[0 ]) !=0 ) { -outb (synu[j++], wkport +0x59 ); +atp_writeb_io (dev,0 ,0x19 , synu[j++]); }else { -outb (synn[j++], wkport +0x59 ); +atp_writeb_io (dev,0 ,0x19 , synn[j++]); } } } } -while ((inb (wkport +0x57 ) &0x80 ) ==0x00 ) +while ((atp_readb_io (dev,0 ,0x17 ) &0x80 ) ==0x00 )cpu_relax (); - j =inb (wkport +0x57 ) &0x0f ; + j =atp_readb_io (dev,0 ,0x17 ) &0x0f ;if (j ==0x0f ) { goto phase_ins; }
@@ -2057,12 +2057,12 @@ try_sync: }continue ; phase_outs: -outb (0x20 , wkport +0x58 ); -while ((inb (wkport +0x5f ) &0x80 ) ==0x00 ) { -if ((inb (wkport +0x5f ) &0x01 ) !=0x00 ) -outb (0x00 , wkport +0x59 ); +atp_writeb_io (dev,0 ,0x18 ,0x20 ); +while ((atp_readb_io (dev,0 ,0x1f ) &0x80 ) ==0x00 ) { +if ((atp_readb_io (dev,0 ,0x1f ) &0x01 ) !=0x00 ) +atp_writeb_io (dev,0 ,0x19 ,0x00 ); } - j =inb (wkport +0x57 ); + j =atp_readb_io (dev,0 ,0x17 );if (j ==0x85 ) { goto tar_dcons; }
@@ -2078,23 +2078,23 @@ phase_outs: }continue ; phase_ins: -outb (0x06 , wkport +0x54 ); -outb (0x20 , wkport +0x58 ); +atp_writeb_io (dev,0 ,0x14 ,0x06 ); +atp_writeb_io (dev,0 ,0x18 ,0x20 ); k =0 ; phase_ins1: - j =inb (wkport +0x5f ); + j =atp_readb_io (dev,0 ,0x1f );if ((j &0x01 ) !=0x00 ) { - mbuf[k++] =inb (wkport +0x59 ); + mbuf[k++] =atp_readb_io (dev,0 ,0x19 ); goto phase_ins1; }if ((j &0x80 ) ==0x00 ) { goto phase_ins1; } -while ((inb (wkport +0x57 ) &0x80 ) ==0x00 ) +while ((atp_readb_io (dev,0 ,0x17 ) &0x80 ) ==0x00 )cpu_relax (); - j =inb (wkport +0x57 ); + j =atp_readb_io (dev,0 ,0x17 );if (j ==0x85 ) { goto tar_dcons; }
@@ -2110,15 +2110,15 @@ phase_ins1: }continue ; phase_cmds: -outb (0x30 , wkport +0x50 ); +atp_writeb_io (dev,0 ,0x10 ,0x30 ); tar_dcons: -outb (0x00 , wkport +0x54 ); -outb (0x08 , wkport +0x58 ); +atp_writeb_io (dev,0 ,0x14 ,0x00 ); +atp_writeb_io (dev,0 ,0x18 ,0x08 ); -while ((inb (wkport +0x5f ) &0x80 ) ==0x00 ) +while ((atp_readb_io (dev,0 ,0x1f ) &0x80 ) ==0x00 )cpu_relax (); - j =inb (wkport +0x57 ); + j =atp_readb_io (dev,0 ,0x17 );if (j !=0x16 ) {continue ; }
@@ -2375,7 +2375,7 @@ flash_ok_880:outb (0x20 , base_io +0x51 );tscam (shpnt); -is880 (p, base_io); +is880 (p);outb (0xb0 , base_io +0x38 ); shpnt->max_id =16 ; shpnt->this_id = host_id;
Signature · 1 line
Ondrej Zary
PATCH 21/52 atp870u: Convert is885() to use wrappers
In reply to Ondrej Zary--- drivers/scsi/atp870u.c | 358 ++++++++++++++++++++++++------------------------ 1 file changed, 179 insertions(+), 179 deletions(-)
drivers/scsi/atp870u.c +179 -179
@@ -41,7 +41,7 @@static struct scsi_host_template atp870u_template;static void send_s870 (struct atp_unit *dev,unsigned char c); -static void is885 (struct atp_unit *dev,unsigned int wkport,unsigned char c); +static void is885 (struct atp_unit *dev,unsigned char c);static void tscam_885 (void );static inline void atp_writeb_base (struct atp_unit *atp,u8 reg,u8 val)
@@ -2521,9 +2521,9 @@ flash_ok_885:tscam_885 ();printk (KERN_INFO " Scanning Channel A SCSI Device ...\n" ); -is885 (p, base_io +0x80 ,0 ); +is885 (p,0 );printk (KERN_INFO " Scanning Channel B SCSI Device ...\n" ); -is885 (p, base_io +0xc0 ,1 ); +is885 (p,1 ); k =inb (base_io +0x28 ) &0xcf ; k |=0xc0 ;
@@ -2825,7 +2825,7 @@ static void tscam_885(void) -static void is885 (struct atp_unit *dev,unsigned int wkport,unsigned char c) +static void is885 (struct atp_unit *dev,unsigned char c) {unsigned char i, j, k, rmb, n, lvdmode;unsigned short int m;
@@ -2839,7 +2839,7 @@ static void is885(struct atp_unit *dev, unsigned int wkport,unsigned char c)static unsigned char wide[6 ] = {0x80 ,1 ,2 ,3 ,1 ,0 };static unsigned char u3[9 ] = {0x80 ,1 ,6 ,4 ,0x09 ,00 ,0x0e ,0x01 ,0x02 }; - lvdmode=inb (wkport +0x1b ) >>7 ; + lvdmode=atp_readb_io (dev, c,0x1b ) >>7 ;for (i =0 ; i <16 ; i++) { m =1 ;
@@ -2851,93 +2851,93 @@ static void is885(struct atp_unit *dev, unsigned int wkport,unsigned char c)printk (KERN_INFO " ID: %2d Host Adapter\n" , dev->host_id[c]);continue ; } -outb (0x01 , wkport +0x1b ); -outb (0x08 , wkport +0x01 ); -outb (0x7f , wkport +0x02 ); -outb (satn[0 ], wkport +0x03 ); -outb (satn[1 ], wkport +0x04 ); -outb (satn[2 ], wkport +0x05 ); -outb (satn[3 ], wkport +0x06 ); -outb (satn[4 ], wkport +0x07 ); -outb (satn[5 ], wkport +0x08 ); -outb (0 , wkport +0x0f ); -outb (dev->id[c][i].devsp, wkport +0x11 ); +atp_writeb_io (dev, c,0x1b ,0x01 ); +atp_writeb_io (dev, c,1 ,0x08 ); +atp_writeb_io (dev, c,2 ,0x7f ); +atp_writeb_io (dev, c,3 , satn[0 ]); +atp_writeb_io (dev, c,4 , satn[1 ]); +atp_writeb_io (dev, c,5 , satn[2 ]); +atp_writeb_io (dev, c,6 , satn[3 ]); +atp_writeb_io (dev, c,7 , satn[4 ]); +atp_writeb_io (dev, c,8 , satn[5 ]); +atp_writeb_io (dev, c,0x0f ,0 ); +atp_writeb_io (dev, c,0x11 , dev->id[c][i].devsp); -outb (0 , wkport +0x12 ); -outb (satn[6 ], wkport +0x13 ); -outb (satn[7 ], wkport +0x14 ); +atp_writeb_io (dev, c,0x12 ,0 ); +atp_writeb_io (dev, c,0x13 , satn[6 ]); +atp_writeb_io (dev, c,0x14 , satn[7 ]); j = i;if ((j &0x08 ) !=0 ) { j = (j &0x07 ) |0x40 ; } -outb (j, wkport +0x15 ); -outb (satn[8 ], wkport +0x18 ); +atp_writeb_io (dev, c,0x15 , j); +atp_writeb_io (dev, c,0x18 , satn[8 ]); -while ((inb (wkport +0x1f ) &0x80 ) ==0x00 ) +while ((atp_readb_io (dev, c,0x1f ) &0x80 ) ==0x00 )cpu_relax (); -if ((inb (wkport +0x17 ) !=0x11 ) && (inb (wkport +0x17 ) !=0x8e )) { +if ((atp_readb_io (dev, c,0x17 ) !=0x11 ) && (atp_readb_io (dev, c,0x17 ) !=0x8e )) {continue ; } -while (inb (wkport +0x17 ) !=0x8e ) +while (atp_readb_io (dev, c,0x17 ) !=0x8e )cpu_relax (); dev->active_id[c] |= m; -outb (0x30 , wkport +0x10 ); -outb (0x00 , wkport +0x14 ); +atp_writeb_io (dev, c,0x10 ,0x30 ); +atp_writeb_io (dev, c,0x14 ,0x00 ); phase_cmd: -outb (0x08 , wkport +0x18 ); -while ((inb (wkport +0x1f ) &0x80 ) ==0x00 ) +atp_writeb_io (dev, c,0x18 ,0x08 ); +while ((atp_readb_io (dev, c,0x1f ) &0x80 ) ==0x00 )cpu_relax (); - j =inb (wkport +0x17 ); + j =atp_readb_io (dev, c,0x17 );if (j !=0x16 ) { -outb (0x41 , wkport +0x10 ); +atp_writeb_io (dev, c,0x10 ,0x41 ); goto phase_cmd; } sel_ok: -outb (inqd[0 ], wkport +0x03 ); -outb (inqd[1 ], wkport +0x04 ); -outb (inqd[2 ], wkport +0x05 ); -outb (inqd[3 ], wkport +0x06 ); -outb (inqd[4 ], wkport +0x07 ); -outb (inqd[5 ], wkport +0x08 ); -outb (0 , wkport +0x0f ); -outb (dev->id[c][i].devsp, wkport +0x11 ); -outb (0 , wkport +0x12 ); -outb (inqd[6 ], wkport +0x13 ); -outb (inqd[7 ], wkport +0x14 ); -outb (inqd[8 ], wkport +0x18 ); -while ((inb (wkport +0x1f ) &0x80 ) ==0x00 ) +atp_writeb_io (dev, c,3 , inqd[0 ]); +atp_writeb_io (dev, c,4 , inqd[1 ]); +atp_writeb_io (dev, c,5 , inqd[2 ]); +atp_writeb_io (dev, c,6 , inqd[3 ]); +atp_writeb_io (dev, c,7 , inqd[4 ]); +atp_writeb_io (dev, c,8 , inqd[5 ]); +atp_writeb_io (dev, c,0x0f ,0 ); +atp_writeb_io (dev, c,0x11 , dev->id[c][i].devsp); +atp_writeb_io (dev, c,0x12 ,0 ); +atp_writeb_io (dev, c,0x13 , inqd[6 ]); +atp_writeb_io (dev, c,0x14 , inqd[7 ]); +atp_writeb_io (dev, c,0x18 , inqd[8 ]); +while ((atp_readb_io (dev, c,0x1f ) &0x80 ) ==0x00 )cpu_relax (); -if ((inb (wkport +0x17 ) !=0x11 ) && (inb (wkport +0x17 ) !=0x8e )) { +if ((atp_readb_io (dev, c,0x17 ) !=0x11 ) && (atp_readb_io (dev, c,0x17 ) !=0x8e )) {continue ; } -while (inb (wkport +0x17 ) !=0x8e ) +while (atp_readb_io (dev, c,0x17 ) !=0x8e )cpu_relax (); -outb (0x00 , wkport +0x1b ); -outb (0x08 , wkport +0x18 ); +atp_writeb_io (dev, c,0x1b ,0x00 ); +atp_writeb_io (dev, c,0x18 ,0x08 ); j =0 ; rd_inq_data: - k =inb (wkport +0x1f ); + k =atp_readb_io (dev, c,0x1f );if ((k &0x01 ) !=0 ) { - mbuf[j++] =inb (wkport +0x19 ); + mbuf[j++] =atp_readb_io (dev, c,0x19 ); goto rd_inq_data; }if ((k &0x80 ) ==0 ) { goto rd_inq_data; } - j =inb (wkport +0x17 ); + j =atp_readb_io (dev, c,0x17 );if (j ==0x16 ) { goto inq_ok; } -outb (0x46 , wkport +0x10 ); -outb (0 , wkport +0x12 ); -outb (0 , wkport +0x13 ); -outb (0 , wkport +0x14 ); -outb (0x08 , wkport +0x18 ); -while ((inb (wkport +0x1f ) &0x80 ) ==0x00 ) +atp_writeb_io (dev, c,0x10 ,0x46 ); +atp_writeb_io (dev, c,0x12 ,0 ); +atp_writeb_io (dev, c,0x13 ,0 ); +atp_writeb_io (dev, c,0x14 ,0 ); +atp_writeb_io (dev, c,0x18 ,0x08 ); +while ((atp_readb_io (dev, c,0x1f ) &0x80 ) ==0x00 )cpu_relax (); -if (inb (wkport +0x17 ) !=0x16 ) { +if (atp_readb_io (dev, c,0x17 ) !=0x16 ) { goto sel_ok; } inq_ok:
@@ -2959,40 +2959,40 @@ inq_ok: goto chg_wide; } -outb (0x01 , wkport +0x1b ); -outb (satn[0 ], wkport +0x03 ); -outb (satn[1 ], wkport +0x04 ); -outb (satn[2 ], wkport +0x05 ); -outb (satn[3 ], wkport +0x06 ); -outb (satn[4 ], wkport +0x07 ); -outb (satn[5 ], wkport +0x08 ); -outb (0 , wkport +0x0f ); -outb (dev->id[c][i].devsp, wkport +0x11 ); -outb (0 , wkport +0x12 ); -outb (satn[6 ], wkport +0x13 ); -outb (satn[7 ], wkport +0x14 ); -outb (satn[8 ], wkport +0x18 ); - -while ((inb (wkport +0x1f ) &0x80 ) ==0x00 ) +atp_writeb_io (dev, c,0x1b ,0x01 ); +atp_writeb_io (dev, c,3 , satn[0 ]); +atp_writeb_io (dev, c,4 , satn[1 ]); +atp_writeb_io (dev, c,5 , satn[2 ]); +atp_writeb_io (dev, c,6 , satn[3 ]); +atp_writeb_io (dev, c,7 , satn[4 ]); +atp_writeb_io (dev, c,8 , satn[5 ]); +atp_writeb_io (dev, c,0x0f ,0 ); +atp_writeb_io (dev, c,0x11 , dev->id[c][i].devsp); +atp_writeb_io (dev, c,0x12 ,0 ); +atp_writeb_io (dev, c,0x13 , satn[6 ]); +atp_writeb_io (dev, c,0x14 , satn[7 ]); +atp_writeb_io (dev, c,0x18 , satn[8 ]); + +while ((atp_readb_io (dev, c,0x1f ) &0x80 ) ==0x00 )cpu_relax (); -if ((inb (wkport +0x17 ) !=0x11 ) && (inb (wkport +0x17 ) !=0x8e )) { +if ((atp_readb_io (dev, c,0x17 ) !=0x11 ) && (atp_readb_io (dev, c,0x17 ) !=0x8e )) {continue ; } -while (inb (wkport +0x17 ) !=0x8e ) +while (atp_readb_io (dev, c,0x17 ) !=0x8e )cpu_relax (); try_u3: j =0 ; -outb (0x09 , wkport +0x14 ); -outb (0x20 , wkport +0x18 ); +atp_writeb_io (dev, c,0x14 ,0x09 ); +atp_writeb_io (dev, c,0x18 ,0x20 ); -while ((inb (wkport +0x1f ) &0x80 ) ==0 ) { -if ((inb (wkport +0x1f ) &0x01 ) !=0 ) -outb (u3[j++], wkport +0x19 ); +while ((atp_readb_io (dev, c,0x1f ) &0x80 ) ==0 ) { +if ((atp_readb_io (dev, c,0x1f ) &0x01 ) !=0 ) +atp_writeb_io (dev, c,0x19 , u3[j++]);cpu_relax (); } -while ((inb (wkport +0x17 ) &0x80 ) ==0x00 ) +while ((atp_readb_io (dev, c,0x17 ) &0x80 ) ==0x00 )cpu_relax (); - j =inb (wkport +0x17 ) &0x0f ; + j =atp_readb_io (dev, c,0x17 ) &0x0f ;if (j ==0x0f ) { goto u3p_in; }
@@ -3004,13 +3004,13 @@ try_u3: }continue ; u3p_out: -outb (0x20 , wkport +0x18 ); -while ((inb (wkport +0x1f ) &0x80 ) ==0 ) { -if ((inb (wkport +0x1f ) &0x01 ) !=0 ) -outb (0 , wkport +0x19 ); +atp_writeb_io (dev, c,0x18 ,0x20 ); +while ((atp_readb_io (dev, c,0x1f ) &0x80 ) ==0 ) { +if ((atp_readb_io (dev, c,0x1f ) &0x01 ) !=0 ) +atp_writeb_io (dev, c,0x19 ,0 );cpu_relax (); } - j =inb (wkport +0x17 ) &0x0f ; + j =atp_readb_io (dev, c,0x17 ) &0x0f ;if (j ==0x0f ) { goto u3p_in; }
@@ -3022,19 +3022,19 @@ u3p_out: }continue ; u3p_in: -outb (0x09 , wkport +0x14 ); -outb (0x20 , wkport +0x18 ); +atp_writeb_io (dev, c,0x14 ,0x09 ); +atp_writeb_io (dev, c,0x18 ,0x20 ); k =0 ; u3p_in1: - j =inb (wkport +0x1f ); + j =atp_readb_io (dev, c,0x1f );if ((j &0x01 ) !=0 ) { - mbuf[k++] =inb (wkport +0x19 ); + mbuf[k++] =atp_readb_io (dev, c,0x19 ); goto u3p_in1; }if ((j &0x80 ) ==0x00 ) { goto u3p_in1; } - j =inb (wkport +0x17 ) &0x0f ; + j =atp_readb_io (dev, c,0x17 ) &0x0f ;if (j ==0x0f ) { goto u3p_in; }
@@ -3046,11 +3046,11 @@ u3p_in1: }continue ; u3p_cmd: -outb (0x30 , wkport +0x10 ); -outb (0x00 , wkport +0x14 ); -outb (0x08 , wkport +0x18 ); -while ((inb (wkport +0x1f ) &0x80 ) ==0x00 ); - j =inb (wkport +0x17 ); +atp_writeb_io (dev, c,0x10 ,0x30 ); +atp_writeb_io (dev, c,0x14 ,0x00 ); +atp_writeb_io (dev, c,0x18 ,0x08 ); +while ((atp_readb_io (dev, c,0x1f ) &0x80 ) ==0x00 ); + j =atp_readb_io (dev, c,0x17 );if (j !=0x16 ) {if (j ==0x4e ) { goto u3p_out;
@@ -3077,40 +3077,40 @@ u3p_cmd:continue ; } chg_wide: -outb (0x01 , wkport +0x1b ); -outb (satn[0 ], wkport +0x03 ); -outb (satn[1 ], wkport +0x04 ); -outb (satn[2 ], wkport +0x05 ); -outb (satn[3 ], wkport +0x06 ); -outb (satn[4 ], wkport +0x07 ); -outb (satn[5 ], wkport +0x08 ); -outb (0 , wkport +0x0f ); -outb (dev->id[c][i].devsp, wkport +0x11 ); -outb (0 , wkport +0x12 ); -outb (satn[6 ], wkport +0x13 ); -outb (satn[7 ], wkport +0x14 ); -outb (satn[8 ], wkport +0x18 ); - -while ((inb (wkport +0x1f ) &0x80 ) ==0x00 ) +atp_writeb_io (dev, c,0x1b ,0x01 ); +atp_writeb_io (dev, c,3 , satn[0 ]); +atp_writeb_io (dev, c,4 , satn[1 ]); +atp_writeb_io (dev, c,5 , satn[2 ]); +atp_writeb_io (dev, c,6 , satn[3 ]); +atp_writeb_io (dev, c,7 , satn[4 ]); +atp_writeb_io (dev, c,8 , satn[5 ]); +atp_writeb_io (dev, c,0x0f ,0 ); +atp_writeb_io (dev, c,0x11 , dev->id[c][i].devsp); +atp_writeb_io (dev, c,0x12 ,0 ); +atp_writeb_io (dev, c,0x13 , satn[6 ]); +atp_writeb_io (dev, c,0x14 , satn[7 ]); +atp_writeb_io (dev, c,0x18 , satn[8 ]); + +while ((atp_readb_io (dev, c,0x1f ) &0x80 ) ==0x00 )cpu_relax (); -if ((inb (wkport +0x17 ) !=0x11 ) && (inb (wkport +0x17 ) !=0x8e )) { +if ((atp_readb_io (dev, c,0x17 ) !=0x11 ) && (atp_readb_io (dev, c,0x17 ) !=0x8e )) {continue ; } -while (inb (wkport +0x17 ) !=0x8e ) +while (atp_readb_io (dev, c,0x17 ) !=0x8e )cpu_relax (); try_wide: j =0 ; -outb (0x05 , wkport +0x14 ); -outb (0x20 , wkport +0x18 ); +atp_writeb_io (dev, c,0x14 ,0x05 ); +atp_writeb_io (dev, c,0x18 ,0x20 ); -while ((inb (wkport +0x1f ) &0x80 ) ==0 ) { -if ((inb (wkport +0x1f ) &0x01 ) !=0 ) -outb (wide[j++], wkport +0x19 ); +while ((atp_readb_io (dev, c,0x1f ) &0x80 ) ==0 ) { +if ((atp_readb_io (dev, c,0x1f ) &0x01 ) !=0 ) +atp_writeb_io (dev, c,0x19 , wide[j++]);cpu_relax (); } -while ((inb (wkport +0x17 ) &0x80 ) ==0x00 ) +while ((atp_readb_io (dev, c,0x17 ) &0x80 ) ==0x00 )cpu_relax (); - j =inb (wkport +0x17 ) &0x0f ; + j =atp_readb_io (dev, c,0x17 ) &0x0f ;if (j ==0x0f ) { goto widep_in; }
@@ -3122,13 +3122,13 @@ try_wide: }continue ; widep_out: -outb (0x20 , wkport +0x18 ); -while ((inb (wkport +0x1f ) &0x80 ) ==0 ) { -if ((inb (wkport +0x1f ) &0x01 ) !=0 ) -outb (0 , wkport +0x19 ); +atp_writeb_io (dev, c,0x18 ,0x20 ); +while ((atp_readb_io (dev, c,0x1f ) &0x80 ) ==0 ) { +if ((atp_readb_io (dev, c,0x1f ) &0x01 ) !=0 ) +atp_writeb_io (dev, c,0x19 ,0 );cpu_relax (); } - j =inb (wkport +0x17 ) &0x0f ; + j =atp_readb_io (dev, c,0x17 ) &0x0f ;if (j ==0x0f ) { goto widep_in; }
@@ -3140,19 +3140,19 @@ widep_out: }continue ; widep_in: -outb (0xff , wkport +0x14 ); -outb (0x20 , wkport +0x18 ); +atp_writeb_io (dev, c,0x14 ,0xff ); +atp_writeb_io (dev, c,0x18 ,0x20 ); k =0 ; widep_in1: - j =inb (wkport +0x1f ); + j =atp_readb_io (dev, c,0x1f );if ((j &0x01 ) !=0 ) { - mbuf[k++] =inb (wkport +0x19 ); + mbuf[k++] =atp_readb_io (dev, c,0x19 ); goto widep_in1; }if ((j &0x80 ) ==0x00 ) { goto widep_in1; } - j =inb (wkport +0x17 ) &0x0f ; + j =atp_readb_io (dev, c,0x17 ) &0x0f ;if (j ==0x0f ) { goto widep_in; }
@@ -3164,12 +3164,12 @@ widep_in1: }continue ; widep_cmd: -outb (0x30 , wkport +0x10 ); -outb (0x00 , wkport +0x14 ); -outb (0x08 , wkport +0x18 ); -while ((inb (wkport +0x1f ) &0x80 ) ==0x00 ) +atp_writeb_io (dev, c,0x10 ,0x30 ); +atp_writeb_io (dev, c,0x14 ,0x00 ); +atp_writeb_io (dev, c,0x18 ,0x08 ); +while ((atp_readb_io (dev, c,0x1f ) &0x80 ) ==0x00 )cpu_relax (); - j =inb (wkport +0x17 ); + j =atp_readb_io (dev, c,0x17 );if (j !=0x16 ) {if (j ==0x4e ) { goto widep_out;
@@ -3215,52 +3215,52 @@ set_sync:if ((m & dev->wide_id[c]) !=0 ) { j |=0x01 ; } -outb (j, wkport +0x1b ); -outb (satn[0 ], wkport +0x03 ); -outb (satn[1 ], wkport +0x04 ); -outb (satn[2 ], wkport +0x05 ); -outb (satn[3 ], wkport +0x06 ); -outb (satn[4 ], wkport +0x07 ); -outb (satn[5 ], wkport +0x08 ); -outb (0 , wkport +0x0f ); -outb (dev->id[c][i].devsp, wkport +0x11 ); -outb (0 , wkport +0x12 ); -outb (satn[6 ], wkport +0x13 ); -outb (satn[7 ], wkport +0x14 ); -outb (satn[8 ], wkport +0x18 ); - -while ((inb (wkport +0x1f ) &0x80 ) ==0x00 ) +atp_writeb_io (dev, c,0x1b , j); +atp_writeb_io (dev, c,3 , satn[0 ]); +atp_writeb_io (dev, c,4 , satn[1 ]); +atp_writeb_io (dev, c,5 , satn[2 ]); +atp_writeb_io (dev, c,6 , satn[3 ]); +atp_writeb_io (dev, c,7 , satn[4 ]); +atp_writeb_io (dev, c,8 , satn[5 ]); +atp_writeb_io (dev, c,0x0f ,0 ); +atp_writeb_io (dev, c,0x11 , dev->id[c][i].devsp); +atp_writeb_io (dev, c,0x12 ,0 ); +atp_writeb_io (dev, c,0x13 , satn[6 ]); +atp_writeb_io (dev, c,0x14 , satn[7 ]); +atp_writeb_io (dev, c,0x18 , satn[8 ]); + +while ((atp_readb_io (dev, c,0x1f ) &0x80 ) ==0x00 )cpu_relax (); -if ((inb (wkport +0x17 ) !=0x11 ) && (inb (wkport +0x17 ) !=0x8e )) { +if ((atp_readb_io (dev, c,0x17 ) !=0x11 ) && (atp_readb_io (dev, c,0x17 ) !=0x8e )) {continue ; } -while (inb (wkport +0x17 ) !=0x8e ) +while (atp_readb_io (dev, c,0x17 ) !=0x8e )cpu_relax (); try_sync: j =0 ; -outb (0x06 , wkport +0x14 ); -outb (0x20 , wkport +0x18 ); +atp_writeb_io (dev, c,0x14 ,0x06 ); +atp_writeb_io (dev, c,0x18 ,0x20 ); -while ((inb (wkport +0x1f ) &0x80 ) ==0 ) { -if ((inb (wkport +0x1f ) &0x01 ) !=0 ) { +while ((atp_readb_io (dev, c,0x1f ) &0x80 ) ==0 ) { +if ((atp_readb_io (dev, c,0x1f ) &0x01 ) !=0 ) {if ((m & dev->wide_id[c]) !=0 ) {if ((m & dev->ultra_map[c]) !=0 ) { -outb (synuw[j++], wkport +0x19 ); +atp_writeb_io (dev, c,0x19 , synuw[j++]); }else { -outb (synw[j++], wkport +0x19 ); +atp_writeb_io (dev, c,0x19 , synw[j++]); } }else {if ((m & dev->ultra_map[c]) !=0 ) { -outb (synu[j++], wkport +0x19 ); +atp_writeb_io (dev, c,0x19 , synu[j++]); }else { -outb (synn[j++], wkport +0x19 ); +atp_writeb_io (dev, c,0x19 , synn[j++]); } } } } -while ((inb (wkport +0x17 ) &0x80 ) ==0x00 ) +while ((atp_readb_io (dev, c,0x17 ) &0x80 ) ==0x00 )cpu_relax (); - j =inb (wkport +0x17 ) &0x0f ; + j =atp_readb_io (dev, c,0x17 ) &0x0f ;if (j ==0x0f ) { goto phase_ins; }
@@ -3272,13 +3272,13 @@ try_sync: }continue ; phase_outs: -outb (0x20 , wkport +0x18 ); -while ((inb (wkport +0x1f ) &0x80 ) ==0x00 ) { -if ((inb (wkport +0x1f ) &0x01 ) !=0x00 ) -outb (0x00 , wkport +0x19 ); +atp_writeb_io (dev, c,0x18 ,0x20 ); +while ((atp_readb_io (dev, c,0x1f ) &0x80 ) ==0x00 ) { +if ((atp_readb_io (dev, c,0x1f ) &0x01 ) !=0x00 ) +atp_writeb_io (dev, c,0x19 ,0x00 );cpu_relax (); } - j =inb (wkport +0x17 ); + j =atp_readb_io (dev, c,0x17 );if (j ==0x85 ) { goto tar_dcons; }
@@ -3294,20 +3294,20 @@ phase_outs: }continue ; phase_ins: -outb (0x06 , wkport +0x14 ); -outb (0x20 , wkport +0x18 ); +atp_writeb_io (dev, c,0x14 ,0x06 ); +atp_writeb_io (dev, c,0x18 ,0x20 ); k =0 ; phase_ins1: - j =inb (wkport +0x1f ); + j =atp_readb_io (dev, c,0x1f );if ((j &0x01 ) !=0x00 ) { - mbuf[k++] =inb (wkport +0x19 ); + mbuf[k++] =atp_readb_io (dev, c,0x19 ); goto phase_ins1; }if ((j &0x80 ) ==0x00 ) { goto phase_ins1; } -while ((inb (wkport +0x17 ) &0x80 ) ==0x00 ); - j =inb (wkport +0x17 ); +while ((atp_readb_io (dev, c,0x17 ) &0x80 ) ==0x00 ); + j =atp_readb_io (dev, c,0x17 );if (j ==0x85 ) { goto tar_dcons; }
@@ -3323,13 +3323,13 @@ phase_ins1: }continue ; phase_cmds: -outb (0x30 , wkport +0x10 ); +atp_writeb_io (dev, c,0x10 ,0x30 ); tar_dcons: -outb (0x00 , wkport +0x14 ); -outb (0x08 , wkport +0x18 ); -while ((inb (wkport +0x1f ) &0x80 ) ==0x00 ) +atp_writeb_io (dev, c,0x14 ,0x00 ); +atp_writeb_io (dev, c,0x18 ,0x08 ); +while ((atp_readb_io (dev, c,0x1f ) &0x80 ) ==0x00 )cpu_relax (); - j =inb (wkport +0x17 ); + j =atp_readb_io (dev, c,0x17 );if (j !=0x16 ) {continue ; }
@@ -3376,7 +3376,7 @@ tar_dcons:printk ("dev->id[%2d][%2d].devsp = %2x\n" ,c,i,dev->id[c][i].devsp);#endif } -outb (0x80 , wkport +0x16 ); +atp_writeb_io (dev, c,0x16 ,0x80 ); }module_init (atp870u_init);
Signature · 1 line
Ondrej Zary
PATCH 22/52 atp870u: Unify code format in is870(), is880() and is885()
In reply to Ondrej ZaryUnify code formatting in is870(), is880() and is885() functions to simplify comparing them.
--- drivers/scsi/atp870u.c | 170 ++++++++++++++++++++++++++++-------------------- 1 file changed, 101 insertions(+), 69 deletions(-)
drivers/scsi/atp870u.c +101 -69
@@ -1173,7 +1173,7 @@ static void is870(struct atp_unit *dev)static unsigned char synu[6 ] = {0x80 ,1 ,3 ,1 ,0x0c ,0x0e };static unsigned char synw[6 ] = {0x80 ,1 ,3 ,1 ,0x0c ,0x07 };static unsigned char wide[6 ] = {0x80 ,1 ,2 ,3 ,1 ,0 }; - +atp_writeb_io (dev,0 ,0x3a ,atp_readb_io (dev,0 ,0x3a ) |0x10 );for (i =0 ; i <16 ; i++) {
@@ -1230,8 +1230,10 @@ static void is870(struct atp_unit *dev) phase_cmd:atp_writeb_io (dev,0 ,0x18 ,0x08 ); +while ((atp_readb_io (dev,0 ,0x1f ) &0x80 ) ==0x00 )cpu_relax (); + j =atp_readb_io (dev,0 ,0x17 );if (j !=0x16 ) {atp_writeb_io (dev,0 ,0x10 ,0x41 );
@@ -1253,13 +1255,13 @@ sel_ok:while ((atp_readb_io (dev,0 ,0x1f ) &0x80 ) ==0x00 )cpu_relax (); - +if (atp_readb_io (dev,0 ,0x17 ) !=0x11 &&atp_readb_io (dev,0 ,0x17 ) !=0x8e )continue ;while (atp_readb_io (dev,0 ,0x17 ) !=0x8e )cpu_relax (); - +if (dev->chip_ver ==4 )atp_writeb_io (dev,0 ,0x1b ,0x00 );
@@ -1286,10 +1288,10 @@ rd_inq_data:while ((atp_readb_io (dev,0 ,0x1f ) &0x80 ) ==0x00 )cpu_relax (); - -if (atp_readb_io (dev,0 ,0x17 ) !=0x16 ) { + +if (atp_readb_io (dev,0 ,0x17 ) !=0x16 ) goto sel_ok; - } + inq_ok: mbuf[36 ] =0 ;printk (KERN_INFO " ID: %2d %s\n" , i, &mbuf[8 ]);
@@ -1321,13 +1323,13 @@ inq_ok:while ((atp_readb_io (dev,0 ,0x1f ) &0x80 ) ==0x00 )cpu_relax (); - +if (atp_readb_io (dev,0 ,0x17 ) !=0x11 &&atp_readb_io (dev,0 ,0x17 ) !=0x8e )continue ;while (atp_readb_io (dev,0 ,0x17 ) !=0x8e )cpu_relax (); - + try_wide: j =0 ;atp_writeb_io (dev,0 ,0x14 ,0x05 );
@@ -1337,10 +1339,10 @@ try_wide:if ((atp_readb_io (dev,0 ,0x1f ) &0x01 ) !=0 )atp_writeb_io (dev,0 ,0x19 , wide[j++]); } - +while ((atp_readb_io (dev,0 ,0x17 ) &0x80 ) ==0x00 )cpu_relax (); - + j =atp_readb_io (dev,0 ,0x17 ) &0x0f ;if (j ==0x0f ) { goto widep_in;
@@ -1449,13 +1451,13 @@ set_sync:while ((atp_readb_io (dev,0 ,0x1f ) &0x80 ) ==0x00 )cpu_relax (); - +if (atp_readb_io (dev,0 ,0x17 ) !=0x11 &&atp_readb_io (dev,0 ,0x17 ) !=0x8e )continue ;while (atp_readb_io (dev,0 ,0x17 ) !=0x8e )cpu_relax (); - + try_sync: j =0 ;atp_writeb_io (dev,0 ,0x14 ,0x06 );
@@ -1474,10 +1476,10 @@ try_sync: } } } - +while ((atp_readb_io (dev,0 ,0x17 ) &0x80 ) ==0x00 )cpu_relax (); - + j =atp_readb_io (dev,0 ,0x17 ) &0x0f ;if (j ==0x0f ) { goto phase_ins;
@@ -1526,7 +1528,7 @@ phase_ins1:while ((atp_readb_io (dev,0 ,0x17 ) &0x80 ) ==0x00 )cpu_relax (); - + j =atp_readb_io (dev,0 ,0x17 );if (j ==0x85 ) { goto tar_dcons;
@@ -1547,10 +1549,10 @@ phase_cmds: tar_dcons:atp_writeb_io (dev,0 ,0x14 ,0x00 );atp_writeb_io (dev,0 ,0x18 ,0x08 ); - +while ((atp_readb_io (dev,0 ,0x1f ) &0x80 ) ==0x00 )cpu_relax (); - + j =atp_readb_io (dev,0 ,0x17 );if (j !=0x16 ) {continue ;
@@ -1649,7 +1651,7 @@ static void is880(struct atp_unit *dev)while (atp_readb_io (dev,0 ,0x17 ) !=0x8e )cpu_relax (); - + dev->active_id[0 ] |= m;atp_writeb_io (dev,0 ,0x10 ,0x30 );
@@ -1657,7 +1659,7 @@ static void is880(struct atp_unit *dev) phase_cmd:atp_writeb_io (dev,0 ,0x18 ,0x08 ); - +while ((atp_readb_io (dev,0 ,0x1f ) &0x80 ) ==0x00 )cpu_relax ();
@@ -1679,16 +1681,16 @@ sel_ok:atp_writeb_io (dev,0 ,0x13 , inqd[6 ]);atp_writeb_io (dev,0 ,0x14 , inqd[7 ]);atp_writeb_io (dev,0 ,0x18 , inqd[8 ]); - +while ((atp_readb_io (dev,0 ,0x1f ) &0x80 ) ==0x00 )cpu_relax (); - +if (atp_readb_io (dev,0 ,0x17 ) !=0x11 &&atp_readb_io (dev,0 ,0x17 ) !=0x8e )continue ;while (atp_readb_io (dev,0 ,0x17 ) !=0x8e )cpu_relax (); - +atp_writeb_io (dev,0 ,0x1b ,0x00 );atp_writeb_io (dev,0 ,0x18 ,0x08 ); j =0 ;
@@ -1710,9 +1712,10 @@ rd_inq_data:atp_writeb_io (dev,0 ,0x13 ,0 );atp_writeb_io (dev,0 ,0x14 ,0 );atp_writeb_io (dev,0 ,0x18 ,0x08 ); +while ((atp_readb_io (dev,0 ,0x1f ) &0x80 ) ==0x00 )cpu_relax (); - +if (atp_readb_io (dev,0 ,0x17 ) !=0x16 ) goto sel_ok;
@@ -1771,7 +1774,7 @@ try_u3:while ((atp_readb_io (dev,0 ,0x17 ) &0x80 ) ==0x00 )cpu_relax (); - + j =atp_readb_io (dev,0 ,0x17 ) &0x0f ;if (j ==0x0f ) { goto u3p_in;
@@ -1828,10 +1831,10 @@ u3p_cmd:atp_writeb_io (dev,0 ,0x10 ,0x30 );atp_writeb_io (dev,0 ,0x14 ,0x00 );atp_writeb_io (dev,0 ,0x18 ,0x08 ); - +while ((atp_readb_io (dev,0 ,0x1f ) &0x80 ) ==0x00 )cpu_relax (); - + j =atp_readb_io (dev,0 ,0x17 );if (j !=0x16 ) {if (j ==0x4e ) {
@@ -1872,13 +1875,13 @@ chg_wide:while ((atp_readb_io (dev,0 ,0x1f ) &0x80 ) ==0x00 )cpu_relax (); - +if (atp_readb_io (dev,0 ,0x17 ) !=0x11 &&atp_readb_io (dev,0 ,0x17 ) !=0x8e )continue ;while (atp_readb_io (dev,0 ,0x17 ) !=0x8e )cpu_relax (); - + try_wide: j =0 ;atp_writeb_io (dev,0 ,0x14 ,0x05 );
@@ -1888,9 +1891,10 @@ try_wide:if ((atp_readb_io (dev,0 ,0x1f ) &0x01 ) !=0 )atp_writeb_io (dev,0 ,0x19 , wide[j++]); } +while ((atp_readb_io (dev,0 ,0x17 ) &0x80 ) ==0x00 )cpu_relax (); - + j =atp_readb_io (dev,0 ,0x17 ) &0x0f ;if (j ==0x0f ) { goto widep_in;
@@ -2013,9 +2017,9 @@ set_sync:while ((atp_readb_io (dev,0 ,0x1f ) &0x80 ) ==0x00 )cpu_relax (); -if (atp_readb_io (dev,0 ,0x17 ) !=0x11 &&atp_readb_io (dev,0 ,0x17 ) !=0x8e ) { +if (atp_readb_io (dev,0 ,0x17 ) !=0x11 &&atp_readb_io (dev,0 ,0x17 ) !=0x8e )continue ; - } +while (atp_readb_io (dev,0 ,0x17 ) !=0x8e )cpu_relax ();
@@ -2830,16 +2834,16 @@ static void is885(struct atp_unit *dev, unsigned char c)unsigned char i, j, k, rmb, n, lvdmode;unsigned short int m;static unsigned char mbuf[512 ]; -static unsigned char satn[9 ] = {0 ,0 ,0 ,0 ,0 ,0 ,0 ,6 ,6 }; -static unsigned char inqd[9 ] = {0x12 ,0 ,0 ,0 ,0x24 ,0 ,0 ,0x24 ,6 }; -static unsigned char synn[6 ] = {0x80 ,1 ,3 ,1 ,0x19 ,0x0e }; -unsigned char synu[6 ] = {0x80 ,1 ,3 ,1 ,0x0a ,0x0e }; -static unsigned char synw[6 ] = {0x80 ,1 ,3 ,1 ,0x19 ,0x0e }; -unsigned char synuw[6 ] = {0x80 ,1 ,3 ,1 ,0x0a ,0x0e }; -static unsigned char wide[6 ] = {0x80 ,1 ,2 ,3 ,1 ,0 }; -static unsigned char u3[9 ] = {0x80 ,1 ,6 ,4 ,0x09 ,00 ,0x0e ,0x01 ,0x02 }; +static unsigned char satn[9 ] = {0 ,0 ,0 ,0 ,0 ,0 ,0 ,6 ,6 }; +static unsigned char inqd[9 ] = {0x12 ,0 ,0 ,0 ,0x24 ,0 ,0 ,0x24 ,6 }; +static unsigned char synn[6 ] = {0x80 ,1 ,3 ,1 ,0x19 ,0x0e }; +unsigned char synu[6 ] = {0x80 ,1 ,3 ,1 ,0x0a ,0x0e }; +static unsigned char synw[6 ] = {0x80 ,1 ,3 ,1 ,0x19 ,0x0e }; +unsigned char synuw[6 ] = {0x80 ,1 ,3 ,1 ,0x0a ,0x0e }; +static unsigned char wide[6 ] = {0x80 ,1 ,2 ,3 ,1 ,0 }; +static unsigned char u3[9 ] = {0x80 ,1 ,6 ,4 ,0x09 ,00 ,0x0e ,0x01 ,0x02 }; - lvdmode=atp_readb_io (dev, c,0x1b ) >>7 ; + lvdmode =atp_readb_io (dev, c,0x1b ) >>7 ;for (i =0 ; i <16 ; i++) { m =1 ;
@@ -2862,7 +2866,6 @@ static void is885(struct atp_unit *dev, unsigned char c)atp_writeb_io (dev, c,8 , satn[5 ]);atp_writeb_io (dev, c,0x0f ,0 );atp_writeb_io (dev, c,0x11 , dev->id[c][i].devsp); -atp_writeb_io (dev, c,0x12 ,0 );atp_writeb_io (dev, c,0x13 , satn[6 ]);atp_writeb_io (dev, c,0x14 , satn[7 ]);
@@ -2875,11 +2878,13 @@ static void is885(struct atp_unit *dev, unsigned char c)while ((atp_readb_io (dev, c,0x1f ) &0x80 ) ==0x00 )cpu_relax (); -if ((atp_readb_io (dev, c,0x17 ) !=0x11 ) && (atp_readb_io (dev, c,0x17 ) !=0x8e )) { + +if (atp_readb_io (dev, c,0x17 ) !=0x11 &&atp_readb_io (dev, c,0x17 ) !=0x8e )continue ; - } +while (atp_readb_io (dev, c,0x17 ) !=0x8e )cpu_relax (); + dev->active_id[c] |= m;atp_writeb_io (dev, c,0x10 ,0x30 );
@@ -2887,8 +2892,10 @@ static void is885(struct atp_unit *dev, unsigned char c) phase_cmd:atp_writeb_io (dev, c,0x18 ,0x08 ); +while ((atp_readb_io (dev, c,0x1f ) &0x80 ) ==0x00 )cpu_relax (); + j =atp_readb_io (dev, c,0x17 );if (j !=0x16 ) {atp_writeb_io (dev, c,0x10 ,0x41 );
@@ -2907,13 +2914,16 @@ sel_ok:atp_writeb_io (dev, c,0x13 , inqd[6 ]);atp_writeb_io (dev, c,0x14 , inqd[7 ]);atp_writeb_io (dev, c,0x18 , inqd[8 ]); +while ((atp_readb_io (dev, c,0x1f ) &0x80 ) ==0x00 )cpu_relax (); -if ((atp_readb_io (dev, c,0x17 ) !=0x11 ) && (atp_readb_io (dev, c,0x17 ) !=0x8e )) { + +if (atp_readb_io (dev, c,0x17 ) !=0x11 &&atp_readb_io (dev, c,0x17 ) !=0x8e )continue ; - } +while (atp_readb_io (dev, c,0x17 ) !=0x8e )cpu_relax (); +atp_writeb_io (dev, c,0x1b ,0x00 );atp_writeb_io (dev, c,0x18 ,0x08 ); j =0 ;
@@ -2935,14 +2945,16 @@ rd_inq_data:atp_writeb_io (dev, c,0x13 ,0 );atp_writeb_io (dev, c,0x14 ,0 );atp_writeb_io (dev, c,0x18 ,0x08 ); +while ((atp_readb_io (dev, c,0x1f ) &0x80 ) ==0x00 )cpu_relax (); -if (atp_readb_io (dev, c,0x17 ) !=0x16 ) { + +if (atp_readb_io (dev, c,0x17 ) !=0x16 ) goto sel_ok; - } + inq_ok: mbuf[36 ] =0 ; -printk (KERN_INFO " ID: %2d %s\n" , i, &mbuf[8 ]); +printk (KERN_INFO " ID: %2d %s\n" , i, &mbuf[8 ]); dev->id[c][i].devtype = mbuf[0 ]; rmb = mbuf[1 ]; n = mbuf[7 ];
@@ -2953,10 +2965,11 @@ inq_ok: goto not_wide; }if (lvdmode ==0 ) { - goto chg_wide; + goto chg_wide; } -if (dev->sp[c][i] !=0x04 ) {// force u2 - goto chg_wide; +if (dev->sp[c][i] !=0x04 )// force u2 + { + goto chg_wide; }atp_writeb_io (dev, c,0x1b ,0x01 );
@@ -2975,11 +2988,13 @@ inq_ok:while ((atp_readb_io (dev, c,0x1f ) &0x80 ) ==0x00 )cpu_relax (); -if ((atp_readb_io (dev, c,0x17 ) !=0x11 ) && (atp_readb_io (dev, c,0x17 ) !=0x8e )) { + +if (atp_readb_io (dev, c,0x17 ) !=0x11 &&atp_readb_io (dev, c,0x17 ) !=0x8e )continue ; - } +while (atp_readb_io (dev, c,0x17 ) !=0x8e )cpu_relax (); + try_u3: j =0 ;atp_writeb_io (dev, c,0x14 ,0x09 );
@@ -2990,8 +3005,10 @@ try_u3:atp_writeb_io (dev, c,0x19 , u3[j++]);cpu_relax (); } +while ((atp_readb_io (dev, c,0x17 ) &0x80 ) ==0x00 )cpu_relax (); + j =atp_readb_io (dev, c,0x17 ) &0x0f ;if (j ==0x0f ) { goto u3p_in;
@@ -3049,7 +3066,9 @@ u3p_cmd:atp_writeb_io (dev, c,0x10 ,0x30 );atp_writeb_io (dev, c,0x14 ,0x00 );atp_writeb_io (dev, c,0x18 ,0x08 ); +while ((atp_readb_io (dev, c,0x1f ) &0x80 ) ==0x00 ); + j =atp_readb_io (dev, c,0x17 );if (j !=0x16 ) {if (j ==0x4e ) {
@@ -3093,11 +3112,13 @@ chg_wide:while ((atp_readb_io (dev, c,0x1f ) &0x80 ) ==0x00 )cpu_relax (); -if ((atp_readb_io (dev, c,0x17 ) !=0x11 ) && (atp_readb_io (dev, c,0x17 ) !=0x8e )) { + +if (atp_readb_io (dev, c,0x17 ) !=0x11 &&atp_readb_io (dev, c,0x17 ) !=0x8e )continue ; - } +while (atp_readb_io (dev, c,0x17 ) !=0x8e )cpu_relax (); + try_wide: j =0 ;atp_writeb_io (dev, c,0x14 ,0x05 );
@@ -3108,8 +3129,10 @@ try_wide:atp_writeb_io (dev, c,0x19 , wide[j++]);cpu_relax (); } +while ((atp_readb_io (dev, c,0x17 ) &0x80 ) ==0x00 )cpu_relax (); + j =atp_readb_io (dev, c,0x17 ) &0x0f ;if (j ==0x0f ) { goto widep_in;
@@ -3167,8 +3190,10 @@ widep_cmd:atp_writeb_io (dev, c,0x10 ,0x30 );atp_writeb_io (dev, c,0x14 ,0x00 );atp_writeb_io (dev, c,0x18 ,0x08 ); +while ((atp_readb_io (dev, c,0x1f ) &0x80 ) ==0x00 )cpu_relax (); + j =atp_readb_io (dev, c,0x17 );if (j !=0x16 ) {if (j ==0x4e ) {
@@ -3192,24 +3217,23 @@ widep_cmd: m = m << i; dev->wide_id[c] |= m; not_wide: -if ((dev->id[c][i].devtype ==0x00 ) || (dev->id[c][i].devtype ==0x07 ) || - ((dev->id[c][i].devtype ==0x05 ) && ((n &0x10 ) !=0 ))) { +if ((dev->id[c][i].devtype ==0x00 ) || (dev->id[c][i].devtype ==0x07 ) || ((dev->id[c][i].devtype ==0x05 ) && ((n &0x10 ) !=0 ))) { m =1 ; m = m << i;if ((dev->async[c] & m) !=0 ) { - goto set_sync; + goto set_sync; } }continue ; set_sync:if (dev->sp[c][i] ==0x02 ) { - synu[4 ]=0x0c ; - synuw[4 ]=0x0c ; + synu[4 ] =0x0c ; + synuw[4 ] =0x0c ; }else { -if (dev->sp[c][i] >=0x03 ) { - synu[4 ]=0x0a ; - synuw[4 ]=0x0a ; - } +if (dev->sp[c][i] >=0x03 ) { + synu[4 ] =0x0a ; + synuw[4 ] =0x0a ; + } } j =0 ;if ((m & dev->wide_id[c]) !=0 ) {
@@ -3231,11 +3255,13 @@ set_sync:while ((atp_readb_io (dev, c,0x1f ) &0x80 ) ==0x00 )cpu_relax (); -if ((atp_readb_io (dev, c,0x17 ) !=0x11 ) && (atp_readb_io (dev, c,0x17 ) !=0x8e )) { + +if (atp_readb_io (dev, c,0x17 ) !=0x11 &&atp_readb_io (dev, c,0x17 ) !=0x8e )continue ; - } +while (atp_readb_io (dev, c,0x17 ) !=0x8e )cpu_relax (); + try_sync: j =0 ;atp_writeb_io (dev, c,0x14 ,0x06 );
@@ -3258,8 +3284,10 @@ try_sync: } } } +while ((atp_readb_io (dev, c,0x17 ) &0x80 ) ==0x00 )cpu_relax (); + j =atp_readb_io (dev, c,0x17 ) &0x0f ;if (j ==0x0f ) { goto phase_ins;
@@ -3306,7 +3334,9 @@ phase_ins1:if ((j &0x80 ) ==0x00 ) { goto phase_ins1; } +while ((atp_readb_io (dev, c,0x17 ) &0x80 ) ==0x00 ); + j =atp_readb_io (dev, c,0x17 );if (j ==0x85 ) { goto tar_dcons;
@@ -3327,8 +3357,10 @@ phase_cmds: tar_dcons:atp_writeb_io (dev, c,0x14 ,0x00 );atp_writeb_io (dev, c,0x18 ,0x08 ); +while ((atp_readb_io (dev, c,0x1f ) &0x80 ) ==0x00 )cpu_relax (); + j =atp_readb_io (dev, c,0x17 );if (j !=0x16 ) {continue ;
@@ -3349,7 +3381,7 @@ tar_dcons: mbuf[4 ] =0x0e ; } dev->id[c][i].devsp = mbuf[4 ]; -if (mbuf[3 ] <0x0c ){ +if (mbuf[3 ] <0x0c ) { j =0xb0 ; goto set_syn_ok; }
@@ -3370,9 +3402,9 @@ tar_dcons: goto set_syn_ok; } j =0x60 ; - set_syn_ok: +set_syn_ok: dev->id[c][i].devsp = (dev->id[c][i].devsp &0x0f ) | j; -#ifdef ED_DBGP +#ifdef ED_DBGP printk ("dev->id[%2d][%2d].devsp = %2x\n" ,c,i,dev->id[c][i].devsp);#endif }
Signature · 1 line
Ondrej Zary
PATCH 23/52 atp870u: Add channel parameter to is870() and is880()
In reply to Ondrej ZaryAdd channel parameter to is870() and is880() functions to simplify comparing them with is885().
--- drivers/scsi/atp870u.c | 684 ++++++++++++++++++++++++------------------------ 1 file changed, 342 insertions(+), 342 deletions(-)
drivers/scsi/atp870u.c +342 -342
@@ -1162,7 +1162,7 @@ static void tscam(struct Scsi_Host *host) } } -static void is870 (struct atp_unit *dev) +static void is870 (struct atp_unit *dev,unsigned char c) {unsigned char i, j, k, rmb, n;unsigned short int m;
@@ -1174,7 +1174,7 @@ static void is870(struct atp_unit *dev)static unsigned char synw[6 ] = {0x80 ,1 ,3 ,1 ,0x0c ,0x07 };static unsigned char wide[6 ] = {0x80 ,1 ,2 ,3 ,1 ,0 }; -atp_writeb_io (dev,0 ,0x3a ,atp_readb_io (dev,0 ,0x3a ) |0x10 ); +atp_writeb_io (dev, c,0x3a ,atp_readb_io (dev, c,0x3a ) |0x10 );for (i =0 ; i <16 ; i++) {if ((dev->chip_ver !=4 ) && (i >7 )) {
@@ -1182,120 +1182,120 @@ static void is870(struct atp_unit *dev) } m =1 ; m = m << i; -if ((m & dev->active_id[0 ]) !=0 ) { +if ((m & dev->active_id[c]) !=0 ) {continue ; } -if (i == dev->host_id[0 ]) { -printk (KERN_INFO " ID: %2d Host Adapter\n" , dev->host_id[0 ]); +if (i == dev->host_id[c]) { +printk (KERN_INFO " ID: %2d Host Adapter\n" , dev->host_id[c]);continue ; }if (dev->chip_ver ==4 ) { -atp_writeb_io (dev,0 ,0x1b ,0x01 ); +atp_writeb_io (dev, c,0x1b ,0x01 ); }else { -atp_writeb_io (dev,0 ,0x1b ,0x00 ); +atp_writeb_io (dev, c,0x1b ,0x00 ); } -atp_writeb_io (dev,0 ,1 ,0x08 ); -atp_writeb_io (dev,0 ,2 ,0x7f ); -atp_writeb_io (dev,0 ,3 , satn[0 ]); -atp_writeb_io (dev,0 ,4 , satn[1 ]); -atp_writeb_io (dev,0 ,5 , satn[2 ]); -atp_writeb_io (dev,0 ,6 , satn[3 ]); -atp_writeb_io (dev,0 ,7 , satn[4 ]); -atp_writeb_io (dev,0 ,8 , satn[5 ]); -atp_writeb_io (dev,0 ,0x0f ,0 ); -atp_writeb_io (dev,0 ,0x11 , dev->id[0 ][i].devsp); -atp_writeb_io (dev,0 ,0x12 ,0 ); -atp_writeb_io (dev,0 ,0x13 , satn[6 ]); -atp_writeb_io (dev,0 ,0x14 , satn[7 ]); +atp_writeb_io (dev, c,1 ,0x08 ); +atp_writeb_io (dev, c,2 ,0x7f ); +atp_writeb_io (dev, c,3 , satn[0 ]); +atp_writeb_io (dev, c,4 , satn[1 ]); +atp_writeb_io (dev, c,5 , satn[2 ]); +atp_writeb_io (dev, c,6 , satn[3 ]); +atp_writeb_io (dev, c,7 , satn[4 ]); +atp_writeb_io (dev, c,8 , satn[5 ]); +atp_writeb_io (dev, c,0x0f ,0 ); +atp_writeb_io (dev, c,0x11 , dev->id[c][i].devsp); +atp_writeb_io (dev, c,0x12 ,0 ); +atp_writeb_io (dev, c,0x13 , satn[6 ]); +atp_writeb_io (dev, c,0x14 , satn[7 ]); j = i;if ((j &0x08 ) !=0 ) { j = (j &0x07 ) |0x40 ; } -atp_writeb_io (dev,0 ,0x15 , j); -atp_writeb_io (dev,0 ,0x18 , satn[8 ]); +atp_writeb_io (dev, c,0x15 , j); +atp_writeb_io (dev, c,0x18 , satn[8 ]); -while ((atp_readb_io (dev,0 ,0x1f ) &0x80 ) ==0x00 ) +while ((atp_readb_io (dev, c,0x1f ) &0x80 ) ==0x00 )cpu_relax (); -if (atp_readb_io (dev,0 ,0x17 ) !=0x11 &&atp_readb_io (dev,0 ,0x17 ) !=0x8e ) +if (atp_readb_io (dev, c,0x17 ) !=0x11 &&atp_readb_io (dev, c,0x17 ) !=0x8e )continue ; -while (atp_readb_io (dev,0 ,0x17 ) !=0x8e ) +while (atp_readb_io (dev, c,0x17 ) !=0x8e )cpu_relax (); - dev->active_id[0 ] |= m; + dev->active_id[c] |= m; -atp_writeb_io (dev,0 ,0x10 ,0x30 ); -atp_writeb_io (dev,0 ,0x04 ,0x00 ); +atp_writeb_io (dev, c,0x10 ,0x30 ); +atp_writeb_io (dev, c,0x04 ,0x00 ); phase_cmd: -atp_writeb_io (dev,0 ,0x18 ,0x08 ); +atp_writeb_io (dev, c,0x18 ,0x08 ); -while ((atp_readb_io (dev,0 ,0x1f ) &0x80 ) ==0x00 ) +while ((atp_readb_io (dev, c,0x1f ) &0x80 ) ==0x00 )cpu_relax (); - j =atp_readb_io (dev,0 ,0x17 ); + j =atp_readb_io (dev, c,0x17 );if (j !=0x16 ) { -atp_writeb_io (dev,0 ,0x10 ,0x41 ); +atp_writeb_io (dev, c,0x10 ,0x41 ); goto phase_cmd; } sel_ok: -atp_writeb_io (dev,0 ,3 , inqd[0 ]); -atp_writeb_io (dev,0 ,4 , inqd[1 ]); -atp_writeb_io (dev,0 ,5 , inqd[2 ]); -atp_writeb_io (dev,0 ,6 , inqd[3 ]); -atp_writeb_io (dev,0 ,7 , inqd[4 ]); -atp_writeb_io (dev,0 ,8 , inqd[5 ]); -atp_writeb_io (dev,0 ,0x0f ,0 ); -atp_writeb_io (dev,0 ,0x11 , dev->id[0 ][i].devsp); -atp_writeb_io (dev,0 ,0x12 ,0 ); -atp_writeb_io (dev,0 ,0x13 , inqd[6 ]); -atp_writeb_io (dev,0 ,0x14 , inqd[7 ]); -atp_writeb_io (dev,0 ,0x18 , inqd[8 ]); +atp_writeb_io (dev, c,3 , inqd[0 ]); +atp_writeb_io (dev, c,4 , inqd[1 ]); +atp_writeb_io (dev, c,5 , inqd[2 ]); +atp_writeb_io (dev, c,6 , inqd[3 ]); +atp_writeb_io (dev, c,7 , inqd[4 ]); +atp_writeb_io (dev, c,8 , inqd[5 ]); +atp_writeb_io (dev, c,0x0f ,0 ); +atp_writeb_io (dev, c,0x11 , dev->id[c][i].devsp); +atp_writeb_io (dev, c,0x12 ,0 ); +atp_writeb_io (dev, c,0x13 , inqd[6 ]); +atp_writeb_io (dev, c,0x14 , inqd[7 ]); +atp_writeb_io (dev, c,0x18 , inqd[8 ]); -while ((atp_readb_io (dev,0 ,0x1f ) &0x80 ) ==0x00 ) +while ((atp_readb_io (dev, c,0x1f ) &0x80 ) ==0x00 )cpu_relax (); -if (atp_readb_io (dev,0 ,0x17 ) !=0x11 &&atp_readb_io (dev,0 ,0x17 ) !=0x8e ) +if (atp_readb_io (dev, c,0x17 ) !=0x11 &&atp_readb_io (dev, c,0x17 ) !=0x8e )continue ; -while (atp_readb_io (dev,0 ,0x17 ) !=0x8e ) +while (atp_readb_io (dev, c,0x17 ) !=0x8e )cpu_relax ();if (dev->chip_ver ==4 ) -atp_writeb_io (dev,0 ,0x1b ,0x00 ); +atp_writeb_io (dev, c,0x1b ,0x00 ); -atp_writeb_io (dev,0 ,0x18 ,0x08 ); +atp_writeb_io (dev, c,0x18 ,0x08 ); j =0 ; rd_inq_data: - k =atp_readb_io (dev,0 ,0x1f ); + k =atp_readb_io (dev, c,0x1f );if ((k &0x01 ) !=0 ) { - mbuf[j++] =atp_readb_io (dev,0 ,0x19 ); + mbuf[j++] =atp_readb_io (dev, c,0x19 ); goto rd_inq_data; }if ((k &0x80 ) ==0 ) { goto rd_inq_data; } - j =atp_readb_io (dev,0 ,0x17 ); + j =atp_readb_io (dev, c,0x17 );if (j ==0x16 ) { goto inq_ok; } -atp_writeb_io (dev,0 ,0x10 ,0x46 ); -atp_writeb_io (dev,0 ,0x12 ,0 ); -atp_writeb_io (dev,0 ,0x13 ,0 ); -atp_writeb_io (dev,0 ,0x14 ,0 ); -atp_writeb_io (dev,0 ,0x18 ,0x08 ); +atp_writeb_io (dev, c,0x10 ,0x46 ); +atp_writeb_io (dev, c,0x12 ,0 ); +atp_writeb_io (dev, c,0x13 ,0 ); +atp_writeb_io (dev, c,0x14 ,0 ); +atp_writeb_io (dev, c,0x18 ,0x08 ); -while ((atp_readb_io (dev,0 ,0x1f ) &0x80 ) ==0x00 ) +while ((atp_readb_io (dev, c,0x1f ) &0x80 ) ==0x00 )cpu_relax (); -if (atp_readb_io (dev,0 ,0x17 ) !=0x16 ) +if (atp_readb_io (dev, c,0x17 ) !=0x16 ) goto sel_ok; inq_ok: mbuf[36 ] =0 ;printk (KERN_INFO " ID: %2d %s\n" , i, &mbuf[8 ]); - dev->id[0 ][i].devtype = mbuf[0 ]; + dev->id[c][i].devtype = mbuf[0 ]; rmb = mbuf[1 ]; n = mbuf[7 ];if (dev->chip_ver !=4 ) {
@@ -1304,46 +1304,46 @@ inq_ok:if ((mbuf[7 ] &0x60 ) ==0 ) { goto not_wide; } -if ((dev->global_map[0 ] &0x20 ) ==0 ) { +if ((dev->global_map[c] &0x20 ) ==0 ) { goto not_wide; } -atp_writeb_io (dev,0 ,0x1b ,0x01 ); -atp_writeb_io (dev,0 ,3 , satn[0 ]); -atp_writeb_io (dev,0 ,4 , satn[1 ]); -atp_writeb_io (dev,0 ,5 , satn[2 ]); -atp_writeb_io (dev,0 ,6 , satn[3 ]); -atp_writeb_io (dev,0 ,7 , satn[4 ]); -atp_writeb_io (dev,0 ,8 , satn[5 ]); -atp_writeb_io (dev,0 ,0x0f ,0 ); -atp_writeb_io (dev,0 ,0x11 , dev->id[0 ][i].devsp); -atp_writeb_io (dev,0 ,0x12 ,0 ); -atp_writeb_io (dev,0 ,0x13 , satn[6 ]); -atp_writeb_io (dev,0 ,0x14 , satn[7 ]); -atp_writeb_io (dev,0 ,0x18 , satn[8 ]); +atp_writeb_io (dev, c,0x1b ,0x01 ); +atp_writeb_io (dev, c,3 , satn[0 ]); +atp_writeb_io (dev, c,4 , satn[1 ]); +atp_writeb_io (dev, c,5 , satn[2 ]); +atp_writeb_io (dev, c,6 , satn[3 ]); +atp_writeb_io (dev, c,7 , satn[4 ]); +atp_writeb_io (dev, c,8 , satn[5 ]); +atp_writeb_io (dev, c,0x0f ,0 ); +atp_writeb_io (dev, c,0x11 , dev->id[c][i].devsp); +atp_writeb_io (dev, c,0x12 ,0 ); +atp_writeb_io (dev, c,0x13 , satn[6 ]); +atp_writeb_io (dev, c,0x14 , satn[7 ]); +atp_writeb_io (dev, c,0x18 , satn[8 ]); -while ((atp_readb_io (dev,0 ,0x1f ) &0x80 ) ==0x00 ) +while ((atp_readb_io (dev, c,0x1f ) &0x80 ) ==0x00 )cpu_relax (); -if (atp_readb_io (dev,0 ,0x17 ) !=0x11 &&atp_readb_io (dev,0 ,0x17 ) !=0x8e ) +if (atp_readb_io (dev, c,0x17 ) !=0x11 &&atp_readb_io (dev, c,0x17 ) !=0x8e )continue ; -while (atp_readb_io (dev,0 ,0x17 ) !=0x8e ) +while (atp_readb_io (dev, c,0x17 ) !=0x8e )cpu_relax (); try_wide: j =0 ; -atp_writeb_io (dev,0 ,0x14 ,0x05 ); -atp_writeb_io (dev,0 ,0x18 ,0x20 ); +atp_writeb_io (dev, c,0x14 ,0x05 ); +atp_writeb_io (dev, c,0x18 ,0x20 ); -while ((atp_readb_io (dev,0 ,0x1f ) &0x80 ) ==0 ) { -if ((atp_readb_io (dev,0 ,0x1f ) &0x01 ) !=0 ) -atp_writeb_io (dev,0 ,0x19 , wide[j++]); +while ((atp_readb_io (dev, c,0x1f ) &0x80 ) ==0 ) { +if ((atp_readb_io (dev, c,0x1f ) &0x01 ) !=0 ) +atp_writeb_io (dev, c,0x19 , wide[j++]); } -while ((atp_readb_io (dev,0 ,0x17 ) &0x80 ) ==0x00 ) +while ((atp_readb_io (dev, c,0x17 ) &0x80 ) ==0x00 )cpu_relax (); - j =atp_readb_io (dev,0 ,0x17 ) &0x0f ; + j =atp_readb_io (dev, c,0x17 ) &0x0f ;if (j ==0x0f ) { goto widep_in; }
@@ -1355,12 +1355,12 @@ try_wide: }continue ; widep_out: -atp_writeb_io (dev,0 ,0x18 ,0x20 ); -while ((atp_readb_io (dev,0 ,0x1f ) &0x80 ) ==0 ) { -if ((atp_readb_io (dev,0 ,0x1f ) &0x01 ) !=0 ) -atp_writeb_io (dev,0 ,0x19 ,0 ); +atp_writeb_io (dev, c,0x18 ,0x20 ); +while ((atp_readb_io (dev, c,0x1f ) &0x80 ) ==0 ) { +if ((atp_readb_io (dev, c,0x1f ) &0x01 ) !=0 ) +atp_writeb_io (dev, c,0x19 ,0 ); } - j =atp_readb_io (dev,0 ,0x17 ) &0x0f ; + j =atp_readb_io (dev, c,0x17 ) &0x0f ;if (j ==0x0f ) { goto widep_in; }
@@ -1372,19 +1372,19 @@ widep_out: }continue ; widep_in: -atp_writeb_io (dev,0 ,0x14 ,0xff ); -atp_writeb_io (dev,0 ,0x18 ,0x20 ); +atp_writeb_io (dev, c,0x14 ,0xff ); +atp_writeb_io (dev, c,0x18 ,0x20 ); k =0 ; widep_in1: - j =atp_readb_io (dev,0 ,0x1f ); + j =atp_readb_io (dev, c,0x1f );if ((j &0x01 ) !=0 ) { - mbuf[k++] =atp_readb_io (dev,0 ,0x19 ); + mbuf[k++] =atp_readb_io (dev, c,0x19 ); goto widep_in1; }if ((j &0x80 ) ==0x00 ) { goto widep_in1; } - j =atp_readb_io (dev,0 ,0x17 ) &0x0f ; + j =atp_readb_io (dev, c,0x17 ) &0x0f ;if (j ==0x0f ) { goto widep_in; }
@@ -1396,14 +1396,14 @@ widep_in1: }continue ; widep_cmd: -atp_writeb_io (dev,0 ,0x10 ,0x30 ); -atp_writeb_io (dev,0 ,0x14 ,0x00 ); -atp_writeb_io (dev,0 ,0x18 ,0x08 ); +atp_writeb_io (dev, c,0x10 ,0x30 ); +atp_writeb_io (dev, c,0x14 ,0x00 ); +atp_writeb_io (dev, c,0x18 ,0x08 ); -while ((atp_readb_io (dev,0 ,0x1f ) &0x80 ) ==0x00 ) +while ((atp_readb_io (dev, c,0x1f ) &0x80 ) ==0x00 )cpu_relax (); - j =atp_readb_io (dev,0 ,0x17 ); + j =atp_readb_io (dev, c,0x17 );if (j !=0x16 ) {if (j ==0x4e ) { goto widep_out;
@@ -1424,63 +1424,63 @@ widep_cmd: } m =1 ; m = m << i; - dev->wide_id[0 ] |= m; + dev->wide_id[c] |= m; not_wide: -if ((dev->id[0 ][i].devtype ==0x00 ) || (dev->id[0 ][i].devtype ==0x07 ) || ((dev->id[0 ][i].devtype ==0x05 ) && ((n &0x10 ) !=0 ))) { +if ((dev->id[c][i].devtype ==0x00 ) || (dev->id[c][i].devtype ==0x07 ) || ((dev->id[c][i].devtype ==0x05 ) && ((n &0x10 ) !=0 ))) { goto set_sync; }continue ; set_sync: j =0 ; -if ((m & dev->wide_id[0 ]) !=0 ) { +if ((m & dev->wide_id[c]) !=0 ) { j |=0x01 ; } -atp_writeb_io (dev,0 ,0x1b , j); -atp_writeb_io (dev,0 ,3 , satn[0 ]); -atp_writeb_io (dev,0 ,4 , satn[1 ]); -atp_writeb_io (dev,0 ,5 , satn[2 ]); -atp_writeb_io (dev,0 ,6 , satn[3 ]); -atp_writeb_io (dev,0 ,7 , satn[4 ]); -atp_writeb_io (dev,0 ,8 , satn[5 ]); -atp_writeb_io (dev,0 ,0x0f ,0 ); -atp_writeb_io (dev,0 ,0x11 , dev->id[0 ][i].devsp); -atp_writeb_io (dev,0 ,0x12 ,0 ); -atp_writeb_io (dev,0 ,0x13 , satn[6 ]); -atp_writeb_io (dev,0 ,0x14 , satn[7 ]); -atp_writeb_io (dev,0 ,0x18 , satn[8 ]); +atp_writeb_io (dev, c,0x1b , j); +atp_writeb_io (dev, c,3 , satn[0 ]); +atp_writeb_io (dev, c,4 , satn[1 ]); +atp_writeb_io (dev, c,5 , satn[2 ]); +atp_writeb_io (dev, c,6 , satn[3 ]); +atp_writeb_io (dev, c,7 , satn[4 ]); +atp_writeb_io (dev, c,8 , satn[5 ]); +atp_writeb_io (dev, c,0x0f ,0 ); +atp_writeb_io (dev, c,0x11 , dev->id[c][i].devsp); +atp_writeb_io (dev, c,0x12 ,0 ); +atp_writeb_io (dev, c,0x13 , satn[6 ]); +atp_writeb_io (dev, c,0x14 , satn[7 ]); +atp_writeb_io (dev, c,0x18 , satn[8 ]); -while ((atp_readb_io (dev,0 ,0x1f ) &0x80 ) ==0x00 ) +while ((atp_readb_io (dev, c,0x1f ) &0x80 ) ==0x00 )cpu_relax (); -if (atp_readb_io (dev,0 ,0x17 ) !=0x11 &&atp_readb_io (dev,0 ,0x17 ) !=0x8e ) +if (atp_readb_io (dev, c,0x17 ) !=0x11 &&atp_readb_io (dev, c,0x17 ) !=0x8e )continue ; -while (atp_readb_io (dev,0 ,0x17 ) !=0x8e ) +while (atp_readb_io (dev, c,0x17 ) !=0x8e )cpu_relax (); try_sync: j =0 ; -atp_writeb_io (dev,0 ,0x14 ,0x06 ); -atp_writeb_io (dev,0 ,0x18 ,0x20 ); +atp_writeb_io (dev, c,0x14 ,0x06 ); +atp_writeb_io (dev, c,0x18 ,0x20 ); -while ((atp_readb_io (dev,0 ,0x1f ) &0x80 ) ==0 ) { -if ((atp_readb_io (dev,0 ,0x1f ) &0x01 ) !=0 ) { -if ((m & dev->wide_id[0 ]) !=0 ) { -atp_writeb_io (dev,0 ,0x19 , synw[j++]); +while ((atp_readb_io (dev, c,0x1f ) &0x80 ) ==0 ) { +if ((atp_readb_io (dev, c,0x1f ) &0x01 ) !=0 ) { +if ((m & dev->wide_id[c]) !=0 ) { +atp_writeb_io (dev, c,0x19 , synw[j++]); }else { -if ((m & dev->ultra_map[0 ]) !=0 ) { -atp_writeb_io (dev,0 ,0x19 , synu[j++]); +if ((m & dev->ultra_map[c]) !=0 ) { +atp_writeb_io (dev, c,0x19 , synu[j++]); }else { -atp_writeb_io (dev,0 ,0x19 , synn[j++]); +atp_writeb_io (dev, c,0x19 , synn[j++]); } } } } -while ((atp_readb_io (dev,0 ,0x17 ) &0x80 ) ==0x00 ) +while ((atp_readb_io (dev, c,0x17 ) &0x80 ) ==0x00 )cpu_relax (); - j =atp_readb_io (dev,0 ,0x17 ) &0x0f ; + j =atp_readb_io (dev, c,0x17 ) &0x0f ;if (j ==0x0f ) { goto phase_ins; }
@@ -1492,12 +1492,12 @@ try_sync: }continue ; phase_outs: -atp_writeb_io (dev,0 ,0x18 ,0x20 ); -while ((atp_readb_io (dev,0 ,0x1f ) &0x80 ) ==0x00 ) { -if ((atp_readb_io (dev,0 ,0x1f ) &0x01 ) !=0x00 ) -atp_writeb_io (dev,0 ,0x19 ,0x00 ); +atp_writeb_io (dev, c,0x18 ,0x20 ); +while ((atp_readb_io (dev, c,0x1f ) &0x80 ) ==0x00 ) { +if ((atp_readb_io (dev, c,0x1f ) &0x01 ) !=0x00 ) +atp_writeb_io (dev, c,0x19 ,0x00 ); } - j =atp_readb_io (dev,0 ,0x17 ); + j =atp_readb_io (dev, c,0x17 );if (j ==0x85 ) { goto tar_dcons; }
@@ -1513,23 +1513,23 @@ phase_outs: }continue ; phase_ins: -atp_writeb_io (dev,0 ,0x14 ,0xff ); -atp_writeb_io (dev,0 ,0x18 ,0x20 ); +atp_writeb_io (dev, c,0x14 ,0xff ); +atp_writeb_io (dev, c,0x18 ,0x20 ); k =0 ; phase_ins1: - j =atp_readb_io (dev,0 ,0x1f ); + j =atp_readb_io (dev, c,0x1f );if ((j &0x01 ) !=0x00 ) { - mbuf[k++] =atp_readb_io (dev,0 ,0x19 ); + mbuf[k++] =atp_readb_io (dev, c,0x19 ); goto phase_ins1; }if ((j &0x80 ) ==0x00 ) { goto phase_ins1; } -while ((atp_readb_io (dev,0 ,0x17 ) &0x80 ) ==0x00 ) +while ((atp_readb_io (dev, c,0x17 ) &0x80 ) ==0x00 )cpu_relax (); - j =atp_readb_io (dev,0 ,0x17 ); + j =atp_readb_io (dev, c,0x17 );if (j ==0x85 ) { goto tar_dcons; }
@@ -1545,15 +1545,15 @@ phase_ins1: }continue ; phase_cmds: -atp_writeb_io (dev,0 ,0x10 ,0x30 ); +atp_writeb_io (dev, c,0x10 ,0x30 ); tar_dcons: -atp_writeb_io (dev,0 ,0x14 ,0x00 ); -atp_writeb_io (dev,0 ,0x18 ,0x08 ); +atp_writeb_io (dev, c,0x14 ,0x00 ); +atp_writeb_io (dev, c,0x18 ,0x08 ); -while ((atp_readb_io (dev,0 ,0x1f ) &0x80 ) ==0x00 ) +while ((atp_readb_io (dev, c,0x1f ) &0x80 ) ==0x00 )cpu_relax (); - j =atp_readb_io (dev,0 ,0x17 ); + j =atp_readb_io (dev, c,0x17 );if (j !=0x16 ) {continue ; }
@@ -1572,7 +1572,7 @@ tar_dcons:if (mbuf[4 ] >0x0c ) { mbuf[4 ] =0x0c ; } - dev->id[0 ][i].devsp = mbuf[4 ]; + dev->id[c][i].devsp = mbuf[4 ];if ((mbuf[3 ] <0x0d ) && (rmb ==0 )) { j =0xa0 ; goto set_syn_ok;
@@ -1591,12 +1591,12 @@ tar_dcons: } j =0x60 ; set_syn_ok: - dev->id[0 ][i].devsp = (dev->id[0 ][i].devsp &0x0f ) | j; + dev->id[c][i].devsp = (dev->id[c][i].devsp &0x0f ) | j; } -atp_writeb_io (dev,0 ,0x3a ,atp_readb_io (dev,0 ,0x3a ) &0xef ); +atp_writeb_io (dev, c,0x3a ,atp_readb_io (dev, c,0x3a ) &0xef ); } -static void is880 (struct atp_unit *dev) +static void is880 (struct atp_unit *dev,unsigned char c) {unsigned char i, j, k, rmb, n, lvdmode;unsigned short int m;
@@ -1615,167 +1615,167 @@ static void is880(struct atp_unit *dev)for (i =0 ; i <16 ; i++) { m =1 ; m = m << i; -if ((m & dev->active_id[0 ]) !=0 ) { +if ((m & dev->active_id[c]) !=0 ) {continue ; } -if (i == dev->host_id[0 ]) { -printk (KERN_INFO " ID: %2d Host Adapter\n" , dev->host_id[0 ]); +if (i == dev->host_id[c]) { +printk (KERN_INFO " ID: %2d Host Adapter\n" , dev->host_id[c]);continue ; } -atp_writeb_io (dev,0 ,0x1b ,0x01 ); -atp_writeb_io (dev,0 ,1 ,0x08 ); -atp_writeb_io (dev,0 ,2 ,0x7f ); -atp_writeb_io (dev,0 ,3 , satn[0 ]); -atp_writeb_io (dev,0 ,4 , satn[1 ]); -atp_writeb_io (dev,0 ,5 , satn[2 ]); -atp_writeb_io (dev,0 ,6 , satn[3 ]); -atp_writeb_io (dev,0 ,7 , satn[4 ]); -atp_writeb_io (dev,0 ,8 , satn[5 ]); -atp_writeb_io (dev,0 ,0x0f ,0 ); -atp_writeb_io (dev,0 ,0x11 , dev->id[0 ][i].devsp); -atp_writeb_io (dev,0 ,0x12 ,0 ); -atp_writeb_io (dev,0 ,0x13 , satn[6 ]); -atp_writeb_io (dev,0 ,0x14 , satn[7 ]); +atp_writeb_io (dev, c,0x1b ,0x01 ); +atp_writeb_io (dev, c,1 ,0x08 ); +atp_writeb_io (dev, c,2 ,0x7f ); +atp_writeb_io (dev, c,3 , satn[0 ]); +atp_writeb_io (dev, c,4 , satn[1 ]); +atp_writeb_io (dev, c,5 , satn[2 ]); +atp_writeb_io (dev, c,6 , satn[3 ]); +atp_writeb_io (dev, c,7 , satn[4 ]); +atp_writeb_io (dev, c,8 , satn[5 ]); +atp_writeb_io (dev, c,0x0f ,0 ); +atp_writeb_io (dev, c,0x11 , dev->id[c][i].devsp); +atp_writeb_io (dev, c,0x12 ,0 ); +atp_writeb_io (dev, c,0x13 , satn[6 ]); +atp_writeb_io (dev, c,0x14 , satn[7 ]); j = i;if ((j &0x08 ) !=0 ) { j = (j &0x07 ) |0x40 ; } -atp_writeb_io (dev,0 ,0x15 , j); -atp_writeb_io (dev,0 ,0x18 , satn[8 ]); +atp_writeb_io (dev, c,0x15 , j); +atp_writeb_io (dev, c,0x18 , satn[8 ]); -while ((atp_readb_io (dev,0 ,0x1f ) &0x80 ) ==0x00 ) +while ((atp_readb_io (dev, c,0x1f ) &0x80 ) ==0x00 )cpu_relax (); -if (atp_readb_io (dev,0 ,0x17 ) !=0x11 &&atp_readb_io (dev,0 ,0x17 ) !=0x8e ) +if (atp_readb_io (dev, c,0x17 ) !=0x11 &&atp_readb_io (dev, c,0x17 ) !=0x8e )continue ; -while (atp_readb_io (dev,0 ,0x17 ) !=0x8e ) +while (atp_readb_io (dev, c,0x17 ) !=0x8e )cpu_relax (); - dev->active_id[0 ] |= m; + dev->active_id[c] |= m; -atp_writeb_io (dev,0 ,0x10 ,0x30 ); -atp_writeb_io (dev,0 ,0x14 ,0x00 ); +atp_writeb_io (dev, c,0x10 ,0x30 ); +atp_writeb_io (dev, c,0x14 ,0x00 ); phase_cmd: -atp_writeb_io (dev,0 ,0x18 ,0x08 ); +atp_writeb_io (dev, c,0x18 ,0x08 ); -while ((atp_readb_io (dev,0 ,0x1f ) &0x80 ) ==0x00 ) +while ((atp_readb_io (dev, c,0x1f ) &0x80 ) ==0x00 )cpu_relax (); - j =atp_readb_io (dev,0 ,0x17 ); + j =atp_readb_io (dev, c,0x17 );if (j !=0x16 ) { -atp_writeb_io (dev,0 ,0x10 ,0x41 ); +atp_writeb_io (dev, c,0x10 ,0x41 ); goto phase_cmd; } sel_ok: -atp_writeb_io (dev,0 ,3 , inqd[0 ]); -atp_writeb_io (dev,0 ,4 , inqd[1 ]); -atp_writeb_io (dev,0 ,5 , inqd[2 ]); -atp_writeb_io (dev,0 ,6 , inqd[3 ]); -atp_writeb_io (dev,0 ,7 , inqd[4 ]); -atp_writeb_io (dev,0 ,8 , inqd[5 ]); -atp_writeb_io (dev,0 ,0x0f ,0 ); -atp_writeb_io (dev,0 ,0x11 , dev->id[0 ][i].devsp); -atp_writeb_io (dev,0 ,0x12 ,0 ); -atp_writeb_io (dev,0 ,0x13 , inqd[6 ]); -atp_writeb_io (dev,0 ,0x14 , inqd[7 ]); -atp_writeb_io (dev,0 ,0x18 , inqd[8 ]); +atp_writeb_io (dev, c,3 , inqd[0 ]); +atp_writeb_io (dev, c,4 , inqd[1 ]); +atp_writeb_io (dev, c,5 , inqd[2 ]); +atp_writeb_io (dev, c,6 , inqd[3 ]); +atp_writeb_io (dev, c,7 , inqd[4 ]); +atp_writeb_io (dev, c,8 , inqd[5 ]); +atp_writeb_io (dev, c,0x0f ,0 ); +atp_writeb_io (dev, c,0x11 , dev->id[c][i].devsp); +atp_writeb_io (dev, c,0x12 ,0 ); +atp_writeb_io (dev, c,0x13 , inqd[6 ]); +atp_writeb_io (dev, c,0x14 , inqd[7 ]); +atp_writeb_io (dev, c,0x18 , inqd[8 ]); -while ((atp_readb_io (dev,0 ,0x1f ) &0x80 ) ==0x00 ) +while ((atp_readb_io (dev, c,0x1f ) &0x80 ) ==0x00 )cpu_relax (); -if (atp_readb_io (dev,0 ,0x17 ) !=0x11 &&atp_readb_io (dev,0 ,0x17 ) !=0x8e ) +if (atp_readb_io (dev, c,0x17 ) !=0x11 &&atp_readb_io (dev, c,0x17 ) !=0x8e )continue ; -while (atp_readb_io (dev,0 ,0x17 ) !=0x8e ) +while (atp_readb_io (dev, c,0x17 ) !=0x8e )cpu_relax (); -atp_writeb_io (dev,0 ,0x1b ,0x00 ); -atp_writeb_io (dev,0 ,0x18 ,0x08 ); +atp_writeb_io (dev, c,0x1b ,0x00 ); +atp_writeb_io (dev, c,0x18 ,0x08 ); j =0 ; rd_inq_data: - k =atp_readb_io (dev,0 ,0x1f ); + k =atp_readb_io (dev, c,0x1f );if ((k &0x01 ) !=0 ) { - mbuf[j++] =atp_readb_io (dev,0 ,0x19 ); + mbuf[j++] =atp_readb_io (dev, c,0x19 ); goto rd_inq_data; }if ((k &0x80 ) ==0 ) { goto rd_inq_data; } - j =atp_readb_io (dev,0 ,0x17 ); + j =atp_readb_io (dev, c,0x17 );if (j ==0x16 ) { goto inq_ok; } -atp_writeb_io (dev,0 ,0x10 ,0x46 ); -atp_writeb_io (dev,0 ,0x12 ,0 ); -atp_writeb_io (dev,0 ,0x13 ,0 ); -atp_writeb_io (dev,0 ,0x14 ,0 ); -atp_writeb_io (dev,0 ,0x18 ,0x08 ); +atp_writeb_io (dev, c,0x10 ,0x46 ); +atp_writeb_io (dev, c,0x12 ,0 ); +atp_writeb_io (dev, c,0x13 ,0 ); +atp_writeb_io (dev, c,0x14 ,0 ); +atp_writeb_io (dev, c,0x18 ,0x08 ); -while ((atp_readb_io (dev,0 ,0x1f ) &0x80 ) ==0x00 ) +while ((atp_readb_io (dev, c,0x1f ) &0x80 ) ==0x00 )cpu_relax (); -if (atp_readb_io (dev,0 ,0x17 ) !=0x16 ) +if (atp_readb_io (dev, c,0x17 ) !=0x16 ) goto sel_ok; inq_ok: mbuf[36 ] =0 ;printk (KERN_INFO " ID: %2d %s\n" , i, &mbuf[8 ]); - dev->id[0 ][i].devtype = mbuf[0 ]; + dev->id[c][i].devtype = mbuf[0 ]; rmb = mbuf[1 ]; n = mbuf[7 ];if ((mbuf[7 ] &0x60 ) ==0 ) { goto not_wide; } -if ((i <8 ) && ((dev->global_map[0 ] &0x20 ) ==0 )) { +if ((i <8 ) && ((dev->global_map[c] &0x20 ) ==0 )) { goto not_wide; }if (lvdmode ==0 ) { goto chg_wide; } -if (dev->sp[0 ][i] !=0x04 )// force u2 +if (dev->sp[c][i] !=0x04 )// force u2 { goto chg_wide; } -atp_writeb_io (dev,0 ,0x1b ,0x01 ); -atp_writeb_io (dev,0 ,3 , satn[0 ]); -atp_writeb_io (dev,0 ,4 , satn[1 ]); -atp_writeb_io (dev,0 ,5 , satn[2 ]); -atp_writeb_io (dev,0 ,6 , satn[3 ]); -atp_writeb_io (dev,0 ,7 , satn[4 ]); -atp_writeb_io (dev,0 ,8 , satn[5 ]); -atp_writeb_io (dev,0 ,0x0f ,0 ); -atp_writeb_io (dev,0 ,0x11 , dev->id[0 ][i].devsp); -atp_writeb_io (dev,0 ,0x12 ,0 ); -atp_writeb_io (dev,0 ,0x13 , satn[6 ]); -atp_writeb_io (dev,0 ,0x14 , satn[7 ]); -atp_writeb_io (dev,0 ,0x18 , satn[8 ]); +atp_writeb_io (dev, c,0x1b ,0x01 ); +atp_writeb_io (dev, c,3 , satn[0 ]); +atp_writeb_io (dev, c,4 , satn[1 ]); +atp_writeb_io (dev, c,5 , satn[2 ]); +atp_writeb_io (dev, c,6 , satn[3 ]); +atp_writeb_io (dev, c,7 , satn[4 ]); +atp_writeb_io (dev, c,8 , satn[5 ]); +atp_writeb_io (dev, c,0x0f ,0 ); +atp_writeb_io (dev, c,0x11 , dev->id[c][i].devsp); +atp_writeb_io (dev, c,0x12 ,0 ); +atp_writeb_io (dev, c,0x13 , satn[6 ]); +atp_writeb_io (dev, c,0x14 , satn[7 ]); +atp_writeb_io (dev, c,0x18 , satn[8 ]); -while ((atp_readb_io (dev,0 ,0x1f ) &0x80 ) ==0x00 ) +while ((atp_readb_io (dev, c,0x1f ) &0x80 ) ==0x00 )cpu_relax (); -if (atp_readb_io (dev,0 ,0x17 ) !=0x11 &&atp_readb_io (dev,0 ,0x17 ) !=0x8e ) +if (atp_readb_io (dev, c,0x17 ) !=0x11 &&atp_readb_io (dev, c,0x17 ) !=0x8e )continue ; -while (atp_readb_io (dev,0 ,0x17 ) !=0x8e ) +while (atp_readb_io (dev, c,0x17 ) !=0x8e )cpu_relax (); try_u3: j =0 ; -atp_writeb_io (dev,0 ,0x14 ,0x09 ); -atp_writeb_io (dev,0 ,0x18 ,0x20 ); +atp_writeb_io (dev, c,0x14 ,0x09 ); +atp_writeb_io (dev, c,0x18 ,0x20 ); -while ((atp_readb_io (dev,0 ,0x1f ) &0x80 ) ==0 ) { -if ((atp_readb_io (dev,0 ,0x1f ) &0x01 ) !=0 ) -atp_writeb_io (dev,0 ,0x19 , u3[j++]); +while ((atp_readb_io (dev, c,0x1f ) &0x80 ) ==0 ) { +if ((atp_readb_io (dev, c,0x1f ) &0x01 ) !=0 ) +atp_writeb_io (dev, c,0x19 , u3[j++]); } -while ((atp_readb_io (dev,0 ,0x17 ) &0x80 ) ==0x00 ) +while ((atp_readb_io (dev, c,0x17 ) &0x80 ) ==0x00 )cpu_relax (); - j =atp_readb_io (dev,0 ,0x17 ) &0x0f ; + j =atp_readb_io (dev, c,0x17 ) &0x0f ;if (j ==0x0f ) { goto u3p_in; }
@@ -1787,12 +1787,12 @@ try_u3: }continue ; u3p_out: -atp_writeb_io (dev,0 ,0x18 ,0x20 ); -while ((atp_readb_io (dev,0 ,0x1f ) &0x80 ) ==0 ) { -if ((atp_readb_io (dev,0 ,0x1f ) &0x01 ) !=0 ) -atp_writeb_io (dev,0 ,0x19 ,0 ); +atp_writeb_io (dev, c,0x18 ,0x20 ); +while ((atp_readb_io (dev, c,0x1f ) &0x80 ) ==0 ) { +if ((atp_readb_io (dev, c,0x1f ) &0x01 ) !=0 ) +atp_writeb_io (dev, c,0x19 ,0 ); } - j =atp_readb_io (dev,0 ,0x17 ) &0x0f ; + j =atp_readb_io (dev, c,0x17 ) &0x0f ;if (j ==0x0f ) { goto u3p_in; }
@@ -1804,19 +1804,19 @@ u3p_out: }continue ; u3p_in: -atp_writeb_io (dev,0 ,0x14 ,0x09 ); -atp_writeb_io (dev,0 ,0x18 ,0x20 ); +atp_writeb_io (dev, c,0x14 ,0x09 ); +atp_writeb_io (dev, c,0x18 ,0x20 ); k =0 ; u3p_in1: - j =atp_readb_io (dev,0 ,0x1f ); + j =atp_readb_io (dev, c,0x1f );if ((j &0x01 ) !=0 ) { - mbuf[k++] =atp_readb_io (dev,0 ,0x19 ); + mbuf[k++] =atp_readb_io (dev, c,0x19 ); goto u3p_in1; }if ((j &0x80 ) ==0x00 ) { goto u3p_in1; } - j =atp_readb_io (dev,0 ,0x17 ) &0x0f ; + j =atp_readb_io (dev, c,0x17 ) &0x0f ;if (j ==0x0f ) { goto u3p_in; }
@@ -1828,14 +1828,14 @@ u3p_in1: }continue ; u3p_cmd: -atp_writeb_io (dev,0 ,0x10 ,0x30 ); -atp_writeb_io (dev,0 ,0x14 ,0x00 ); -atp_writeb_io (dev,0 ,0x18 ,0x08 ); +atp_writeb_io (dev, c,0x10 ,0x30 ); +atp_writeb_io (dev, c,0x14 ,0x00 ); +atp_writeb_io (dev, c,0x18 ,0x08 ); -while ((atp_readb_io (dev,0 ,0x1f ) &0x80 ) ==0x00 ) +while ((atp_readb_io (dev, c,0x1f ) &0x80 ) ==0x00 )cpu_relax (); - j =atp_readb_io (dev,0 ,0x17 ); + j =atp_readb_io (dev, c,0x17 );if (j !=0x16 ) {if (j ==0x4e ) { goto u3p_out;
@@ -1854,48 +1854,48 @@ u3p_cmd:if (mbuf[3 ] ==0x09 ) { m =1 ; m = m << i; - dev->wide_id[0 ] |= m; - dev->id[0 ][i].devsp =0xce ; + dev->wide_id[c] |= m; + dev->id[c][i].devsp =0xce ;continue ; } chg_wide: -atp_writeb_io (dev,0 ,0x1b ,0x01 ); -atp_writeb_io (dev,0 ,3 , satn[0 ]); -atp_writeb_io (dev,0 ,4 , satn[1 ]); -atp_writeb_io (dev,0 ,5 , satn[2 ]); -atp_writeb_io (dev,0 ,6 , satn[3 ]); -atp_writeb_io (dev,0 ,7 , satn[4 ]); -atp_writeb_io (dev,0 ,8 , satn[5 ]); -atp_writeb_io (dev,0 ,0x0f ,0 ); -atp_writeb_io (dev,0 ,0x11 , dev->id[0 ][i].devsp); -atp_writeb_io (dev,0 ,0x12 ,0 ); -atp_writeb_io (dev,0 ,0x13 , satn[6 ]); -atp_writeb_io (dev,0 ,0x14 , satn[7 ]); -atp_writeb_io (dev,0 ,0x18 , satn[8 ]); +atp_writeb_io (dev, c,0x1b ,0x01 ); +atp_writeb_io (dev, c,3 , satn[0 ]); +atp_writeb_io (dev, c,4 , satn[1 ]); +atp_writeb_io (dev, c,5 , satn[2 ]); +atp_writeb_io (dev, c,6 , satn[3 ]); +atp_writeb_io (dev, c,7 , satn[4 ]); +atp_writeb_io (dev, c,8 , satn[5 ]); +atp_writeb_io (dev, c,0x0f ,0 ); +atp_writeb_io (dev, c,0x11 , dev->id[c][i].devsp); +atp_writeb_io (dev, c,0x12 ,0 ); +atp_writeb_io (dev, c,0x13 , satn[6 ]); +atp_writeb_io (dev, c,0x14 , satn[7 ]); +atp_writeb_io (dev, c,0x18 , satn[8 ]); -while ((atp_readb_io (dev,0 ,0x1f ) &0x80 ) ==0x00 ) +while ((atp_readb_io (dev, c,0x1f ) &0x80 ) ==0x00 )cpu_relax (); -if (atp_readb_io (dev,0 ,0x17 ) !=0x11 &&atp_readb_io (dev,0 ,0x17 ) !=0x8e ) +if (atp_readb_io (dev, c,0x17 ) !=0x11 &&atp_readb_io (dev, c,0x17 ) !=0x8e )continue ; -while (atp_readb_io (dev,0 ,0x17 ) !=0x8e ) +while (atp_readb_io (dev, c,0x17 ) !=0x8e )cpu_relax (); try_wide: j =0 ; -atp_writeb_io (dev,0 ,0x14 ,0x05 ); -atp_writeb_io (dev,0 ,0x18 ,0x20 ); +atp_writeb_io (dev, c,0x14 ,0x05 ); +atp_writeb_io (dev, c,0x18 ,0x20 ); -while ((atp_readb_io (dev,0 ,0x1f ) &0x80 ) ==0 ) { -if ((atp_readb_io (dev,0 ,0x1f ) &0x01 ) !=0 ) -atp_writeb_io (dev,0 ,0x19 , wide[j++]); +while ((atp_readb_io (dev, c,0x1f ) &0x80 ) ==0 ) { +if ((atp_readb_io (dev, c,0x1f ) &0x01 ) !=0 ) +atp_writeb_io (dev, c,0x19 , wide[j++]); } -while ((atp_readb_io (dev,0 ,0x17 ) &0x80 ) ==0x00 ) +while ((atp_readb_io (dev, c,0x17 ) &0x80 ) ==0x00 )cpu_relax (); - j =atp_readb_io (dev,0 ,0x17 ) &0x0f ; + j =atp_readb_io (dev, c,0x17 ) &0x0f ;if (j ==0x0f ) { goto widep_in; }
@@ -1907,12 +1907,12 @@ try_wide: }continue ; widep_out: -atp_writeb_io (dev,0 ,0x18 ,0x20 ); -while ((atp_readb_io (dev,0 ,0x1f ) &0x80 ) ==0 ) { -if ((atp_readb_io (dev,0 ,0x1f ) &0x01 ) !=0 ) -atp_writeb_io (dev,0 ,0x19 ,0 ); +atp_writeb_io (dev, c,0x18 ,0x20 ); +while ((atp_readb_io (dev, c,0x1f ) &0x80 ) ==0 ) { +if ((atp_readb_io (dev, c,0x1f ) &0x01 ) !=0 ) +atp_writeb_io (dev, c,0x19 ,0 ); } - j =atp_readb_io (dev,0 ,0x17 ) &0x0f ; + j =atp_readb_io (dev, c,0x17 ) &0x0f ;if (j ==0x0f ) { goto widep_in; }
@@ -1924,19 +1924,19 @@ widep_out: }continue ; widep_in: -atp_writeb_io (dev,0 ,0x14 ,0xff ); -atp_writeb_io (dev,0 ,0x18 ,0x20 ); +atp_writeb_io (dev, c,0x14 ,0xff ); +atp_writeb_io (dev, c,0x18 ,0x20 ); k =0 ; widep_in1: - j =atp_readb_io (dev,0 ,0x1f ); + j =atp_readb_io (dev, c,0x1f );if ((j &0x01 ) !=0 ) { - mbuf[k++] =atp_readb_io (dev,0 ,0x19 ); + mbuf[k++] =atp_readb_io (dev, c,0x19 ); goto widep_in1; }if ((j &0x80 ) ==0x00 ) { goto widep_in1; } - j =atp_readb_io (dev,0 ,0x17 ) &0x0f ; + j =atp_readb_io (dev, c,0x17 ) &0x0f ;if (j ==0x0f ) { goto widep_in; }
@@ -1948,14 +1948,14 @@ widep_in1: }continue ; widep_cmd: -atp_writeb_io (dev,0 ,0x10 ,0x30 ); -atp_writeb_io (dev,0 ,0x14 ,0x00 ); -atp_writeb_io (dev,0 ,0x18 ,0x08 ); +atp_writeb_io (dev, c,0x10 ,0x30 ); +atp_writeb_io (dev, c,0x14 ,0x00 ); +atp_writeb_io (dev, c,0x18 ,0x08 ); -while ((atp_readb_io (dev,0 ,0x1f ) &0x80 ) ==0x00 ) +while ((atp_readb_io (dev, c,0x1f ) &0x80 ) ==0x00 )cpu_relax (); - j =atp_readb_io (dev,0 ,0x17 ); + j =atp_readb_io (dev, c,0x17 );if (j !=0x16 ) {if (j ==0x4e ) { goto widep_out;
@@ -1976,80 +1976,80 @@ widep_cmd: } m =1 ; m = m << i; - dev->wide_id[0 ] |= m; + dev->wide_id[c] |= m; not_wide: -if ((dev->id[0 ][i].devtype ==0x00 ) || (dev->id[0 ][i].devtype ==0x07 ) || ((dev->id[0 ][i].devtype ==0x05 ) && ((n &0x10 ) !=0 ))) { +if ((dev->id[c][i].devtype ==0x00 ) || (dev->id[c][i].devtype ==0x07 ) || ((dev->id[c][i].devtype ==0x05 ) && ((n &0x10 ) !=0 ))) { m =1 ; m = m << i; -if ((dev->async[0 ] & m) !=0 ) { +if ((dev->async[c] & m) !=0 ) { goto set_sync; } }continue ; set_sync: -if (dev->sp[0 ][i] ==0x02 ) { +if (dev->sp[c][i] ==0x02 ) { synu[4 ] =0x0c ; synuw[4 ] =0x0c ; }else { -if (dev->sp[0 ][i] >=0x03 ) { +if (dev->sp[c][i] >=0x03 ) { synu[4 ] =0x0a ; synuw[4 ] =0x0a ; } } j =0 ; -if ((m & dev->wide_id[0 ]) !=0 ) { +if ((m & dev->wide_id[c]) !=0 ) { j |=0x01 ; } -atp_writeb_io (dev,0 ,0x1b , j); -atp_writeb_io (dev,0 ,3 , satn[0 ]); -atp_writeb_io (dev,0 ,4 , satn[1 ]); -atp_writeb_io (dev,0 ,5 , satn[2 ]); -atp_writeb_io (dev,0 ,6 , satn[3 ]); -atp_writeb_io (dev,0 ,7 , satn[4 ]); -atp_writeb_io (dev,0 ,8 , satn[5 ]); -atp_writeb_io (dev,0 ,0x0f ,0 ); -atp_writeb_io (dev,0 ,0x11 , dev->id[0 ][i].devsp); -atp_writeb_io (dev,0 ,0x12 ,0 ); -atp_writeb_io (dev,0 ,0x13 , satn[6 ]); -atp_writeb_io (dev,0 ,0x14 , satn[7 ]); -atp_writeb_io (dev,0 ,0x18 , satn[8 ]); +atp_writeb_io (dev, c,0x1b , j); +atp_writeb_io (dev, c,3 , satn[0 ]); +atp_writeb_io (dev, c,4 , satn[1 ]); +atp_writeb_io (dev, c,5 , satn[2 ]); +atp_writeb_io (dev, c,6 , satn[3 ]); +atp_writeb_io (dev, c,7 , satn[4 ]); +atp_writeb_io (dev, c,8 , satn[5 ]); +atp_writeb_io (dev, c,0x0f ,0 ); +atp_writeb_io (dev, c,0x11 , dev->id[c][i].devsp); +atp_writeb_io (dev, c,0x12 ,0 ); +atp_writeb_io (dev, c,0x13 , satn[6 ]); +atp_writeb_io (dev, c,0x14 , satn[7 ]); +atp_writeb_io (dev, c,0x18 , satn[8 ]); -while ((atp_readb_io (dev,0 ,0x1f ) &0x80 ) ==0x00 ) +while ((atp_readb_io (dev, c,0x1f ) &0x80 ) ==0x00 )cpu_relax (); -if (atp_readb_io (dev,0 ,0x17 ) !=0x11 &&atp_readb_io (dev,0 ,0x17 ) !=0x8e ) +if (atp_readb_io (dev, c,0x17 ) !=0x11 &&atp_readb_io (dev, c,0x17 ) !=0x8e )continue ; -while (atp_readb_io (dev,0 ,0x17 ) !=0x8e ) +while (atp_readb_io (dev, c,0x17 ) !=0x8e )cpu_relax (); try_sync: j =0 ; -atp_writeb_io (dev,0 ,0x14 ,0x06 ); -atp_writeb_io (dev,0 ,0x18 ,0x20 ); - -while ((atp_readb_io (dev,0 ,0x1f ) &0x80 ) ==0 ) { -if ((atp_readb_io (dev,0 ,0x1f ) &0x01 ) !=0 ) { -if ((m & dev->wide_id[0 ]) !=0 ) { -if ((m & dev->ultra_map[0 ]) !=0 ) { -atp_writeb_io (dev,0 ,0x19 , synuw[j++]); +atp_writeb_io (dev, c,0x14 ,0x06 ); +atp_writeb_io (dev, c,0x18 ,0x20 ); + +while ((atp_readb_io (dev, c,0x1f ) &0x80 ) ==0 ) { +if ((atp_readb_io (dev, c,0x1f ) &0x01 ) !=0 ) { +if ((m & dev->wide_id[c]) !=0 ) { +if ((m & dev->ultra_map[c]) !=0 ) { +atp_writeb_io (dev, c,0x19 , synuw[j++]); }else { -atp_writeb_io (dev,0 ,0x19 , synw[j++]); +atp_writeb_io (dev, c,0x19 , synw[j++]); } }else { -if ((m & dev->ultra_map[0 ]) !=0 ) { -atp_writeb_io (dev,0 ,0x19 , synu[j++]); +if ((m & dev->ultra_map[c]) !=0 ) { +atp_writeb_io (dev, c,0x19 , synu[j++]); }else { -atp_writeb_io (dev,0 ,0x19 , synn[j++]); +atp_writeb_io (dev, c,0x19 , synn[j++]); } } } } -while ((atp_readb_io (dev,0 ,0x17 ) &0x80 ) ==0x00 ) +while ((atp_readb_io (dev, c,0x17 ) &0x80 ) ==0x00 )cpu_relax (); - j =atp_readb_io (dev,0 ,0x17 ) &0x0f ; + j =atp_readb_io (dev, c,0x17 ) &0x0f ;if (j ==0x0f ) { goto phase_ins; }
@@ -2061,12 +2061,12 @@ try_sync: }continue ; phase_outs: -atp_writeb_io (dev,0 ,0x18 ,0x20 ); -while ((atp_readb_io (dev,0 ,0x1f ) &0x80 ) ==0x00 ) { -if ((atp_readb_io (dev,0 ,0x1f ) &0x01 ) !=0x00 ) -atp_writeb_io (dev,0 ,0x19 ,0x00 ); +atp_writeb_io (dev, c,0x18 ,0x20 ); +while ((atp_readb_io (dev, c,0x1f ) &0x80 ) ==0x00 ) { +if ((atp_readb_io (dev, c,0x1f ) &0x01 ) !=0x00 ) +atp_writeb_io (dev, c,0x19 ,0x00 ); } - j =atp_readb_io (dev,0 ,0x17 ); + j =atp_readb_io (dev, c,0x17 );if (j ==0x85 ) { goto tar_dcons; }
@@ -2082,23 +2082,23 @@ phase_outs: }continue ; phase_ins: -atp_writeb_io (dev,0 ,0x14 ,0x06 ); -atp_writeb_io (dev,0 ,0x18 ,0x20 ); +atp_writeb_io (dev, c,0x14 ,0x06 ); +atp_writeb_io (dev, c,0x18 ,0x20 ); k =0 ; phase_ins1: - j =atp_readb_io (dev,0 ,0x1f ); + j =atp_readb_io (dev, c,0x1f );if ((j &0x01 ) !=0x00 ) { - mbuf[k++] =atp_readb_io (dev,0 ,0x19 ); + mbuf[k++] =atp_readb_io (dev, c,0x19 ); goto phase_ins1; }if ((j &0x80 ) ==0x00 ) { goto phase_ins1; } -while ((atp_readb_io (dev,0 ,0x17 ) &0x80 ) ==0x00 ) +while ((atp_readb_io (dev, c,0x17 ) &0x80 ) ==0x00 )cpu_relax (); - j =atp_readb_io (dev,0 ,0x17 ); + j =atp_readb_io (dev, c,0x17 );if (j ==0x85 ) { goto tar_dcons; }
@@ -2114,15 +2114,15 @@ phase_ins1: }continue ; phase_cmds: -atp_writeb_io (dev,0 ,0x10 ,0x30 ); +atp_writeb_io (dev, c,0x10 ,0x30 ); tar_dcons: -atp_writeb_io (dev,0 ,0x14 ,0x00 ); -atp_writeb_io (dev,0 ,0x18 ,0x08 ); +atp_writeb_io (dev, c,0x14 ,0x00 ); +atp_writeb_io (dev, c,0x18 ,0x08 ); -while ((atp_readb_io (dev,0 ,0x1f ) &0x80 ) ==0x00 ) +while ((atp_readb_io (dev, c,0x1f ) &0x80 ) ==0x00 )cpu_relax (); - j =atp_readb_io (dev,0 ,0x17 ); + j =atp_readb_io (dev, c,0x17 );if (j !=0x16 ) {continue ; }
@@ -2141,7 +2141,7 @@ tar_dcons:if (mbuf[4 ] >0x0e ) { mbuf[4 ] =0x0e ; } - dev->id[0 ][i].devsp = mbuf[4 ]; + dev->id[c][i].devsp = mbuf[4 ];if (mbuf[3 ] <0x0c ) { j =0xb0 ; goto set_syn_ok;
@@ -2164,7 +2164,7 @@ tar_dcons: } j =0x60 ; set_syn_ok: - dev->id[0 ][i].devsp = (dev->id[0 ][i].devsp &0x0f ) | j; + dev->id[c][i].devsp = (dev->id[c][i].devsp &0x0f ) | j; } }
@@ -2379,7 +2379,7 @@ flash_ok_880:outb (0x20 , base_io +0x51 );tscam (shpnt); -is880 (p); +is880 (p,0 );outb (0xb0 , base_io +0x38 ); shpnt->max_id =16 ; shpnt->this_id = host_id;
@@ -2609,7 +2609,7 @@ flash_ok_885:outb (0x20 , base_io +0x11 );tscam (shpnt); -is870 (p); +is870 (p,0 );outb ((inb (base_io +0x3a ) &0xef ), base_io +0x3a );outb ((inb (base_io +0x3b ) |0x20 ), base_io +0x3b );if (atpdev->chip_ver ==4 )
Signature · 1 line
Ondrej Zary
PATCH 24/52 atp870u: Move chip-specific lines out of is880() and is885()
In reply to Ondrej ZaryMove few chip-specifis lines out of is880() and is885() so they become almost identical.
--- drivers/scsi/atp870u.c | 24 ++++++++++-------------- 1 file changed, 10 insertions(+), 14 deletions(-)
drivers/scsi/atp870u.c +10 -14
@@ -41,7 +41,7 @@static struct scsi_host_template atp870u_template;static void send_s870 (struct atp_unit *dev,unsigned char c); -static void is885 (struct atp_unit *dev,unsigned char c); +static void is885 (struct atp_unit *dev,unsigned char c,unsigned char lvdmode);static void tscam_885 (void );static inline void atp_writeb_base (struct atp_unit *atp,u8 reg,u8 val)
@@ -1596,9 +1596,9 @@ set_syn_ok:atp_writeb_io (dev, c,0x3a ,atp_readb_io (dev, c,0x3a ) &0xef ); } -static void is880 (struct atp_unit *dev,unsigned char c) +static void is880 (struct atp_unit *dev,unsigned char c,unsigned char lvdmode) { -unsigned char i, j, k, rmb, n, lvdmode; +unsigned char i, j, k, rmb, n;unsigned short int m;static unsigned char mbuf[512 ];static unsigned char satn[9 ] = {0 ,0 ,0 ,0 ,0 ,0 ,0 ,6 ,6 };
@@ -1610,8 +1610,6 @@ static void is880(struct atp_unit *dev, unsigned char c)static unsigned char wide[6 ] = {0x80 ,1 ,2 ,3 ,1 ,0 };static unsigned char u3[9 ] = {0x80 ,1 ,6 ,4 ,0x09 ,00 ,0x0e ,0x01 ,0x02 }; - lvdmode =atp_readb_base (dev,0x3f ) &0x40 ; -for (i =0 ; i <16 ; i++) { m =1 ; m = m << i;
@@ -2379,7 +2377,7 @@ flash_ok_880:outb (0x20 , base_io +0x51 );tscam (shpnt); -is880 (p,0 ); +is880 (p,0 ,atp_readb_base (p,0x3f ) &0x40 );outb (0xb0 , base_io +0x38 ); shpnt->max_id =16 ; shpnt->this_id = host_id;
@@ -2525,10 +2523,11 @@ flash_ok_885:tscam_885 ();printk (KERN_INFO " Scanning Channel A SCSI Device ...\n" ); -is885 (p,0 ); +is885 (p,0 ,atp_readb_io (p,0 ,0x1b ) >>7 ); +atp_writeb_io (p,0 ,0x16 ,0x80 );printk (KERN_INFO " Scanning Channel B SCSI Device ...\n" ); -is885 (p,1 ); - +is885 (p,1 ,atp_readb_io (p,1 ,0x1b ) >>7 ); +atp_writeb_io (p,1 ,0x16 ,0x80 ); k =inb (base_io +0x28 ) &0xcf ; k |=0xc0 ;outb (k, base_io +0x28 );
@@ -2829,9 +2828,9 @@ static void tscam_885(void) -static void is885 (struct atp_unit *dev,unsigned char c) +static void is885 (struct atp_unit *dev,unsigned char c,unsigned char lvdmode) { -unsigned char i, j, k, rmb, n, lvdmode; +unsigned char i, j, k, rmb, n;unsigned short int m;static unsigned char mbuf[512 ];static unsigned char satn[9 ] = {0 ,0 ,0 ,0 ,0 ,0 ,0 ,6 ,6 };
@@ -2843,8 +2842,6 @@ static void is885(struct atp_unit *dev, unsigned char c)static unsigned char wide[6 ] = {0x80 ,1 ,2 ,3 ,1 ,0 };static unsigned char u3[9 ] = {0x80 ,1 ,6 ,4 ,0x09 ,00 ,0x0e ,0x01 ,0x02 }; - lvdmode =atp_readb_io (dev, c,0x1b ) >>7 ; -for (i =0 ; i <16 ; i++) { m =1 ; m = m << i;
@@ -3408,7 +3405,6 @@ set_syn_ok:printk ("dev->id[%2d][%2d].devsp = %2x\n" ,c,i,dev->id[c][i].devsp);#endif } -atp_writeb_io (dev, c,0x16 ,0x80 ); }module_init (atp870u_init);
Signature · 1 line
Ondrej Zary
PATCH 25/52 atp870u: Remove is880()
In reply to Ondrej ZaryNow that is880() and is885() are almost identical (except for some cpu_relax() calls and debug printks), remove is880() and use is885() instead.
--- drivers/scsi/atp870u.c | 572 +----------------------------------------------- 1 file changed, 1 insertion(+), 571 deletions(-)
drivers/scsi/atp870u.c +1 -571
@@ -1596,576 +1596,6 @@ set_syn_ok:atp_writeb_io (dev, c,0x3a ,atp_readb_io (dev, c,0x3a ) &0xef ); } -static void is880 (struct atp_unit *dev,unsigned char c,unsigned char lvdmode) -{ -unsigned char i, j, k, rmb, n; -unsigned short int m; -static unsigned char mbuf[512 ]; -static unsigned char satn[9 ] = {0 ,0 ,0 ,0 ,0 ,0 ,0 ,6 ,6 }; -static unsigned char inqd[9 ] = {0x12 ,0 ,0 ,0 ,0x24 ,0 ,0 ,0x24 ,6 }; -static unsigned char synn[6 ] = {0x80 ,1 ,3 ,1 ,0x19 ,0x0e }; -unsigned char synu[6 ] = {0x80 ,1 ,3 ,1 ,0x0a ,0x0e }; -static unsigned char synw[6 ] = {0x80 ,1 ,3 ,1 ,0x19 ,0x0e }; -unsigned char synuw[6 ] = {0x80 ,1 ,3 ,1 ,0x0a ,0x0e }; -static unsigned char wide[6 ] = {0x80 ,1 ,2 ,3 ,1 ,0 }; -static unsigned char u3[9 ] = {0x80 ,1 ,6 ,4 ,0x09 ,00 ,0x0e ,0x01 ,0x02 }; - -for (i =0 ; i <16 ; i++) { - m =1 ; - m = m << i; -if ((m & dev->active_id[c]) !=0 ) { -continue ; - } -if (i == dev->host_id[c]) { -printk (KERN_INFO " ID: %2d Host Adapter\n" , dev->host_id[c]); -continue ; - } -atp_writeb_io (dev, c,0x1b ,0x01 ); -atp_writeb_io (dev, c,1 ,0x08 ); -atp_writeb_io (dev, c,2 ,0x7f ); -atp_writeb_io (dev, c,3 , satn[0 ]); -atp_writeb_io (dev, c,4 , satn[1 ]); -atp_writeb_io (dev, c,5 , satn[2 ]); -atp_writeb_io (dev, c,6 , satn[3 ]); -atp_writeb_io (dev, c,7 , satn[4 ]); -atp_writeb_io (dev, c,8 , satn[5 ]); -atp_writeb_io (dev, c,0x0f ,0 ); -atp_writeb_io (dev, c,0x11 , dev->id[c][i].devsp); -atp_writeb_io (dev, c,0x12 ,0 ); -atp_writeb_io (dev, c,0x13 , satn[6 ]); -atp_writeb_io (dev, c,0x14 , satn[7 ]); - j = i; -if ((j &0x08 ) !=0 ) { - j = (j &0x07 ) |0x40 ; - } -atp_writeb_io (dev, c,0x15 , j); -atp_writeb_io (dev, c,0x18 , satn[8 ]); - -while ((atp_readb_io (dev, c,0x1f ) &0x80 ) ==0x00 ) -cpu_relax (); - -if (atp_readb_io (dev, c,0x17 ) !=0x11 &&atp_readb_io (dev, c,0x17 ) !=0x8e ) -continue ; - -while (atp_readb_io (dev, c,0x17 ) !=0x8e ) -cpu_relax (); - - dev->active_id[c] |= m; - -atp_writeb_io (dev, c,0x10 ,0x30 ); -atp_writeb_io (dev, c,0x14 ,0x00 ); - -phase_cmd: -atp_writeb_io (dev, c,0x18 ,0x08 ); - -while ((atp_readb_io (dev, c,0x1f ) &0x80 ) ==0x00 ) -cpu_relax (); - - j =atp_readb_io (dev, c,0x17 ); -if (j !=0x16 ) { -atp_writeb_io (dev, c,0x10 ,0x41 ); - goto phase_cmd; - } -sel_ok: -atp_writeb_io (dev, c,3 , inqd[0 ]); -atp_writeb_io (dev, c,4 , inqd[1 ]); -atp_writeb_io (dev, c,5 , inqd[2 ]); -atp_writeb_io (dev, c,6 , inqd[3 ]); -atp_writeb_io (dev, c,7 , inqd[4 ]); -atp_writeb_io (dev, c,8 , inqd[5 ]); -atp_writeb_io (dev, c,0x0f ,0 ); -atp_writeb_io (dev, c,0x11 , dev->id[c][i].devsp); -atp_writeb_io (dev, c,0x12 ,0 ); -atp_writeb_io (dev, c,0x13 , inqd[6 ]); -atp_writeb_io (dev, c,0x14 , inqd[7 ]); -atp_writeb_io (dev, c,0x18 , inqd[8 ]); - -while ((atp_readb_io (dev, c,0x1f ) &0x80 ) ==0x00 ) -cpu_relax (); - -if (atp_readb_io (dev, c,0x17 ) !=0x11 &&atp_readb_io (dev, c,0x17 ) !=0x8e ) -continue ; - -while (atp_readb_io (dev, c,0x17 ) !=0x8e ) -cpu_relax (); - -atp_writeb_io (dev, c,0x1b ,0x00 ); -atp_writeb_io (dev, c,0x18 ,0x08 ); - j =0 ; -rd_inq_data: - k =atp_readb_io (dev, c,0x1f ); -if ((k &0x01 ) !=0 ) { - mbuf[j++] =atp_readb_io (dev, c,0x19 ); - goto rd_inq_data; - } -if ((k &0x80 ) ==0 ) { - goto rd_inq_data; - } - j =atp_readb_io (dev, c,0x17 ); -if (j ==0x16 ) { - goto inq_ok; - } -atp_writeb_io (dev, c,0x10 ,0x46 ); -atp_writeb_io (dev, c,0x12 ,0 ); -atp_writeb_io (dev, c,0x13 ,0 ); -atp_writeb_io (dev, c,0x14 ,0 ); -atp_writeb_io (dev, c,0x18 ,0x08 ); - -while ((atp_readb_io (dev, c,0x1f ) &0x80 ) ==0x00 ) -cpu_relax (); - -if (atp_readb_io (dev, c,0x17 ) !=0x16 ) - goto sel_ok; - -inq_ok: - mbuf[36 ] =0 ; -printk (KERN_INFO " ID: %2d %s\n" , i, &mbuf[8 ]); - dev->id[c][i].devtype = mbuf[0 ]; - rmb = mbuf[1 ]; - n = mbuf[7 ]; -if ((mbuf[7 ] &0x60 ) ==0 ) { - goto not_wide; - } -if ((i <8 ) && ((dev->global_map[c] &0x20 ) ==0 )) { - goto not_wide; - } -if (lvdmode ==0 ) { - goto chg_wide; - } -if (dev->sp[c][i] !=0x04 )// force u2 - { - goto chg_wide; - } - -atp_writeb_io (dev, c,0x1b ,0x01 ); -atp_writeb_io (dev, c,3 , satn[0 ]); -atp_writeb_io (dev, c,4 , satn[1 ]); -atp_writeb_io (dev, c,5 , satn[2 ]); -atp_writeb_io (dev, c,6 , satn[3 ]); -atp_writeb_io (dev, c,7 , satn[4 ]); -atp_writeb_io (dev, c,8 , satn[5 ]); -atp_writeb_io (dev, c,0x0f ,0 ); -atp_writeb_io (dev, c,0x11 , dev->id[c][i].devsp); -atp_writeb_io (dev, c,0x12 ,0 ); -atp_writeb_io (dev, c,0x13 , satn[6 ]); -atp_writeb_io (dev, c,0x14 , satn[7 ]); -atp_writeb_io (dev, c,0x18 , satn[8 ]); - -while ((atp_readb_io (dev, c,0x1f ) &0x80 ) ==0x00 ) -cpu_relax (); - -if (atp_readb_io (dev, c,0x17 ) !=0x11 &&atp_readb_io (dev, c,0x17 ) !=0x8e ) -continue ; - -while (atp_readb_io (dev, c,0x17 ) !=0x8e ) -cpu_relax (); - -try_u3: - j =0 ; -atp_writeb_io (dev, c,0x14 ,0x09 ); -atp_writeb_io (dev, c,0x18 ,0x20 ); - -while ((atp_readb_io (dev, c,0x1f ) &0x80 ) ==0 ) { -if ((atp_readb_io (dev, c,0x1f ) &0x01 ) !=0 ) -atp_writeb_io (dev, c,0x19 , u3[j++]); - } - -while ((atp_readb_io (dev, c,0x17 ) &0x80 ) ==0x00 ) -cpu_relax (); - - j =atp_readb_io (dev, c,0x17 ) &0x0f ; -if (j ==0x0f ) { - goto u3p_in; - } -if (j ==0x0a ) { - goto u3p_cmd; - } -if (j ==0x0e ) { - goto try_u3; - } -continue ; -u3p_out: -atp_writeb_io (dev, c,0x18 ,0x20 ); -while ((atp_readb_io (dev, c,0x1f ) &0x80 ) ==0 ) { -if ((atp_readb_io (dev, c,0x1f ) &0x01 ) !=0 ) -atp_writeb_io (dev, c,0x19 ,0 ); - } - j =atp_readb_io (dev, c,0x17 ) &0x0f ; -if (j ==0x0f ) { - goto u3p_in; - } -if (j ==0x0a ) { - goto u3p_cmd; - } -if (j ==0x0e ) { - goto u3p_out; - } -continue ; -u3p_in: -atp_writeb_io (dev, c,0x14 ,0x09 ); -atp_writeb_io (dev, c,0x18 ,0x20 ); - k =0 ; -u3p_in1: - j =atp_readb_io (dev, c,0x1f ); -if ((j &0x01 ) !=0 ) { - mbuf[k++] =atp_readb_io (dev, c,0x19 ); - goto u3p_in1; - } -if ((j &0x80 ) ==0x00 ) { - goto u3p_in1; - } - j =atp_readb_io (dev, c,0x17 ) &0x0f ; -if (j ==0x0f ) { - goto u3p_in; - } -if (j ==0x0a ) { - goto u3p_cmd; - } -if (j ==0x0e ) { - goto u3p_out; - } -continue ; -u3p_cmd: -atp_writeb_io (dev, c,0x10 ,0x30 ); -atp_writeb_io (dev, c,0x14 ,0x00 ); -atp_writeb_io (dev, c,0x18 ,0x08 ); - -while ((atp_readb_io (dev, c,0x1f ) &0x80 ) ==0x00 ) -cpu_relax (); - - j =atp_readb_io (dev, c,0x17 ); -if (j !=0x16 ) { -if (j ==0x4e ) { - goto u3p_out; - } -continue ; - } -if (mbuf[0 ] !=0x01 ) { - goto chg_wide; - } -if (mbuf[1 ] !=0x06 ) { - goto chg_wide; - } -if (mbuf[2 ] !=0x04 ) { - goto chg_wide; - } -if (mbuf[3 ] ==0x09 ) { - m =1 ; - m = m << i; - dev->wide_id[c] |= m; - dev->id[c][i].devsp =0xce ; -continue ; - } -chg_wide: -atp_writeb_io (dev, c,0x1b ,0x01 ); -atp_writeb_io (dev, c,3 , satn[0 ]); -atp_writeb_io (dev, c,4 , satn[1 ]); -atp_writeb_io (dev, c,5 , satn[2 ]); -atp_writeb_io (dev, c,6 , satn[3 ]); -atp_writeb_io (dev, c,7 , satn[4 ]); -atp_writeb_io (dev, c,8 , satn[5 ]); -atp_writeb_io (dev, c,0x0f ,0 ); -atp_writeb_io (dev, c,0x11 , dev->id[c][i].devsp); -atp_writeb_io (dev, c,0x12 ,0 ); -atp_writeb_io (dev, c,0x13 , satn[6 ]); -atp_writeb_io (dev, c,0x14 , satn[7 ]); -atp_writeb_io (dev, c,0x18 , satn[8 ]); - -while ((atp_readb_io (dev, c,0x1f ) &0x80 ) ==0x00 ) -cpu_relax (); - -if (atp_readb_io (dev, c,0x17 ) !=0x11 &&atp_readb_io (dev, c,0x17 ) !=0x8e ) -continue ; - -while (atp_readb_io (dev, c,0x17 ) !=0x8e ) -cpu_relax (); - -try_wide: - j =0 ; -atp_writeb_io (dev, c,0x14 ,0x05 ); -atp_writeb_io (dev, c,0x18 ,0x20 ); - -while ((atp_readb_io (dev, c,0x1f ) &0x80 ) ==0 ) { -if ((atp_readb_io (dev, c,0x1f ) &0x01 ) !=0 ) -atp_writeb_io (dev, c,0x19 , wide[j++]); - } - -while ((atp_readb_io (dev, c,0x17 ) &0x80 ) ==0x00 ) -cpu_relax (); - - j =atp_readb_io (dev, c,0x17 ) &0x0f ; -if (j ==0x0f ) { - goto widep_in; - } -if (j ==0x0a ) { - goto widep_cmd; - } -if (j ==0x0e ) { - goto try_wide; - } -continue ; -widep_out: -atp_writeb_io (dev, c,0x18 ,0x20 ); -while ((atp_readb_io (dev, c,0x1f ) &0x80 ) ==0 ) { -if ((atp_readb_io (dev, c,0x1f ) &0x01 ) !=0 ) -atp_writeb_io (dev, c,0x19 ,0 ); - } - j =atp_readb_io (dev, c,0x17 ) &0x0f ; -if (j ==0x0f ) { - goto widep_in; - } -if (j ==0x0a ) { - goto widep_cmd; - } -if (j ==0x0e ) { - goto widep_out; - } -continue ; -widep_in: -atp_writeb_io (dev, c,0x14 ,0xff ); -atp_writeb_io (dev, c,0x18 ,0x20 ); - k =0 ; -widep_in1: - j =atp_readb_io (dev, c,0x1f ); -if ((j &0x01 ) !=0 ) { - mbuf[k++] =atp_readb_io (dev, c,0x19 ); - goto widep_in1; - } -if ((j &0x80 ) ==0x00 ) { - goto widep_in1; - } - j =atp_readb_io (dev, c,0x17 ) &0x0f ; -if (j ==0x0f ) { - goto widep_in; - } -if (j ==0x0a ) { - goto widep_cmd; - } -if (j ==0x0e ) { - goto widep_out; - } -continue ; -widep_cmd: -atp_writeb_io (dev, c,0x10 ,0x30 ); -atp_writeb_io (dev, c,0x14 ,0x00 ); -atp_writeb_io (dev, c,0x18 ,0x08 ); - -while ((atp_readb_io (dev, c,0x1f ) &0x80 ) ==0x00 ) -cpu_relax (); - - j =atp_readb_io (dev, c,0x17 ); -if (j !=0x16 ) { -if (j ==0x4e ) { - goto widep_out; - } -continue ; - } -if (mbuf[0 ] !=0x01 ) { - goto not_wide; - } -if (mbuf[1 ] !=0x02 ) { - goto not_wide; - } -if (mbuf[2 ] !=0x03 ) { - goto not_wide; - } -if (mbuf[3 ] !=0x01 ) { - goto not_wide; - } - m =1 ; - m = m << i; - dev->wide_id[c] |= m; -not_wide: -if ((dev->id[c][i].devtype ==0x00 ) || (dev->id[c][i].devtype ==0x07 ) || ((dev->id[c][i].devtype ==0x05 ) && ((n &0x10 ) !=0 ))) { - m =1 ; - m = m << i; -if ((dev->async[c] & m) !=0 ) { - goto set_sync; - } - } -continue ; -set_sync: -if (dev->sp[c][i] ==0x02 ) { - synu[4 ] =0x0c ; - synuw[4 ] =0x0c ; - }else { -if (dev->sp[c][i] >=0x03 ) { - synu[4 ] =0x0a ; - synuw[4 ] =0x0a ; - } - } - j =0 ; -if ((m & dev->wide_id[c]) !=0 ) { - j |=0x01 ; - } -atp_writeb_io (dev, c,0x1b , j); -atp_writeb_io (dev, c,3 , satn[0 ]); -atp_writeb_io (dev, c,4 , satn[1 ]); -atp_writeb_io (dev, c,5 , satn[2 ]); -atp_writeb_io (dev, c,6 , satn[3 ]); -atp_writeb_io (dev, c,7 , satn[4 ]); -atp_writeb_io (dev, c,8 , satn[5 ]); -atp_writeb_io (dev, c,0x0f ,0 ); -atp_writeb_io (dev, c,0x11 , dev->id[c][i].devsp); -atp_writeb_io (dev, c,0x12 ,0 ); -atp_writeb_io (dev, c,0x13 , satn[6 ]); -atp_writeb_io (dev, c,0x14 , satn[7 ]); -atp_writeb_io (dev, c,0x18 , satn[8 ]); - -while ((atp_readb_io (dev, c,0x1f ) &0x80 ) ==0x00 ) -cpu_relax (); - -if (atp_readb_io (dev, c,0x17 ) !=0x11 &&atp_readb_io (dev, c,0x17 ) !=0x8e ) -continue ; - -while (atp_readb_io (dev, c,0x17 ) !=0x8e ) -cpu_relax (); - -try_sync: - j =0 ; -atp_writeb_io (dev, c,0x14 ,0x06 ); -atp_writeb_io (dev, c,0x18 ,0x20 ); - -while ((atp_readb_io (dev, c,0x1f ) &0x80 ) ==0 ) { -if ((atp_readb_io (dev, c,0x1f ) &0x01 ) !=0 ) { -if ((m & dev->wide_id[c]) !=0 ) { -if ((m & dev->ultra_map[c]) !=0 ) { -atp_writeb_io (dev, c,0x19 , synuw[j++]); - }else { -atp_writeb_io (dev, c,0x19 , synw[j++]); - } - }else { -if ((m & dev->ultra_map[c]) !=0 ) { -atp_writeb_io (dev, c,0x19 , synu[j++]); - }else { -atp_writeb_io (dev, c,0x19 , synn[j++]); - } - } - } - } - -while ((atp_readb_io (dev, c,0x17 ) &0x80 ) ==0x00 ) -cpu_relax (); - - j =atp_readb_io (dev, c,0x17 ) &0x0f ; -if (j ==0x0f ) { - goto phase_ins; - } -if (j ==0x0a ) { - goto phase_cmds; - } -if (j ==0x0e ) { - goto try_sync; - } -continue ; -phase_outs: -atp_writeb_io (dev, c,0x18 ,0x20 ); -while ((atp_readb_io (dev, c,0x1f ) &0x80 ) ==0x00 ) { -if ((atp_readb_io (dev, c,0x1f ) &0x01 ) !=0x00 ) -atp_writeb_io (dev, c,0x19 ,0x00 ); - } - j =atp_readb_io (dev, c,0x17 ); -if (j ==0x85 ) { - goto tar_dcons; - } - j &=0x0f ; -if (j ==0x0f ) { - goto phase_ins; - } -if (j ==0x0a ) { - goto phase_cmds; - } -if (j ==0x0e ) { - goto phase_outs; - } -continue ; -phase_ins: -atp_writeb_io (dev, c,0x14 ,0x06 ); -atp_writeb_io (dev, c,0x18 ,0x20 ); - k =0 ; -phase_ins1: - j =atp_readb_io (dev, c,0x1f ); -if ((j &0x01 ) !=0x00 ) { - mbuf[k++] =atp_readb_io (dev, c,0x19 ); - goto phase_ins1; - } -if ((j &0x80 ) ==0x00 ) { - goto phase_ins1; - } - -while ((atp_readb_io (dev, c,0x17 ) &0x80 ) ==0x00 ) -cpu_relax (); - - j =atp_readb_io (dev, c,0x17 ); -if (j ==0x85 ) { - goto tar_dcons; - } - j &=0x0f ; -if (j ==0x0f ) { - goto phase_ins; - } -if (j ==0x0a ) { - goto phase_cmds; - } -if (j ==0x0e ) { - goto phase_outs; - } -continue ; -phase_cmds: -atp_writeb_io (dev, c,0x10 ,0x30 ); -tar_dcons: -atp_writeb_io (dev, c,0x14 ,0x00 ); -atp_writeb_io (dev, c,0x18 ,0x08 ); - -while ((atp_readb_io (dev, c,0x1f ) &0x80 ) ==0x00 ) -cpu_relax (); - - j =atp_readb_io (dev, c,0x17 ); -if (j !=0x16 ) { -continue ; - } -if (mbuf[0 ] !=0x01 ) { -continue ; - } -if (mbuf[1 ] !=0x03 ) { -continue ; - } -if (mbuf[4 ] ==0x00 ) { -continue ; - } -if (mbuf[3 ] >0x64 ) { -continue ; - } -if (mbuf[4 ] >0x0e ) { - mbuf[4 ] =0x0e ; - } - dev->id[c][i].devsp = mbuf[4 ]; -if (mbuf[3 ] <0x0c ) { - j =0xb0 ; - goto set_syn_ok; - } -if ((mbuf[3 ] <0x0d ) && (rmb ==0 )) { - j =0xa0 ; - goto set_syn_ok; - } -if (mbuf[3 ] <0x1a ) { - j =0x20 ; - goto set_syn_ok; - } -if (mbuf[3 ] <0x33 ) { - j =0x40 ; - goto set_syn_ok; - } -if (mbuf[3 ] <0x4c ) { - j =0x50 ; - goto set_syn_ok; - } - j =0x60 ; -set_syn_ok: - dev->id[c][i].devsp = (dev->id[c][i].devsp &0x0f ) | j; - } -} -static void atp870u_free_tables (struct Scsi_Host *host) {struct atp_unit *atp_dev = (struct atp_unit *)&host->hostdata;
@@ -2377,7 +1807,7 @@ flash_ok_880:outb (0x20 , base_io +0x51 );tscam (shpnt); -is880 (p,0 ,atp_readb_base (p,0x3f ) &0x40 ); +is885 (p,0 ,atp_readb_base (p,0x3f ) &0x40 );outb (0xb0 , base_io +0x38 ); shpnt->max_id =16 ; shpnt->this_id = host_id;
Signature · 1 line
Ondrej Zary
PATCH 26/52 atp870u: Add wide_chip parameter to is870() and is885()
In reply to Ondrej ZaryDon't check chip_ver in is870() but add wide_chip parameter for that. Then add the non-wide support to is885().
--- drivers/scsi/atp870u.c | 46 +++++++++++++++++++++++++--------------------- 1 file changed, 25 insertions(+), 21 deletions(-)
drivers/scsi/atp870u.c +25 -21
@@ -41,7 +41,7 @@static struct scsi_host_template atp870u_template;static void send_s870 (struct atp_unit *dev,unsigned char c); -static void is885 (struct atp_unit *dev,unsigned char c,unsigned char lvdmode); +static void is885 (struct atp_unit *dev,unsigned char c,bool wide_chip,unsigned char lvdmode);static void tscam_885 (void );static inline void atp_writeb_base (struct atp_unit *atp,u8 reg,u8 val)
@@ -1162,7 +1162,7 @@ static void tscam(struct Scsi_Host *host) } } -static void is870 (struct atp_unit *dev,unsigned char c) +static void is870 (struct atp_unit *dev,unsigned char c,bool wide_chip) {unsigned char i, j, k, rmb, n;unsigned short int m;
@@ -1177,9 +1177,8 @@ static void is870(struct atp_unit *dev, unsigned char c)atp_writeb_io (dev, c,0x3a ,atp_readb_io (dev, c,0x3a ) |0x10 );for (i =0 ; i <16 ; i++) { -if ((dev->chip_ver !=4 ) && (i >7 )) { +if (!wide_chip && (i >7 ))break ; - } m =1 ; m = m << i;if ((m & dev->active_id[c]) !=0 ) {
@@ -1189,11 +1188,7 @@ static void is870(struct atp_unit *dev, unsigned char c)printk (KERN_INFO " ID: %2d Host Adapter\n" , dev->host_id[c]);continue ; } -if (dev->chip_ver ==4 ) { -atp_writeb_io (dev, c,0x1b ,0x01 ); - }else { -atp_writeb_io (dev, c,0x1b ,0x00 ); - } +atp_writeb_io (dev, c,0x1b , wide_chip ?0x01 :0x00 );atp_writeb_io (dev, c,1 ,0x08 );atp_writeb_io (dev, c,2 ,0x7f );atp_writeb_io (dev, c,3 , satn[0 ]);
@@ -1262,7 +1257,7 @@ sel_ok:while (atp_readb_io (dev, c,0x17 ) !=0x8e )cpu_relax (); -if (dev->chip_ver ==4 ) +if (wide_chip)atp_writeb_io (dev, c,0x1b ,0x00 );atp_writeb_io (dev, c,0x18 ,0x08 );
@@ -1298,9 +1293,8 @@ inq_ok: dev->id[c][i].devtype = mbuf[0 ]; rmb = mbuf[1 ]; n = mbuf[7 ]; -if (dev->chip_ver !=4 ) { +if (!wide_chip) goto not_wide; - }if ((mbuf[7 ] &0x60 ) ==0 ) { goto not_wide; }
@@ -1807,7 +1801,7 @@ flash_ok_880:outb (0x20 , base_io +0x51 );tscam (shpnt); -is885 (p,0 ,atp_readb_base (p,0x3f ) &0x40 ); +is885 (p,0 , true,atp_readb_base (p,0x3f ) &0x40 );outb (0xb0 , base_io +0x38 ); shpnt->max_id =16 ; shpnt->this_id = host_id;
@@ -1953,10 +1947,10 @@ flash_ok_885:tscam_885 ();printk (KERN_INFO " Scanning Channel A SCSI Device ...\n" ); -is885 (p,0 ,atp_readb_io (p,0 ,0x1b ) >>7 ); +is885 (p,0 , true,atp_readb_io (p,0 ,0x1b ) >>7 );atp_writeb_io (p,0 ,0x16 ,0x80 );printk (KERN_INFO " Scanning Channel B SCSI Device ...\n" ); -is885 (p,1 ,atp_readb_io (p,1 ,0x1b ) >>7 ); +is885 (p,1 , true,atp_readb_io (p,1 ,0x1b ) >>7 );atp_writeb_io (p,1 ,0x16 ,0x80 ); k =inb (base_io +0x28 ) &0xcf ; k |=0xc0 ;
@@ -2038,7 +2032,7 @@ flash_ok_885:outb (0x20 , base_io +0x11 );tscam (shpnt); -is870 (p,0 ); +is870 (p,0 , p->chip_ver ==4 );outb ((inb (base_io +0x3a ) &0xef ), base_io +0x3a );outb ((inb (base_io +0x3b ) |0x20 ), base_io +0x3b );if (atpdev->chip_ver ==4 )
@@ -2258,7 +2252,7 @@ static void tscam_885(void) -static void is885 (struct atp_unit *dev,unsigned char c,unsigned char lvdmode) +static void is885 (struct atp_unit *dev,unsigned char c,bool wide_chip,unsigned char lvdmode) {unsigned char i, j, k, rmb, n;unsigned short int m;
@@ -2273,6 +2267,8 @@ static void is885(struct atp_unit *dev, unsigned char c, unsigned char lvdmode)static unsigned char u3[9 ] = {0x80 ,1 ,6 ,4 ,0x09 ,00 ,0x0e ,0x01 ,0x02 };for (i =0 ; i <16 ; i++) { +if (!wide_chip && (i >7 )) +break ; m =1 ; m = m << i;if ((m & dev->active_id[c]) !=0 ) {
@@ -2282,7 +2278,7 @@ static void is885(struct atp_unit *dev, unsigned char c, unsigned char lvdmode)printk (KERN_INFO " ID: %2d Host Adapter\n" , dev->host_id[c]);continue ; } -atp_writeb_io (dev, c,0x1b ,0x01 ); +atp_writeb_io (dev, c,0x1b , wide_chip ?0x01 :0x00 );atp_writeb_io (dev, c,1 ,0x08 );atp_writeb_io (dev, c,2 ,0x7f );atp_writeb_io (dev, c,3 , satn[0 ]);
@@ -2351,7 +2347,9 @@ sel_ok:while (atp_readb_io (dev, c,0x17 ) !=0x8e )cpu_relax (); -atp_writeb_io (dev, c,0x1b ,0x00 ); +if (wide_chip) +atp_writeb_io (dev, c,0x1b ,0x00 ); +atp_writeb_io (dev, c,0x18 ,0x08 ); j =0 ; rd_inq_data:
@@ -2385,11 +2383,17 @@ inq_ok: dev->id[c][i].devtype = mbuf[0 ]; rmb = mbuf[1 ]; n = mbuf[7 ]; +if (!wide_chip) + goto not_wide;if ((mbuf[7 ] &0x60 ) ==0 ) { goto not_wide; } -if ((i <8 ) && ((dev->global_map[c] &0x20 ) ==0 )) { - goto not_wide; +if (dev->dev_id ==ATP885_DEVID || dev->dev_id ==ATP880_DEVID1 || dev->dev_id ==ATP880_DEVID2 ) { +if ((i <8 ) && ((dev->global_map[c] &0x20 ) ==0 )) + goto not_wide; + }else {/* result of is870() merge - is this a bug? */ +if ((dev->global_map[c] &0x20 ) ==0 ) + goto not_wide; }if (lvdmode ==0 ) { goto chg_wide;
Signature · 1 line
Ondrej Zary
PATCH 27/52 atp870u: Add remaining 870 support to is885()
In reply to Ondrej ZaryAdd remaining 870 support to is885():
- different synw, no synuw
- synu[4] = 0x0c
- atp_writeb_io(dev, c, 0x04, 0x00); instead of atp_writeb_io(dev, c, 0x14, 0x00); (isn't that a bug?)
- atp_writeb_io(dev, c, 0x14, 0xff); instead of atp_writeb_io(dev, c, 0x14, 0x06);
- different mbuf[3] and mbuf[4] checks
--- drivers/scsi/atp870u.c | 45 +++++++++++++++++++++++++++++++-------------- 1 file changed, 31 insertions(+), 14 deletions(-)
drivers/scsi/atp870u.c +31 -14
@@ -2262,6 +2262,7 @@ static void is885(struct atp_unit *dev, unsigned char c, bool wide_chip, unsignestatic unsigned char synn[6 ] = {0x80 ,1 ,3 ,1 ,0x19 ,0x0e };unsigned char synu[6 ] = {0x80 ,1 ,3 ,1 ,0x0a ,0x0e };static unsigned char synw[6 ] = {0x80 ,1 ,3 ,1 ,0x19 ,0x0e }; +static unsigned char synw_870[6 ] = {0x80 ,1 ,3 ,1 ,0x0c ,0x07 };unsigned char synuw[6 ] = {0x80 ,1 ,3 ,1 ,0x0a ,0x0e };static unsigned char wide[6 ] = {0x80 ,1 ,2 ,3 ,1 ,0 };static unsigned char u3[9 ] = {0x80 ,1 ,6 ,4 ,0x09 ,00 ,0x0e ,0x01 ,0x02 };
@@ -2311,7 +2312,10 @@ static void is885(struct atp_unit *dev, unsigned char c, bool wide_chip, unsigne dev->active_id[c] |= m;atp_writeb_io (dev, c,0x10 ,0x30 ); -atp_writeb_io (dev, c,0x14 ,0x00 ); +if (dev->dev_id ==ATP885_DEVID || dev->dev_id ==ATP880_DEVID1 || dev->dev_id ==ATP880_DEVID2 ) +atp_writeb_io (dev, c,0x14 ,0x00 ); +else /* result of is870() merge - is this a bug? */ +atp_writeb_io (dev, c,0x04 ,0x00 ); phase_cmd:atp_writeb_io (dev, c,0x18 ,0x08 );
@@ -2657,7 +2661,7 @@ not_wide: }continue ; set_sync: -if (dev->sp[c][i] ==0x02 ) { +if ((dev->dev_id !=ATP885_DEVID && dev->dev_id !=ATP880_DEVID1 && dev->dev_id !=ATP880_DEVID2 ) || (dev->sp[c][i] ==0x02 )) { synu[4 ] =0x0c ; synuw[4 ] =0x0c ; }else {
@@ -2701,11 +2705,14 @@ try_sync:while ((atp_readb_io (dev, c,0x1f ) &0x80 ) ==0 ) {if ((atp_readb_io (dev, c,0x1f ) &0x01 ) !=0 ) {if ((m & dev->wide_id[c]) !=0 ) { -if ((m & dev->ultra_map[c]) !=0 ) { -atp_writeb_io (dev, c,0x19 , synuw[j++]); - }else { -atp_writeb_io (dev, c,0x19 , synw[j++]); - } +if (dev->dev_id ==ATP885_DEVID || dev->dev_id ==ATP880_DEVID1 || dev->dev_id ==ATP880_DEVID2 ) { +if ((m & dev->ultra_map[c]) !=0 ) { +atp_writeb_io (dev, c,0x19 , synuw[j++]); + }else { +atp_writeb_io (dev, c,0x19 , synw[j++]); + } + }else +atp_writeb_io (dev, c,0x19 , synw_870[j++]); }else {if ((m & dev->ultra_map[c]) !=0 ) {atp_writeb_io (dev, c,0x19 , synu[j++]);
@@ -2753,7 +2760,10 @@ phase_outs: }continue ; phase_ins: -atp_writeb_io (dev, c,0x14 ,0x06 ); +if (dev->dev_id ==ATP885_DEVID || dev->dev_id ==ATP880_DEVID1 || dev->dev_id ==ATP880_DEVID2 ) +atp_writeb_io (dev, c,0x14 ,0x06 ); +else +atp_writeb_io (dev, c,0x14 ,0xff );atp_writeb_io (dev, c,0x18 ,0x20 ); k =0 ; phase_ins1:
@@ -2808,14 +2818,21 @@ tar_dcons:if (mbuf[3 ] >0x64 ) {continue ; } -if (mbuf[4 ] >0x0e ) { - mbuf[4 ] =0x0e ; +if (dev->dev_id ==ATP885_DEVID || dev->dev_id ==ATP880_DEVID1 || dev->dev_id ==ATP880_DEVID2 ) { +if (mbuf[4 ] >0x0e ) { + mbuf[4 ] =0x0e ; + } + }else { +if (mbuf[4 ] >0x0c ) { + mbuf[4 ] =0x0c ; + } } dev->id[c][i].devsp = mbuf[4 ]; -if (mbuf[3 ] <0x0c ) { - j =0xb0 ; - goto set_syn_ok; - } +if (dev->dev_id ==ATP885_DEVID || dev->dev_id ==ATP880_DEVID1 || dev->dev_id ==ATP880_DEVID2 ) +if (mbuf[3 ] <0x0c ) { + j =0xb0 ; + goto set_syn_ok; + }if ((mbuf[3 ] <0x0d ) && (rmb ==0 )) { j =0xa0 ; goto set_syn_ok;
Signature · 1 line
Ondrej Zary
PATCH 28/52 atp870u: Move 870-specific code out of is870()
In reply to Ondrej ZaryMove few remaining 870-specific code lines out of is870()
--- drivers/scsi/atp870u.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)
drivers/scsi/atp870u.c +2 -3
@@ -1174,8 +1174,6 @@ static void is870(struct atp_unit *dev, unsigned char c, bool wide_chip)static unsigned char synw[6 ] = {0x80 ,1 ,3 ,1 ,0x0c ,0x07 };static unsigned char wide[6 ] = {0x80 ,1 ,2 ,3 ,1 ,0 }; -atp_writeb_io (dev, c,0x3a ,atp_readb_io (dev, c,0x3a ) |0x10 ); -for (i =0 ; i <16 ; i++) {if (!wide_chip && (i >7 ))break ;
@@ -1587,7 +1585,6 @@ tar_dcons: set_syn_ok: dev->id[c][i].devsp = (dev->id[c][i].devsp &0x0f ) | j; } -atp_writeb_io (dev, c,0x3a ,atp_readb_io (dev, c,0x3a ) &0xef ); }static void atp870u_free_tables (struct Scsi_Host *host)
@@ -2032,7 +2029,9 @@ flash_ok_885:outb (0x20 , base_io +0x11 );tscam (shpnt); +atp_writeb_io (p,0 ,0x3a ,atp_readb_io (p,0 ,0x3a ) |0x10 );is870 (p,0 , p->chip_ver ==4 ); +atp_writeb_io (p,0 ,0x3a ,atp_readb_io (p,0 ,0x3a ) &0xef );outb ((inb (base_io +0x3a ) &0xef ), base_io +0x3a );outb ((inb (base_io +0x3b ) |0x20 ), base_io +0x3b );if (atpdev->chip_ver ==4 )
Signature · 1 line
Ondrej Zary
PATCH 29/52 atp870u: Remove is870()
In reply to Ondrej ZaryNow that is885() supports everything from is870() and the rest of the code is almost identical, remove is870() and use is885() instead.
--- drivers/scsi/atp870u.c | 427 +----------------------------------------------- 1 file changed, 1 insertion(+), 426 deletions(-)
drivers/scsi/atp870u.c +1 -426
@@ -1162,431 +1162,6 @@ static void tscam(struct Scsi_Host *host) } } -static void is870 (struct atp_unit *dev,unsigned char c,bool wide_chip) -{ -unsigned char i, j, k, rmb, n; -unsigned short int m; -static unsigned char mbuf[512 ]; -static unsigned char satn[9 ] = {0 ,0 ,0 ,0 ,0 ,0 ,0 ,6 ,6 }; -static unsigned char inqd[9 ] = {0x12 ,0 ,0 ,0 ,0x24 ,0 ,0 ,0x24 ,6 }; -static unsigned char synn[6 ] = {0x80 ,1 ,3 ,1 ,0x19 ,0x0e }; -static unsigned char synu[6 ] = {0x80 ,1 ,3 ,1 ,0x0c ,0x0e }; -static unsigned char synw[6 ] = {0x80 ,1 ,3 ,1 ,0x0c ,0x07 }; -static unsigned char wide[6 ] = {0x80 ,1 ,2 ,3 ,1 ,0 }; - -for (i =0 ; i <16 ; i++) { -if (!wide_chip && (i >7 )) -break ; - m =1 ; - m = m << i; -if ((m & dev->active_id[c]) !=0 ) { -continue ; - } -if (i == dev->host_id[c]) { -printk (KERN_INFO " ID: %2d Host Adapter\n" , dev->host_id[c]); -continue ; - } -atp_writeb_io (dev, c,0x1b , wide_chip ?0x01 :0x00 ); -atp_writeb_io (dev, c,1 ,0x08 ); -atp_writeb_io (dev, c,2 ,0x7f ); -atp_writeb_io (dev, c,3 , satn[0 ]); -atp_writeb_io (dev, c,4 , satn[1 ]); -atp_writeb_io (dev, c,5 , satn[2 ]); -atp_writeb_io (dev, c,6 , satn[3 ]); -atp_writeb_io (dev, c,7 , satn[4 ]); -atp_writeb_io (dev, c,8 , satn[5 ]); -atp_writeb_io (dev, c,0x0f ,0 ); -atp_writeb_io (dev, c,0x11 , dev->id[c][i].devsp); -atp_writeb_io (dev, c,0x12 ,0 ); -atp_writeb_io (dev, c,0x13 , satn[6 ]); -atp_writeb_io (dev, c,0x14 , satn[7 ]); - j = i; -if ((j &0x08 ) !=0 ) { - j = (j &0x07 ) |0x40 ; - } -atp_writeb_io (dev, c,0x15 , j); -atp_writeb_io (dev, c,0x18 , satn[8 ]); - -while ((atp_readb_io (dev, c,0x1f ) &0x80 ) ==0x00 ) -cpu_relax (); - -if (atp_readb_io (dev, c,0x17 ) !=0x11 &&atp_readb_io (dev, c,0x17 ) !=0x8e ) -continue ; - -while (atp_readb_io (dev, c,0x17 ) !=0x8e ) -cpu_relax (); - - dev->active_id[c] |= m; - -atp_writeb_io (dev, c,0x10 ,0x30 ); -atp_writeb_io (dev, c,0x04 ,0x00 ); - -phase_cmd: -atp_writeb_io (dev, c,0x18 ,0x08 ); - -while ((atp_readb_io (dev, c,0x1f ) &0x80 ) ==0x00 ) -cpu_relax (); - - j =atp_readb_io (dev, c,0x17 ); -if (j !=0x16 ) { -atp_writeb_io (dev, c,0x10 ,0x41 ); - goto phase_cmd; - } -sel_ok: -atp_writeb_io (dev, c,3 , inqd[0 ]); -atp_writeb_io (dev, c,4 , inqd[1 ]); -atp_writeb_io (dev, c,5 , inqd[2 ]); -atp_writeb_io (dev, c,6 , inqd[3 ]); -atp_writeb_io (dev, c,7 , inqd[4 ]); -atp_writeb_io (dev, c,8 , inqd[5 ]); -atp_writeb_io (dev, c,0x0f ,0 ); -atp_writeb_io (dev, c,0x11 , dev->id[c][i].devsp); -atp_writeb_io (dev, c,0x12 ,0 ); -atp_writeb_io (dev, c,0x13 , inqd[6 ]); -atp_writeb_io (dev, c,0x14 , inqd[7 ]); -atp_writeb_io (dev, c,0x18 , inqd[8 ]); - -while ((atp_readb_io (dev, c,0x1f ) &0x80 ) ==0x00 ) -cpu_relax (); - -if (atp_readb_io (dev, c,0x17 ) !=0x11 &&atp_readb_io (dev, c,0x17 ) !=0x8e ) -continue ; - -while (atp_readb_io (dev, c,0x17 ) !=0x8e ) -cpu_relax (); - -if (wide_chip) -atp_writeb_io (dev, c,0x1b ,0x00 ); - -atp_writeb_io (dev, c,0x18 ,0x08 ); - j =0 ; -rd_inq_data: - k =atp_readb_io (dev, c,0x1f ); -if ((k &0x01 ) !=0 ) { - mbuf[j++] =atp_readb_io (dev, c,0x19 ); - goto rd_inq_data; - } -if ((k &0x80 ) ==0 ) { - goto rd_inq_data; - } - j =atp_readb_io (dev, c,0x17 ); -if (j ==0x16 ) { - goto inq_ok; - } -atp_writeb_io (dev, c,0x10 ,0x46 ); -atp_writeb_io (dev, c,0x12 ,0 ); -atp_writeb_io (dev, c,0x13 ,0 ); -atp_writeb_io (dev, c,0x14 ,0 ); -atp_writeb_io (dev, c,0x18 ,0x08 ); - -while ((atp_readb_io (dev, c,0x1f ) &0x80 ) ==0x00 ) -cpu_relax (); - -if (atp_readb_io (dev, c,0x17 ) !=0x16 ) - goto sel_ok; - -inq_ok: - mbuf[36 ] =0 ; -printk (KERN_INFO " ID: %2d %s\n" , i, &mbuf[8 ]); - dev->id[c][i].devtype = mbuf[0 ]; - rmb = mbuf[1 ]; - n = mbuf[7 ]; -if (!wide_chip) - goto not_wide; -if ((mbuf[7 ] &0x60 ) ==0 ) { - goto not_wide; - } -if ((dev->global_map[c] &0x20 ) ==0 ) { - goto not_wide; - } -atp_writeb_io (dev, c,0x1b ,0x01 ); -atp_writeb_io (dev, c,3 , satn[0 ]); -atp_writeb_io (dev, c,4 , satn[1 ]); -atp_writeb_io (dev, c,5 , satn[2 ]); -atp_writeb_io (dev, c,6 , satn[3 ]); -atp_writeb_io (dev, c,7 , satn[4 ]); -atp_writeb_io (dev, c,8 , satn[5 ]); -atp_writeb_io (dev, c,0x0f ,0 ); -atp_writeb_io (dev, c,0x11 , dev->id[c][i].devsp); -atp_writeb_io (dev, c,0x12 ,0 ); -atp_writeb_io (dev, c,0x13 , satn[6 ]); -atp_writeb_io (dev, c,0x14 , satn[7 ]); -atp_writeb_io (dev, c,0x18 , satn[8 ]); - -while ((atp_readb_io (dev, c,0x1f ) &0x80 ) ==0x00 ) -cpu_relax (); - -if (atp_readb_io (dev, c,0x17 ) !=0x11 &&atp_readb_io (dev, c,0x17 ) !=0x8e ) -continue ; - -while (atp_readb_io (dev, c,0x17 ) !=0x8e ) -cpu_relax (); - -try_wide: - j =0 ; -atp_writeb_io (dev, c,0x14 ,0x05 ); -atp_writeb_io (dev, c,0x18 ,0x20 ); - -while ((atp_readb_io (dev, c,0x1f ) &0x80 ) ==0 ) { -if ((atp_readb_io (dev, c,0x1f ) &0x01 ) !=0 ) -atp_writeb_io (dev, c,0x19 , wide[j++]); - } - -while ((atp_readb_io (dev, c,0x17 ) &0x80 ) ==0x00 ) -cpu_relax (); - - j =atp_readb_io (dev, c,0x17 ) &0x0f ; -if (j ==0x0f ) { - goto widep_in; - } -if (j ==0x0a ) { - goto widep_cmd; - } -if (j ==0x0e ) { - goto try_wide; - } -continue ; -widep_out: -atp_writeb_io (dev, c,0x18 ,0x20 ); -while ((atp_readb_io (dev, c,0x1f ) &0x80 ) ==0 ) { -if ((atp_readb_io (dev, c,0x1f ) &0x01 ) !=0 ) -atp_writeb_io (dev, c,0x19 ,0 ); - } - j =atp_readb_io (dev, c,0x17 ) &0x0f ; -if (j ==0x0f ) { - goto widep_in; - } -if (j ==0x0a ) { - goto widep_cmd; - } -if (j ==0x0e ) { - goto widep_out; - } -continue ; -widep_in: -atp_writeb_io (dev, c,0x14 ,0xff ); -atp_writeb_io (dev, c,0x18 ,0x20 ); - k =0 ; -widep_in1: - j =atp_readb_io (dev, c,0x1f ); -if ((j &0x01 ) !=0 ) { - mbuf[k++] =atp_readb_io (dev, c,0x19 ); - goto widep_in1; - } -if ((j &0x80 ) ==0x00 ) { - goto widep_in1; - } - j =atp_readb_io (dev, c,0x17 ) &0x0f ; -if (j ==0x0f ) { - goto widep_in; - } -if (j ==0x0a ) { - goto widep_cmd; - } -if (j ==0x0e ) { - goto widep_out; - } -continue ; -widep_cmd: -atp_writeb_io (dev, c,0x10 ,0x30 ); -atp_writeb_io (dev, c,0x14 ,0x00 ); -atp_writeb_io (dev, c,0x18 ,0x08 ); - -while ((atp_readb_io (dev, c,0x1f ) &0x80 ) ==0x00 ) -cpu_relax (); - - j =atp_readb_io (dev, c,0x17 ); -if (j !=0x16 ) { -if (j ==0x4e ) { - goto widep_out; - } -continue ; - } -if (mbuf[0 ] !=0x01 ) { - goto not_wide; - } -if (mbuf[1 ] !=0x02 ) { - goto not_wide; - } -if (mbuf[2 ] !=0x03 ) { - goto not_wide; - } -if (mbuf[3 ] !=0x01 ) { - goto not_wide; - } - m =1 ; - m = m << i; - dev->wide_id[c] |= m; -not_wide: -if ((dev->id[c][i].devtype ==0x00 ) || (dev->id[c][i].devtype ==0x07 ) || ((dev->id[c][i].devtype ==0x05 ) && ((n &0x10 ) !=0 ))) { - goto set_sync; - } -continue ; -set_sync: - j =0 ; -if ((m & dev->wide_id[c]) !=0 ) { - j |=0x01 ; - } -atp_writeb_io (dev, c,0x1b , j); -atp_writeb_io (dev, c,3 , satn[0 ]); -atp_writeb_io (dev, c,4 , satn[1 ]); -atp_writeb_io (dev, c,5 , satn[2 ]); -atp_writeb_io (dev, c,6 , satn[3 ]); -atp_writeb_io (dev, c,7 , satn[4 ]); -atp_writeb_io (dev, c,8 , satn[5 ]); -atp_writeb_io (dev, c,0x0f ,0 ); -atp_writeb_io (dev, c,0x11 , dev->id[c][i].devsp); -atp_writeb_io (dev, c,0x12 ,0 ); -atp_writeb_io (dev, c,0x13 , satn[6 ]); -atp_writeb_io (dev, c,0x14 , satn[7 ]); -atp_writeb_io (dev, c,0x18 , satn[8 ]); - -while ((atp_readb_io (dev, c,0x1f ) &0x80 ) ==0x00 ) -cpu_relax (); - -if (atp_readb_io (dev, c,0x17 ) !=0x11 &&atp_readb_io (dev, c,0x17 ) !=0x8e ) -continue ; - -while (atp_readb_io (dev, c,0x17 ) !=0x8e ) -cpu_relax (); - -try_sync: - j =0 ; -atp_writeb_io (dev, c,0x14 ,0x06 ); -atp_writeb_io (dev, c,0x18 ,0x20 ); - -while ((atp_readb_io (dev, c,0x1f ) &0x80 ) ==0 ) { -if ((atp_readb_io (dev, c,0x1f ) &0x01 ) !=0 ) { -if ((m & dev->wide_id[c]) !=0 ) { -atp_writeb_io (dev, c,0x19 , synw[j++]); - }else { -if ((m & dev->ultra_map[c]) !=0 ) { -atp_writeb_io (dev, c,0x19 , synu[j++]); - }else { -atp_writeb_io (dev, c,0x19 , synn[j++]); - } - } - } - } - -while ((atp_readb_io (dev, c,0x17 ) &0x80 ) ==0x00 ) -cpu_relax (); - - j =atp_readb_io (dev, c,0x17 ) &0x0f ; -if (j ==0x0f ) { - goto phase_ins; - } -if (j ==0x0a ) { - goto phase_cmds; - } -if (j ==0x0e ) { - goto try_sync; - } -continue ; -phase_outs: -atp_writeb_io (dev, c,0x18 ,0x20 ); -while ((atp_readb_io (dev, c,0x1f ) &0x80 ) ==0x00 ) { -if ((atp_readb_io (dev, c,0x1f ) &0x01 ) !=0x00 ) -atp_writeb_io (dev, c,0x19 ,0x00 ); - } - j =atp_readb_io (dev, c,0x17 ); -if (j ==0x85 ) { - goto tar_dcons; - } - j &=0x0f ; -if (j ==0x0f ) { - goto phase_ins; - } -if (j ==0x0a ) { - goto phase_cmds; - } -if (j ==0x0e ) { - goto phase_outs; - } -continue ; -phase_ins: -atp_writeb_io (dev, c,0x14 ,0xff ); -atp_writeb_io (dev, c,0x18 ,0x20 ); - k =0 ; -phase_ins1: - j =atp_readb_io (dev, c,0x1f ); -if ((j &0x01 ) !=0x00 ) { - mbuf[k++] =atp_readb_io (dev, c,0x19 ); - goto phase_ins1; - } -if ((j &0x80 ) ==0x00 ) { - goto phase_ins1; - } - -while ((atp_readb_io (dev, c,0x17 ) &0x80 ) ==0x00 ) -cpu_relax (); - - j =atp_readb_io (dev, c,0x17 ); -if (j ==0x85 ) { - goto tar_dcons; - } - j &=0x0f ; -if (j ==0x0f ) { - goto phase_ins; - } -if (j ==0x0a ) { - goto phase_cmds; - } -if (j ==0x0e ) { - goto phase_outs; - } -continue ; -phase_cmds: -atp_writeb_io (dev, c,0x10 ,0x30 ); -tar_dcons: -atp_writeb_io (dev, c,0x14 ,0x00 ); -atp_writeb_io (dev, c,0x18 ,0x08 ); - -while ((atp_readb_io (dev, c,0x1f ) &0x80 ) ==0x00 ) -cpu_relax (); - - j =atp_readb_io (dev, c,0x17 ); -if (j !=0x16 ) { -continue ; - } -if (mbuf[0 ] !=0x01 ) { -continue ; - } -if (mbuf[1 ] !=0x03 ) { -continue ; - } -if (mbuf[4 ] ==0x00 ) { -continue ; - } -if (mbuf[3 ] >0x64 ) { -continue ; - } -if (mbuf[4 ] >0x0c ) { - mbuf[4 ] =0x0c ; - } - dev->id[c][i].devsp = mbuf[4 ]; -if ((mbuf[3 ] <0x0d ) && (rmb ==0 )) { - j =0xa0 ; - goto set_syn_ok; - } -if (mbuf[3 ] <0x1a ) { - j =0x20 ; - goto set_syn_ok; - } -if (mbuf[3 ] <0x33 ) { - j =0x40 ; - goto set_syn_ok; - } -if (mbuf[3 ] <0x4c ) { - j =0x50 ; - goto set_syn_ok; - } - j =0x60 ; -set_syn_ok: - dev->id[c][i].devsp = (dev->id[c][i].devsp &0x0f ) | j; - } -} -static void atp870u_free_tables (struct Scsi_Host *host) {struct atp_unit *atp_dev = (struct atp_unit *)&host->hostdata;
@@ -2030,7 +1605,7 @@ flash_ok_885:tscam (shpnt);atp_writeb_io (p,0 ,0x3a ,atp_readb_io (p,0 ,0x3a ) |0x10 ); -is870 (p,0 , p->chip_ver ==4 ); +is885 (p,0 , p->chip_ver ==4 ,0 );atp_writeb_io (p,0 ,0x3a ,atp_readb_io (p,0 ,0x3a ) &0xef );outb ((inb (base_io +0x3a ) &0xef ), base_io +0x3a );outb ((inb (base_io +0x3b ) |0x20 ), base_io +0x3b );
Signature · 1 line
Ondrej Zary
PATCH 30/52 atp870u: Rename is885() to atp_is()
In reply to Ondrej ZaryNow that all the is* functions except is885() are gone, rename is885() to atp_is() to avoid confusion. Don't know what "is" means, though...
--- drivers/scsi/atp870u.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)
drivers/scsi/atp870u.c +6 -6
@@ -41,7 +41,7 @@static struct scsi_host_template atp870u_template;static void send_s870 (struct atp_unit *dev,unsigned char c); -static void is885 (struct atp_unit *dev,unsigned char c,bool wide_chip,unsigned char lvdmode); +static void atp_is (struct atp_unit *dev,unsigned char c,bool wide_chip,unsigned char lvdmode);static void tscam_885 (void );static inline void atp_writeb_base (struct atp_unit *atp,u8 reg,u8 val)
@@ -1373,7 +1373,7 @@ flash_ok_880:outb (0x20 , base_io +0x51 );tscam (shpnt); -is885 (p,0 , true,atp_readb_base (p,0x3f ) &0x40 ); +atp_is (p,0 , true,atp_readb_base (p,0x3f ) &0x40 );outb (0xb0 , base_io +0x38 ); shpnt->max_id =16 ; shpnt->this_id = host_id;
@@ -1519,10 +1519,10 @@ flash_ok_885:tscam_885 ();printk (KERN_INFO " Scanning Channel A SCSI Device ...\n" ); -is885 (p,0 , true,atp_readb_io (p,0 ,0x1b ) >>7 ); +atp_is (p,0 , true,atp_readb_io (p,0 ,0x1b ) >>7 );atp_writeb_io (p,0 ,0x16 ,0x80 );printk (KERN_INFO " Scanning Channel B SCSI Device ...\n" ); -is885 (p,1 , true,atp_readb_io (p,1 ,0x1b ) >>7 ); +atp_is (p,1 , true,atp_readb_io (p,1 ,0x1b ) >>7 );atp_writeb_io (p,1 ,0x16 ,0x80 ); k =inb (base_io +0x28 ) &0xcf ; k |=0xc0 ;
@@ -1605,7 +1605,7 @@ flash_ok_885:tscam (shpnt);atp_writeb_io (p,0 ,0x3a ,atp_readb_io (p,0 ,0x3a ) |0x10 ); -is885 (p,0 , p->chip_ver ==4 ,0 ); +atp_is (p,0 , p->chip_ver ==4 ,0 );atp_writeb_io (p,0 ,0x3a ,atp_readb_io (p,0 ,0x3a ) &0xef );outb ((inb (base_io +0x3a ) &0xef ), base_io +0x3a );outb ((inb (base_io +0x3b ) |0x20 ), base_io +0x3b );
@@ -1826,7 +1826,7 @@ static void tscam_885(void) -static void is885 (struct atp_unit *dev,unsigned char c,bool wide_chip,unsigned char lvdmode) +static void atp_is (struct atp_unit *dev,unsigned char c,bool wide_chip,unsigned char lvdmode) {unsigned char i, j, k, rmb, n;unsigned short int m;
Signature · 1 line
Ondrej Zary
PATCH 31/52 atp870u: Convert remaining in[bwl] and out[bwl] to wrappers
In reply to Ondrej Zary--- drivers/scsi/atp870u.c | 222 +++++++++++++++++++++++++----------------------- 1 file changed, 118 insertions(+), 104 deletions(-)
drivers/scsi/atp870u.c +118 -104
@@ -49,6 +49,11 @@ static inline void atp_writeb_base(struct atp_unit *atp, u8 reg, u8 val)outb (val, atp->baseport + reg); } +static inline void atp_writew_base (struct atp_unit *atp,u8 reg,u16 val) +{ +outw (val, atp->baseport + reg); +} +static inline void atp_writeb_io (struct atp_unit *atp,u8 channel,u8 reg,u8 val) {outb (val, atp->ioport[channel] + reg);
@@ -74,6 +79,16 @@ static inline u8 atp_readb_base(struct atp_unit *atp, u8 reg)return inb (atp->baseport + reg); } +static inline u16 atp_readw_base (struct atp_unit *atp,u8 reg) +{ +return inw (atp->baseport + reg); +} + +static inline u32 atp_readl_base (struct atp_unit *atp,u8 reg) +{ +return inl (atp->baseport + reg); +} +static inline u8 atp_readb_io (struct atp_unit *atp,u8 channel,u8 reg) {return inb (atp->ioport[channel] + reg);
@@ -1268,19 +1283,20 @@ static int atp870u_probe(struct pci_dev *pdev, const struct pci_device_id *ent) atpdev->chip_ver = pdev->revision;pci_write_config_byte (pdev,PCI_LATENCY_TIMER ,0x80 );//JCC082803 - host_id =inb (base_io +0x39 ); + atpdev->ioport[0 ] = base_io +0x40 ; + atpdev->pciport[0 ] = base_io +0x28 ; + + host_id =atp_readb_base (atpdev,0x39 ); host_id >>=0x04 ;printk (KERN_INFO " ACARD AEC-67160 PCI Ultra3 LVD Host Adapter: %d" " IO:%x, IRQ:%d.\n" , count, base_io, pdev->irq); - atpdev->ioport[0 ] = base_io +0x40 ; - atpdev->pciport[0 ] = base_io +0x28 ; atpdev->dev_id = ent->device; atpdev->host_id[0 ] = host_id; - atpdev->scam_on =inb (base_io +0x22 ); - atpdev->global_map[0 ] =inb (base_io +0x35 ); - atpdev->ultra_map[0 ] =inw (base_io +0x3c ); + atpdev->scam_on =atp_readb_base (atpdev,0x22 ); + atpdev->global_map[0 ] =atp_readb_base (atpdev,0x35 ); + atpdev->ultra_map[0 ] =atp_readw_base (atpdev,0x3c ); n =0x3f09 ; next_fblk_880:
@@ -1288,37 +1304,37 @@ next_fblk_880: goto flash_ok_880; m =0 ; -outw (n, base_io +0x34 ); +atp_writew_base (atpdev,0x34 , n); n +=0x0002 ; -if (inb (base_io +0x30 ) ==0xff ) +if (atp_readb_base (atpdev,0x30 ) ==0xff ) goto flash_ok_880; - atpdev->sp[0 ][m++] =inb (base_io +0x30 ); - atpdev->sp[0 ][m++] =inb (base_io +0x31 ); - atpdev->sp[0 ][m++] =inb (base_io +0x32 ); - atpdev->sp[0 ][m++] =inb (base_io +0x33 ); -outw (n, base_io +0x34 ); + atpdev->sp[0 ][m++] =atp_readb_base (atpdev,0x30 ); + atpdev->sp[0 ][m++] =atp_readb_base (atpdev,0x31 ); + atpdev->sp[0 ][m++] =atp_readb_base (atpdev,0x32 ); + atpdev->sp[0 ][m++] =atp_readb_base (atpdev,0x33 ); +atp_writew_base (atpdev,0x34 , n); n +=0x0002 ; - atpdev->sp[0 ][m++] =inb (base_io +0x30 ); - atpdev->sp[0 ][m++] =inb (base_io +0x31 ); - atpdev->sp[0 ][m++] =inb (base_io +0x32 ); - atpdev->sp[0 ][m++] =inb (base_io +0x33 ); -outw (n, base_io +0x34 ); + atpdev->sp[0 ][m++] =atp_readb_base (atpdev,0x30 ); + atpdev->sp[0 ][m++] =atp_readb_base (atpdev,0x31 ); + atpdev->sp[0 ][m++] =atp_readb_base (atpdev,0x32 ); + atpdev->sp[0 ][m++] =atp_readb_base (atpdev,0x33 ); +atp_writew_base (atpdev,0x34 , n); n +=0x0002 ; - atpdev->sp[0 ][m++] =inb (base_io +0x30 ); - atpdev->sp[0 ][m++] =inb (base_io +0x31 ); - atpdev->sp[0 ][m++] =inb (base_io +0x32 ); - atpdev->sp[0 ][m++] =inb (base_io +0x33 ); -outw (n, base_io +0x34 ); + atpdev->sp[0 ][m++] =atp_readb_base (atpdev,0x30 ); + atpdev->sp[0 ][m++] =atp_readb_base (atpdev,0x31 ); + atpdev->sp[0 ][m++] =atp_readb_base (atpdev,0x32 ); + atpdev->sp[0 ][m++] =atp_readb_base (atpdev,0x33 ); +atp_writew_base (atpdev,0x34 , n); n +=0x0002 ; - atpdev->sp[0 ][m++] =inb (base_io +0x30 ); - atpdev->sp[0 ][m++] =inb (base_io +0x31 ); - atpdev->sp[0 ][m++] =inb (base_io +0x32 ); - atpdev->sp[0 ][m++] =inb (base_io +0x33 ); + atpdev->sp[0 ][m++] =atp_readb_base (atpdev,0x30 ); + atpdev->sp[0 ][m++] =atp_readb_base (atpdev,0x31 ); + atpdev->sp[0 ][m++] =atp_readb_base (atpdev,0x32 ); + atpdev->sp[0 ][m++] =atp_readb_base (atpdev,0x33 ); n +=0x0018 ; goto next_fblk_880; flash_ok_880: -outw (0 , base_io +0x34 ); +atp_writew_base (atpdev,0x34 ,0 ); atpdev->ultra_map[0 ] =0 ; atpdev->async[0 ] =0 ;for (k =0 ; k <16 ; k++) {
@@ -1332,7 +1348,7 @@ flash_ok_880: } } atpdev->async[0 ] = ~(atpdev->async[0 ]); -outb (atpdev->global_map[0 ], base_io +0x35 ); +atp_writeb_base (atpdev,0x35 , atpdev->global_map[0 ]); shpnt =scsi_host_alloc (&atp870u_template,sizeof (struct atp_unit ));if (!shpnt)
@@ -1355,26 +1371,26 @@ flash_ok_880: }spin_lock_irqsave (shpnt->host_lock, flags); - k =inb (base_io +0x38 ) &0x80 ; -outb (k, base_io +0x38 ); -outb (0x20 , base_io +0x3b ); + k =atp_readb_base (p,0x38 ) &0x80 ; +atp_writeb_base (p,0x38 , k); +atp_writeb_base (p,0x3b ,0x20 );mdelay (32 ); -outb (0 , base_io +0x3b ); +atp_writeb_base (p,0x3b ,0 );mdelay (32 ); -inb (base_io +0x5b ); -inb (base_io +0x57 ); -outb ((host_id |0x08 ), base_io +0x40 ); -outb (0 , base_io +0x58 ); -while ((inb (base_io +0x5f ) &0x80 ) ==0 ) +atp_readb_io (p,0 ,0x1b ); +atp_readb_io (p,0 ,0x17 ); +atp_writeb_io (p,0 ,0 , host_id |0x08 ); +atp_writeb_io (p,0 ,0x18 ,0 ); +while ((atp_readb_io (p,0 ,0x1f ) &0x80 ) ==0 )mdelay (1 ); -inb (base_io +0x57 ); -outb (8 , base_io +0x41 ); -outb (0x7f , base_io +0x42 ); -outb (0x20 , base_io +0x51 ); +atp_readb_io (p,0 ,0x17 ); +atp_writeb_io (p,0 ,1 ,8 ); +atp_writeb_io (p,0 ,2 ,0x7f ); +atp_writeb_io (p,0 ,0x11 ,0x20 );tscam (shpnt);atp_is (p,0 , true,atp_readb_base (p,0x3f ) &0x40 ); -outb (0xb0 , base_io +0x38 ); +atp_writeb_base (p,0x38 ,0xb0 ); shpnt->max_id =16 ; shpnt->this_id = host_id; shpnt->unique_id = base_io;
@@ -1415,27 +1431,27 @@ flash_ok_880:spin_lock_irqsave (shpnt->host_lock, flags); - c=inb (base_io +0x29 ); -outb ((c |0x04 ),base_io +0x29 ); + c =atp_readb_base (p,0x29 ); +atp_writeb_base (p,0x29 , c |0x04 ); n=0x1f80 ; next_fblk_885:if (n >=0x2000 ) { goto flash_ok_885; } -outw (n,base_io +0x3c ); -if (inl (base_io +0x38 ) ==0xffffffff ) { +atp_writew_base (p,0x3c , n); +if (atp_readl_base (p,0x38 ) ==0xffffffff ) { goto flash_ok_885; }for (m=0 ; m <2 ; m++) { p->global_map[m]=0 ;for (k=0 ; k <4 ; k++) { -outw (n++,base_io +0x3c ); - ((unsigned long *)&setupdata[m][0 ])[k]=inl (base_io +0x38 ); +atp_writew_base (p,0x3c , n++); + ((unsigned long *)&setupdata[m][0 ])[k] =atp_readl_base (p,0x38 ); }for (k=0 ; k <4 ; k++) { -outw (n++,base_io +0x3c ); - ((unsigned long *)&p->sp[m][0 ])[k]=inl (base_io +0x38 ); +atp_writew_base (p,0x3c , n++); + ((unsigned long *)&p->sp[m][0 ])[k] =atp_readl_base (p,0x38 ); } n +=8 ; }
@@ -1444,8 +1460,8 @@ flash_ok_885:#ifdef ED_DBGP printk ("Flash Read OK\n" );#endif - c=inb (base_io +0x29 ); -outb ((c &0xfb ),base_io +0x29 ); + c =atp_readb_base (p,0x29 ); +atp_writeb_base (p,0x29 , c &0xfb );for (c=0 ;c <2 ;c++) { p->ultra_map[c]=0 ; p->async[c] =0 ;
@@ -1474,48 +1490,48 @@ flash_ok_885: } } - k =inb (base_io +0x28 ) &0x8f ; + k =atp_readb_base (p,0x28 ) &0x8f ; k |=0x10 ; -outb (k, base_io +0x28 ); -outb (0x80 , base_io +0x41 ); -outb (0x80 , base_io +0x51 ); +atp_writeb_base (p,0x28 , k); +atp_writeb_pci (p,0 ,1 ,0x80 ); +atp_writeb_pci (p,1 ,1 ,0x80 );mdelay (100 ); -outb (0 , base_io +0x41 ); -outb (0 , base_io +0x51 ); +atp_writeb_pci (p,0 ,1 ,0 ); +atp_writeb_pci (p,1 ,1 ,0 );mdelay (1000 ); -inb (base_io +0x9b ); -inb (base_io +0x97 ); -inb (base_io +0xdb ); -inb (base_io +0xd7 ); +atp_readb_io (p,0 ,0x1b ); +atp_readb_io (p,0 ,0x17 ); +atp_readb_io (p,1 ,0x1b ); +atp_readb_io (p,1 ,0x17 ); k=p->host_id[0 ];if (k >7 ) k = (k &0x07 ) |0x40 ; k |=0x08 ; -outb (k, base_io +0x80 ); -outb (0 , base_io +0x98 ); +atp_writeb_io (p,0 ,0 , k); +atp_writeb_io (p,0 ,0x18 ,0 ); -while ((inb (base_io +0x9f ) &0x80 ) ==0 ) +while ((atp_readb_io (p,0 ,0x1f ) &0x80 ) ==0 )cpu_relax (); -inb (base_io +0x97 ); -outb (8 , base_io +0x81 ); -outb (0x7f , base_io +0x82 ); -outb (0x20 , base_io +0x91 ); +atp_readb_io (p,0 ,0x17 ); +atp_writeb_io (p,0 ,1 ,8 ); +atp_writeb_io (p,0 ,2 ,0x7f ); +atp_writeb_io (p,0 ,0x11 ,0x20 ); k=p->host_id[1 ];if (k >7 ) k = (k &0x07 ) |0x40 ; k |=0x08 ; -outb (k, base_io +0xc0 ); -outb (0 , base_io +0xd8 ); +atp_writeb_io (p,1 ,0 , k); +atp_writeb_io (p,1 ,0x18 ,0 ); -while ((inb (base_io +0xdf ) &0x80 ) ==0 ) +while ((atp_readb_io (p,1 ,0x1f ) &0x80 ) ==0 )cpu_relax (); -inb (base_io +0xd7 ); -outb (8 , base_io +0xc1 ); -outb (0x7f , base_io +0xc2 ); -outb (0x20 , base_io +0xd1 ); +atp_readb_io (p,1 ,0x17 ); +atp_writeb_io (p,1 ,1 ,8 ); +atp_writeb_io (p,1 ,2 ,0x7f ); +atp_writeb_io (p,1 ,0x11 ,0x20 );tscam_885 ();printk (KERN_INFO " Scanning Channel A SCSI Device ...\n" );
@@ -1524,13 +1540,13 @@ flash_ok_885:printk (KERN_INFO " Scanning Channel B SCSI Device ...\n" );atp_is (p,1 , true,atp_readb_io (p,1 ,0x1b ) >>7 );atp_writeb_io (p,1 ,0x16 ,0x80 ); - k =inb (base_io +0x28 ) &0xcf ; + k =atp_readb_base (p,0x28 ) &0xcf ; k |=0xc0 ; -outb (k, base_io +0x28 ); - k =inb (base_io +0x1f ) |0x80 ; -outb (k, base_io +0x1f ); - k =inb (base_io +0x29 ) |0x01 ; -outb (k, base_io +0x29 ); +atp_writeb_base (p,0x28 , k); + k =atp_readb_base (p,0x1f ) |0x80 ; +atp_writeb_base (p,0x1f , k); + k =atp_readb_base (p,0x29 ) |0x01 ; +atp_writeb_base (p,0x29 , k);#ifdef ED_DBGP //printk("atp885: atp_host[0] 0x%p\n", atp_host[0]); #endif
@@ -1554,9 +1570,9 @@ flash_ok_885: atpdev->dev_id = ent->device; host_id &=0x07 ; atpdev->host_id[0 ] = host_id; - atpdev->scam_on =inb (base_io +0x22 ); - atpdev->global_map[0 ] =inb (base_io +0x2d ); - atpdev->ultra_map[0 ] =inw (base_io +0x2e ); + atpdev->scam_on =atp_readb_pci (atpdev,0 ,2 ); + atpdev->global_map[0 ] =atp_readb_base (atpdev,0x2d ); + atpdev->ultra_map[0 ] =atp_readw_base (atpdev,0x2e );if (atpdev->ultra_map[0 ] ==0 ) { atpdev->scam_on =0x00 ;
@@ -1583,32 +1599,30 @@ flash_ok_885: }spin_lock_irqsave (shpnt->host_lock, flags); -if (atpdev->chip_ver >0x07 ) {/* check if atp876 chip then enable terminator */ -outb (0x00 , base_io +0x3e ); - } +if (atpdev->chip_ver >0x07 )/* check if atp876 chip then enable terminator */ +atp_writeb_base (p,0x3e ,0x00 ); - k = (inb (base_io +0x3a ) &0xf3 ) |0x10 ; -outb (k, base_io +0x3a ); -outb ((k &0xdf ), base_io +0x3a ); + k = (atp_readb_base (p,0x3a ) &0xf3 ) |0x10 ; +atp_writeb_base (p,0x3a , k); +atp_writeb_base (p,0x3a , k &0xdf );mdelay (32 ); -outb (k, base_io +0x3a ); +atp_writeb_base (p,0x3a , k);mdelay (32 ); -outb ((host_id |0x08 ), base_io +0 ); -outb (0 , base_io +0x18 ); -while ((inb (base_io +0x1f ) &0x80 ) ==0 ) +atp_writeb_io (p,0 ,0 , host_id |0x08 ); +atp_writeb_io (p,0 ,0x18 ,0 ); +while ((atp_readb_io (p,0 ,0x1f ) &0x80 ) ==0 )mdelay (1 ); -inb (base_io +0x17 ); -outb (8 , base_io +1 ); -outb (0x7f , base_io +2 ); -outb (0x20 , base_io +0x11 ); +atp_readb_io (p,0 ,0x17 ); +atp_writeb_io (p,0 ,1 ,8 ); +atp_writeb_io (p,0 ,2 ,0x7f ); +atp_writeb_io (p,0 ,0x11 ,0x20 );tscam (shpnt); -atp_writeb_io (p,0 ,0x3a ,atp_readb_io (p,0 ,0x3a ) |0x10 ); +atp_writeb_base (p,0x3a ,atp_readb_base (p,0x3a ) |0x10 );atp_is (p,0 , p->chip_ver ==4 ,0 ); -atp_writeb_io (p,0 ,0x3a ,atp_readb_io (p,0 ,0x3a ) &0xef ); -outb ((inb (base_io +0x3a ) &0xef ), base_io +0x3a ); -outb ((inb (base_io +0x3b ) |0x20 ), base_io +0x3b ); +atp_writeb_base (p,0x3a ,atp_readb_base (p,0x3a ) &0xef ); +atp_writeb_base (p,0x3b ,atp_readb_base (p,0x3b ) |0x20 );if (atpdev->chip_ver ==4 ) shpnt->max_id =16 ;else
Signature · 1 line
Ondrej Zary
PATCH 32/52 atp870u: Replace port 0x80 delay by udelay
In reply to Ondrej Zarytscam() is using port 0x80 access for delays but that's x86-only. Use udelay(2) instead.
--- drivers/scsi/atp870u.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-)
drivers/scsi/atp870u.c +9 -9
@@ -1036,7 +1036,7 @@ static void tscam(struct Scsi_Host *host)atp_writeb_io (dev,0 ,0x02 ,0x7f );atp_writeb_io (dev,0 ,0x1b ,0x02 ); -outb (0 ,0x80 ); +udelay (2 ); val =0x0080 ;/* bsy */ atp_writew_io (dev,0 ,0x1c , val);
@@ -1044,7 +1044,7 @@ static void tscam(struct Scsi_Host *host)atp_writew_io (dev,0 ,0x1c , val); val |=0x0004 ;/* msg */ atp_writew_io (dev,0 ,0x1c , val); -inb (0x80 );/* 2 deskew delay(45ns*2=90ns) */ +udelay (2 );/* 2 deskew delay(45ns*2=90ns) */ val &=0x007f ;/* no bsy */ atp_writew_io (dev,0 ,0x1c , val);mdelay (128 );
@@ -1052,7 +1052,7 @@ static void tscam(struct Scsi_Host *host)atp_writew_io (dev,0 ,0x1c , val);while ((atp_readb_io (dev,0 ,0x1c ) &0x04 ) !=0 ) ; -outb (1 ,0x80 ); +udelay (2 );udelay (100 );for (n =0 ; n <0x30000 ; n++)if ((atp_readb_io (dev,0 ,0x1c ) &0x80 ) !=0 )/* bsy ? */
@@ -1060,13 +1060,13 @@ static void tscam(struct Scsi_Host *host)if (n <0x30000 )for (n =0 ; n <0x30000 ; n++)if ((atp_readb_io (dev,0 ,0x1c ) &0x81 ) ==0x0081 ) { -inb (0x80 ); +udelay (2 ); val |=0x8003 ;/* io,cd,db7 */ atp_writew_io (dev,0 ,0x1c , val); -inb (0x80 ); +udelay (2 ); val &=0x00bf ;/* no sel */ atp_writew_io (dev,0 ,0x1c , val); -outb (2 ,0x80 ); +udelay (2 );break ; }while (1 ) {
@@ -1093,18 +1093,18 @@ static void tscam(struct Scsi_Host *host) val &=0x00ff ;/* synchronization */ val |=0x3f00 ;fun_scam (dev, &val); -outb (3 ,0x80 ); +udelay (2 ); val &=0x00ff ;/* isolation */ val |=0x2000 ;fun_scam (dev, &val); -outb (4 ,0x80 ); +udelay (2 ); i =8 ; j =0 ;while (1 ) {if ((atp_readw_io (dev,0 ,0x1c ) &0x2000 ) ==0 )continue ; -outb (5 ,0x80 ); +udelay (2 ); val &=0x00ff ;/* get ID_STRING */ val |=0x2000 ; k =fun_scam (dev, &val);
Signature · 1 line
Ondrej Zary
PATCH 33/52 atp870u: Fix incorrect writeb_io access to register 0x3a
In reply to Ondrej ZaryThe ioport region is 0x20 bytes long so accessing 0x3a register using writeb_io is incorrect. Use writeb_base instead.
There's no change in behavior as 870 chips have ioport = baseport.
--- drivers/scsi/atp870u.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/scsi/atp870u.c +4 -4
@@ -364,9 +364,9 @@ static irqreturn_t atp870u_intr_handle(int irq, void *dev_id)atp_writeb_base (dev,0x3b ,atp_readb_base (dev,0x3b ) &0x3f ); }else {if ((workreq->cmnd[0 ] ==0x08 ) || (workreq->cmnd[0 ] ==0x28 ) || (workreq->cmnd[0 ] ==0x0a ) || (workreq->cmnd[0 ] ==0x2a )) -atp_writeb_io (dev, c,0x3a , (atp_readb_io (dev, c,0x3a ) &0xf3 ) |0x08 ); +atp_writeb_base (dev,0x3a , (atp_readb_base (dev,0x3a ) &0xf3 ) |0x08 );else -atp_writeb_io (dev, c,0x3a ,atp_readb_io (dev, c,0x3a ) &0xf3 ); +atp_writeb_base (dev,0x3a ,atp_readb_base (dev,0x3a ) &0xf3 ); } j =0 ; id =1 ;
@@ -889,9 +889,9 @@ static void send_s870(struct atp_unit *dev,unsigned char c)atp_writeb_base (dev,0x3b ,atp_readb_base (dev,0x3b ) &0x3f ); }else {if ((workreq->cmnd[0 ] ==0x08 ) || (workreq->cmnd[0 ] ==0x28 ) || (workreq->cmnd[0 ] ==0x0a ) || (workreq->cmnd[0 ] ==0x2a )) -atp_writeb_io (dev, c,0x3a , (atp_readb_io (dev, c,0x3a ) &0xf3 ) |0x08 ); +atp_writeb_base (dev,0x3a , (atp_readb_base (dev,0x3a ) &0xf3 ) |0x08 );else -atp_writeb_io (dev, c,0x3a ,atp_readb_io (dev, c,0x3a ) &0xf3 ); +atp_writeb_base (dev,0x3a ,atp_readb_base (dev,0x3a ) &0xf3 ); }if (workreq->sc_data_direction ==DMA_TO_DEVICE ) {
Signature · 1 line
Ondrej Zary
PATCH 34/52 atp870u: Introduce atp_set_host_id
In reply to Ondrej ZaryThe code for setting host adapter ID is the same for all chips. Move it to a common function.
--- drivers/scsi/atp870u.c | 57 +++++++++++++++--------------------------------- 1 file changed, 18 insertions(+), 39 deletions(-)
drivers/scsi/atp870u.c +18 -39
@@ -1229,6 +1229,18 @@ static int atp870u_init_tables(struct Scsi_Host *host)return 0 ; } +static void atp_set_host_id (struct atp_unit *atp,u8 c,u8 host_id) +{ +atp_writeb_io (atp, c,0 , host_id |0x08 ); +atp_writeb_io (atp, c,0x18 ,0 ); +while ((atp_readb_io (atp, c,0x1f ) &0x80 ) ==0 ) +mdelay (1 ); +atp_readb_io (atp, c,0x17 ); +atp_writeb_io (atp, c,1 ,8 ); +atp_writeb_io (atp, c,2 ,0x7f ); +atp_writeb_io (atp, c,0x11 ,0x20 ); +} +/* return non-zero on detection */ static int atp870u_probe (struct pci_dev *pdev,const struct pci_device_id *ent) {
@@ -1379,14 +1391,8 @@ flash_ok_880:mdelay (32 );atp_readb_io (p,0 ,0x1b );atp_readb_io (p,0 ,0x17 ); -atp_writeb_io (p,0 ,0 , host_id |0x08 ); -atp_writeb_io (p,0 ,0x18 ,0 ); -while ((atp_readb_io (p,0 ,0x1f ) &0x80 ) ==0 ) -mdelay (1 ); -atp_readb_io (p,0 ,0x17 ); -atp_writeb_io (p,0 ,1 ,8 ); -atp_writeb_io (p,0 ,2 ,0x7f ); -atp_writeb_io (p,0 ,0x11 ,0x20 ); + +atp_set_host_id (p,0 , host_id);tscam (shpnt);atp_is (p,0 , true,atp_readb_base (p,0x3f ) &0x40 );
@@ -1503,35 +1509,16 @@ flash_ok_885:atp_readb_io (p,0 ,0x17 );atp_readb_io (p,1 ,0x1b );atp_readb_io (p,1 ,0x17 ); + k=p->host_id[0 ];if (k >7 ) k = (k &0x07 ) |0x40 ; - k |=0x08 ; -atp_writeb_io (p,0 ,0 , k); -atp_writeb_io (p,0 ,0x18 ,0 ); - -while ((atp_readb_io (p,0 ,0x1f ) &0x80 ) ==0 ) -cpu_relax (); - -atp_readb_io (p,0 ,0x17 ); -atp_writeb_io (p,0 ,1 ,8 ); -atp_writeb_io (p,0 ,2 ,0x7f ); -atp_writeb_io (p,0 ,0x11 ,0x20 ); +atp_set_host_id (p,0 , k); k=p->host_id[1 ];if (k >7 ) k = (k &0x07 ) |0x40 ; - k |=0x08 ; -atp_writeb_io (p,1 ,0 , k); -atp_writeb_io (p,1 ,0x18 ,0 ); - -while ((atp_readb_io (p,1 ,0x1f ) &0x80 ) ==0 ) -cpu_relax (); - -atp_readb_io (p,1 ,0x17 ); -atp_writeb_io (p,1 ,1 ,8 ); -atp_writeb_io (p,1 ,2 ,0x7f ); -atp_writeb_io (p,1 ,0x11 ,0x20 ); +atp_set_host_id (p,1 , k);tscam_885 ();printk (KERN_INFO " Scanning Channel A SCSI Device ...\n" );
@@ -1608,15 +1595,7 @@ flash_ok_885:mdelay (32 );atp_writeb_base (p,0x3a , k);mdelay (32 ); -atp_writeb_io (p,0 ,0 , host_id |0x08 ); -atp_writeb_io (p,0 ,0x18 ,0 ); -while ((atp_readb_io (p,0 ,0x1f ) &0x80 ) ==0 ) -mdelay (1 ); - -atp_readb_io (p,0 ,0x17 ); -atp_writeb_io (p,0 ,1 ,8 ); -atp_writeb_io (p,0 ,2 ,0x7f ); -atp_writeb_io (p,0 ,0x11 ,0x20 ); +atp_set_host_id (p,0 , host_id);tscam (shpnt);atp_writeb_base (p,0x3a ,atp_readb_base (p,0x3a ) |0x10 );
Signature · 1 line
Ondrej Zary
PATCH 35/52 atp870u: Reduce log spam on module load/unload
In reply to Ondrej Zary--- drivers/scsi/atp870u.c | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-)
drivers/scsi/atp870u.c +1 -6
@@ -1260,9 +1260,7 @@ static int atp870u_probe(struct pci_dev *pdev, const struct pci_device_id *ent)if (pci_enable_device (pdev)) goto err_eio; -if (!pci_set_dma_mask (pdev,DMA_BIT_MASK (32 ))) { -printk (KERN_INFO "atp870u: use 32bit DMA mask.\n" ); - }else { +if (pci_set_dma_mask (pdev,DMA_BIT_MASK (32 ))) {printk (KERN_ERR "atp870u: DMA mask required but not available.\n" ); goto err_eio; }
@@ -1742,12 +1740,9 @@ static void atp870u_remove (struct pci_dev *pdev)scsi_remove_host (pshost); -printk (KERN_INFO "free_irq : %d\n" ,pshost->irq);free_irq (pshost->irq, pshost);release_region (pshost->io_port, pshost->n_io_port); -printk (KERN_INFO "atp870u_free_tables : %p\n" ,pshost);atp870u_free_tables (pshost); -printk (KERN_INFO "scsi_host_put : %p\n" ,pshost);scsi_host_put (pshost); }MODULE_LICENSE ("GPL" );
Signature · 1 line
Ondrej Zary
PATCH 36/52 atp870u: Remove empty tscam_885()
In reply to Ondrej Zarytscam_885() is empty (except a delay) so remove it.
--- drivers/scsi/atp870u.c | 15 +-------------- 1 file changed, 1 insertion(+), 14 deletions(-)
drivers/scsi/atp870u.c +1 -14
@@ -42,7 +42,6 @@static struct scsi_host_template atp870u_template;static void send_s870 (struct atp_unit *dev,unsigned char c);static void atp_is (struct atp_unit *dev,unsigned char c,bool wide_chip,unsigned char lvdmode); -static void tscam_885 (void );static inline void atp_writeb_base (struct atp_unit *atp,u8 reg,u8 val) {
@@ -1518,7 +1517,7 @@ flash_ok_885: k = (k &0x07 ) |0x40 ;atp_set_host_id (p,1 , k); -tscam_885 (); +mdelay (600 );/* this delay used to be called tscam_885() */ printk (KERN_INFO " Scanning Channel A SCSI Device ...\n" );atp_is (p,0 , true,atp_readb_io (p,0 ,0x1b ) >>7 );atp_writeb_io (p,0 ,0x16 ,0x80 );
@@ -1802,18 +1801,6 @@ static void __exit atp870u_exit(void)pci_unregister_driver (&atp870u_driver); } -static void tscam_885 (void ) -{ -unsigned char i; - -for (i =0 ; i <0x2 ; i++) { -mdelay (300 ); - } -return ; -} - - -static void atp_is (struct atp_unit *dev,unsigned char c,bool wide_chip,unsigned char lvdmode) {unsigned char i, j, k, rmb, n;
Signature · 1 line
Ondrej Zary
PATCH 37/52 atp870u: Use module_pci_driver
In reply to Ondrej Zary--- drivers/scsi/atp870u.c | 20 +------------------- 1 file changed, 1 insertion(+), 19 deletions(-)
drivers/scsi/atp870u.c +1 -19
@@ -1785,21 +1785,7 @@ static struct pci_driver atp870u_driver = { .remove = atp870u_remove, }; -static int __init atp870u_init (void ) -{ -#ifdef ED_DBGP -printk ("atp870u_init: Entry\n" ); -#endif -return pci_register_driver (&atp870u_driver); -} - -static void __exit atp870u_exit(void) -{ -#ifdef ED_DBGP -printk ("atp870u_exit: Entry\n" ); -#endif -pci_unregister_driver (&atp870u_driver); -} +module_pci_driver (atp870u_driver);static void atp_is (struct atp_unit *dev,unsigned char c,bool wide_chip,unsigned char lvdmode) {
@@ -2406,7 +2392,3 @@ set_syn_ok:#endif } } - -module_init (atp870u_init); -module_exit (atp870u_exit); -
Signature · 1 line
Ondrej Zary
PATCH 38/52 atp870u: Use n_io_port in request_region and release_region
In reply to Ondrej Zary--- drivers/scsi/atp870u.c | 20 +++----------------- 1 file changed, 3 insertions(+), 17 deletions(-)
drivers/scsi/atp870u.c +3 -17
@@ -1610,16 +1610,8 @@ flash_ok_885: shpnt->irq = pdev->irq; }spin_unlock_irqrestore (shpnt->host_lock, flags); -if (ent->device==ATP885_DEVID ) { -if (!request_region (base_io,0xff ,"atp870u" ))/* Register the IO ports that we use */ - goto request_io_fail; - }else if ((ent->device==ATP880_DEVID1 )||(ent->device==ATP880_DEVID2 )) { -if (!request_region (base_io,0x60 ,"atp870u" ))/* Register the IO ports that we use */ - goto request_io_fail; - }else { -if (!request_region (base_io,0x40 ,"atp870u" ))/* Register the IO ports that we use */ - goto request_io_fail; - } +if (!request_region (base_io, shpnt->n_io_port,"atp870u" )) + goto request_io_fail; count++;if (scsi_add_host (shpnt, &pdev->dev)) goto scsi_add_fail;
@@ -1631,13 +1623,7 @@ flash_ok_885: scsi_add_fail:printk ("atp870u_prob:scsi_add_fail\n" ); -if (ent->device==ATP885_DEVID ) { -release_region (base_io,0xff ); - }else if ((ent->device==ATP880_DEVID1 )||(ent->device==ATP880_DEVID2 )) { -release_region (base_io,0x60 ); - }else { -release_region (base_io,0x40 ); - } +release_region (base_io, shpnt->n_io_port); request_io_fail:printk ("atp870u_prob:request_io_fail\n" );free_irq (pdev->irq, shpnt);
Signature · 1 line
Ondrej Zary
PATCH 39/52 atp870u: Remove useless and broken card counting
In reply to Ondrej Zary--- drivers/scsi/atp870u.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-)
drivers/scsi/atp870u.c +4 -6
@@ -1250,7 +1250,6 @@ static int atp870u_probe(struct pci_dev *pdev, const struct pci_device_id *ent)struct Scsi_Host *shpnt =NULL ;struct atp_unit *atpdev, *p;unsigned char setupdata[2 ][16 ]; -int count =0 ; atpdev =kzalloc (sizeof (*atpdev),GFP_KERNEL );if (!atpdev)
@@ -1298,8 +1297,8 @@ static int atp870u_probe(struct pci_dev *pdev, const struct pci_device_id *ent) host_id =atp_readb_base (atpdev,0x39 ); host_id >>=0x04 ; -printk (KERN_INFO " ACARD AEC-67160 PCI Ultra3 LVD Host Adapter: %d" -" IO:%x, IRQ:%d.\n" , count, base_io, pdev->irq); +printk (KERN_INFO " ACARD AEC-67160 PCI Ultra3 LVD Host Adapter:" +" IO:%x, IRQ:%d.\n" , base_io, pdev->irq); atpdev->dev_id = ent->device; atpdev->host_id[0 ] = host_id;
@@ -1546,8 +1545,8 @@ flash_ok_885: }else { error =pci_read_config_byte (pdev,0x49 , &host_id); -printk (KERN_INFO " ACARD AEC-671X PCI Ultra/W SCSI-2/3 Host Adapter: %d " -"IO:%x, IRQ:%d.\n" , count, base_io, pdev->irq); +printk (KERN_INFO " ACARD AEC-671X PCI Ultra/W SCSI-2/3 Host Adapter: " +"IO:%x, IRQ:%d.\n" , base_io, pdev->irq); atpdev->ioport[0 ] = base_io; atpdev->pciport[0 ] = base_io +0x20 ;
@@ -1612,7 +1611,6 @@ flash_ok_885:spin_unlock_irqrestore (shpnt->host_lock, flags);if (!request_region (base_io, shpnt->n_io_port,"atp870u" )) goto request_io_fail; - count++;if (scsi_add_host (shpnt, &pdev->dev)) goto scsi_add_fail;scsi_scan_host (shpnt);
Signature · 1 line
Ondrej Zary
PATCH 40/52 atp870u: Remove unused irq from struct atp_unit
In reply to Ondrej Zary--- drivers/scsi/atp870u.h | 1 - 1 file changed, 1 deletion(-)
drivers/scsi/atp870u.h +0 -1
@@ -26,7 +26,6 @@ struct atp_unitunsigned long baseport;unsigned long ioport[2 ];unsigned long pciport[2 ]; -unsigned long irq;unsigned char last_cmd[2 ];unsigned char in_snd[2 ];unsigned char in_int[2 ];
Signature · 1 line
Ondrej Zary
PATCH 41/52 atp870u: Improve _probe()
In reply to Ondrej ZaryMove scsi_host_alloc() to the top of _probe() to remove code duplication, *p and unneeded atpdev (de)allocation and copying.
While at it, fix the error paths to return real error codes and also add missing pci_disble_device() call.
--- drivers/scsi/atp870u.c | 236 +++++++++++++++++++++++------------------------- 1 file changed, 113 insertions(+), 123 deletions(-)
drivers/scsi/atp870u.c +113 -123
@@ -1248,29 +1248,41 @@ static int atp870u_probe(struct pci_dev *pdev, const struct pci_device_id *ent)unsigned int base_io, error,n;unsigned char host_id;struct Scsi_Host *shpnt =NULL ; -struct atp_unit *atpdev, *p; +struct atp_unit *atpdev;unsigned char setupdata[2 ][16 ]; +int err; - atpdev =kzalloc (sizeof (*atpdev),GFP_KERNEL ); -if (!atpdev) -return -ENOMEM ; - -if (pci_enable_device (pdev)) - goto err_eio; + err =pci_enable_device (pdev); +if (err) + goto fail;if (pci_set_dma_mask (pdev,DMA_BIT_MASK (32 ))) {printk (KERN_ERR "atp870u: DMA mask required but not available.\n" ); - goto err_eio; + err = -EIO ; + goto disable_device; } + err = -ENOMEM ; + shpnt =scsi_host_alloc (&atp870u_template,sizeof (struct atp_unit )); +if (!shpnt) + goto disable_device; + + atpdev =shost_priv (shpnt); + + atpdev->host = shpnt; + atpdev->pdev = pdev; +pci_set_drvdata (pdev, atpdev); +/* * It's probably easier to weed out some revisions like * this than via the PCI device table */ if (ent->device ==PCI_DEVICE_ID_ARTOP_AEC7610 ) { atpdev->chip_ver = pdev->revision; -if (atpdev->chip_ver <2 ) - goto err_eio; +if (atpdev->chip_ver <2 ) { + err = -ENODEV ; + goto unregister; + } }switch (ent->device) {
@@ -1358,41 +1370,33 @@ flash_ok_880: atpdev->async[0 ] = ~(atpdev->async[0 ]);atp_writeb_base (atpdev,0x35 , atpdev->global_map[0 ]); - shpnt =scsi_host_alloc (&atp870u_template,sizeof (struct atp_unit )); -if (!shpnt) - goto err_nomem; - - p = (struct atp_unit *)&shpnt->hostdata; - - atpdev->host = shpnt; - atpdev->pdev = pdev; -pci_set_drvdata (pdev, p); -memcpy (p, atpdev,sizeof (*atpdev));if (atp870u_init_tables (shpnt) <0 ) {printk (KERN_ERR "Unable to allocate tables for Acard controller\n" ); + err = -ENOMEM ; goto unregister; } -if (request_irq (pdev->irq, atp870u_intr_handle,IRQF_SHARED ,"atp880i" , shpnt)) { + err =request_irq (pdev->irq, atp870u_intr_handle,IRQF_SHARED ,"atp880i" , shpnt); +if (err) {printk (KERN_ERR "Unable to allocate IRQ%d for Acard controller.\n" , pdev->irq); goto free_tables; }spin_lock_irqsave (shpnt->host_lock, flags); - k =atp_readb_base (p,0x38 ) &0x80 ; -atp_writeb_base (p,0x38 , k); -atp_writeb_base (p,0x3b ,0x20 ); + k =atp_readb_base (atpdev,0x38 ) &0x80 ; +atp_writeb_base (atpdev,0x38 , k); +atp_writeb_base (atpdev,0x3b ,0x20 );mdelay (32 ); -atp_writeb_base (p,0x3b ,0 ); +atp_writeb_base (atpdev,0x3b ,0 );mdelay (32 ); -atp_readb_io (p,0 ,0x1b ); -atp_readb_io (p,0 ,0x17 ); +atp_readb_io (atpdev,0 ,0x1b ); +atp_readb_io (atpdev,0 ,0x17 ); -atp_set_host_id (p,0 , host_id); +atp_set_host_id (atpdev,0 , host_id);tscam (shpnt); -atp_is (p,0 , true,atp_readb_base (p,0x3f ) &0x40 ); -atp_writeb_base (p,0x38 ,0xb0 ); +atp_is (atpdev,0 , true,atp_readb_base (atpdev,0x3f ) &0x40 ); +atp_writeb_base (atpdev,0x38 ,0xb0 ); shpnt->max_id =16 ; shpnt->this_id = host_id; shpnt->unique_id = base_io;
@@ -1410,50 +1414,43 @@ flash_ok_880: atpdev->pciport[0 ] = base_io +0x40 ; atpdev->pciport[1 ] = base_io +0x50 ; - shpnt =scsi_host_alloc (&atp870u_template,sizeof (struct atp_unit )); -if (!shpnt) - goto err_nomem; - - p = (struct atp_unit *)&shpnt->hostdata; - - atpdev->host = shpnt; - atpdev->pdev = pdev; -pci_set_drvdata (pdev, p); -memcpy (p, atpdev,sizeof (struct atp_unit )); -if (atp870u_init_tables (shpnt) <0 ) +if (atp870u_init_tables (shpnt) <0 ) { + err = -ENOMEM ; goto unregister; + }#ifdef ED_DBGP -printk ("request_irq() shpnt %p hostdata %p\n" , shpnt, p); +printk ("request_irq() shpnt %p hostdata %p\n" , shpnt, atpdev);#endif -if (request_irq (pdev->irq, atp870u_intr_handle,IRQF_SHARED ,"atp870u" , shpnt)) { + err =request_irq (pdev->irq, atp870u_intr_handle,IRQF_SHARED ,"atp870u" , shpnt); +if (err) {printk (KERN_ERR "Unable to allocate IRQ for Acard controller.\n" ); goto free_tables; }spin_lock_irqsave (shpnt->host_lock, flags); - c =atp_readb_base (p,0x29 ); -atp_writeb_base (p,0x29 , c |0x04 ); + c =atp_readb_base (atpdev,0x29 ); +atp_writeb_base (atpdev,0x29 , c |0x04 ); n=0x1f80 ; next_fblk_885:if (n >=0x2000 ) { goto flash_ok_885; } -atp_writew_base (p,0x3c , n); -if (atp_readl_base (p,0x38 ) ==0xffffffff ) { +atp_writew_base (atpdev,0x3c , n); +if (atp_readl_base (atpdev,0x38 ) ==0xffffffff ) { goto flash_ok_885; }for (m=0 ; m <2 ; m++) { - p->global_map[m]=0 ; + atpdev->global_map[m]=0 ;for (k=0 ; k <4 ; k++) { -atp_writew_base (p,0x3c , n++); - ((unsigned long *)&setupdata[m][0 ])[k] =atp_readl_base (p,0x38 ); +atp_writew_base (atpdev,0x3c , n++); + ((unsigned long *)&setupdata[m][0 ])[k] =atp_readl_base (atpdev,0x38 ); }for (k=0 ; k <4 ; k++) { -atp_writew_base (p,0x3c , n++); - ((unsigned long *)&p->sp[m][0 ])[k] =atp_readl_base (p,0x38 ); +atp_writew_base (atpdev,0x3c , n++); + ((unsigned long *)&atpdev->sp[m][0 ])[k] =atp_readl_base (atpdev,0x38 ); } n +=8 ; }
@@ -1462,81 +1459,81 @@ flash_ok_885:#ifdef ED_DBGP printk ("Flash Read OK\n" );#endif - c =atp_readb_base (p,0x29 ); -atp_writeb_base (p,0x29 , c &0xfb ); + c =atp_readb_base (atpdev,0x29 ); +atp_writeb_base (atpdev,0x29 , c &0xfb );for (c=0 ;c <2 ;c++) { - p->ultra_map[c]=0 ; - p->async[c] =0 ; + atpdev->ultra_map[c]=0 ; + atpdev->async[c] =0 ;for (k=0 ; k <16 ; k++) { n=1 ; n = n << k; -if (p->sp[c][k] >1 ) { - p->ultra_map[c] |= n; +if (atpdev->sp[c][k] >1 ) { + atpdev->ultra_map[c] |= n; }else { -if (p->sp[c][k] ==0 ) { - p->async[c] |= n; +if (atpdev->sp[c][k] ==0 ) { + atpdev->async[c] |= n; } } } - p->async[c] = ~(p->async[c]); + atpdev->async[c] = ~(atpdev->async[c]); -if (p->global_map[c] ==0 ) { +if (atpdev->global_map[c] ==0 ) { k=setupdata[c][1 ];if ((k &0x40 ) !=0 ) - p->global_map[c] |=0x20 ; + atpdev->global_map[c] |=0x20 ; k &=0x07 ; - p->global_map[c] |= k; + atpdev->global_map[c] |= k;if ((setupdata[c][2 ] &0x04 ) !=0 ) - p->global_map[c] |=0x08 ; - p->host_id[c] = setupdata[c][0 ] &0x07 ; + atpdev->global_map[c] |=0x08 ; + atpdev->host_id[c] = setupdata[c][0 ] &0x07 ; } } - k =atp_readb_base (p,0x28 ) &0x8f ; + k =atp_readb_base (atpdev,0x28 ) &0x8f ; k |=0x10 ; -atp_writeb_base (p,0x28 , k); -atp_writeb_pci (p,0 ,1 ,0x80 ); -atp_writeb_pci (p,1 ,1 ,0x80 ); +atp_writeb_base (atpdev,0x28 , k); +atp_writeb_pci (atpdev,0 ,1 ,0x80 ); +atp_writeb_pci (atpdev,1 ,1 ,0x80 );mdelay (100 ); -atp_writeb_pci (p,0 ,1 ,0 ); -atp_writeb_pci (p,1 ,1 ,0 ); +atp_writeb_pci (atpdev,0 ,1 ,0 ); +atp_writeb_pci (atpdev,1 ,1 ,0 );mdelay (1000 ); -atp_readb_io (p,0 ,0x1b ); -atp_readb_io (p,0 ,0x17 ); -atp_readb_io (p,1 ,0x1b ); -atp_readb_io (p,1 ,0x17 ); +atp_readb_io (atpdev,0 ,0x1b ); +atp_readb_io (atpdev,0 ,0x17 ); +atp_readb_io (atpdev,1 ,0x1b ); +atp_readb_io (atpdev,1 ,0x17 ); - k=p->host_id[0 ]; + k=atpdev->host_id[0 ];if (k >7 ) k = (k &0x07 ) |0x40 ; -atp_set_host_id (p,0 , k); +atp_set_host_id (atpdev,0 , k); - k=p->host_id[1 ]; + k=atpdev->host_id[1 ];if (k >7 ) k = (k &0x07 ) |0x40 ; -atp_set_host_id (p,1 , k); +atp_set_host_id (atpdev,1 , k);mdelay (600 );/* this delay used to be called tscam_885() */ printk (KERN_INFO " Scanning Channel A SCSI Device ...\n" ); -atp_is (p,0 , true,atp_readb_io (p,0 ,0x1b ) >>7 ); -atp_writeb_io (p,0 ,0x16 ,0x80 ); +atp_is (atpdev,0 , true,atp_readb_io (atpdev,0 ,0x1b ) >>7 ); +atp_writeb_io (atpdev,0 ,0x16 ,0x80 );printk (KERN_INFO " Scanning Channel B SCSI Device ...\n" ); -atp_is (p,1 , true,atp_readb_io (p,1 ,0x1b ) >>7 ); -atp_writeb_io (p,1 ,0x16 ,0x80 ); - k =atp_readb_base (p,0x28 ) &0xcf ; +atp_is (atpdev,1 , true,atp_readb_io (atpdev,1 ,0x1b ) >>7 ); +atp_writeb_io (atpdev,1 ,0x16 ,0x80 ); + k =atp_readb_base (atpdev,0x28 ) &0xcf ; k |=0xc0 ; -atp_writeb_base (p,0x28 , k); - k =atp_readb_base (p,0x1f ) |0x80 ; -atp_writeb_base (p,0x1f , k); - k =atp_readb_base (p,0x29 ) |0x01 ; -atp_writeb_base (p,0x29 , k); +atp_writeb_base (atpdev,0x28 , k); + k =atp_readb_base (atpdev,0x1f ) |0x80 ; +atp_writeb_base (atpdev,0x1f , k); + k =atp_readb_base (atpdev,0x29 ) |0x01 ; +atp_writeb_base (atpdev,0x29 , k);#ifdef ED_DBGP //printk("atp885: atp_host[0] 0x%p\n", atp_host[0]); #endif shpnt->max_id =16 ; - shpnt->max_lun = (p->global_map[0 ] &0x07 ) +1 ; + shpnt->max_lun = (atpdev->global_map[0 ] &0x07 ) +1 ; shpnt->max_channel =1 ; - shpnt->this_id = p->host_id[0 ]; + shpnt->this_id = atpdev->host_id[0 ]; shpnt->unique_id = base_io; shpnt->io_port = base_io; shpnt->n_io_port =0xff ;/* Number of bytes of I/O space used */
@@ -1563,41 +1560,35 @@ flash_ok_885: atpdev->ultra_map[0 ] =0xffff ; } - shpnt =scsi_host_alloc (&atp870u_template,sizeof (struct atp_unit )); -if (!shpnt) - goto err_nomem; - p = (struct atp_unit *)&shpnt->hostdata; - - atpdev->host = shpnt; - atpdev->pdev = pdev; -pci_set_drvdata (pdev, p); -memcpy (p, atpdev,sizeof (*atpdev)); -if (atp870u_init_tables (shpnt) <0 ) +if (atp870u_init_tables (shpnt) <0 ) { + err = -ENOMEM ; goto unregister; + } -if (request_irq (pdev->irq, atp870u_intr_handle,IRQF_SHARED ,"atp870i" , shpnt)) { + err =request_irq (pdev->irq, atp870u_intr_handle,IRQF_SHARED ,"atp870i" , shpnt); +if (err) {printk (KERN_ERR "Unable to allocate IRQ%d for Acard controller.\n" , pdev->irq); goto free_tables; }spin_lock_irqsave (shpnt->host_lock, flags);if (atpdev->chip_ver >0x07 )/* check if atp876 chip then enable terminator */ -atp_writeb_base (p,0x3e ,0x00 ); +atp_writeb_base (atpdev,0x3e ,0x00 ); - k = (atp_readb_base (p,0x3a ) &0xf3 ) |0x10 ; -atp_writeb_base (p,0x3a , k); -atp_writeb_base (p,0x3a , k &0xdf ); + k = (atp_readb_base (atpdev,0x3a ) &0xf3 ) |0x10 ; +atp_writeb_base (atpdev,0x3a , k); +atp_writeb_base (atpdev,0x3a , k &0xdf );mdelay (32 ); -atp_writeb_base (p,0x3a , k); +atp_writeb_base (atpdev,0x3a , k);mdelay (32 ); -atp_set_host_id (p,0 , host_id); +atp_set_host_id (atpdev,0 , host_id);tscam (shpnt); -atp_writeb_base (p,0x3a ,atp_readb_base (p,0x3a ) |0x10 ); -atp_is (p,0 , p->chip_ver ==4 ,0 ); -atp_writeb_base (p,0x3a ,atp_readb_base (p,0x3a ) &0xef ); -atp_writeb_base (p,0x3b ,atp_readb_base (p,0x3b ) |0x20 ); +atp_writeb_base (atpdev,0x3a ,atp_readb_base (atpdev,0x3a ) |0x10 ); +atp_is (atpdev,0 , atpdev->chip_ver ==4 ,0 ); +atp_writeb_base (atpdev,0x3a ,atp_readb_base (atpdev,0x3a ) &0xef ); +atp_writeb_base (atpdev,0x3b ,atp_readb_base (atpdev,0x3b ) |0x20 );if (atpdev->chip_ver ==4 ) shpnt->max_id =16 ;else
@@ -1609,9 +1600,12 @@ flash_ok_885: shpnt->irq = pdev->irq; }spin_unlock_irqrestore (shpnt->host_lock, flags); -if (!request_region (base_io, shpnt->n_io_port,"atp870u" )) +if (!request_region (base_io, shpnt->n_io_port,"atp870u" )) { + err = -EBUSY ; goto request_io_fail; -if (scsi_add_host (shpnt, &pdev->dev)) + } + err =scsi_add_host (shpnt, &pdev->dev); +if (err) goto scsi_add_fail;scsi_scan_host (shpnt);#ifdef ED_DBGP
@@ -1629,15 +1623,11 @@ free_tables:printk ("atp870u_prob:free_table\n" );atp870u_free_tables (shpnt); unregister: -printk ("atp870u_prob:unregister\n" );scsi_host_put (shpnt); -return -1 ; -err_eio: -kfree (atpdev); -return -EIO ; -err_nomem: -kfree (atpdev); -return -ENOMEM ; +disable_device: +pci_disable_device (pdev); +fail: +return err; }/* The abort command does not leave the device in a clean state where
Signature · 1 line
Ondrej Zary
PATCH 42/52 atp870u: Improve unsupported chip detection
In reply to Ondrej Zary--- drivers/scsi/atp870u.c | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-)
drivers/scsi/atp870u.c +8 -12
@@ -1252,6 +1252,11 @@ static int atp870u_probe(struct pci_dev *pdev, const struct pci_device_id *ent)unsigned char setupdata[2 ][16 ];int err; +if (ent->device ==PCI_DEVICE_ID_ARTOP_AEC7610 && pdev->revision <2 ) { +dev_err (&pdev->dev,"ATP850S chips (AEC6710L/F cards) are not supported.\n" ); +return -ENODEV ; + } + err =pci_enable_device (pdev);if (err) goto fail;
@@ -1273,19 +1278,10 @@ static int atp870u_probe(struct pci_dev *pdev, const struct pci_device_id *ent) atpdev->pdev = pdev;pci_set_drvdata (pdev, atpdev); -/* -* It's probably easier to weed out some revisions like -* this than via the PCI device table -*/ -if (ent->device ==PCI_DEVICE_ID_ARTOP_AEC7610 ) { - atpdev->chip_ver = pdev->revision; -if (atpdev->chip_ver <2 ) { - err = -ENODEV ; - goto unregister; - } - } -switch (ent->device) { +case PCI_DEVICE_ID_ARTOP_AEC7610 : + atpdev->chip_ver = pdev->revision; +break ;case PCI_DEVICE_ID_ARTOP_AEC7612UW :case PCI_DEVICE_ID_ARTOP_AEC7612SUW :case ATP880_DEVID1 :
Signature · 1 line
Ondrej Zary
PATCH 43/52 atp870u: Remove chip_ver from struct atp_unit
In reply to Ondrej Zarychip_ver is used for wide chip detection only. Remove it and use a local variable instead (for 870; 880 and 885 are always wide).
--- drivers/scsi/atp870u.c | 39 ++++++++++++++------------------------- drivers/scsi/atp870u.h | 1 - 2 files changed, 14 insertions(+), 26 deletions(-)
drivers/scsi/atp870u.c +14 -25
@@ -954,7 +954,7 @@ static unsigned char fun_scam(struct atp_unit *dev, unsigned short int *val)return j; } -static void tscam (struct Scsi_Host *host) +static void tscam (struct Scsi_Host *host,bool wide_chip) {unsigned char i, j, k;
@@ -983,7 +983,7 @@ static void tscam(struct Scsi_Host *host) m =1 ; m <<= dev->host_id[0 ]; j =16 ; -if (dev->chip_ver <4 ) { +if (!wide_chip) { m |=0xff00 ; j =8 ; }
@@ -1012,7 +1012,7 @@ static void tscam(struct Scsi_Host *host) k = i; }atp_writeb_io (dev,0 ,0x15 , k); -if (dev->chip_ver ==4 ) +if (wide_chip)atp_writeb_io (dev,0 ,0x1b ,0x01 );else atp_writeb_io (dev,0 ,0x1b ,0x00 );
@@ -1278,25 +1278,11 @@ static int atp870u_probe(struct pci_dev *pdev, const struct pci_device_id *ent) atpdev->pdev = pdev;pci_set_drvdata (pdev, atpdev); -switch (ent->device) { -case PCI_DEVICE_ID_ARTOP_AEC7610 : - atpdev->chip_ver = pdev->revision; -break ; -case PCI_DEVICE_ID_ARTOP_AEC7612UW : -case PCI_DEVICE_ID_ARTOP_AEC7612SUW : -case ATP880_DEVID1 : -case ATP880_DEVID2 : -case ATP885_DEVID : - atpdev->chip_ver =0x04 ; -default : -break ; - } base_io =pci_resource_start (pdev,0 ); base_io &=0xfffffff8 ; atpdev->baseport = base_io;if ((ent->device ==ATP880_DEVID1 )||(ent->device ==ATP880_DEVID2 )) { - atpdev->chip_ver = pdev->revision;pci_write_config_byte (pdev,PCI_LATENCY_TIMER ,0x80 );//JCC082803 atpdev->ioport[0 ] = base_io +0x40 ;
@@ -1390,7 +1376,7 @@ flash_ok_880:atp_set_host_id (atpdev,0 , host_id); -tscam (shpnt); +tscam (shpnt, true);atp_is (atpdev,0 , true,atp_readb_base (atpdev,0x3f ) &0x40 );atp_writeb_base (atpdev,0x38 ,0xb0 ); shpnt->max_id =16 ;
@@ -1536,6 +1522,11 @@ flash_ok_885: shpnt->irq = pdev->irq; }else { +bool wide_chip = + (ent->device ==PCI_DEVICE_ID_ARTOP_AEC7610 && + pdev->revision ==4 ) || + (ent->device ==PCI_DEVICE_ID_ARTOP_AEC7612UW ) || + (ent->device ==PCI_DEVICE_ID_ARTOP_AEC7612SUW ); error =pci_read_config_byte (pdev,0x49 , &host_id); printk(KERN_INFO " ACARD AEC-671X PCI Ultra/W SCSI-2/3 Host Adapter: "
@@ -1569,7 +1560,7 @@ flash_ok_885: }spin_lock_irqsave (shpnt->host_lock, flags); -if (atpdev->chip_ver >0x07 )/* check if atp876 chip then enable terminator */ +if (pdev->revision >0x07 )/* check if atp876 chip then enable terminator */ atp_writeb_base (atpdev,0x3e ,0x00 ); k = (atp_readb_base (atpdev,0x3a ) &0xf3 ) |0x10 ;
@@ -1580,15 +1571,13 @@ flash_ok_885:mdelay (32 );atp_set_host_id (atpdev,0 , host_id); -tscam (shpnt); + +tscam (shpnt, wide_chip);atp_writeb_base (atpdev,0x3a ,atp_readb_base (atpdev,0x3a ) |0x10 ); -atp_is (atpdev,0 , atpdev->chip_ver ==4 ,0 ); +atp_is (atpdev,0 , wide_chip,0 );atp_writeb_base (atpdev,0x3a ,atp_readb_base (atpdev,0x3a ) &0xef );atp_writeb_base (atpdev,0x3b ,atp_readb_base (atpdev,0x3b ) |0x20 ); -if (atpdev->chip_ver ==4 ) - shpnt->max_id =16 ; -else - shpnt->max_id =8 ; + shpnt->max_id = wide_chip ?16 :8 ; shpnt->this_id = host_id; shpnt->unique_id = base_io; shpnt->io_port = base_io;
drivers/scsi/atp870u.h +0 -1
@@ -32,7 +32,6 @@ struct atp_unitunsigned char quhd[2 ];unsigned char quend[2 ];unsigned char global_map[2 ]; -unsigned char chip_ver;unsigned char scam_on;unsigned char host_id[2 ];unsigned int working[2 ];
Signature · 1 line
Ondrej Zary
PATCH 44/52 atp870u: Simplify _probe()
In reply to Ondrej ZaryMove shpnt common code to the top, remove base_io, use pci_resource_len.
--- drivers/scsi/atp870u.c | 65 +++++++++++++++++++++--------------------------- 1 file changed, 28 insertions(+), 37 deletions(-)
drivers/scsi/atp870u.c +28 -37
@@ -1245,7 +1245,7 @@ static int atp870u_probe(struct pci_dev *pdev, const struct pci_device_id *ent) {unsigned char k, m, c;unsigned long flags; -unsigned int base_io, error,n; +unsigned int error,n;unsigned char host_id;struct Scsi_Host *shpnt =NULL ;struct atp_unit *atpdev;
@@ -1278,21 +1278,24 @@ static int atp870u_probe(struct pci_dev *pdev, const struct pci_device_id *ent) atpdev->pdev = pdev;pci_set_drvdata (pdev, atpdev); - base_io =pci_resource_start (pdev,0 ); - base_io &=0xfffffff8 ; - atpdev->baseport = base_io; + shpnt->io_port =pci_resource_start (pdev,0 ); + shpnt->io_port &=0xfffffff8 ; + shpnt->n_io_port =pci_resource_len (pdev,0 ); + atpdev->baseport = shpnt->io_port; + shpnt->unique_id = shpnt->io_port; + shpnt->irq = pdev->irq;if ((ent->device ==ATP880_DEVID1 )||(ent->device ==ATP880_DEVID2 )) {pci_write_config_byte (pdev,PCI_LATENCY_TIMER ,0x80 );//JCC082803 - atpdev->ioport[0 ] = base_io +0x40 ; - atpdev->pciport[0 ] = base_io +0x28 ; + atpdev->ioport[0 ] = shpnt->io_port +0x40 ; + atpdev->pciport[0 ] = shpnt->io_port +0x28 ; host_id =atp_readb_base (atpdev,0x39 ); host_id >>=0x04 ;printk (KERN_INFO " ACARD AEC-67160 PCI Ultra3 LVD Host Adapter:" -" IO:%x, IRQ:%d.\n" , base_io, pdev->irq); +" IO:%lx, IRQ:%d.\n" , shpnt->io_port, shpnt->irq); atpdev->dev_id = ent->device; atpdev->host_id[0 ] = host_id;
@@ -1358,9 +1361,9 @@ flash_ok_880: goto unregister; } - err =request_irq (pdev->irq, atp870u_intr_handle,IRQF_SHARED ,"atp880i" , shpnt); + err =request_irq (shpnt->irq, atp870u_intr_handle,IRQF_SHARED ,"atp880i" , shpnt);if (err) { -printk (KERN_ERR "Unable to allocate IRQ%d for Acard controller.\n" , pdev->irq); +printk (KERN_ERR "Unable to allocate IRQ%d for Acard controller.\n" , shpnt->irq); goto free_tables; }
@@ -1381,20 +1384,16 @@ flash_ok_880:atp_writeb_base (atpdev,0x38 ,0xb0 ); shpnt->max_id =16 ; shpnt->this_id = host_id; - shpnt->unique_id = base_io; - shpnt->io_port = base_io; - shpnt->n_io_port =0x60 ;/* Number of bytes of I/O space used */ - shpnt->irq = pdev->irq; }else if (ent->device ==ATP885_DEVID ) { -printk (KERN_INFO " ACARD AEC-67162 PCI Ultra3 LVD Host Adapter: IO:%x, IRQ:%d.\n" - , base_io, pdev->irq); +printk (KERN_INFO " ACARD AEC-67162 PCI Ultra3 LVD Host Adapter: IO:%lx, IRQ:%d.\n" + , shpnt->io_port, shpnt->irq); atpdev->pdev = pdev; atpdev->dev_id = ent->device; - atpdev->ioport[0 ] = base_io +0x80 ; - atpdev->ioport[1 ] = base_io +0xc0 ; - atpdev->pciport[0 ] = base_io +0x40 ; - atpdev->pciport[1 ] = base_io +0x50 ; + atpdev->ioport[0 ] = shpnt->io_port +0x80 ; + atpdev->ioport[1 ] = shpnt->io_port +0xc0 ; + atpdev->pciport[0 ] = shpnt->io_port +0x40 ; + atpdev->pciport[1 ] = shpnt->io_port +0x50 ;if (atp870u_init_tables (shpnt) <0 ) { err = -ENOMEM ;
@@ -1404,7 +1403,7 @@ flash_ok_880:#ifdef ED_DBGP printk ("request_irq() shpnt %p hostdata %p\n" , shpnt, atpdev);#endif - err =request_irq (pdev->irq, atp870u_intr_handle,IRQF_SHARED ,"atp870u" , shpnt); + err =request_irq (shpnt->irq, atp870u_intr_handle,IRQF_SHARED ,"atp870u" , shpnt);if (err) {printk (KERN_ERR "Unable to allocate IRQ for Acard controller.\n" ); goto free_tables;
@@ -1516,11 +1515,6 @@ flash_ok_885: shpnt->max_lun = (atpdev->global_map[0 ] &0x07 ) +1 ; shpnt->max_channel =1 ; shpnt->this_id = atpdev->host_id[0 ]; - shpnt->unique_id = base_io; - shpnt->io_port = base_io; - shpnt->n_io_port =0xff ;/* Number of bytes of I/O space used */ - shpnt->irq = pdev->irq; - }else { bool wide_chip = (ent->device == PCI_DEVICE_ID_ARTOP_AEC7610 &&
@@ -1530,10 +1524,10 @@ flash_ok_885: error =pci_read_config_byte (pdev,0x49 , &host_id);printk (KERN_INFO " ACARD AEC-671X PCI Ultra/W SCSI-2/3 Host Adapter: " -"IO:%x, IRQ:%d.\n" , base_io, pdev->irq); +"IO:%lx, IRQ:%d.\n" , shpnt->io_port, shpnt->irq); - atpdev->ioport[0 ] = base_io; - atpdev->pciport[0 ] = base_io +0x20 ; + atpdev->ioport[0 ] = shpnt->io_port; + atpdev->pciport[0 ] = shpnt->io_port +0x20 ; atpdev->dev_id = ent->device; host_id &=0x07 ; atpdev->host_id[0 ] = host_id;
@@ -1553,9 +1547,9 @@ flash_ok_885: goto unregister; } - err =request_irq (pdev->irq, atp870u_intr_handle,IRQF_SHARED ,"atp870i" , shpnt); + err =request_irq (shpnt->irq, atp870u_intr_handle,IRQF_SHARED ,"atp870i" , shpnt);if (err) { -printk (KERN_ERR "Unable to allocate IRQ%d for Acard controller.\n" , pdev->irq); +printk (KERN_ERR "Unable to allocate IRQ%d for Acard controller.\n" , shpnt->irq); goto free_tables; }
@@ -1579,13 +1573,10 @@ flash_ok_885:atp_writeb_base (atpdev,0x3b ,atp_readb_base (atpdev,0x3b ) |0x20 ); shpnt->max_id = wide_chip ?16 :8 ; shpnt->this_id = host_id; - shpnt->unique_id = base_io; - shpnt->io_port = base_io; - shpnt->n_io_port =0x40 ;/* Number of bytes of I/O space used */ - shpnt->irq = pdev->irq; + }spin_unlock_irqrestore (shpnt->host_lock, flags); -if (!request_region (base_io, shpnt->n_io_port,"atp870u" )) { +if (!request_region (shpnt->io_port, shpnt->n_io_port,"atp870u" )) { err = -EBUSY ; goto request_io_fail; }
@@ -1600,10 +1591,10 @@ flash_ok_885: scsi_add_fail:printk ("atp870u_prob:scsi_add_fail\n" ); -release_region (base_io, shpnt->n_io_port); +release_region (shpnt->io_port, shpnt->n_io_port); request_io_fail:printk ("atp870u_prob:request_io_fail\n" ); -free_irq (pdev->irq, shpnt); +free_irq (shpnt->irq, shpnt); free_tables:printk ("atp870u_prob:free_table\n" );atp870u_free_tables (shpnt);
Signature · 1 line
Ondrej Zary
PATCH 45/52 atp870u: Introduce is880(), is885() and remove dev_id
In reply to Ondrej ZaryIntroduce chip type inline functions to simplify code, allowing to delete dev_id from struct atp_unit.
--- drivers/scsi/atp870u.c | 70 ++++++++++++++++++++++++++---------------------- drivers/scsi/atp870u.h | 1 - 2 files changed, 38 insertions(+), 33 deletions(-)
drivers/scsi/atp870u.c +38 -32
@@ -103,6 +103,17 @@ static inline u8 atp_readb_pci(struct atp_unit *atp, u8 channel, u8 reg)return inb (atp->pciport[channel] + reg); } +static inline bool is880 (struct atp_unit *atp) +{ +return atp->pdev->device ==ATP880_DEVID1 || + atp->pdev->device ==ATP880_DEVID2 ; +} + +static inline bool is885 (struct atp_unit *atp) +{ +return atp->pdev->device ==ATP885_DEVID ; +} +static irqreturn_t atp870u_intr_handle (int irq,void *dev_id) {unsigned long flags;
@@ -131,7 +142,7 @@ static irqreturn_t atp870u_intr_handle(int irq, void *dev_id) dev->in_int[c] =1 ; cmdp =atp_readb_io (dev, c,0x10 );if (dev->working[c] !=0 ) { -if (dev->dev_id ==ATP885_DEVID ) { +if (is885 (dev)) {if ((atp_readb_io (dev, c,0x16 ) &0x80 ) ==0 )atp_writeb_io (dev, c,0x16 , (atp_readb_io (dev, c,0x16 ) |0x80 )); }
@@ -148,7 +159,7 @@ static irqreturn_t atp870u_intr_handle(int irq, void *dev_id) i =atp_readb_io (dev, c,0x17 ); -if (dev->dev_id ==ATP885_DEVID ) +if (is885 (dev))atp_writeb_pci (dev, c,2 ,0x06 ); target_id =atp_readb_io (dev, c,0x15 );
@@ -169,7 +180,7 @@ static irqreturn_t atp870u_intr_handle(int irq, void *dev_id) } dev->last_cmd[c] |=0x40 ; } -if (dev->dev_id ==ATP885_DEVID ) +if (is885 (dev)) dev->r1f[c][target_id] |= j;#ifdef ED_DBGP printk ("atp870u_intr_handle status = %x\n" ,i);
@@ -178,7 +189,7 @@ static irqreturn_t atp870u_intr_handle(int irq, void *dev_id)if ((dev->last_cmd[c] &0xf0 ) !=0x40 ) { dev->last_cmd[c] =0xff ; } -if (dev->dev_id ==ATP885_DEVID ) { +if (is885 (dev)) { adrcnt =0 ; ((unsigned char *) &adrcnt)[2 ] =atp_readb_io (dev, c,0x12 ); ((unsigned char *) &adrcnt)[1 ] =atp_readb_io (dev, c,0x13 );
@@ -249,7 +260,7 @@ static irqreturn_t atp870u_intr_handle(int irq, void *dev_id)return IRQ_HANDLED ; } -if (dev->dev_id ==ATP885_DEVID ) { +if (is885 (dev)) {if ((i ==0x4c ) || (i ==0x4d ) || (i ==0x8c ) || (i ==0x8d )) {if ((i ==0x4c ) || (i ==0x8c )) i=0x48 ;
@@ -301,7 +312,7 @@ static irqreturn_t atp870u_intr_handle(int irq, void *dev_id)if (dev->last_cmd[c] !=0xff ) { dev->last_cmd[c] |=0x40 ; } -if (dev->dev_id ==ATP885_DEVID ) { +if (is885 (dev)) { j =atp_readb_base (dev,0x29 ) &0xfe ;atp_writeb_base (dev,0x29 , j); }else
@@ -316,7 +327,7 @@ static irqreturn_t atp870u_intr_handle(int irq, void *dev_id) }else { target_id &=0x07 ; } -if (dev->dev_id ==ATP885_DEVID ) +if (is885 (dev))atp_writeb_io (dev, c,0x10 ,0x45 ); workreq = dev->id[c][target_id].curr_req;#ifdef ED_DBGP
@@ -348,15 +359,14 @@ static irqreturn_t atp870u_intr_handle(int irq, void *dev_id)atp_writeb_io (dev, c,0x16 ,0x80 );/* enable 32 bit fifo transfer */ -if (dev->dev_id ==ATP885_DEVID ) { +if (is885 (dev)) { i =atp_readb_pci (dev, c,1 ) &0xf3 ;//j=workreq->cmnd[0]; if ((workreq->cmnd[0 ] ==0x08 ) || (workreq->cmnd[0 ] ==0x28 ) || (workreq->cmnd[0 ] ==0x0a ) || (workreq->cmnd[0 ] ==0x2a )) { i |=0x0c ; }atp_writeb_pci (dev, c,1 , i); - }else if ((dev->dev_id ==ATP880_DEVID1 ) || - (dev->dev_id ==ATP880_DEVID2 ) ) { + }else if (is880 (dev)) {if ((workreq->cmnd[0 ] ==0x08 ) || (workreq->cmnd[0 ] ==0x28 ) || (workreq->cmnd[0 ] ==0x0a ) || (workreq->cmnd[0 ] ==0x2a ))atp_writeb_base (dev,0x3b , (atp_readb_base (dev,0x3b ) &0x3f ) |0xc0 );else
@@ -417,7 +427,7 @@ static irqreturn_t atp870u_intr_handle(int irq, void *dev_id)#ifdef ED_DBGP printk ("dev->id[%d][%d].prdaddr 0x%8x\n" , c, target_id, dev->id[c][target_id].prdaddr);#endif -if (dev->dev_id !=ATP885_DEVID ) { +if (!is885 (dev)) {atp_writeb_pci (dev, c,2 ,0x06 );atp_writeb_pci (dev, c,2 ,0x00 ); }
@@ -454,14 +464,14 @@ static irqreturn_t atp870u_intr_handle(int irq, void *dev_id) }if (i ==0x16 ) { workreq->result =atp_readb_io (dev, c,0x0f ); -if (((dev->r1f[c][target_id] &0x10 ) !=0 )&&(dev->dev_id==ATP885_DEVID )) { +if (((dev->r1f[c][target_id] &0x10 ) !=0 ) &&is885 (dev)) {printk (KERN_WARNING "AEC67162 CRC ERROR !\n" ); workreq->result =0x02 ; } }else workreq->result =0x02 ; -if (dev->dev_id ==ATP885_DEVID ) { +if (is885 (dev)) { j =atp_readb_base (dev,0x29 ) |0x01 ;atp_writeb_base (dev,0x29 , j); }
@@ -516,7 +526,7 @@ static irqreturn_t atp870u_intr_handle(int irq, void *dev_id)atp_writeb_pci (dev, c,2 ,0x06 );atp_writeb_pci (dev, c,2 ,0x00 );atp_writeb_io (dev, c,0x10 ,0x41 ); -if (dev->dev_id ==ATP885_DEVID ) { +if (is885 (dev)) { k = dev->id[c][target_id].last_len;atp_writeb_io (dev, c,0x12 , ((unsigned char *) (&k))[2 ]);atp_writeb_io (dev, c,0x13 , ((unsigned char *) (&k))[1 ]);
@@ -535,7 +545,7 @@ static irqreturn_t atp870u_intr_handle(int irq, void *dev_id)atp_writeb_pci (dev, c,2 ,0x06 );atp_writeb_pci (dev, c,2 ,0x00 );atp_writeb_io (dev, c,0x10 ,0x41 ); -if (dev->dev_id ==ATP885_DEVID ) { +if (is885 (dev)) { k = dev->id[c][target_id].last_len;atp_writeb_io (dev, c,0x12 , ((unsigned char *) (&k))[2 ]);atp_writeb_io (dev, c,0x13 , ((unsigned char *) (&k))[1 ]);
@@ -737,7 +747,7 @@ static void send_s870(struct atp_unit *dev,unsigned char c)#endif l =scsi_bufflen (workreq); -if (dev->dev_id ==ATP885_DEVID ) { +if (is885 (dev)) { j =atp_readb_base (dev,0x29 ) &0xfe ;atp_writeb_base (dev,0x29 , j); dev->r1f[c][scmd_id (workreq)] =0 ;
@@ -775,7 +785,7 @@ static void send_s870(struct atp_unit *dev,unsigned char c)atp_writeb_io (dev, c,0x00 , workreq->cmd_len);atp_writeb_io (dev, c,0x01 ,0x2c ); -if (dev->dev_id ==ATP885_DEVID ) +if (is885 (dev))atp_writeb_io (dev, c,0x02 ,0x7f );else atp_writeb_io (dev, c,0x02 ,0xcf );
@@ -873,15 +883,14 @@ static void send_s870(struct atp_unit *dev,unsigned char c)atp_writel_pci (dev, c,4 , dev->id[c][target_id].prdaddr);atp_writeb_pci (dev, c,2 ,0x06 );atp_writeb_pci (dev, c,2 ,0x00 ); -if (dev->dev_id ==ATP885_DEVID ) { +if (is885 (dev)) { j =atp_readb_pci (dev, c,1 ) &0xf3 ;if ((workreq->cmnd[0 ] ==0x08 ) || (workreq->cmnd[0 ] ==0x28 ) || (workreq->cmnd[0 ] ==0x0a ) || (workreq->cmnd[0 ] ==0x2a )) { j |=0x0c ; }atp_writeb_pci (dev, c,1 , j); - }else if ((dev->dev_id ==ATP880_DEVID1 ) || - (dev->dev_id ==ATP880_DEVID2 )) { + }else if (is880 (dev)) {if ((workreq->cmnd[0 ] ==0x08 ) || (workreq->cmnd[0 ] ==0x28 ) || (workreq->cmnd[0 ] ==0x0a ) || (workreq->cmnd[0 ] ==0x2a ))atp_writeb_base (dev,0x3b , (atp_readb_base (dev,0x3b ) &0x3f ) |0xc0 );else
@@ -1285,7 +1294,7 @@ static int atp870u_probe(struct pci_dev *pdev, const struct pci_device_id *ent) shpnt->unique_id = shpnt->io_port; shpnt->irq = pdev->irq; -if ((ent->device ==ATP880_DEVID1 )||(ent->device ==ATP880_DEVID2 )) { +if (is880 (atpdev)) {pci_write_config_byte (pdev,PCI_LATENCY_TIMER ,0x80 );//JCC082803 atpdev->ioport[0 ] = shpnt->io_port +0x40 ;
@@ -1296,7 +1305,6 @@ static int atp870u_probe(struct pci_dev *pdev, const struct pci_device_id *ent)printk (KERN_INFO " ACARD AEC-67160 PCI Ultra3 LVD Host Adapter:" " IO:%lx, IRQ:%d.\n" , shpnt->io_port, shpnt->irq); - atpdev->dev_id = ent->device; atpdev->host_id[0 ] = host_id; atpdev->scam_on =atp_readb_base (atpdev,0x22 );
@@ -1384,12 +1392,11 @@ flash_ok_880:atp_writeb_base (atpdev,0x38 ,0xb0 ); shpnt->max_id =16 ; shpnt->this_id = host_id; - }else if (ent->device ==ATP885_DEVID ) { + }else if (is885 (atpdev)) {printk (KERN_INFO " ACARD AEC-67162 PCI Ultra3 LVD Host Adapter: IO:%lx, IRQ:%d.\n" , shpnt->io_port, shpnt->irq); atpdev->pdev = pdev; - atpdev->dev_id = ent->device; atpdev->ioport[0 ] = shpnt->io_port +0x80 ; atpdev->ioport[1 ] = shpnt->io_port +0xc0 ; atpdev->pciport[0 ] = shpnt->io_port +0x40 ;
@@ -1528,7 +1535,6 @@ flash_ok_885: atpdev->ioport[0 ] = shpnt->io_port; atpdev->pciport[0 ] = shpnt->io_port +0x20 ; - atpdev->dev_id = ent->device; host_id &=0x07 ; atpdev->host_id[0 ] = host_id; atpdev->scam_on =atp_readb_pci (atpdev,0 ,2 );
@@ -1797,7 +1803,7 @@ static void atp_is(struct atp_unit *dev, unsigned char c, bool wide_chip, unsign dev->active_id[c] |= m;atp_writeb_io (dev, c,0x10 ,0x30 ); -if (dev->dev_id ==ATP885_DEVID || dev->dev_id ==ATP880_DEVID1 || dev->dev_id ==ATP880_DEVID2 ) +if (is885 (dev) ||is880 (dev))atp_writeb_io (dev, c,0x14 ,0x00 );else /* result of is870() merge - is this a bug? */ atp_writeb_io (dev, c,0x04 ,0x00 );
@@ -1877,7 +1883,7 @@ inq_ok:if ((mbuf[7 ] &0x60 ) ==0 ) { goto not_wide; } -if (dev->dev_id ==ATP885_DEVID || dev->dev_id ==ATP880_DEVID1 || dev->dev_id ==ATP880_DEVID2 ) { +if (is885 (dev) ||is880 (dev)) {if ((i <8 ) && ((dev->global_map[c] &0x20 ) ==0 )) goto not_wide; }else {/* result of is870() merge - is this a bug? */
@@ -2146,7 +2152,7 @@ not_wide: }continue ; set_sync: -if ((dev->dev_id !=ATP885_DEVID && dev->dev_id !=ATP880_DEVID1 && dev->dev_id !=ATP880_DEVID2 ) || (dev->sp[c][i] ==0x02 )) { +if ((!is885 (dev) && !is880 (dev)) || (dev->sp[c][i] ==0x02 )) { synu[4 ] =0x0c ; synuw[4 ] =0x0c ; }else {
@@ -2190,7 +2196,7 @@ try_sync:while ((atp_readb_io (dev, c,0x1f ) &0x80 ) ==0 ) {if ((atp_readb_io (dev, c,0x1f ) &0x01 ) !=0 ) {if ((m & dev->wide_id[c]) !=0 ) { -if (dev->dev_id ==ATP885_DEVID || dev->dev_id ==ATP880_DEVID1 || dev->dev_id ==ATP880_DEVID2 ) { +if (is885 (dev) ||is880 (dev)) {if ((m & dev->ultra_map[c]) !=0 ) {atp_writeb_io (dev, c,0x19 , synuw[j++]); }else {
@@ -2245,7 +2251,7 @@ phase_outs: }continue ; phase_ins: -if (dev->dev_id ==ATP885_DEVID || dev->dev_id ==ATP880_DEVID1 || dev->dev_id ==ATP880_DEVID2 ) +if (is885 (dev) ||is880 (dev))atp_writeb_io (dev, c,0x14 ,0x06 );else atp_writeb_io (dev, c,0x14 ,0xff );
@@ -2303,7 +2309,7 @@ tar_dcons:if (mbuf[3 ] >0x64 ) {continue ; } -if (dev->dev_id ==ATP885_DEVID || dev->dev_id ==ATP880_DEVID1 || dev->dev_id ==ATP880_DEVID2 ) { +if (is885 (dev) ||is880 (dev)) {if (mbuf[4 ] >0x0e ) { mbuf[4 ] =0x0e ; }
@@ -2313,7 +2319,7 @@ tar_dcons: } } dev->id[c][i].devsp = mbuf[4 ]; -if (dev->dev_id ==ATP885_DEVID || dev->dev_id ==ATP880_DEVID1 || dev->dev_id ==ATP880_DEVID2 ) +if (is885 (dev) ||is880 (dev))if (mbuf[3 ] <0x0c ) { j =0xb0 ; goto set_syn_ok;
drivers/scsi/atp870u.h +0 -1
@@ -39,7 +39,6 @@ struct atp_unitunsigned short active_id[2 ];unsigned short ultra_map[2 ];unsigned short async[2 ]; -unsigned short dev_id;unsigned char sp[2 ][16 ];unsigned char r1f[2 ][16 ];struct scsi_cmnd *quereq[2 ][qcnt];
Signature · 1 line
Ondrej Zary
PATCH 46/52 atp870u: Use pci_request_regions
In reply to Ondrej ZaryUse pci_request_regions and do it before accessing the I/O ports. Also add missing pci_disable_device() call to atp870u_remove().
--- drivers/scsi/atp870u.c | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-)
drivers/scsi/atp870u.c +10 -11
@@ -1276,10 +1276,15 @@ static int atp870u_probe(struct pci_dev *pdev, const struct pci_device_id *ent) goto disable_device; } + err =pci_request_regions (pdev,"atp870u" ); +if (err) + goto disable_device; +pci_set_master (pdev); + err = -ENOMEM ; shpnt =scsi_host_alloc (&atp870u_template,sizeof (struct atp_unit ));if (!shpnt) - goto disable_device; + goto release_region; atpdev =shost_priv (shpnt);
@@ -1582,10 +1587,6 @@ flash_ok_885: }spin_unlock_irqrestore (shpnt->host_lock, flags); -if (!request_region (shpnt->io_port, shpnt->n_io_port,"atp870u" )) { - err = -EBUSY ; - goto request_io_fail; - } err =scsi_add_host (shpnt, &pdev->dev);if (err) goto scsi_add_fail;
@@ -1596,16 +1597,13 @@ flash_ok_885:return 0 ; scsi_add_fail: -printk ("atp870u_prob:scsi_add_fail\n" ); -release_region (shpnt->io_port, shpnt->n_io_port); -request_io_fail: -printk ("atp870u_prob:request_io_fail\n" );free_irq (shpnt->irq, shpnt); free_tables: -printk ("atp870u_prob:free_table\n" );atp870u_free_tables (shpnt); unregister:scsi_host_put (shpnt); +release_region: +pci_release_regions (pdev); disable_device:pci_disable_device (pdev); fail:
@@ -1696,7 +1694,8 @@ static void atp870u_remove (struct pci_dev *pdev)scsi_remove_host (pshost);free_irq (pshost->irq, pshost); -release_region (pshost->io_port, pshost->n_io_port); +pci_release_regions (pdev); +pci_disable_device (pdev);atp870u_free_tables (pshost);scsi_host_put (pshost); }
Signature · 1 line
Ondrej Zary
PATCH 47/52 atp870u: Request IRQ later, remove weird locking
In reply to Ondrej ZaryAllocate IRQ later during probe to avoid code duplication and also remove the need for weird locking in _probe.
(It was probably there to prevent race with the IRQ handler?)
--- drivers/scsi/atp870u.c | 47 ++++++++++++----------------------------------- 1 file changed, 12 insertions(+), 35 deletions(-)
drivers/scsi/atp870u.c +12 -35
@@ -1253,7 +1253,6 @@ static void atp_set_host_id(struct atp_unit *atp, u8 c, u8 host_id)static int atp870u_probe (struct pci_dev *pdev,const struct pci_device_id *ent) {unsigned char k, m, c; -unsigned long flags;unsigned int error,n;unsigned char host_id;struct Scsi_Host *shpnt =NULL ;
@@ -1374,13 +1373,6 @@ flash_ok_880: goto unregister; } - err =request_irq (shpnt->irq, atp870u_intr_handle,IRQF_SHARED ,"atp880i" , shpnt); -if (err) { -printk (KERN_ERR "Unable to allocate IRQ%d for Acard controller.\n" , shpnt->irq); - goto free_tables; - } - -spin_lock_irqsave (shpnt->host_lock, flags); k =atp_readb_base (atpdev,0x38 ) &0x80 ;atp_writeb_base (atpdev,0x38 , k);atp_writeb_base (atpdev,0x3b ,0x20 );
@@ -1412,17 +1404,6 @@ flash_ok_880: goto unregister; } -#ifdef ED_DBGP -printk ("request_irq() shpnt %p hostdata %p\n" , shpnt, atpdev); -#endif - err =request_irq (shpnt->irq, atp870u_intr_handle,IRQF_SHARED ,"atp870u" , shpnt); -if (err) { -printk (KERN_ERR "Unable to allocate IRQ for Acard controller.\n" ); - goto free_tables; - } - -spin_lock_irqsave (shpnt->host_lock, flags); - c =atp_readb_base (atpdev,0x29 );atp_writeb_base (atpdev,0x29 , c |0x04 );
@@ -1558,13 +1539,6 @@ flash_ok_885: goto unregister; } - err =request_irq (shpnt->irq, atp870u_intr_handle,IRQF_SHARED ,"atp870i" , shpnt); -if (err) { -printk (KERN_ERR "Unable to allocate IRQ%d for Acard controller.\n" , shpnt->irq); - goto free_tables; - } - -spin_lock_irqsave (shpnt->host_lock, flags);if (pdev->revision >0x07 )/* check if atp876 chip then enable terminator */ atp_writeb_base (atpdev,0x3e ,0x00 );
@@ -1586,15 +1560,18 @@ flash_ok_885: shpnt->this_id = host_id; } -spin_unlock_irqrestore (shpnt->host_lock, flags); - err =scsi_add_host (shpnt, &pdev->dev); -if (err) - goto scsi_add_fail; -scsi_scan_host (shpnt); -#ifdef ED_DBGP -printk ("atp870u_prob : exit\n" ); -#endif -return 0 ; + err =request_irq (shpnt->irq, atp870u_intr_handle,IRQF_SHARED ,"atp870u" , shpnt); +if (err) { +dev_err (&pdev->dev,"Unable to allocate IRQ %d.\n" , shpnt->irq); + goto free_tables; + } + + err =scsi_add_host (shpnt, &pdev->dev); +if (err) + goto scsi_add_fail; +scsi_scan_host (shpnt); + +return 0 ; scsi_add_fail:free_irq (shpnt->irq, shpnt);
Signature · 1 line
Ondrej Zary
PATCH 48/52 atp870u: Remove scam_on from struct atp_unit
In reply to Ondrej Zaryscam_on is used only during probe, no need to keep it later.
--- drivers/scsi/atp870u.c | 14 +++++++------- drivers/scsi/atp870u.h | 1 - 2 files changed, 7 insertions(+), 8 deletions(-)
drivers/scsi/atp870u.c +7 -7
@@ -963,7 +963,7 @@ static unsigned char fun_scam(struct atp_unit *dev, unsigned short int *val)return j; } -static void tscam (struct Scsi_Host *host,bool wide_chip) +static void tscam (struct Scsi_Host *host,bool wide_chip,u8 scam_on) {unsigned char i, j, k;
@@ -986,7 +986,7 @@ static void tscam(struct Scsi_Host *host, bool wide_chip)atp_writeb_io (dev,0 ,2 ,0x7f );atp_writeb_io (dev,0 ,0x11 ,0x20 ); -if ((dev->scam_on &0x40 ) ==0 ) { +if ((scam_on &0x40 ) ==0 ) {return ; } m =1 ;
@@ -1311,7 +1311,6 @@ static int atp870u_probe(struct pci_dev *pdev, const struct pci_device_id *ent) " IO:%lx, IRQ:%d.\n", shpnt->io_port, shpnt->irq); atpdev->host_id[0 ] = host_id; - atpdev->scam_on =atp_readb_base (atpdev,0x22 ); atpdev->global_map[0 ] =atp_readb_base (atpdev,0x35 ); atpdev->ultra_map[0 ] =atp_readw_base (atpdev,0x3c );
@@ -1384,7 +1383,7 @@ flash_ok_880:atp_set_host_id (atpdev,0 , host_id); -tscam (shpnt, true); +tscam (shpnt, true,atp_readb_base (atpdev,0x22 ));atp_is (atpdev,0 , true,atp_readb_base (atpdev,0x3f ) &0x40 );atp_writeb_base (atpdev,0x38 ,0xb0 ); shpnt->max_id =16 ;
@@ -1509,6 +1508,7 @@ flash_ok_885: shpnt->max_channel =1 ; shpnt->this_id = atpdev->host_id[0 ]; }else { +u8 scam_on;bool wide_chip = (ent->device ==PCI_DEVICE_ID_ARTOP_AEC7610 && pdev->revision == 4) ||
@@ -1523,12 +1523,12 @@ flash_ok_885: atpdev->pciport[0 ] = shpnt->io_port +0x20 ; host_id &=0x07 ; atpdev->host_id[0 ] = host_id; - atpdev->scam_on =atp_readb_pci (atpdev,0 ,2 ); + scam_on =atp_readb_pci (atpdev,0 ,2 ); atpdev->global_map[0 ] =atp_readb_base (atpdev,0x2d ); atpdev->ultra_map[0 ] =atp_readw_base (atpdev,0x2e );if (atpdev->ultra_map[0 ] ==0 ) { - atpdev->scam_on =0x00 ; + scam_on =0x00 ; atpdev->global_map[0 ] =0x20 ; atpdev->ultra_map[0 ] =0xffff ; }
@@ -1551,7 +1551,7 @@ flash_ok_885:atp_set_host_id (atpdev,0 , host_id); -tscam (shpnt, wide_chip); +tscam (shpnt, wide_chip, scam_on);atp_writeb_base (atpdev,0x3a ,atp_readb_base (atpdev,0x3a ) |0x10 );atp_is (atpdev,0 , wide_chip,0 );atp_writeb_base (atpdev,0x3a ,atp_readb_base (atpdev,0x3a ) &0xef );
drivers/scsi/atp870u.h +0 -1
@@ -32,7 +32,6 @@ struct atp_unitunsigned char quhd[2 ];unsigned char quend[2 ];unsigned char global_map[2 ]; -unsigned char scam_on;unsigned char host_id[2 ];unsigned int working[2 ];unsigned short wide_id[2 ];
Signature · 1 line
Ondrej Zary
PATCH 49/52 atp870u: Initialize tables earlier
In reply to Ondrej ZaryCall _init_tables before chip-specific initialization. This avoids code duplication and fixes a bug(?) in 880 init where the values read from flash into atpdev->sp are then overwritten by calling init_tables.
--- drivers/scsi/atp870u.c | 22 ++++++---------------- 1 file changed, 6 insertions(+), 16 deletions(-)
drivers/scsi/atp870u.c +6 -16
@@ -1298,6 +1298,12 @@ static int atp870u_probe(struct pci_dev *pdev, const struct pci_device_id *ent) shpnt->unique_id = shpnt->io_port; shpnt->irq = pdev->irq; + err =atp870u_init_tables (shpnt); +if (err) { +dev_err (&pdev->dev,"Unable to allocate tables for Acard controller\n" ); + goto unregister; + } +if (is880 (atpdev)) {pci_write_config_byte (pdev,PCI_LATENCY_TIMER ,0x80 );//JCC082803
@@ -1366,11 +1372,6 @@ flash_ok_880: atpdev->async[0 ] = ~(atpdev->async[0 ]);atp_writeb_base (atpdev,0x35 , atpdev->global_map[0 ]); -if (atp870u_init_tables (shpnt) <0 ) { -printk (KERN_ERR "Unable to allocate tables for Acard controller\n" ); - err = -ENOMEM ; - goto unregister; - } k =atp_readb_base (atpdev,0x38 ) &0x80 ;atp_writeb_base (atpdev,0x38 , k);
@@ -1398,11 +1399,6 @@ flash_ok_880: atpdev->pciport[0 ] = shpnt->io_port +0x40 ; atpdev->pciport[1 ] = shpnt->io_port +0x50 ; -if (atp870u_init_tables (shpnt) <0 ) { - err = -ENOMEM ; - goto unregister; - } - c =atp_readb_base (atpdev,0x29 );atp_writeb_base (atpdev,0x29 , c |0x04 );
@@ -1533,12 +1529,6 @@ flash_ok_885: atpdev->ultra_map[0 ] =0xffff ; } - -if (atp870u_init_tables (shpnt) <0 ) { - err = -ENOMEM ; - goto unregister; - } -if (pdev->revision >0x07 )/* check if atp876 chip then enable terminator */ atp_writeb_base (atpdev,0x3e ,0x00 );
Signature · 1 line
Ondrej Zary
PATCH 50/52 atp870u: Introduce atp880_init()
In reply to Ondrej ZaryMove 880-specific init code to a separate function atp880_init()
--- drivers/scsi/atp870u.c | 174 ++++++++++++++++++++++++------------------------ 1 file changed, 88 insertions(+), 86 deletions(-)
drivers/scsi/atp870u.c +88 -86
@@ -1249,6 +1249,91 @@ static void atp_set_host_id(struct atp_unit *atp, u8 c, u8 host_id)atp_writeb_io (atp, c,0x11 ,0x20 ); } +static void atp880_init (struct Scsi_Host *shpnt) +{ +struct atp_unit *atpdev =shost_priv (shpnt); +struct pci_dev *pdev = atpdev->pdev; +unsigned char k, m, host_id; +unsigned int n; + +pci_write_config_byte (pdev,PCI_LATENCY_TIMER ,0x80 ); + + atpdev->ioport[0 ] = shpnt->io_port +0x40 ; + atpdev->pciport[0 ] = shpnt->io_port +0x28 ; + + host_id =atp_readb_base (atpdev,0x39 ) >>4 ; + +dev_info (&pdev->dev,"ACARD AEC-67160 PCI Ultra3 LVD Host Adapter: IO:%lx, IRQ:%d.\n" , + shpnt->io_port, shpnt->irq); + atpdev->host_id[0 ] = host_id; + + atpdev->global_map[0 ] =atp_readb_base (atpdev,0x35 ); + atpdev->ultra_map[0 ] =atp_readw_base (atpdev,0x3c ); + + n =0x3f09 ; +while (n <0x4000 ) { + m =0 ; +atp_writew_base (atpdev,0x34 , n); + n +=0x0002 ; +if (atp_readb_base (atpdev,0x30 ) ==0xff ) +break ; + + atpdev->sp[0 ][m++] =atp_readb_base (atpdev,0x30 ); + atpdev->sp[0 ][m++] =atp_readb_base (atpdev,0x31 ); + atpdev->sp[0 ][m++] =atp_readb_base (atpdev,0x32 ); + atpdev->sp[0 ][m++] =atp_readb_base (atpdev,0x33 ); +atp_writew_base (atpdev,0x34 , n); + n +=0x0002 ; + atpdev->sp[0 ][m++] =atp_readb_base (atpdev,0x30 ); + atpdev->sp[0 ][m++] =atp_readb_base (atpdev,0x31 ); + atpdev->sp[0 ][m++] =atp_readb_base (atpdev,0x32 ); + atpdev->sp[0 ][m++] =atp_readb_base (atpdev,0x33 ); +atp_writew_base (atpdev,0x34 , n); + n +=0x0002 ; + atpdev->sp[0 ][m++] =atp_readb_base (atpdev,0x30 ); + atpdev->sp[0 ][m++] =atp_readb_base (atpdev,0x31 ); + atpdev->sp[0 ][m++] =atp_readb_base (atpdev,0x32 ); + atpdev->sp[0 ][m++] =atp_readb_base (atpdev,0x33 ); +atp_writew_base (atpdev,0x34 , n); + n +=0x0002 ; + atpdev->sp[0 ][m++] =atp_readb_base (atpdev,0x30 ); + atpdev->sp[0 ][m++] =atp_readb_base (atpdev,0x31 ); + atpdev->sp[0 ][m++] =atp_readb_base (atpdev,0x32 ); + atpdev->sp[0 ][m++] =atp_readb_base (atpdev,0x33 ); + n +=0x0018 ; + } +atp_writew_base (atpdev,0x34 ,0 ); + atpdev->ultra_map[0 ] =0 ; + atpdev->async[0 ] =0 ; +for (k =0 ; k <16 ; k++) { + n =1 << k; +if (atpdev->sp[0 ][k] >1 ) + atpdev->ultra_map[0 ] |= n; +else +if (atpdev->sp[0 ][k] ==0 ) + atpdev->async[0 ] |= n; + } + atpdev->async[0 ] = ~(atpdev->async[0 ]); +atp_writeb_base (atpdev,0x35 , atpdev->global_map[0 ]); + + k =atp_readb_base (atpdev,0x38 ) &0x80 ; +atp_writeb_base (atpdev,0x38 , k); +atp_writeb_base (atpdev,0x3b ,0x20 ); +mdelay (32 ); +atp_writeb_base (atpdev,0x3b ,0 ); +mdelay (32 ); +atp_readb_io (atpdev,0 ,0x1b ); +atp_readb_io (atpdev,0 ,0x17 ); + +atp_set_host_id (atpdev,0 , host_id); + +tscam (shpnt, true,atp_readb_base (atpdev,0x22 )); +atp_is (atpdev,0 , true,atp_readb_base (atpdev,0x3f ) &0x40 ); +atp_writeb_base (atpdev,0x38 ,0xb0 ); + shpnt->max_id =16 ; + shpnt->this_id = host_id; +} +/* return non-zero on detection */ static int atp870u_probe (struct pci_dev *pdev,const struct pci_device_id *ent) {
@@ -1304,92 +1389,9 @@ static int atp870u_probe(struct pci_dev *pdev, const struct pci_device_id *ent) goto unregister; } -if (is880 (atpdev)) { -pci_write_config_byte (pdev,PCI_LATENCY_TIMER ,0x80 );//JCC082803 - - atpdev->ioport[0 ] = shpnt->io_port +0x40 ; - atpdev->pciport[0 ] = shpnt->io_port +0x28 ; - - host_id =atp_readb_base (atpdev,0x39 ); - host_id >>=0x04 ; - -printk (KERN_INFO " ACARD AEC-67160 PCI Ultra3 LVD Host Adapter:" -" IO:%lx, IRQ:%d.\n" , shpnt->io_port, shpnt->irq); - atpdev->host_id[0 ] = host_id; - - atpdev->global_map[0 ] =atp_readb_base (atpdev,0x35 ); - atpdev->ultra_map[0 ] =atp_readw_base (atpdev,0x3c ); - - n =0x3f09 ; -next_fblk_880: -if (n >=0x4000 ) - goto flash_ok_880; - - m =0 ; -atp_writew_base (atpdev,0x34 , n); - n +=0x0002 ; -if (atp_readb_base (atpdev,0x30 ) ==0xff ) - goto flash_ok_880; - - atpdev->sp[0 ][m++] =atp_readb_base (atpdev,0x30 ); - atpdev->sp[0 ][m++] =atp_readb_base (atpdev,0x31 ); - atpdev->sp[0 ][m++] =atp_readb_base (atpdev,0x32 ); - atpdev->sp[0 ][m++] =atp_readb_base (atpdev,0x33 ); -atp_writew_base (atpdev,0x34 , n); - n +=0x0002 ; - atpdev->sp[0 ][m++] =atp_readb_base (atpdev,0x30 ); - atpdev->sp[0 ][m++] =atp_readb_base (atpdev,0x31 ); - atpdev->sp[0 ][m++] =atp_readb_base (atpdev,0x32 ); - atpdev->sp[0 ][m++] =atp_readb_base (atpdev,0x33 ); -atp_writew_base (atpdev,0x34 , n); - n +=0x0002 ; - atpdev->sp[0 ][m++] =atp_readb_base (atpdev,0x30 ); - atpdev->sp[0 ][m++] =atp_readb_base (atpdev,0x31 ); - atpdev->sp[0 ][m++] =atp_readb_base (atpdev,0x32 ); - atpdev->sp[0 ][m++] =atp_readb_base (atpdev,0x33 ); -atp_writew_base (atpdev,0x34 , n); - n +=0x0002 ; - atpdev->sp[0 ][m++] =atp_readb_base (atpdev,0x30 ); - atpdev->sp[0 ][m++] =atp_readb_base (atpdev,0x31 ); - atpdev->sp[0 ][m++] =atp_readb_base (atpdev,0x32 ); - atpdev->sp[0 ][m++] =atp_readb_base (atpdev,0x33 ); - n +=0x0018 ; - goto next_fblk_880; -flash_ok_880: -atp_writew_base (atpdev,0x34 ,0 ); - atpdev->ultra_map[0 ] =0 ; - atpdev->async[0 ] =0 ; -for (k =0 ; k <16 ; k++) { - n =1 ; - n = n << k; -if (atpdev->sp[0 ][k] >1 ) { - atpdev->ultra_map[0 ] |= n; - }else { -if (atpdev->sp[0 ][k] ==0 ) - atpdev->async[0 ] |= n; - } - } - atpdev->async[0 ] = ~(atpdev->async[0 ]); -atp_writeb_base (atpdev,0x35 , atpdev->global_map[0 ]); - - - k =atp_readb_base (atpdev,0x38 ) &0x80 ; -atp_writeb_base (atpdev,0x38 , k); -atp_writeb_base (atpdev,0x3b ,0x20 ); -mdelay (32 ); -atp_writeb_base (atpdev,0x3b ,0 ); -mdelay (32 ); -atp_readb_io (atpdev,0 ,0x1b ); -atp_readb_io (atpdev,0 ,0x17 ); - -atp_set_host_id (atpdev,0 , host_id); - -tscam (shpnt, true,atp_readb_base (atpdev,0x22 )); -atp_is (atpdev,0 , true,atp_readb_base (atpdev,0x3f ) &0x40 ); -atp_writeb_base (atpdev,0x38 ,0xb0 ); - shpnt->max_id =16 ; - shpnt->this_id = host_id; - }else if (is885 (atpdev)) { +if (is880 (atpdev)) +atp880_init (shpnt); +else if (is885 (atpdev)) {printk (KERN_INFO " ACARD AEC-67162 PCI Ultra3 LVD Host Adapter: IO:%lx, IRQ:%d.\n" , shpnt->io_port, shpnt->irq);
Signature · 1 line
Ondrej Zary
PATCH 51/52 atp870u: Introduce atp885_init()
In reply to Ondrej ZaryMove 885-specific init code to a separate function atp885_init()
--- drivers/scsi/atp870u.c | 231 +++++++++++++++++++++++------------------------- 1 file changed, 113 insertions(+), 118 deletions(-)
drivers/scsi/atp870u.c +113 -118
@@ -1334,15 +1334,122 @@ static void atp880_init(struct Scsi_Host *shpnt) shpnt->this_id = host_id; } +static void atp885_init (struct Scsi_Host *shpnt) +{ +struct atp_unit *atpdev =shost_priv (shpnt); +struct pci_dev *pdev = atpdev->pdev; +unsigned char k, m, c; +unsigned int n; +unsigned char setupdata[2 ][16 ]; + +dev_info (&pdev->dev,"ACARD AEC-67162 PCI Ultra3 LVD Host Adapter: IO:%lx, IRQ:%d.\n" , + shpnt->io_port, shpnt->irq); + + atpdev->ioport[0 ] = shpnt->io_port +0x80 ; + atpdev->ioport[1 ] = shpnt->io_port +0xc0 ; + atpdev->pciport[0 ] = shpnt->io_port +0x40 ; + atpdev->pciport[1 ] = shpnt->io_port +0x50 ; + + c =atp_readb_base (atpdev,0x29 ); +atp_writeb_base (atpdev,0x29 , c |0x04 ); + + n =0x1f80 ; +while (n <0x2000 ) { +atp_writew_base (atpdev,0x3c , n); +if (atp_readl_base (atpdev,0x38 ) ==0xffffffff ) +break ; +for (m =0 ; m <2 ; m++) { + atpdev->global_map[m] =0 ; +for (k =0 ; k <4 ; k++) { +atp_writew_base (atpdev,0x3c , n++); + ((unsigned long *)&setupdata[m][0 ])[k] =atp_readl_base (atpdev,0x38 ); + } +for (k =0 ; k <4 ; k++) { +atp_writew_base (atpdev,0x3c , n++); + ((unsigned long *)&atpdev->sp[m][0 ])[k] =atp_readl_base (atpdev,0x38 ); + } + n +=8 ; + } + } + c =atp_readb_base (atpdev,0x29 ); +atp_writeb_base (atpdev,0x29 , c &0xfb ); +for (c =0 ; c <2 ; c++) { + atpdev->ultra_map[c] =0 ; + atpdev->async[c] =0 ; +for (k =0 ; k <16 ; k++) { + n =1 << k; +if (atpdev->sp[c][k] >1 ) + atpdev->ultra_map[c] |= n; +else +if (atpdev->sp[c][k] ==0 ) + atpdev->async[c] |= n; + } + atpdev->async[c] = ~(atpdev->async[c]); + +if (atpdev->global_map[c] ==0 ) { + k = setupdata[c][1 ]; +if ((k &0x40 ) !=0 ) + atpdev->global_map[c] |=0x20 ; + k &=0x07 ; + atpdev->global_map[c] |= k; +if ((setupdata[c][2 ] &0x04 ) !=0 ) + atpdev->global_map[c] |=0x08 ; + atpdev->host_id[c] = setupdata[c][0 ] &0x07 ; + } + } + + k =atp_readb_base (atpdev,0x28 ) &0x8f ; + k |=0x10 ; +atp_writeb_base (atpdev,0x28 , k); +atp_writeb_pci (atpdev,0 ,1 ,0x80 ); +atp_writeb_pci (atpdev,1 ,1 ,0x80 ); +mdelay (100 ); +atp_writeb_pci (atpdev,0 ,1 ,0 ); +atp_writeb_pci (atpdev,1 ,1 ,0 ); +mdelay (1000 ); +atp_readb_io (atpdev,0 ,0x1b ); +atp_readb_io (atpdev,0 ,0x17 ); +atp_readb_io (atpdev,1 ,0x1b ); +atp_readb_io (atpdev,1 ,0x17 ); + + k = atpdev->host_id[0 ]; +if (k >7 ) + k = (k &0x07 ) |0x40 ; +atp_set_host_id (atpdev,0 , k); + + k = atpdev->host_id[1 ]; +if (k >7 ) + k = (k &0x07 ) |0x40 ; +atp_set_host_id (atpdev,1 , k); + +mdelay (600 );/* this delay used to be called tscam_885() */ +dev_info (&pdev->dev,"Scanning Channel A SCSI Device ...\n" ); +atp_is (atpdev,0 , true,atp_readb_io (atpdev,0 ,0x1b ) >>7 ); +atp_writeb_io (atpdev,0 ,0x16 ,0x80 ); +dev_info (&pdev->dev,"Scanning Channel B SCSI Device ...\n" ); +atp_is (atpdev,1 , true,atp_readb_io (atpdev,1 ,0x1b ) >>7 ); +atp_writeb_io (atpdev,1 ,0x16 ,0x80 ); + k =atp_readb_base (atpdev,0x28 ) &0xcf ; + k |=0xc0 ; +atp_writeb_base (atpdev,0x28 , k); + k =atp_readb_base (atpdev,0x1f ) |0x80 ; +atp_writeb_base (atpdev,0x1f , k); + k =atp_readb_base (atpdev,0x29 ) |0x01 ; +atp_writeb_base (atpdev,0x29 , k); + shpnt->max_id =16 ; + shpnt->max_lun = (atpdev->global_map[0 ] &0x07 ) +1 ; + shpnt->max_channel =1 ; + shpnt->this_id = atpdev->host_id[0 ]; +} +/* return non-zero on detection */ static int atp870u_probe (struct pci_dev *pdev,const struct pci_device_id *ent) { -unsigned char k, m, c; -unsigned int error,n; +unsigned char k; +unsigned int error;unsigned char host_id;struct Scsi_Host *shpnt =NULL ;struct atp_unit *atpdev; -unsigned char setupdata[2 ][16 ];int err;if (ent->device ==PCI_DEVICE_ID_ARTOP_AEC7610 && pdev->revision <2 ) {
@@ -1391,121 +1498,9 @@ static int atp870u_probe(struct pci_dev *pdev, const struct pci_device_id *ent)if (is880 (atpdev))atp880_init (shpnt); -else if (is885 (atpdev)) { -printk (KERN_INFO " ACARD AEC-67162 PCI Ultra3 LVD Host Adapter: IO:%lx, IRQ:%d.\n" - , shpnt->io_port, shpnt->irq); - - atpdev->pdev = pdev; - atpdev->ioport[0 ] = shpnt->io_port +0x80 ; - atpdev->ioport[1 ] = shpnt->io_port +0xc0 ; - atpdev->pciport[0 ] = shpnt->io_port +0x40 ; - atpdev->pciport[1 ] = shpnt->io_port +0x50 ; - - c =atp_readb_base (atpdev,0x29 ); -atp_writeb_base (atpdev,0x29 , c |0x04 ); - - n=0x1f80 ; -next_fblk_885: -if (n >=0x2000 ) { - goto flash_ok_885; - } -atp_writew_base (atpdev,0x3c , n); -if (atp_readl_base (atpdev,0x38 ) ==0xffffffff ) { - goto flash_ok_885; - } -for (m=0 ; m <2 ; m++) { - atpdev->global_map[m]=0 ; -for (k=0 ; k <4 ; k++) { -atp_writew_base (atpdev,0x3c , n++); - ((unsigned long *)&setupdata[m][0 ])[k] =atp_readl_base (atpdev,0x38 ); - } -for (k=0 ; k <4 ; k++) { -atp_writew_base (atpdev,0x3c , n++); - ((unsigned long *)&atpdev->sp[m][0 ])[k] =atp_readl_base (atpdev,0x38 ); - } - n +=8 ; - } - goto next_fblk_885; -flash_ok_885: -#ifdef ED_DBGP -printk ("Flash Read OK\n" ); -#endif - c =atp_readb_base (atpdev,0x29 ); -atp_writeb_base (atpdev,0x29 , c &0xfb ); -for (c=0 ;c <2 ;c++) { - atpdev->ultra_map[c]=0 ; - atpdev->async[c] =0 ; -for (k=0 ; k <16 ; k++) { - n=1 ; - n = n << k; -if (atpdev->sp[c][k] >1 ) { - atpdev->ultra_map[c] |= n; - }else { -if (atpdev->sp[c][k] ==0 ) { - atpdev->async[c] |= n; - } - } - } - atpdev->async[c] = ~(atpdev->async[c]); - -if (atpdev->global_map[c] ==0 ) { - k=setupdata[c][1 ]; -if ((k &0x40 ) !=0 ) - atpdev->global_map[c] |=0x20 ; - k &=0x07 ; - atpdev->global_map[c] |= k; -if ((setupdata[c][2 ] &0x04 ) !=0 ) - atpdev->global_map[c] |=0x08 ; - atpdev->host_id[c] = setupdata[c][0 ] &0x07 ; - } - } - - k =atp_readb_base (atpdev,0x28 ) &0x8f ; - k |=0x10 ; -atp_writeb_base (atpdev,0x28 , k); -atp_writeb_pci (atpdev,0 ,1 ,0x80 ); -atp_writeb_pci (atpdev,1 ,1 ,0x80 ); -mdelay (100 ); -atp_writeb_pci (atpdev,0 ,1 ,0 ); -atp_writeb_pci (atpdev,1 ,1 ,0 ); -mdelay (1000 ); -atp_readb_io (atpdev,0 ,0x1b ); -atp_readb_io (atpdev,0 ,0x17 ); -atp_readb_io (atpdev,1 ,0x1b ); -atp_readb_io (atpdev,1 ,0x17 ); - - k=atpdev->host_id[0 ]; -if (k >7 ) - k = (k &0x07 ) |0x40 ; -atp_set_host_id (atpdev,0 , k); - - k=atpdev->host_id[1 ]; -if (k >7 ) - k = (k &0x07 ) |0x40 ; -atp_set_host_id (atpdev,1 , k); - -mdelay (600 );/* this delay used to be called tscam_885() */ -printk (KERN_INFO " Scanning Channel A SCSI Device ...\n" ); -atp_is (atpdev,0 , true,atp_readb_io (atpdev,0 ,0x1b ) >>7 ); -atp_writeb_io (atpdev,0 ,0x16 ,0x80 ); -printk (KERN_INFO " Scanning Channel B SCSI Device ...\n" ); -atp_is (atpdev,1 , true,atp_readb_io (atpdev,1 ,0x1b ) >>7 ); -atp_writeb_io (atpdev,1 ,0x16 ,0x80 ); - k =atp_readb_base (atpdev,0x28 ) &0xcf ; - k |=0xc0 ; -atp_writeb_base (atpdev,0x28 , k); - k =atp_readb_base (atpdev,0x1f ) |0x80 ; -atp_writeb_base (atpdev,0x1f , k); - k =atp_readb_base (atpdev,0x29 ) |0x01 ; -atp_writeb_base (atpdev,0x29 , k); -#ifdef ED_DBGP -//printk("atp885: atp_host[0] 0x%p\n", atp_host[0]); -#endif - shpnt->max_id =16 ; - shpnt->max_lun = (atpdev->global_map[0 ] &0x07 ) +1 ; - shpnt->max_channel =1 ; - shpnt->this_id = atpdev->host_id[0 ]; - }else { +else if (is885 (atpdev)) +atp885_init (shpnt); +else {u8 scam_on; bool wide_chip = (ent->device == PCI_DEVICE_ID_ARTOP_AEC7610 &&
Signature · 1 line
Ondrej Zary
PATCH 52/52 atp870u: Introduce atp870_init()
In reply to Ondrej ZaryMove 870-specific init code to a separate function atp870_init()
--- drivers/scsi/atp870u.c | 104 +++++++++++++++++++++++++----------------------- 1 file changed, 54 insertions(+), 50 deletions(-)
drivers/scsi/atp870u.c +54 -50
@@ -1249,6 +1249,57 @@ static void atp_set_host_id(struct atp_unit *atp, u8 c, u8 host_id)atp_writeb_io (atp, c,0x11 ,0x20 ); } +static void atp870_init (struct Scsi_Host *shpnt) +{ +struct atp_unit *atpdev =shost_priv (shpnt); +struct pci_dev *pdev = atpdev->pdev; +unsigned char k, host_id; +u8 scam_on; +bool wide_chip = + (pdev->device ==PCI_DEVICE_ID_ARTOP_AEC7610 && + pdev->revision ==4 ) || + (pdev->device ==PCI_DEVICE_ID_ARTOP_AEC7612UW ) || + (pdev->device ==PCI_DEVICE_ID_ARTOP_AEC7612SUW ); + +pci_read_config_byte (pdev,0x49 , &host_id); + +dev_info (&pdev->dev,"ACARD AEC-671X PCI Ultra/W SCSI-2/3 Host Adapter: IO:%lx, IRQ:%d.\n" , + shpnt->io_port, shpnt->irq); + + atpdev->ioport[0 ] = shpnt->io_port; + atpdev->pciport[0 ] = shpnt->io_port +0x20 ; + host_id &=0x07 ; + atpdev->host_id[0 ] = host_id; + scam_on =atp_readb_pci (atpdev,0 ,2 ); + atpdev->global_map[0 ] =atp_readb_base (atpdev,0x2d ); + atpdev->ultra_map[0 ] =atp_readw_base (atpdev,0x2e ); + +if (atpdev->ultra_map[0 ] ==0 ) { + scam_on =0x00 ; + atpdev->global_map[0 ] =0x20 ; + atpdev->ultra_map[0 ] =0xffff ; + } + +if (pdev->revision >0x07 )/* check if atp876 chip */ +atp_writeb_base (atpdev,0x3e ,0x00 );/* enable terminator */ + + k = (atp_readb_base (atpdev,0x3a ) &0xf3 ) |0x10 ; +atp_writeb_base (atpdev,0x3a , k); +atp_writeb_base (atpdev,0x3a , k &0xdf ); +mdelay (32 ); +atp_writeb_base (atpdev,0x3a , k); +mdelay (32 ); +atp_set_host_id (atpdev,0 , host_id); + +tscam (shpnt, wide_chip, scam_on); +atp_writeb_base (atpdev,0x3a ,atp_readb_base (atpdev,0x3a ) |0x10 ); +atp_is (atpdev,0 , wide_chip,0 ); +atp_writeb_base (atpdev,0x3a ,atp_readb_base (atpdev,0x3a ) &0xef ); +atp_writeb_base (atpdev,0x3b ,atp_readb_base (atpdev,0x3b ) |0x20 ); + shpnt->max_id = wide_chip ?16 :8 ; + shpnt->this_id = host_id; +} +static void atp880_init (struct Scsi_Host *shpnt) {struct atp_unit *atpdev =shost_priv (shpnt);
@@ -1445,9 +1496,6 @@ static void atp885_init(struct Scsi_Host *shpnt)/* return non-zero on detection */ static int atp870u_probe (struct pci_dev *pdev,const struct pci_device_id *ent) { -unsigned char k; -unsigned int error; -unsigned char host_id;struct Scsi_Host *shpnt =NULL ;struct atp_unit *atpdev;int err;
@@ -1500,53 +1548,9 @@ static int atp870u_probe(struct pci_dev *pdev, const struct pci_device_id *ent)atp880_init (shpnt); else if (is885(atpdev)) atp885_init(shpnt); - else { -u8 scam_on; -bool wide_chip = - (ent->device ==PCI_DEVICE_ID_ARTOP_AEC7610 && - pdev->revision ==4 ) || - (ent->device ==PCI_DEVICE_ID_ARTOP_AEC7612UW ) || - (ent->device ==PCI_DEVICE_ID_ARTOP_AEC7612SUW ); - error =pci_read_config_byte (pdev,0x49 , &host_id); - -printk (KERN_INFO " ACARD AEC-671X PCI Ultra/W SCSI-2/3 Host Adapter: " -"IO:%lx, IRQ:%d.\n" , shpnt->io_port, shpnt->irq); - - atpdev->ioport[0 ] = shpnt->io_port; - atpdev->pciport[0 ] = shpnt->io_port +0x20 ; - host_id &=0x07 ; - atpdev->host_id[0 ] = host_id; - scam_on =atp_readb_pci (atpdev,0 ,2 ); - atpdev->global_map[0 ] =atp_readb_base (atpdev,0x2d ); - atpdev->ultra_map[0 ] =atp_readw_base (atpdev,0x2e ); - -if (atpdev->ultra_map[0 ] ==0 ) { - scam_on =0x00 ; - atpdev->global_map[0 ] =0x20 ; - atpdev->ultra_map[0 ] =0xffff ; - } - -if (pdev->revision >0x07 )/* check if atp876 chip then enable terminator */ -atp_writeb_base (atpdev,0x3e ,0x00 ); - - k = (atp_readb_base (atpdev,0x3a ) &0xf3 ) |0x10 ; -atp_writeb_base (atpdev,0x3a , k); -atp_writeb_base (atpdev,0x3a , k &0xdf ); -mdelay (32 ); -atp_writeb_base (atpdev,0x3a , k); -mdelay (32 ); -atp_set_host_id (atpdev,0 , host_id); - - -tscam (shpnt, wide_chip, scam_on); -atp_writeb_base (atpdev,0x3a ,atp_readb_base (atpdev,0x3a ) |0x10 ); -atp_is (atpdev,0 , wide_chip,0 ); -atp_writeb_base (atpdev,0x3a ,atp_readb_base (atpdev,0x3a ) &0xef ); -atp_writeb_base (atpdev,0x3b ,atp_readb_base (atpdev,0x3b ) |0x20 ); - shpnt->max_id = wide_chip ?16 :8 ; - shpnt->this_id = host_id; - - } + else +atp870_init (shpnt ); + err =request_irq (shpnt->irq, atp870u_intr_handle,IRQF_SHARED ,"atp870u" , shpnt);if (err) {dev_err (&pdev->dev,"Unable to allocate IRQ %d.\n" , shpnt->irq);
Signature · 1 line
Ondrej Zary
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
"Ondrej" == Ondrej Zary <[email protected]> writes:
Ondrej> This patch series removes the first level of crap from atp870u - Ondrej> the worst (in-tree) SCSI driver [1] and then cleans up the code Ondrej> a bit.
Ondrej> First the driver is converted to C from something that looks Ondrej> like a (bad) assembler code: use of tmport for all I/O accesses Ondrej> and gotos all over the code. Then I/O access wrappers are Ondrej> introduced. Finally, is870, is880 and is885 are unified and two Ondrej> of them removed.
Queued for 4.5.
Signature · 1 line
Martin K. Petersen Oracle Linux Engineering