Fedora kernel-2.6.17-1.2142_FC4 patched with stable patch-2.6.17.4-vs2.0.2-rc26.diff
[linux-2.6.git] / drivers / scsi / ppa.c
index b3b976e..108910f 100644 (file)
 #include <linux/kernel.h>
 #include <linux/module.h>
 #include <linux/blkdev.h>
-#include <asm/io.h>
 #include <linux/parport.h>
 #include <linux/workqueue.h>
-#include "scsi.h"
-#include "hosts.h"
+#include <linux/delay.h>
+#include <linux/jiffies.h>
+#include <asm/io.h>
+
+#include <scsi/scsi.h>
+#include <scsi/scsi_cmnd.h>
+#include <scsi/scsi_device.h>
+#include <scsi/scsi_host.h>
+
+
 static void ppa_reset_pulse(unsigned int base);
 
 typedef struct {
        struct pardevice *dev;  /* Parport device entry         */
        int base;               /* Actual port address          */
        int mode;               /* Transfer mode                */
-       Scsi_Cmnd *cur_cmd;     /* Current queued command       */
+       struct scsi_cmnd *cur_cmd;      /* Current queued command       */
        struct work_struct ppa_tq;      /* Polling interrupt stuff       */
        unsigned long jstart;   /* Jiffies at start             */
        unsigned long recon_tmo;        /* How many usecs to wait for reconnection (6th bit) */
@@ -44,7 +51,7 @@ static inline ppa_struct *ppa_dev(struct Scsi_Host *host)
        return *(ppa_struct **)&host->hostdata;
 }
 
-static spinlock_t arbitration_lock = SPIN_LOCK_UNLOCKED;
+static DEFINE_SPINLOCK(arbitration_lock);
 
 static void got_it(ppa_struct *dev)
 {
@@ -501,7 +508,7 @@ static int ppa_init(ppa_struct *dev)
        return device_check(dev);
 }
 
-static inline int ppa_send_command(Scsi_Cmnd *cmd)
+static inline int ppa_send_command(struct scsi_cmnd *cmd)
 {
        ppa_struct *dev = ppa_dev(cmd->device->host);
        int k;
@@ -522,7 +529,7 @@ static inline int ppa_send_command(Scsi_Cmnd *cmd)
  * The driver appears to remain stable if we speed up the parallel port
  * i/o in this function, but not elsewhere.
  */
-static int ppa_completion(Scsi_Cmnd *cmd)
+static int ppa_completion(struct scsi_cmnd *cmd)
 {
        /* Return codes:
         * -1     Error
@@ -626,7 +633,7 @@ static int ppa_completion(Scsi_Cmnd *cmd)
 static void ppa_interrupt(void *data)
 {
        ppa_struct *dev = (ppa_struct *) data;
-       Scsi_Cmnd *cmd = dev->cur_cmd;
+       struct scsi_cmnd *cmd = dev->cur_cmd;
 
        if (!cmd) {
                printk("PPA: bug in ppa_interrupt\n");
@@ -677,12 +684,12 @@ static void ppa_interrupt(void *data)
 
        ppa_pb_dismiss(dev);
 
-       dev->cur_cmd = 0;
+       dev->cur_cmd = NULL;
 
        cmd->scsi_done(cmd);
 }
 
-static int ppa_engine(ppa_struct *dev, Scsi_Cmnd *cmd)
+static int ppa_engine(ppa_struct *dev, struct scsi_cmnd *cmd)
 {
        unsigned short ppb = dev->base;
        unsigned char l = 0, h = 0;
@@ -720,7 +727,7 @@ static int ppa_engine(ppa_struct *dev, Scsi_Cmnd *cmd)
                                retv--;
 
                        if (retv) {
-                               if ((jiffies - dev->jstart) > (1 * HZ)) {
+                               if (time_after(jiffies, dev->jstart + (1 * HZ))) {
                                        printk
                                            ("ppa: Parallel port cable is unplugged!!\n");
                                        ppa_fail(dev, DID_BUS_BUSY);
@@ -734,7 +741,7 @@ static int ppa_engine(ppa_struct *dev, Scsi_Cmnd *cmd)
                }
 
        case 2:         /* Phase 2 - We are now talking to the scsi bus */
-               if (!ppa_select(dev, cmd->device->id)) {
+               if (!ppa_select(dev, scmd_id(cmd))) {
                        ppa_fail(dev, DID_NO_CONNECT);
                        return 0;
                }
@@ -802,7 +809,8 @@ static int ppa_engine(ppa_struct *dev, Scsi_Cmnd *cmd)
        return 0;
 }
 
-static int ppa_queuecommand(Scsi_Cmnd *cmd, void (*done) (Scsi_Cmnd *))
+static int ppa_queuecommand(struct scsi_cmnd *cmd,
+               void (*done) (struct scsi_cmnd *))
 {
        ppa_struct *dev = ppa_dev(cmd->device->host);
 
@@ -847,7 +855,7 @@ static int ppa_biosparam(struct scsi_device *sdev, struct block_device *dev,
        return 0;
 }
 
-static int ppa_abort(Scsi_Cmnd *cmd)
+static int ppa_abort(struct scsi_cmnd *cmd)
 {
        ppa_struct *dev = ppa_dev(cmd->device->host);
        /*
@@ -875,7 +883,7 @@ static void ppa_reset_pulse(unsigned int base)
        w_ctr(base, 0xc);
 }
 
-static int ppa_reset(Scsi_Cmnd *cmd)
+static int ppa_reset(struct scsi_cmnd *cmd)
 {
        ppa_struct *dev = ppa_dev(cmd->device->host);
 
@@ -885,9 +893,9 @@ static int ppa_reset(Scsi_Cmnd *cmd)
 
        ppa_connect(dev, CONNECT_NORMAL);
        ppa_reset_pulse(dev->base);
-       udelay(1000);           /* device settle delay */
+       mdelay(1);              /* device settle delay */
        ppa_disconnect(dev);
-       udelay(1000);           /* device settle delay */
+       mdelay(1);              /* device settle delay */
        return SUCCESS;
 }
 
@@ -974,7 +982,13 @@ static int device_check(ppa_struct *dev)
        return -ENODEV;
 }
 
-static Scsi_Host_Template ppa_template = {
+static int ppa_adjust_queue(struct scsi_device *device)
+{
+       blk_queue_bounce_limit(device->request_queue, BLK_BOUNCE_HIGH);
+       return 0;
+}
+
+static struct scsi_host_template ppa_template = {
        .module                 = THIS_MODULE,
        .proc_name              = "ppa",
        .proc_info              = ppa_proc_info,
@@ -989,6 +1003,7 @@ static Scsi_Host_Template ppa_template = {
        .cmd_per_lun            = 1,
        .use_clustering         = ENABLE_CLUSTERING,
        .can_queue              = 1,
+       .slave_alloc            = ppa_adjust_queue,
 };
 
 /***************************************************************************