fedora core 6 1.2949 + vserver 2.2.0
[linux-2.6.git] / drivers / scsi / ppa.c
index 390bbbd..584ba4d 100644 (file)
@@ -6,17 +6,16 @@
  * (c) 1995,1996 Grant R. Guenther, grant@torque.net,
  * under the terms of the GNU General Public License.
  * 
- * Current Maintainer: David Campbell (Perth, Western Australia, GMT+0800)
- *                     campbell@torque.net
  */
 
-#include <linux/config.h>
 #include <linux/init.h>
 #include <linux/kernel.h>
 #include <linux/module.h>
 #include <linux/blkdev.h>
 #include <linux/parport.h>
 #include <linux/workqueue.h>
+#include <linux/delay.h>
+#include <linux/jiffies.h>
 #include <asm/io.h>
 
 #include <scsi/scsi.h>
@@ -32,7 +31,7 @@ typedef struct {
        int base;               /* Actual port address          */
        int mode;               /* Transfer mode                */
        struct scsi_cmnd *cur_cmd;      /* Current queued command       */
-       struct work_struct ppa_tq;      /* Polling interrupt stuff       */
+       struct delayed_work ppa_tq;     /* Polling interrupt stuff       */
        unsigned long jstart;   /* Jiffies at start             */
        unsigned long recon_tmo;        /* How many usecs to wait for reconnection (6th bit) */
        unsigned int failed:1;  /* Failure flag                 */
@@ -49,7 +48,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)
 {
@@ -628,9 +627,9 @@ static int ppa_completion(struct scsi_cmnd *cmd)
  * the scheduler's task queue to generate a stream of call-backs and
  * complete the request when the drive is ready.
  */
-static void ppa_interrupt(void *data)
+static void ppa_interrupt(struct work_struct *work)
 {
-       ppa_struct *dev = (ppa_struct *) data;
+       ppa_struct *dev = container_of(work, ppa_struct, ppa_tq.work);
        struct scsi_cmnd *cmd = dev->cur_cmd;
 
        if (!cmd) {
@@ -638,7 +637,6 @@ static void ppa_interrupt(void *data)
                return;
        }
        if (ppa_engine(dev, cmd)) {
-               dev->ppa_tq.data = (void *) dev;
                schedule_delayed_work(&dev->ppa_tq, 1);
                return;
        }
@@ -682,7 +680,7 @@ static void ppa_interrupt(void *data)
 
        ppa_pb_dismiss(dev);
 
-       dev->cur_cmd = 0;
+       dev->cur_cmd = NULL;
 
        cmd->scsi_done(cmd);
 }
@@ -725,7 +723,7 @@ static int ppa_engine(ppa_struct *dev, struct 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);
@@ -739,7 +737,7 @@ static int ppa_engine(ppa_struct *dev, struct 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;
                }
@@ -823,8 +821,7 @@ static int ppa_queuecommand(struct scsi_cmnd *cmd,
        cmd->result = DID_ERROR << 16;  /* default return code */
        cmd->SCp.phase = 0;     /* bus free */
 
-       dev->ppa_tq.data = dev;
-       schedule_work(&dev->ppa_tq);
+       schedule_delayed_work(&dev->ppa_tq, 0);
 
        ppa_pb_claim(dev);
 
@@ -891,9 +888,9 @@ static int ppa_reset(struct 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;
 }
 
@@ -980,6 +977,12 @@ static int device_check(ppa_struct *dev)
        return -ENODEV;
 }
 
+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",
@@ -995,6 +998,7 @@ static struct scsi_host_template ppa_template = {
        .cmd_per_lun            = 1,
        .use_clustering         = ENABLE_CLUSTERING,
        .can_queue              = 1,
+       .slave_alloc            = ppa_adjust_queue,
 };
 
 /***************************************************************************
@@ -1006,7 +1010,7 @@ static LIST_HEAD(ppa_hosts);
 static int __ppa_attach(struct parport *pb)
 {
        struct Scsi_Host *host;
-       DECLARE_WAIT_QUEUE_HEAD(waiting);
+       DECLARE_WAIT_QUEUE_HEAD_ONSTACK(waiting);
        DEFINE_WAIT(wait);
        ppa_struct *dev;
        int ports;
@@ -1080,7 +1084,7 @@ static int __ppa_attach(struct parport *pb)
        else
                ports = 8;
 
-       INIT_WORK(&dev->ppa_tq, ppa_interrupt, dev);
+       INIT_DELAYED_WORK(&dev->ppa_tq, ppa_interrupt);
 
        err = -ENOMEM;
        host = scsi_host_alloc(&ppa_template, sizeof(ppa_struct *));