#include <linux/sched.h>
#include <linux/string.h>
#include <linux/delay.h>
-#include <linux/version.h>
#include <linux/init.h>
+#include <linux/interrupt.h>
#include <linux/blkdev.h>
-#include <asm/irq.h>
-#include "scsi.h"
-#include "hosts.h"
+#include <scsi/scsi.h>
+#include <scsi/scsi_cmnd.h>
+#include <scsi/scsi_device.h>
+#include <scsi/scsi_host.h>
#include "wd33c93.h"
static char *setup_args[] = { "", "", "", "", "", "", "", "", "" };
static char *setup_strings;
-MODULE_PARM(setup_strings, "s");
+module_param(setup_strings, charp, 0);
static void wd33c93_execute(struct Scsi_Host *instance);
return x;
}
-/* The 33c93 needs to be told which direction a command transfers its
- * data; we use this function to figure it out. Returns true if there
- * will be a DATA_OUT phase with this command, false otherwise.
- * (Thanks to Joerg Dorchain for the research and suggestion.)
- */
-static inline int
-is_dir_out(Scsi_Cmnd * cmd)
-{
- return cmd->sc_data_direction == SCSI_DATA_WRITE;
-}
-
static struct sx_period sx_table[] = {
{1, 0x20},
{252, 0x20},
}
int
-wd33c93_queuecommand(Scsi_Cmnd * cmd, void (*done) (Scsi_Cmnd *))
+wd33c93_queuecommand(struct scsi_cmnd *cmd,
+ void (*done)(struct scsi_cmnd *))
{
struct WD33C93_hostdata *hostdata;
- Scsi_Cmnd *tmp;
+ struct scsi_cmnd *tmp;
hostdata = (struct WD33C93_hostdata *) cmd->device->host->hostdata;
DB(DB_QUEUE_COMMAND,
printk("Q-%d-%02x-%ld( ", cmd->device->id, cmd->cmnd[0], cmd->pid))
-/* Set up a few fields in the Scsi_Cmnd structure for our own use:
+/* Set up a few fields in the scsi_cmnd structure for our own use:
* - host_scribble is the pointer to the next cmd in the input queue
* - scsi_done points to the routine we call when a cmd is finished
* - result is what you'd expect
cmd->host_scribble = (uchar *) hostdata->input_Q;
hostdata->input_Q = cmd;
} else { /* find the end of the queue */
- for (tmp = (Scsi_Cmnd *) hostdata->input_Q; tmp->host_scribble;
- tmp = (Scsi_Cmnd *) tmp->host_scribble) ;
+ for (tmp = (struct scsi_cmnd *) hostdata->input_Q;
+ tmp->host_scribble;
+ tmp = (struct scsi_cmnd *) tmp->host_scribble) ;
tmp->host_scribble = (uchar *) cmd;
}
struct WD33C93_hostdata *hostdata =
(struct WD33C93_hostdata *) instance->hostdata;
const wd33c93_regs regs = hostdata->regs;
- Scsi_Cmnd *cmd, *prev;
+ struct scsi_cmnd *cmd, *prev;
DB(DB_EXECUTE, printk("EX("))
if (hostdata->selecting || hostdata->connected) {
* for an idle target/lun.
*/
- cmd = (Scsi_Cmnd *) hostdata->input_Q;
- prev = 0;
+ cmd = (struct scsi_cmnd *) hostdata->input_Q;
+ prev = NULL;
while (cmd) {
if (!(hostdata->busy[cmd->device->id] & (1 << cmd->device->lun)))
break;
prev = cmd;
- cmd = (Scsi_Cmnd *) cmd->host_scribble;
+ cmd = (struct scsi_cmnd *) cmd->host_scribble;
}
/* quit if queue empty or all possible targets are busy */
if (prev)
prev->host_scribble = cmd->host_scribble;
else
- hostdata->input_Q = (Scsi_Cmnd *) cmd->host_scribble;
+ hostdata->input_Q = (struct scsi_cmnd *) cmd->host_scribble;
#ifdef PROC_STATISTICS
hostdata->cmd_cnt[cmd->device->id]++;
* Start the selection process
*/
- if (is_dir_out(cmd))
+ if (cmd->sc_data_direction == DMA_TO_DEVICE)
write_wd33c93(regs, WD_DESTINATION_ID, cmd->device->id);
else
write_wd33c93(regs, WD_DESTINATION_ID, cmd->device->id | DSTID_DPD);
goto yes;
if (!(hostdata->input_Q)) /* input_Q empty? */
goto no;
- for (prev = (Scsi_Cmnd *) hostdata->input_Q; prev;
- prev = (Scsi_Cmnd *) prev->host_scribble) {
+ for (prev = (struct scsi_cmnd *) hostdata->input_Q; prev;
+ prev = (struct scsi_cmnd *) prev->host_scribble) {
if ((prev->device->id != cmd->device->id) ||
(prev->device->lun != cmd->device->lun)) {
- for (prev = (Scsi_Cmnd *) hostdata->input_Q; prev;
- prev = (Scsi_Cmnd *) prev->host_scribble)
+ for (prev = (struct scsi_cmnd *) hostdata->input_Q; prev;
+ prev = (struct scsi_cmnd *) prev->host_scribble)
prev->SCp.phase = 1;
goto yes;
}
if ((cmd->SCp.phase == 0) && (hostdata->no_dma == 0)) {
if (hostdata->dma_setup(cmd,
- (is_dir_out(cmd)) ? DATA_OUT_DIR
- : DATA_IN_DIR))
+ (cmd->sc_data_direction == DMA_TO_DEVICE) ?
+ DATA_OUT_DIR : DATA_IN_DIR))
write_wd33c93_count(regs, 0); /* guarantee a DATA_PHASE interrupt */
else {
write_wd33c93_count(regs,
}
static void
-transfer_bytes(const wd33c93_regs regs, Scsi_Cmnd * cmd, int data_in_dir)
+transfer_bytes(const wd33c93_regs regs, struct scsi_cmnd *cmd,
+ int data_in_dir)
{
struct WD33C93_hostdata *hostdata;
unsigned long length;
struct WD33C93_hostdata *hostdata =
(struct WD33C93_hostdata *) instance->hostdata;
const wd33c93_regs regs = hostdata->regs;
- Scsi_Cmnd *patch, *cmd;
+ struct scsi_cmnd *patch, *cmd;
uchar asr, sr, phs, id, lun, *ucp, msg;
unsigned long length, flags;
hostdata->int_cnt++;
#endif
- cmd = (Scsi_Cmnd *) hostdata->connected; /* assume we're connected */
+ cmd = (struct scsi_cmnd *) hostdata->connected; /* assume we're connected */
sr = read_wd33c93(regs, WD_SCSI_STATUS); /* clear the interrupt */
phs = read_wd33c93(regs, WD_COMMAND_PHASE);
if (hostdata->state == S_RUNNING_LEVEL2)
hostdata->connected = NULL;
else {
- cmd = (Scsi_Cmnd *) hostdata->selecting; /* get a valid cmd */
+ cmd = (struct scsi_cmnd *) hostdata->selecting; /* get a valid cmd */
hostdata->selecting = NULL;
}
case CSR_SELECT:
DB(DB_INTR, printk("SELECT"))
hostdata->connected = cmd =
- (Scsi_Cmnd *) hostdata->selecting;
+ (struct scsi_cmnd *) hostdata->selecting;
hostdata->selecting = NULL;
/* construct an IDENTIFY message with correct disconnect bit */
if (hostdata->level2 <= L2_NONE) {
if (hostdata->selecting) {
- cmd = (Scsi_Cmnd *) hostdata->selecting;
+ cmd = (struct scsi_cmnd *) hostdata->selecting;
hostdata->selecting = NULL;
hostdata->busy[cmd->device->id] &= ~(1 << cmd->device->lun);
cmd->host_scribble =
/* Now we look for the command that's reconnecting. */
- cmd = (Scsi_Cmnd *) hostdata->disconnected_Q;
+ cmd = (struct scsi_cmnd *) hostdata->disconnected_Q;
patch = NULL;
while (cmd) {
if (id == cmd->device->id && lun == cmd->device->lun)
break;
patch = cmd;
- cmd = (Scsi_Cmnd *) cmd->host_scribble;
+ cmd = (struct scsi_cmnd *) cmd->host_scribble;
}
/* Hmm. Couldn't find a valid command.... What to do? */
patch->host_scribble = cmd->host_scribble;
else
hostdata->disconnected_Q =
- (Scsi_Cmnd *) cmd->host_scribble;
+ (struct scsi_cmnd *) cmd->host_scribble;
hostdata->connected = cmd;
/* We don't need to worry about 'initialize_SCp()' or 'hostdata->busy[]'
* But we DO need to fix the DPD bit so it's correct for this command.
*/
- if (is_dir_out(cmd))
+ if (cmd->sc_data_direction == DMA_TO_DEVICE)
write_wd33c93(regs, WD_DESTINATION_ID, cmd->device->id);
else
write_wd33c93(regs, WD_DESTINATION_ID,
}
int
-wd33c93_host_reset(Scsi_Cmnd * SCpnt)
+wd33c93_host_reset(struct scsi_cmnd * SCpnt)
{
struct Scsi_Host *instance;
struct WD33C93_hostdata *hostdata;
}
int
-wd33c93_abort(Scsi_Cmnd * cmd)
+wd33c93_abort(struct scsi_cmnd * cmd)
{
struct Scsi_Host *instance;
struct WD33C93_hostdata *hostdata;
wd33c93_regs regs;
- Scsi_Cmnd *tmp, *prev;
+ struct scsi_cmnd *tmp, *prev;
disable_irq(cmd->device->host->irq);
* from the input_Q.
*/
- tmp = (Scsi_Cmnd *) hostdata->input_Q;
- prev = 0;
+ tmp = (struct scsi_cmnd *) hostdata->input_Q;
+ prev = NULL;
while (tmp) {
if (tmp == cmd) {
if (prev)
prev->host_scribble = cmd->host_scribble;
else
hostdata->input_Q =
- (Scsi_Cmnd *) cmd->host_scribble;
+ (struct scsi_cmnd *) cmd->host_scribble;
cmd->host_scribble = NULL;
cmd->result = DID_ABORT << 16;
printk
return SUCCESS;
}
prev = tmp;
- tmp = (Scsi_Cmnd *) tmp->host_scribble;
+ tmp = (struct scsi_cmnd *) tmp->host_scribble;
}
/*
* an ABORT_SNOOZE and hope for the best...
*/
- tmp = (Scsi_Cmnd *) hostdata->disconnected_Q;
+ tmp = (struct scsi_cmnd *) hostdata->disconnected_Q;
while (tmp) {
if (tmp == cmd) {
printk
enable_irq(cmd->device->host->irq);
return FAILED;
}
- tmp = (Scsi_Cmnd *) tmp->host_scribble;
+ tmp = (struct scsi_cmnd *) tmp->host_scribble;
}
/*
char *bp;
char tbuf[128];
struct WD33C93_hostdata *hd;
- Scsi_Cmnd *cmd;
+ struct scsi_cmnd *cmd;
int x, i;
static int stop = 0;
if (hd->proc & PR_CONNECTED) {
strcat(bp, "\nconnected: ");
if (hd->connected) {
- cmd = (Scsi_Cmnd *) hd->connected;
+ cmd = (struct scsi_cmnd *) hd->connected;
sprintf(tbuf, " %ld-%d:%d(%02x)",
cmd->pid, cmd->device->id, cmd->device->lun, cmd->cmnd[0]);
strcat(bp, tbuf);
}
if (hd->proc & PR_INPUTQ) {
strcat(bp, "\ninput_Q: ");
- cmd = (Scsi_Cmnd *) hd->input_Q;
+ cmd = (struct scsi_cmnd *) hd->input_Q;
while (cmd) {
sprintf(tbuf, " %ld-%d:%d(%02x)",
cmd->pid, cmd->device->id, cmd->device->lun, cmd->cmnd[0]);
strcat(bp, tbuf);
- cmd = (Scsi_Cmnd *) cmd->host_scribble;
+ cmd = (struct scsi_cmnd *) cmd->host_scribble;
}
}
if (hd->proc & PR_DISCQ) {
strcat(bp, "\ndisconnected_Q:");
- cmd = (Scsi_Cmnd *) hd->disconnected_Q;
+ cmd = (struct scsi_cmnd *) hd->disconnected_Q;
while (cmd) {
sprintf(tbuf, " %ld-%d:%d(%02x)",
cmd->pid, cmd->device->id, cmd->device->lun, cmd->cmnd[0]);
strcat(bp, tbuf);
- cmd = (Scsi_Cmnd *) cmd->host_scribble;
+ cmd = (struct scsi_cmnd *) cmd->host_scribble;
}
}
strcat(bp, "\n");