aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/scsi
diff options
context:
space:
mode:
authorAlan Cox <alan@lxorguk.ukuu.org.uk>2007-09-20 10:15:27 -0400
committerJames Bottomley <jejb@mulgrave.localdomain>2007-10-12 14:49:19 -0400
commit1a1d641490e59b6d71e3a4b38616161ee6738aac (patch)
tree978c2ff992ba6b7fed45fd2ff781d60187eaeb4c /drivers/scsi
parentf72abc2110dc07892ed815f46e433cd97309ab7c (diff)
[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>
Diffstat (limited to 'drivers/scsi')
-rw-r--r--drivers/scsi/eata_pio.c88
1 files changed, 39 insertions, 49 deletions
diff --git a/drivers/scsi/eata_pio.c b/drivers/scsi/eata_pio.c
index f33ad01064a9..73260e590f22 100644
--- a/drivers/scsi/eata_pio.c
+++ b/drivers/scsi/eata_pio.c
@@ -107,59 +107,44 @@ static struct scsi_host_template driver_template;
107static int eata_pio_proc_info(struct Scsi_Host *shost, char *buffer, char **start, off_t offset, 107static int eata_pio_proc_info(struct Scsi_Host *shost, char *buffer, char **start, off_t offset,
108 int length, int rw) 108 int length, int rw)
109{ 109{
110 static u8 buff[512]; 110 int len = 0;
111 int size, len = 0; 111 off_t begin = 0, pos = 0;
112 off_t begin = 0, pos = 0;
113 112
114 if (rw) 113 if (rw)
115 return -ENOSYS; 114 return -ENOSYS;
116 if (offset == 0)
117 memset(buff, 0, sizeof(buff));
118 115
119 size = sprintf(buffer+len, "EATA (Extended Attachment) PIO driver version: " 116 len += sprintf(buffer+len, "EATA (Extended Attachment) PIO driver version: "
120 "%d.%d%s\n",VER_MAJOR, VER_MINOR, VER_SUB); 117 "%d.%d%s\n",VER_MAJOR, VER_MINOR, VER_SUB);
121 len += size; pos = begin + len; 118 len += sprintf(buffer + len, "queued commands: %10ld\n"
122 size = sprintf(buffer + len, "queued commands: %10ld\n"
123 "processed interrupts:%10ld\n", queue_counter, int_counter); 119 "processed interrupts:%10ld\n", queue_counter, int_counter);
124 len += size; pos = begin + len; 120 len += sprintf(buffer + len, "\nscsi%-2d: HBA %.10s\n",
125
126 size = sprintf(buffer + len, "\nscsi%-2d: HBA %.10s\n",
127 shost->host_no, SD(shost)->name); 121 shost->host_no, SD(shost)->name);
128 len += size; 122 len += sprintf(buffer + len, "Firmware revision: v%s\n",
129 pos = begin + len;
130 size = sprintf(buffer + len, "Firmware revision: v%s\n",
131 SD(shost)->revision); 123 SD(shost)->revision);
132 len += size; 124 len += sprintf(buffer + len, "IO: PIO\n");
133 pos = begin + len; 125 len += sprintf(buffer + len, "Base IO : %#.4x\n", (u32) shost->base);
134 size = sprintf(buffer + len, "IO: PIO\n"); 126 len += sprintf(buffer + len, "Host Bus: %s\n",
135 len += size;
136 pos = begin + len;
137 size = sprintf(buffer + len, "Base IO : %#.4x\n", (u32) shost->base);
138 len += size;
139 pos = begin + len;
140 size = sprintf(buffer + len, "Host Bus: %s\n",
141 (SD(shost)->bustype == 'P')?"PCI ": 127 (SD(shost)->bustype == 'P')?"PCI ":
142 (SD(shost)->bustype == 'E')?"EISA":"ISA "); 128 (SD(shost)->bustype == 'E')?"EISA":"ISA ");
143 129
144 len += size; 130 pos = begin + len;
145 pos = begin + len;
146 131
147 if (pos < offset) { 132 if (pos < offset) {
148 len = 0; 133 len = 0;
149 begin = pos; 134 begin = pos;
150 } 135 }
151 if (pos > offset + length) 136 if (pos > offset + length)
152 goto stop_output; 137 goto stop_output;
153 138
154 stop_output: 139stop_output:
155 DBG(DBG_PROC, printk("2pos: %ld offset: %ld len: %d\n", pos, offset, len)); 140 DBG(DBG_PROC, printk("2pos: %ld offset: %ld len: %d\n", pos, offset, len));
156 *start=buffer+(offset-begin); /* Start of wanted data */ 141 *start = buffer + (offset - begin); /* Start of wanted data */
157 len-=(offset-begin); /* Start slop */ 142 len -= (offset - begin); /* Start slop */
158 if(len>length) 143 if (len > length)
159 len = length; /* Ending slop */ 144 len = length; /* Ending slop */
160 DBG(DBG_PROC, printk("3pos: %ld offset: %ld len: %d\n", pos, offset, len)); 145 DBG(DBG_PROC, printk("3pos: %ld offset: %ld len: %d\n", pos, offset, len));
161 146
162 return (len); 147 return len;
163} 148}
164 149
165static int eata_pio_release(struct Scsi_Host *sh) 150static int eata_pio_release(struct Scsi_Host *sh)
@@ -438,7 +423,7 @@ static int eata_pio_queue(struct scsi_cmnd *cmd,
438 "returning DID_BUS_BUSY, done.\n", cmd->pid); 423 "returning DID_BUS_BUSY, done.\n", cmd->pid);
439 done(cmd); 424 done(cmd);
440 cp->status = FREE; 425 cp->status = FREE;
441 return (0); 426 return 0;
442 } 427 }
443 /* FIXME: timeout */ 428 /* FIXME: timeout */
444 while (!(inb(base + HA_RSTATUS) & HA_SDRQ)) 429 while (!(inb(base + HA_RSTATUS) & HA_SDRQ))
@@ -452,7 +437,7 @@ static int eata_pio_queue(struct scsi_cmnd *cmd,
452 "Queued base %#.4lx pid: %ld " 437 "Queued base %#.4lx pid: %ld "
453 "slot %d irq %d\n", sh->base, cmd->pid, y, sh->irq)); 438 "slot %d irq %d\n", sh->base, cmd->pid, y, sh->irq));
454 439
455 return (0); 440 return 0;
456} 441}
457 442
458static int eata_pio_abort(struct scsi_cmnd *cmd) 443static 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
589 cp.cp_cdb[5] = 0; 574 cp.cp_cdb[5] = 0;
590 575
591 if (eata_pio_send_command(base, EATA_CMD_PIO_SEND_CP)) 576 if (eata_pio_send_command(base, EATA_CMD_PIO_SEND_CP))
592 return (NULL); 577 return NULL;
593 while (!(inb(base + HA_RSTATUS) & HA_SDRQ)); 578
579 while (!(inb(base + HA_RSTATUS) & HA_SDRQ))
580 cpu_relax();
581
594 outsw(base + HA_RDATA, &cp, cplen); 582 outsw(base + HA_RDATA, &cp, cplen);
595 outb(EATA_CMD_PIO_TRUNC, base + HA_WCOMMAND); 583 outb(EATA_CMD_PIO_TRUNC, base + HA_WCOMMAND);
596 for (z = 0; z < cppadlen; z++) 584 for (z = 0; z < cppadlen; z++)
597 outw(0, base + HA_RDATA); 585 outw(0, base + HA_RDATA);
598 586
599 while (inb(base + HA_RSTATUS) & HA_SBUSY); 587 while (inb(base + HA_RSTATUS) & HA_SBUSY)
588 cpu_relax();
589
600 if (inb(base + HA_RSTATUS) & HA_SERROR) 590 if (inb(base + HA_RSTATUS) & HA_SERROR)
601 return (NULL); 591 return NULL;
602 else if (!(inb(base + HA_RSTATUS) & HA_SDRQ)) 592 else if (!(inb(base + HA_RSTATUS) & HA_SDRQ))
603 return (NULL); 593 return NULL;
604 else { 594 else {
605 insw(base + HA_RDATA, &buff, 127); 595 insw(base + HA_RDATA, &buff, 127);
606 while (inb(base + HA_RSTATUS) & HA_SDRQ) 596 while (inb(base + HA_RSTATUS) & HA_SDRQ)
607 inw(base + HA_RDATA); 597 inw(base + HA_RDATA);
608 return (buff); 598 return buff;
609 } 599 }
610} 600}
611 601