]> err.no Git - linux-2.6/blobdiff - drivers/scsi/qlogicpti.c
[PATCH] W1: cleanups
[linux-2.6] / drivers / scsi / qlogicpti.c
index a917ab7475acacd4583503065f10422e5fea1b7b..2203103adced5c342195a5a075bf8cf1b1afae13 100644 (file)
@@ -24,6 +24,7 @@
 #include <linux/spinlock.h>
 #include <linux/interrupt.h>
 #include <linux/module.h>
+#include <linux/jiffies.h>
 
 #include <asm/byteorder.h>
 
@@ -42,7 +43,6 @@
 #include <scsi/scsi_cmnd.h>
 #include <scsi/scsi_device.h>
 #include <scsi/scsi_eh.h>
-#include <scsi/scsi_request.h>
 #include <scsi/scsi_tcq.h>
 #include <scsi/scsi_host.h>
 
@@ -131,7 +131,7 @@ static const u_char mbox_param[] = {
        PACKB(0, 0)     /* 0x0042 */
 };
 
-#define MAX_MBOX_COMMAND       (sizeof(mbox_param)/sizeof(u_short))
+#define MAX_MBOX_COMMAND       ARRAY_SIZE(mbox_param)
 
 /* queue length's _must_ be power of two: */
 #define QUEUE_DEPTH(in, out, ql)       ((in - out) & (ql))
@@ -724,7 +724,7 @@ static int __init qpti_register_irq(struct qlogicpti *qpti)
                        SA_SHIRQ, "Qlogic/PTI", qpti))
                goto fail;
 
-       printk("qpti%d: IRQ %s ", qpti->qpti_id, __irq_itoa(qpti->irq));
+       printk("qpti%d: IRQ %d ", qpti->qpti_id, qpti->irq);
 
        return 0;
 
@@ -987,8 +987,8 @@ const char *qlogicpti_info(struct Scsi_Host *host)
        static char buf[80];
        struct qlogicpti *qpti = (struct qlogicpti *) host->hostdata;
 
-       sprintf(buf, "PTI Qlogic,ISP SBUS SCSI irq %s regs at %p",
-               __irq_itoa(qpti->qhost->irq), qpti->qregs);
+       sprintf(buf, "PTI Qlogic,ISP SBUS SCSI irq %d regs at %p",
+               qpti->qhost->irq, qpti->qregs);
        return buf;
 }
 
@@ -1017,7 +1017,7 @@ static inline void cmd_frob(struct Command_Entry *cmd, struct scsi_cmnd *Cmnd,
        if (Cmnd->device->tagged_supported) {
                if (qpti->cmd_count[Cmnd->device->id] == 0)
                        qpti->tag_ages[Cmnd->device->id] = jiffies;
-               if ((jiffies - qpti->tag_ages[Cmnd->device->id]) > (5*HZ)) {
+               if (time_after(jiffies, qpti->tag_ages[Cmnd->device->id] + (5*HZ))) {
                        cmd->control_flags = CFLAG_ORDERED_TAG;
                        qpti->tag_ages[Cmnd->device->id] = jiffies;
                } else
@@ -1119,6 +1119,36 @@ static inline void update_can_queue(struct Scsi_Host *host, u_int in_ptr, u_int
        host->sg_tablesize = QLOGICPTI_MAX_SG(num_free);
 }
 
+static unsigned int scsi_rbuf_get(struct scsi_cmnd *cmd, unsigned char **buf_out)
+{
+       unsigned char *buf;
+       unsigned int buflen;
+
+       if (cmd->use_sg) {
+               struct scatterlist *sg;
+
+               sg = (struct scatterlist *) cmd->request_buffer;
+               buf = kmap_atomic(sg->page, KM_IRQ0) + sg->offset;
+               buflen = sg->length;
+       } else {
+               buf = cmd->request_buffer;
+               buflen = cmd->request_bufflen;
+       }
+
+       *buf_out = buf;
+       return buflen;
+}
+
+static void scsi_rbuf_put(struct scsi_cmnd *cmd, unsigned char *buf)
+{
+       if (cmd->use_sg) {
+               struct scatterlist *sg;
+
+               sg = (struct scatterlist *) cmd->request_buffer;
+               kunmap_atomic(buf - sg->offset, KM_IRQ0);
+       }
+}
+
 /*
  * Until we scan the entire bus with inquiries, go throught this fella...
  */
@@ -1145,11 +1175,9 @@ static void ourdone(struct scsi_cmnd *Cmnd)
                int ok = host_byte(Cmnd->result) == DID_OK;
                if (Cmnd->cmnd[0] == 0x12 && ok) {
                        unsigned char *iqd;
+                       unsigned int iqd_len;
 
-                       if (Cmnd->use_sg != 0)
-                               BUG();
-
-                       iqd = ((unsigned char *)Cmnd->buffer);
+                       iqd_len = scsi_rbuf_get(Cmnd, &iqd);
 
                        /* tags handled in midlayer */
                        /* enable sync mode? */
@@ -1163,6 +1191,9 @@ static void ourdone(struct scsi_cmnd *Cmnd)
                        if (iqd[7] & 0x20) {
                                qpti->dev_param[tgt].device_flags |= 0x20;
                        }
+
+                       scsi_rbuf_put(Cmnd, iqd);
+
                        qpti->sbits |= (1 << tgt);
                } else if (!ok) {
                        qpti->sbits |= (1 << tgt);