Archived
14
0
Fork 0

[SCSI] eata_pio: Clean up proc handling, bracketing and use cpu_relax()

So its ancient, its crap, but it kept showing up in my scans for stuff
that wanted fixing...

- Redo the proc code to be far cleaner
- Clean various return (0) type constructs
- Use cpu_relax()

The various waits ought to time out but thats another issue and probably
not worth solving.

Signed-off-by: Alan Cox <alan@redhat.com>
Signed-off-by: James Bottomley <James.Bottomley@SteelEye.com>
This commit is contained in:
Alan Cox 2007-09-20 15:15:27 +01:00 committed by James Bottomley
parent f72abc2110
commit 1a1d641490

View file

@ -107,59 +107,44 @@ static struct scsi_host_template driver_template;
static int eata_pio_proc_info(struct Scsi_Host *shost, char *buffer, char **start, off_t offset, static int eata_pio_proc_info(struct Scsi_Host *shost, char *buffer, char **start, off_t offset,
int length, int rw) int length, int rw)
{ {
static u8 buff[512]; int len = 0;
int size, len = 0; off_t begin = 0, pos = 0;
off_t begin = 0, pos = 0;
if (rw) if (rw)
return -ENOSYS; return -ENOSYS;
if (offset == 0)
memset(buff, 0, sizeof(buff));
size = sprintf(buffer+len, "EATA (Extended Attachment) PIO driver version: " len += sprintf(buffer+len, "EATA (Extended Attachment) PIO driver version: "
"%d.%d%s\n",VER_MAJOR, VER_MINOR, VER_SUB); "%d.%d%s\n",VER_MAJOR, VER_MINOR, VER_SUB);
len += size; pos = begin + len; len += sprintf(buffer + len, "queued commands: %10ld\n"
size = sprintf(buffer + len, "queued commands: %10ld\n"
"processed interrupts:%10ld\n", queue_counter, int_counter); "processed interrupts:%10ld\n", queue_counter, int_counter);
len += size; pos = begin + len; len += sprintf(buffer + len, "\nscsi%-2d: HBA %.10s\n",
size = sprintf(buffer + len, "\nscsi%-2d: HBA %.10s\n",
shost->host_no, SD(shost)->name); shost->host_no, SD(shost)->name);
len += size; len += sprintf(buffer + len, "Firmware revision: v%s\n",
pos = begin + len;
size = sprintf(buffer + len, "Firmware revision: v%s\n",
SD(shost)->revision); SD(shost)->revision);
len += size; len += sprintf(buffer + len, "IO: PIO\n");
pos = begin + len; len += sprintf(buffer + len, "Base IO : %#.4x\n", (u32) shost->base);
size = sprintf(buffer + len, "IO: PIO\n"); len += sprintf(buffer + len, "Host Bus: %s\n",
len += size;
pos = begin + len;
size = sprintf(buffer + len, "Base IO : %#.4x\n", (u32) shost->base);
len += size;
pos = begin + len;
size = sprintf(buffer + len, "Host Bus: %s\n",
(SD(shost)->bustype == 'P')?"PCI ": (SD(shost)->bustype == 'P')?"PCI ":
(SD(shost)->bustype == 'E')?"EISA":"ISA "); (SD(shost)->bustype == 'E')?"EISA":"ISA ");
len += size; pos = begin + len;
pos = begin + len;
if (pos < offset) { if (pos < offset) {
len = 0; len = 0;
begin = pos; begin = pos;
} }
if (pos > offset + length) if (pos > offset + length)
goto stop_output; goto stop_output;
stop_output: stop_output:
DBG(DBG_PROC, printk("2pos: %ld offset: %ld len: %d\n", pos, offset, len)); DBG(DBG_PROC, printk("2pos: %ld offset: %ld len: %d\n", pos, offset, len));
*start=buffer+(offset-begin); /* Start of wanted data */ *start = buffer + (offset - begin); /* Start of wanted data */
len-=(offset-begin); /* Start slop */ len -= (offset - begin); /* Start slop */
if(len>length) if (len > length)
len = length; /* Ending slop */ len = length; /* Ending slop */
DBG(DBG_PROC, printk("3pos: %ld offset: %ld len: %d\n", pos, offset, len)); DBG(DBG_PROC, printk("3pos: %ld offset: %ld len: %d\n", pos, offset, len));
return (len); return len;
} }
static int eata_pio_release(struct Scsi_Host *sh) static int eata_pio_release(struct Scsi_Host *sh)
@ -438,7 +423,7 @@ static int eata_pio_queue(struct scsi_cmnd *cmd,
"returning DID_BUS_BUSY, done.\n", cmd->pid); "returning DID_BUS_BUSY, done.\n", cmd->pid);
done(cmd); done(cmd);
cp->status = FREE; cp->status = FREE;
return (0); return 0;
} }
/* FIXME: timeout */ /* FIXME: timeout */
while (!(inb(base + HA_RSTATUS) & HA_SDRQ)) while (!(inb(base + HA_RSTATUS) & HA_SDRQ))
@ -452,7 +437,7 @@ static int eata_pio_queue(struct scsi_cmnd *cmd,
"Queued base %#.4lx pid: %ld " "Queued base %#.4lx pid: %ld "
"slot %d irq %d\n", sh->base, cmd->pid, y, sh->irq)); "slot %d irq %d\n", sh->base, cmd->pid, y, sh->irq));
return (0); return 0;
} }
static int eata_pio_abort(struct scsi_cmnd *cmd) static int eata_pio_abort(struct scsi_cmnd *cmd)
@ -589,23 +574,28 @@ static char *get_pio_board_data(unsigned long base, unsigned int irq, unsigned i
cp.cp_cdb[5] = 0; cp.cp_cdb[5] = 0;
if (eata_pio_send_command(base, EATA_CMD_PIO_SEND_CP)) if (eata_pio_send_command(base, EATA_CMD_PIO_SEND_CP))
return (NULL); return NULL;
while (!(inb(base + HA_RSTATUS) & HA_SDRQ));
while (!(inb(base + HA_RSTATUS) & HA_SDRQ))
cpu_relax();
outsw(base + HA_RDATA, &cp, cplen); outsw(base + HA_RDATA, &cp, cplen);
outb(EATA_CMD_PIO_TRUNC, base + HA_WCOMMAND); outb(EATA_CMD_PIO_TRUNC, base + HA_WCOMMAND);
for (z = 0; z < cppadlen; z++) for (z = 0; z < cppadlen; z++)
outw(0, base + HA_RDATA); outw(0, base + HA_RDATA);
while (inb(base + HA_RSTATUS) & HA_SBUSY); while (inb(base + HA_RSTATUS) & HA_SBUSY)
cpu_relax();
if (inb(base + HA_RSTATUS) & HA_SERROR) if (inb(base + HA_RSTATUS) & HA_SERROR)
return (NULL); return NULL;
else if (!(inb(base + HA_RSTATUS) & HA_SDRQ)) else if (!(inb(base + HA_RSTATUS) & HA_SDRQ))
return (NULL); return NULL;
else { else {
insw(base + HA_RDATA, &buff, 127); insw(base + HA_RDATA, &buff, 127);
while (inb(base + HA_RSTATUS) & HA_SDRQ) while (inb(base + HA_RSTATUS) & HA_SDRQ)
inw(base + HA_RDATA); inw(base + HA_RDATA);
return (buff); return buff;
} }
} }