Revert to Fedora kernel-2.6.17-1.2187_FC5 patched with vs2.0.2.1; there are too many...
[linux-2.6.git] / drivers / scsi / atp870u.c
index b3f5462..a198d86 100644 (file)
@@ -28,6 +28,7 @@
 #include <linux/spinlock.h>
 #include <linux/pci.h>
 #include <linux/blkdev.h>
+#include <linux/dma-mapping.h>
 #include <asm/system.h>
 #include <asm/io.h>
 
@@ -39,9 +40,9 @@
 #include "atp870u.h"
 
 static struct scsi_host_template atp870u_template;
-void send_s870(struct atp_unit *dev,unsigned char c);
-void is885(struct atp_unit *dev, unsigned int wkport,unsigned char c);
-void tscam_885(void);
+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 irqreturn_t atp870u_intr_handle(int irq, void *dev_id, struct pt_regs *regs)
 {
@@ -297,11 +298,10 @@ stop_dma:
                        }
                        workreq = dev->id[c][target_id].curr_req;
 #ifdef ED_DBGP                 
-                       printk(KERN_DEBUG "Channel = %d ID = %d LUN = %d CDB",c,workreq->device->id,workreq->device->lun);
-                       for(l=0;l<workreq->cmd_len;l++)
-                       {
+                       scmd_printk(KERN_DEBUG, workreq, "CDB");
+                       for (l = 0; l < workreq->cmd_len; l++)
                                printk(KERN_DEBUG " %x",workreq->cmnd[l]);
-                       }
+                       printk("\n");
 #endif 
                        
                        tmport = workport + 0x0f;
@@ -364,7 +364,7 @@ stop_dma:
                        }
                        outb(j, tmport);
                        while ((inb(tmport) & 0x01) != j) {
-                          outb(j,tmport);
+                               outb(j,tmport);
                        }
                        if (dev->id[c][target_id].last_len == 0) {
                                tmport = workport + 0x18;
@@ -491,7 +491,7 @@ go_42:
                        /*
                         *      Clear it off the queue
                         */
-                       dev->id[c][target_id].curr_req = 0;
+                       dev->id[c][target_id].curr_req = NULL;
                        dev->working[c]--;
                        spin_unlock_irqrestore(dev->host->host_lock, flags);
                        /*
@@ -614,17 +614,18 @@ handled:
  *
  *     Queue a command to the ATP queue. Called with the host lock held.
  */
-int atp870u_queuecommand(struct scsi_cmnd * req_p, void (*done) (struct scsi_cmnd *))
+static int atp870u_queuecommand(struct scsi_cmnd * req_p, 
+                        void (*done) (struct scsi_cmnd *))
 {
        unsigned char c;
        unsigned int tmport,m;  
        struct atp_unit *dev;
        struct Scsi_Host *host;
 
-       c = req_p->device->channel;     
+       c = scmd_channel(req_p);
        req_p->sense_buffer[0]=0;
        req_p->resid = 0;
-       if (req_p->device->channel > 1) {
+       if (scmd_channel(req_p) > 1) {
                req_p->result = 0x00040000;
                done(req_p);
 #ifdef ED_DBGP         
@@ -639,7 +640,7 @@ int atp870u_queuecommand(struct scsi_cmnd * req_p, void (*done) (struct scsi_cmn
 
                
        m = 1;
-       m = m << req_p->device->id;
+       m = m << scmd_id(req_p);
 
        /*
         *      Fake a timeout for missing targets
@@ -711,7 +712,7 @@ int atp870u_queuecommand(struct scsi_cmnd * req_p, void (*done) (struct scsi_cmn
  *
  *     Caller holds the host lock.
  */
-void send_s870(struct atp_unit *dev,unsigned char c)
+static void send_s870(struct atp_unit *dev,unsigned char c)
 {
        unsigned int tmport;
        struct scsi_cmnd *workreq;
@@ -757,9 +758,9 @@ void send_s870(struct atp_unit *dev,unsigned char c)
                dev->quhd[c] = 0;
        }
        workreq = dev->quereq[c][dev->quhd[c]];
-       if (dev->id[c][workreq->device->id].curr_req == 0) {    
-               dev->id[c][workreq->device->id].curr_req = workreq;
-               dev->last_cmd[c] = workreq->device->id;
+       if (dev->id[c][scmd_id(workreq)].curr_req == 0) {       
+               dev->id[c][scmd_id(workreq)].curr_req = workreq;
+               dev->last_cmd[c] = scmd_id(workreq);
                goto cmd_subp;
        }       
        dev->quhd[c] = j;
@@ -786,16 +787,16 @@ abortsnd:
 oktosend:
 #ifdef ED_DBGP
        printk("OK to Send\n");
-       printk("CDB");
+       scmd_printk(KERN_DEBUG, workreq, "CDB");
        for(i=0;i<workreq->cmd_len;i++) {
                printk(" %x",workreq->cmnd[i]);
        }
-       printk("\nChannel = %d ID = %d LUN = %d\n",c,workreq->device->id,workreq->device->lun);
+       printk("\n");
 #endif 
        if (dev->dev_id == ATP885_DEVID) {
                j = inb(dev->baseport + 0x29) & 0xfe;
                outb(j, dev->baseport + 0x29);
-               dev->r1f[c][workreq->device->id] = 0;
+               dev->r1f[c][scmd_id(workreq)] = 0;
        }
        
        if (workreq->cmnd[0] == READ_CAPACITY) {
@@ -809,7 +810,7 @@ oktosend:
 
        tmport = workport + 0x1b;
        j = 0;
-       target_id = workreq->device->id;
+       target_id = scmd_id(workreq);
 
        /*
         *      Wide ?
@@ -821,9 +822,9 @@ oktosend:
        }
        outb(j, tmport);
        while ((inb(tmport) & 0x01) != j) {
-          outb(j,tmport);
+               outb(j,tmport);
 #ifdef ED_DBGP
-          printk("send_s870 while loop 1\n");
+               printk("send_s870 while loop 1\n");
 #endif
        }
        /*
@@ -946,18 +947,18 @@ oktosend:
 #ifdef ED_DBGP         
                printk("1. bttl %x, l %x\n",bttl, l);
 #endif                 
-                       while (l > 0x10000) {
-                                       (((u16 *) (prd))[i + 3]) = 0x0000;
-                                       (((u16 *) (prd))[i + 2]) = 0x0000;
-                                       (((u32 *) (prd))[i >> 1]) = cpu_to_le32(bttl);
-                                       l -= 0x10000;
-                                       bttl += 0x10000;
-                                       i += 0x04;
-                               }
+               while (l > 0x10000) {
+                               (((u16 *) (prd))[i + 3]) = 0x0000;
+                               (((u16 *) (prd))[i + 2]) = 0x0000;
                                (((u32 *) (prd))[i >> 1]) = cpu_to_le32(bttl);
-                               (((u16 *) (prd))[i + 2]) = cpu_to_le16(l);
-                               (((u16 *) (prd))[i + 3]) = 0;
-                               i += 0x04;                      
+                               l -= 0x10000;
+                               bttl += 0x10000;
+                               i += 0x04;
+                       }
+                       (((u32 *) (prd))[i >> 1]) = cpu_to_le32(bttl);
+                       (((u16 *) (prd))[i + 2]) = cpu_to_le16(l);
+                       (((u16 *) (prd))[i + 3]) = 0;
+                       i += 0x04;                      
                }
                (((u16 *) (prd))[i - 1]) = cpu_to_le16(0x8000); 
 #ifdef ED_DBGP         
@@ -992,13 +993,10 @@ oktosend:
                
        }
        tmpcip += 4;
-#ifdef ED_DBGP 
-       printk("send_s870: prdaddr_1 0x%8x\n", dev->id[c][target_id].prdaddr);
-#endif
-       dev->id[c][target_id].prdaddr = virt_to_bus(dev->id[c][target_id].prd_table);
 #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);
 #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);
@@ -1178,7 +1176,8 @@ wait_rdyok:
                outb(0x09, tmport);
                tmport += 0x07;
 
-               while ((inb(tmport) & 0x80) == 0x00);
+               while ((inb(tmport) & 0x80) == 0x00)
+                       cpu_relax();
                tmport -= 0x08;
                k = inb(tmport);
                if (k != 0x16) {
@@ -1249,7 +1248,8 @@ TCM_SYNC:
                tmport += 0x03;
                outb(0x09, tmport);
                tmport += 0x07;
-               while ((inb(tmport) & 0x80) == 0);
+               while ((inb(tmport) & 0x80) == 0)
+                       cpu_relax();
                tmport -= 0x08;
                inb(tmport);
                return;
@@ -1345,7 +1345,7 @@ G2Q_QUIN:         /* k=binID#,       */
 
 }
 
-void is870(struct atp_unit *dev, unsigned int wkport)
+static void is870(struct atp_unit *dev, unsigned int wkport)
 {
        unsigned int tmport;
        unsigned char i, j, k, rmb, n;
@@ -1405,12 +1405,16 @@ void is870(struct atp_unit *dev, unsigned int wkport)
                outb(satn[8], tmport);
                tmport += 0x07;
 
-               while ((inb(tmport) & 0x80) == 0x00);
+               while ((inb(tmport) & 0x80) == 0x00)
+                       cpu_relax();
+
                tmport -= 0x08;
-               if ((inb(tmport) != 0x11) && (inb(tmport) != 0x8e)) {
+               if (inb(tmport) != 0x11 && inb(tmport) != 0x8e)
                        continue;
-               }
-               while (inb(tmport) != 0x8e);
+
+               while (inb(tmport) != 0x8e)
+                       cpu_relax();
+
                dev->active_id[0] |= m;
 
                tmport = wkport + 0x10;
@@ -1422,7 +1426,8 @@ phase_cmd:
                tmport = wkport + 0x18;
                outb(0x08, tmport);
                tmport += 0x07;
-               while ((inb(tmport) & 0x80) == 0x00);
+               while ((inb(tmport) & 0x80) == 0x00)
+                       cpu_relax();
                tmport -= 0x08;
                j = inb(tmport);
                if (j != 0x16) {
@@ -1448,16 +1453,21 @@ sel_ok:
                tmport += 0x03;
                outb(inqd[8], tmport);
                tmport += 0x07;
-               while ((inb(tmport) & 0x80) == 0x00);
+
+               while ((inb(tmport) & 0x80) == 0x00)
+                       cpu_relax();
+                       
                tmport -= 0x08;
-               if ((inb(tmport) != 0x11) && (inb(tmport) != 0x8e)) {
+               if (inb(tmport) != 0x11 && inb(tmport) != 0x8e)
                        continue;
-               }
-               while (inb(tmport) != 0x8e);
+
+               while (inb(tmport) != 0x8e)
+                       cpu_relax();
+                       
                tmport = wkport + 0x1b;
-               if (dev->chip_ver == 4) {
+               if (dev->chip_ver == 4)
                        outb(0x00, tmport);
-               }
+
                tmport = wkport + 0x18;
                outb(0x08, tmport);
                tmport += 0x07;
@@ -1487,7 +1497,10 @@ rd_inq_data:
                tmport += 0x03;
                outb(0x08, tmport);
                tmport += 0x07;
-               while ((inb(tmport) & 0x80) == 0x00);
+
+               while ((inb(tmport) & 0x80) == 0x00)
+                       cpu_relax();
+                       
                tmport -= 0x08;
                if (inb(tmport) != 0x16) {
                        goto sel_ok;
@@ -1527,12 +1540,16 @@ inq_ok:
                outb(satn[8], tmport);
                tmport += 0x07;
 
-               while ((inb(tmport) & 0x80) == 0x00);
+               while ((inb(tmport) & 0x80) == 0x00)
+                       cpu_relax();
+                       
                tmport -= 0x08;
-               if ((inb(tmport) != 0x11) && (inb(tmport) != 0x8e)) {
+               if (inb(tmport) != 0x11 && inb(tmport) != 0x8e)
                        continue;
-               }
-               while (inb(tmport) != 0x8e);
+
+               while (inb(tmport) != 0x8e)
+                       cpu_relax();
+                       
 try_wide:
                j = 0;
                tmport = wkport + 0x14;
@@ -1549,7 +1566,10 @@ try_wide:
                        }
                }
                tmport -= 0x08;
-               while ((inb(tmport) & 0x80) == 0x00);
+               
+               while ((inb(tmport) & 0x80) == 0x00)
+                       cpu_relax();
+                       
                j = inb(tmport) & 0x0f;
                if (j == 0x0f) {
                        goto widep_in;
@@ -1622,7 +1642,10 @@ widep_cmd:
                tmport += 0x04;
                outb(0x08, tmport);
                tmport += 0x07;
-               while ((inb(tmport) & 0x80) == 0x00);
+               
+               while ((inb(tmport) & 0x80) == 0x00)
+                       cpu_relax();
+
                tmport -= 0x08;
                j = inb(tmport);
                if (j != 0x16) {
@@ -1676,12 +1699,16 @@ set_sync:
                outb(satn[8], tmport);
                tmport += 0x07;
 
-               while ((inb(tmport) & 0x80) == 0x00);
+               while ((inb(tmport) & 0x80) == 0x00)
+                       cpu_relax();
+                       
                tmport -= 0x08;
-               if ((inb(tmport) != 0x11) && (inb(tmport) != 0x8e)) {
+               if (inb(tmport) != 0x11 && inb(tmport) != 0x8e)
                        continue;
-               }
-               while (inb(tmport) != 0x8e);
+
+               while (inb(tmport) != 0x8e)
+                       cpu_relax();
+                       
 try_sync:
                j = 0;
                tmport = wkport + 0x14;
@@ -1706,7 +1733,10 @@ try_sync:
                        }
                }
                tmport -= 0x08;
-               while ((inb(tmport) & 0x80) == 0x00);
+               
+               while ((inb(tmport) & 0x80) == 0x00)
+                       cpu_relax();
+                       
                j = inb(tmport) & 0x0f;
                if (j == 0x0f) {
                        goto phase_ins;
@@ -1764,7 +1794,10 @@ phase_ins1:
                        goto phase_ins1;
                }
                tmport -= 0x08;
-               while ((inb(tmport) & 0x80) == 0x00);
+
+               while ((inb(tmport) & 0x80) == 0x00)
+                       cpu_relax();
+                       
                j = inb(tmport);
                if (j == 0x85) {
                        goto tar_dcons;
@@ -1789,7 +1822,10 @@ tar_dcons:
                tmport += 0x04;
                outb(0x08, tmport);
                tmport += 0x07;
-               while ((inb(tmport) & 0x80) == 0x00);
+               
+               while ((inb(tmport) & 0x80) == 0x00)
+                       cpu_relax();
+                       
                tmport -= 0x08;
                j = inb(tmport);
                if (j != 0x16) {
@@ -1889,12 +1925,16 @@ static void is880(struct atp_unit *dev, unsigned int wkport)
                outb(satn[8], tmport);
                tmport += 0x07;
 
-               while ((inb(tmport) & 0x80) == 0x00);
+               while ((inb(tmport) & 0x80) == 0x00)
+                       cpu_relax();
+
                tmport -= 0x08;
-               if ((inb(tmport) != 0x11) && (inb(tmport) != 0x8e)) {
+               if (inb(tmport) != 0x11 && inb(tmport) != 0x8e)
                        continue;
-               }
-               while (inb(tmport) != 0x8e);
+
+               while (inb(tmport) != 0x8e)
+                       cpu_relax();
+                       
                dev->active_id[0] |= m;
 
                tmport = wkport + 0x50;
@@ -1906,7 +1946,10 @@ phase_cmd:
                tmport = wkport + 0x58;
                outb(0x08, tmport);
                tmport += 0x07;
-               while ((inb(tmport) & 0x80) == 0x00);
+               
+               while ((inb(tmport) & 0x80) == 0x00)
+                       cpu_relax();
+
                tmport -= 0x08;
                j = inb(tmport);
                if (j != 0x16) {
@@ -1932,12 +1975,17 @@ sel_ok:
                tmport += 0x03;
                outb(inqd[8], tmport);
                tmport += 0x07;
-               while ((inb(tmport) & 0x80) == 0x00);
+               
+               while ((inb(tmport) & 0x80) == 0x00)
+                       cpu_relax();
+                       
                tmport -= 0x08;
-               if ((inb(tmport) != 0x11) && (inb(tmport) != 0x8e)) {
+               if (inb(tmport) != 0x11 && inb(tmport) != 0x8e)
                        continue;
-               }
-               while (inb(tmport) != 0x8e);
+
+               while (inb(tmport) != 0x8e)
+                       cpu_relax();
+                       
                tmport = wkport + 0x5b;
                outb(0x00, tmport);
                tmport = wkport + 0x58;
@@ -1969,11 +2017,13 @@ rd_inq_data:
                tmport += 0x03;
                outb(0x08, tmport);
                tmport += 0x07;
-               while ((inb(tmport) & 0x80) == 0x00);
+               while ((inb(tmport) & 0x80) == 0x00)
+                       cpu_relax();
+                       
                tmport -= 0x08;
-               if (inb(tmport) != 0x16) {
+               if (inb(tmport) != 0x16)
                        goto sel_ok;
-               }
+
 inq_ok:
                mbuf[36] = 0;
                printk(KERN_INFO "         ID: %2d  %s\n", i, &mbuf[8]);
@@ -2014,12 +2064,17 @@ inq_ok:
                outb(satn[8], tmport);
                tmport += 0x07;
 
-               while ((inb(tmport) & 0x80) == 0x00);
+               while ((inb(tmport) & 0x80) == 0x00)
+                       cpu_relax();
+
                tmport -= 0x08;
-               if ((inb(tmport) != 0x11) && (inb(tmport) != 0x8e)) {
+
+               if (inb(tmport) != 0x11 && inb(tmport) != 0x8e)
                        continue;
-               }
-               while (inb(tmport) != 0x8e);
+
+               while (inb(tmport) != 0x8e)
+                       cpu_relax();
+
 try_u3:
                j = 0;
                tmport = wkport + 0x54;
@@ -2036,7 +2091,10 @@ try_u3:
                        }
                }
                tmport -= 0x08;
-               while ((inb(tmport) & 0x80) == 0x00);
+
+               while ((inb(tmport) & 0x80) == 0x00)
+                       cpu_relax();
+                       
                j = inb(tmport) & 0x0f;
                if (j == 0x0f) {
                        goto u3p_in;
@@ -2109,7 +2167,10 @@ u3p_cmd:
                tmport += 0x04;
                outb(0x08, tmport);
                tmport += 0x07;
-               while ((inb(tmport) & 0x80) == 0x00);
+               
+               while ((inb(tmport) & 0x80) == 0x00)
+                       cpu_relax();
+                       
                tmport -= 0x08;
                j = inb(tmport);
                if (j != 0x16) {
@@ -2155,12 +2216,16 @@ chg_wide:
                outb(satn[8], tmport);
                tmport += 0x07;
 
-               while ((inb(tmport) & 0x80) == 0x00);
+               while ((inb(tmport) & 0x80) == 0x00)
+                       cpu_relax();
+                       
                tmport -= 0x08;
-               if ((inb(tmport) != 0x11) && (inb(tmport) != 0x8e)) {
+               if (inb(tmport) != 0x11 && inb(tmport) != 0x8e)
                        continue;
-               }
-               while (inb(tmport) != 0x8e);
+
+               while (inb(tmport) != 0x8e)
+                       cpu_relax();
+                       
 try_wide:
                j = 0;
                tmport = wkport + 0x54;
@@ -2177,7 +2242,9 @@ try_wide:
                        }
                }
                tmport -= 0x08;
-               while ((inb(tmport) & 0x80) == 0x00);
+               while ((inb(tmport) & 0x80) == 0x00)
+                       cpu_relax();
+                       
                j = inb(tmport) & 0x0f;
                if (j == 0x0f) {
                        goto widep_in;
@@ -2250,7 +2317,10 @@ widep_cmd:
                tmport += 0x04;
                outb(0x08, tmport);
                tmport += 0x07;
-               while ((inb(tmport) & 0x80) == 0x00);
+
+               while ((inb(tmport) & 0x80) == 0x00)
+                       cpu_relax();
+
                tmport -= 0x08;
                j = inb(tmport);
                if (j != 0x16) {
@@ -2317,12 +2387,16 @@ set_sync:
                outb(satn[8], tmport);
                tmport += 0x07;
 
-               while ((inb(tmport) & 0x80) == 0x00);
+               while ((inb(tmport) & 0x80) == 0x00)
+                       cpu_relax();
+
                tmport -= 0x08;
                if ((inb(tmport) != 0x11) && (inb(tmport) != 0x8e)) {
                        continue;
                }
-               while (inb(tmport) != 0x8e);
+               while (inb(tmport) != 0x8e)
+                       cpu_relax();
+
 try_sync:
                j = 0;
                tmport = wkport + 0x54;
@@ -2351,7 +2425,10 @@ try_sync:
                        }
                }
                tmport -= 0x08;
-               while ((inb(tmport) & 0x80) == 0x00);
+
+               while ((inb(tmport) & 0x80) == 0x00)
+                       cpu_relax();
+
                j = inb(tmport) & 0x0f;
                if (j == 0x0f) {
                        goto phase_ins;
@@ -2409,7 +2486,10 @@ phase_ins1:
                        goto phase_ins1;
                }
                tmport -= 0x08;
-               while ((inb(tmport) & 0x80) == 0x00);
+
+               while ((inb(tmport) & 0x80) == 0x00)
+                       cpu_relax();
+
                j = inb(tmport);
                if (j == 0x85) {
                        goto tar_dcons;
@@ -2434,7 +2514,10 @@ tar_dcons:
                tmport += 0x04;
                outb(0x08, tmport);
                tmport += 0x07;
-               while ((inb(tmport) & 0x80) == 0x00);
+
+               while ((inb(tmport) & 0x80) == 0x00)
+                       cpu_relax();
+
                tmport -= 0x08;
                j = inb(tmport);
                if (j != 0x16) {
@@ -2490,7 +2573,7 @@ static void atp870u_free_tables(struct Scsi_Host *host)
                for (k = 0; k < 16; k++) {
                        if (!atp_dev->id[j][k].prd_table)
                                continue;
-                       pci_free_consistent(atp_dev->pdev, 1024, atp_dev->id[j][k].prd_table, atp_dev->id[j][k].prdaddr);
+                       pci_free_consistent(atp_dev->pdev, 1024, atp_dev->id[j][k].prd_table, atp_dev->id[j][k].prd_bus);
                        atp_dev->id[j][k].prd_table = NULL;
                }
        }
@@ -2502,12 +2585,13 @@ static int atp870u_init_tables(struct Scsi_Host *host)
        int c,k;
        for(c=0;c < 2;c++) {
                for(k=0;k<16;k++) {
-                               atp_dev->id[c][k].prd_table = pci_alloc_consistent(atp_dev->pdev, 1024, &(atp_dev->id[c][k].prdaddr));
+                               atp_dev->id[c][k].prd_table = pci_alloc_consistent(atp_dev->pdev, 1024, &(atp_dev->id[c][k].prd_bus));
                                if (!atp_dev->id[c][k].prd_table) {
                                        printk("atp870u_init_tables fail\n");
                                atp870u_free_tables(host);
                                return -ENOMEM;
                        }
+                       atp_dev->id[c][k].prdaddr = atp_dev->id[c][k].prd_bus;
                        atp_dev->id[c][k].devsp=0x20;
                        atp_dev->id[c][k].devtype = 0x7f;
                        atp_dev->id[c][k].curr_req = NULL;                         
@@ -2548,7 +2632,7 @@ static int atp870u_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
        if (pci_enable_device(pdev))
                return -EIO;
 
-        if (!pci_set_dma_mask(pdev, 0xFFFFFFUL)) {
+        if (!pci_set_dma_mask(pdev, DMA_32BIT_MASK)) {
                 printk(KERN_INFO "atp870u: use 32bit DMA mask.\n");
         } else {
                 printk(KERN_ERR "atp870u: DMA mask required but not available.\n");
@@ -2826,7 +2910,10 @@ flash_ok_885:
                tmport += 0x18;
                outb(0, tmport);
                tmport += 0x07;
-               while ((inb(tmport) & 0x80) == 0);
+
+               while ((inb(tmport) & 0x80) == 0)
+                       cpu_relax();
+       
                tmport -= 0x08;
                inb(tmport);
                tmport = base_io + 0x81;
@@ -2844,7 +2931,10 @@ flash_ok_885:
                tmport += 0x18;
                outb(0, tmport);
                tmport += 0x07;
-               while ((inb(tmport) & 0x80) == 0);
+
+               while ((inb(tmport) & 0x80) == 0)
+                       cpu_relax();
+
                tmport -= 0x08;
                inb(tmport);
                tmport = base_io + 0xc1;
@@ -3009,7 +3099,7 @@ unregister:
    it is available to be used again.  Until this gets worked out, we will
    leave it commented out.  */
 
-int atp870u_abort(struct scsi_cmnd * SCpnt)
+static int atp870u_abort(struct scsi_cmnd * SCpnt)
 {
        unsigned char  j, k, c;
        struct scsi_cmnd *workrequ;
@@ -3019,7 +3109,7 @@ int atp870u_abort(struct scsi_cmnd * SCpnt)
        host = SCpnt->device->host;
 
        dev = (struct atp_unit *)&host->hostdata;
-       c=SCpnt->device->channel;
+       c = scmd_channel(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]);
@@ -3048,7 +3138,7 @@ int atp870u_abort(struct scsi_cmnd * SCpnt)
        return SUCCESS;
 }
 
-const char *atp870u_info(struct Scsi_Host *notused)
+static const char *atp870u_info(struct Scsi_Host *notused)
 {
        static char buffer[128];
 
@@ -3057,13 +3147,9 @@ const char *atp870u_info(struct Scsi_Host *notused)
        return buffer;
 }
 
-int atp870u_set_info(char *buffer, int length, struct Scsi_Host *HBAptr)
-{
-       return -ENOSYS;         /* Currently this is a no-op */
-}
-
 #define BLS buffer + len + size
-int atp870u_proc_info(struct Scsi_Host *HBAptr, char *buffer, char **start, off_t offset, int length, int inout)
+static int atp870u_proc_info(struct Scsi_Host *HBAptr, char *buffer, 
+                            char **start, off_t offset, int length, int inout)
 {
        static u8 buff[512];
        int size = 0;
@@ -3072,10 +3158,9 @@ int atp870u_proc_info(struct Scsi_Host *HBAptr, char *buffer, char **start, off_
        off_t pos = 0;
        
        if (inout)      
-               return -ENOSYS;
-       if (offset == 0) {
+               return -EINVAL;
+       if (offset == 0)
                memset(buff, 0, sizeof(buff));
-       }
        size += sprintf(BLS, "ACARD AEC-671X Driver Version: 2.6+ac\n");
        len += size;
        pos = begin + len;
@@ -3192,7 +3277,7 @@ static void __exit atp870u_exit(void)
        pci_unregister_driver(&atp870u_driver);
 }
 
-void tscam_885(void)
+static void tscam_885(void)
 {
        unsigned char i;
 
@@ -3204,7 +3289,7 @@ void tscam_885(void)
 
 
 
-void is885(struct atp_unit *dev, unsigned int wkport,unsigned char c)
+static void is885(struct atp_unit *dev, unsigned int wkport,unsigned char c)
 {
        unsigned int tmport;
        unsigned char i, j, k, rmb, n, lvdmode;
@@ -3259,12 +3344,14 @@ void is885(struct atp_unit *dev, unsigned int wkport,unsigned char c)
                outb(satn[8], tmport);
                tmport += 0x07;
 
-               while ((inb(tmport) & 0x80) == 0x00);
+               while ((inb(tmport) & 0x80) == 0x00)
+                       cpu_relax();
                tmport -= 0x08;
                if ((inb(tmport) != 0x11) && (inb(tmport) != 0x8e)) {
                        continue;
                }
-               while (inb(tmport) != 0x8e);
+               while (inb(tmport) != 0x8e)
+                       cpu_relax();
                dev->active_id[c] |= m;
 
                tmport = wkport + 0x10;
@@ -3276,7 +3363,8 @@ phase_cmd:
                tmport = wkport + 0x18;
                outb(0x08, tmport);
                tmport += 0x07;
-               while ((inb(tmport) & 0x80) == 0x00);
+               while ((inb(tmport) & 0x80) == 0x00)
+                       cpu_relax();
                tmport -= 0x08;
                j = inb(tmport);
                if (j != 0x16) {
@@ -3302,12 +3390,14 @@ sel_ok:
                tmport += 0x03;
                outb(inqd[8], tmport);
                tmport += 0x07;
-               while ((inb(tmport) & 0x80) == 0x00);
+               while ((inb(tmport) & 0x80) == 0x00)
+                       cpu_relax();
                tmport -= 0x08;
                if ((inb(tmport) != 0x11) && (inb(tmport) != 0x8e)) {
                        continue;
                }
-               while (inb(tmport) != 0x8e);
+               while (inb(tmport) != 0x8e)
+                       cpu_relax();
                tmport = wkport + 0x1b;
                outb(0x00, tmport);
                tmport = wkport + 0x18;
@@ -3339,7 +3429,8 @@ rd_inq_data:
                tmport += 0x03;
                outb(0x08, tmport);
                tmport += 0x07;
-               while ((inb(tmport) & 0x80) == 0x00);
+               while ((inb(tmport) & 0x80) == 0x00)
+                       cpu_relax();
                tmport -= 0x08;
                if (inb(tmport) != 0x16) {
                        goto sel_ok;
@@ -3383,12 +3474,14 @@ inq_ok:
                outb(satn[8], tmport);
                tmport += 0x07;
 
-               while ((inb(tmport) & 0x80) == 0x00);
+               while ((inb(tmport) & 0x80) == 0x00)
+                       cpu_relax();
                tmport -= 0x08;
                if ((inb(tmport) != 0x11) && (inb(tmport) != 0x8e)) {
                        continue;
                }
-               while (inb(tmport) != 0x8e);
+               while (inb(tmport) != 0x8e)
+                       cpu_relax();
 try_u3:
                j = 0;
                tmport = wkport + 0x14;
@@ -3403,9 +3496,11 @@ try_u3:
                                outb(u3[j++], tmport);
                                tmport += 0x06;
                        }
+                       cpu_relax();
                }
                tmport -= 0x08;
-               while ((inb(tmport) & 0x80) == 0x00);
+               while ((inb(tmport) & 0x80) == 0x00)
+                       cpu_relax();
                j = inb(tmport) & 0x0f;
                if (j == 0x0f) {
                        goto u3p_in;
@@ -3427,6 +3522,7 @@ u3p_out:
                                outb(0, tmport);
                                tmport += 0x06;
                        }
+                       cpu_relax();
                }
                tmport -= 0x08;
                j = inb(tmport) & 0x0f;
@@ -3497,14 +3593,14 @@ u3p_cmd:
                        goto chg_wide;
                }
                if (mbuf[3] == 0x09) {
-                  m = 1;
-                  m = m << i;
-                  dev->wide_id[c] |= m;
-                  dev->id[c][i].devsp = 0xce;
+                       m = 1;
+                       m = m << i;
+                       dev->wide_id[c] |= m;
+                       dev->id[c][i].devsp = 0xce;
 #ifdef ED_DBGP            
-                  printk("dev->id[%2d][%2d].devsp = %2x\n",c,i,dev->id[c][i].devsp);
+                       printk("dev->id[%2d][%2d].devsp = %2x\n",c,i,dev->id[c][i].devsp);
 #endif
-                  continue;
+                       continue;
                }
 chg_wide:
                tmport = wkport + 0x1b;
@@ -3527,12 +3623,14 @@ chg_wide:
                outb(satn[8], tmport);
                tmport += 0x07;
 
-               while ((inb(tmport) & 0x80) == 0x00);
+               while ((inb(tmport) & 0x80) == 0x00)
+                       cpu_relax();
                tmport -= 0x08;
                if ((inb(tmport) != 0x11) && (inb(tmport) != 0x8e)) {
                        continue;
                }
-               while (inb(tmport) != 0x8e);
+               while (inb(tmport) != 0x8e)
+                       cpu_relax();
 try_wide:
                j = 0;
                tmport = wkport + 0x14;
@@ -3547,9 +3645,11 @@ try_wide:
                                outb(wide[j++], tmport);
                                tmport += 0x06;
                        }
+                       cpu_relax();
                }
                tmport -= 0x08;
-               while ((inb(tmport) & 0x80) == 0x00);
+               while ((inb(tmport) & 0x80) == 0x00)
+                       cpu_relax();
                j = inb(tmport) & 0x0f;
                if (j == 0x0f) {
                        goto widep_in;
@@ -3571,6 +3671,7 @@ widep_out:
                                outb(0, tmport);
                                tmport += 0x06;
                        }
+                       cpu_relax();
                }
                tmport -= 0x08;
                j = inb(tmport) & 0x0f;
@@ -3622,7 +3723,8 @@ widep_cmd:
                tmport += 0x04;
                outb(0x08, tmport);
                tmport += 0x07;
-               while ((inb(tmport) & 0x80) == 0x00);
+               while ((inb(tmport) & 0x80) == 0x00)
+                       cpu_relax();
                tmport -= 0x08;
                j = inb(tmport);
                if (j != 0x16) {
@@ -3690,12 +3792,14 @@ set_sync:
                outb(satn[8], tmport);
                tmport += 0x07;
 
-               while ((inb(tmport) & 0x80) == 0x00);
+               while ((inb(tmport) & 0x80) == 0x00)
+                       cpu_relax();
                tmport -= 0x08;
                if ((inb(tmport) != 0x11) && (inb(tmport) != 0x8e)) {
                        continue;
                }
-               while (inb(tmport) != 0x8e);
+               while (inb(tmport) != 0x8e)
+                       cpu_relax();
 try_sync:
                j = 0;
                tmport = wkport + 0x14;
@@ -3724,7 +3828,8 @@ try_sync:
                        }
                }
                tmport -= 0x08;
-               while ((inb(tmport) & 0x80) == 0x00);
+               while ((inb(tmport) & 0x80) == 0x00)
+                       cpu_relax();
                j = inb(tmport) & 0x0f;
                if (j == 0x0f) {
                        goto phase_ins;
@@ -3746,6 +3851,7 @@ phase_outs:
                                outb(0x00, tmport);
                                tmport += 0x06;
                        }
+                       cpu_relax();
                }
                tmport -= 0x08;
                j = inb(tmport);
@@ -3807,7 +3913,8 @@ tar_dcons:
                tmport += 0x04;
                outb(0x08, tmport);
                tmport += 0x07;
-               while ((inb(tmport) & 0x80) == 0x00);
+               while ((inb(tmport) & 0x80) == 0x00)
+                       cpu_relax();
                tmport -= 0x08;
                j = inb(tmport);
                if (j != 0x16) {