Commit 64a29c61 authored by Alexander Viro's avatar Alexander Viro Committed by Linus Torvalds

[PATCH] scsi/ppa.c cleanup and fixes (1/9)

	* ppa.c fed through Lindent, functions unused elsewhere (by now -
	  all of them) made static.
parent 1f9530ba
...@@ -21,7 +21,7 @@ ...@@ -21,7 +21,7 @@
#include <linux/workqueue.h> #include <linux/workqueue.h>
#include "scsi.h" #include "scsi.h"
#include "hosts.h" #include "hosts.h"
int ppa_release(struct Scsi_Host *); static int ppa_release(struct Scsi_Host *);
static void ppa_reset_pulse(unsigned int base); static void ppa_reset_pulse(unsigned int base);
typedef struct { typedef struct {
...@@ -49,11 +49,11 @@ typedef struct { ...@@ -49,11 +49,11 @@ typedef struct {
#define NO_HOSTS 4 #define NO_HOSTS 4
static ppa_struct ppa_hosts[NO_HOSTS] = static ppa_struct ppa_hosts[NO_HOSTS] =
{PPA_EMPTY, PPA_EMPTY, PPA_EMPTY, PPA_EMPTY}; { PPA_EMPTY, PPA_EMPTY, PPA_EMPTY, PPA_EMPTY };
#define PPA_BASE(x) ppa_hosts[(x)].base #define PPA_BASE(x) ppa_hosts[(x)].base
void ppa_wakeup(void *ref) static void ppa_wakeup(void *ref)
{ {
ppa_struct *ppa_dev = (ppa_struct *) ref; ppa_struct *ppa_dev = (ppa_struct *) ref;
...@@ -71,7 +71,7 @@ void ppa_wakeup(void *ref) ...@@ -71,7 +71,7 @@ void ppa_wakeup(void *ref)
return; return;
} }
int ppa_release(struct Scsi_Host *host) static int ppa_release(struct Scsi_Host *host)
{ {
int host_no = host->unique_id; int host_no = host->unique_id;
...@@ -114,13 +114,14 @@ static Scsi_Host_Template driver_template = { ...@@ -114,13 +114,14 @@ static Scsi_Host_Template driver_template = {
.cmd_per_lun = 1, .cmd_per_lun = 1,
.use_clustering = ENABLE_CLUSTERING, .use_clustering = ENABLE_CLUSTERING,
}; };
#include "scsi_module.c" #include "scsi_module.c"
/* /*
* Start of Chipset kludges * Start of Chipset kludges
*/ */
int ppa_detect(Scsi_Host_Template * host) static int ppa_detect(Scsi_Host_Template * host)
{ {
struct Scsi_Host *hreg = NULL; struct Scsi_Host *hreg = NULL;
int ports; int ports;
...@@ -160,11 +161,14 @@ int ppa_detect(Scsi_Host_Template * host) ...@@ -160,11 +161,14 @@ int ppa_detect(Scsi_Host_Template * host)
while (ppa_hosts[i].p_busy) { while (ppa_hosts[i].p_busy) {
schedule(); /* We are safe to schedule here */ schedule(); /* We are safe to schedule here */
if (time_after(jiffies, now + 3 * HZ)) { if (time_after(jiffies, now + 3 * HZ)) {
printk(KERN_ERR "ppa%d: failed to claim parport because a " printk(KERN_ERR
"ppa%d: failed to claim parport because a "
"pardevice is owning the port for too longtime!\n", "pardevice is owning the port for too longtime!\n",
i); i);
parport_unregister_device(ppa_hosts[i].dev); parport_unregister_device(ppa_hosts[i].
spin_lock_irq(ppa_hosts[i].cur_cmd->device->host->host_lock); dev);
spin_lock_irq(ppa_hosts[i].cur_cmd->
device->host->host_lock);
return 0; return 0;
} }
} }
...@@ -218,7 +222,7 @@ int ppa_detect(Scsi_Host_Template * host) ...@@ -218,7 +222,7 @@ int ppa_detect(Scsi_Host_Template * host)
host->can_queue = PPA_CAN_QUEUE; host->can_queue = PPA_CAN_QUEUE;
host->sg_tablesize = ppa_sg; host->sg_tablesize = ppa_sg;
hreg = scsi_register(host, 0); hreg = scsi_register(host, 0);
if(hreg == NULL) if (hreg == NULL)
continue; continue;
hreg->io_port = pb->base; hreg->io_port = pb->base;
hreg->n_io_port = ports; hreg->n_io_port = ports;
...@@ -230,10 +234,14 @@ int ppa_detect(Scsi_Host_Template * host) ...@@ -230,10 +234,14 @@ int ppa_detect(Scsi_Host_Template * host)
if (nhosts == 0) { if (nhosts == 0) {
if (try_again == 1) { if (try_again == 1) {
printk("WARNING - no ppa compatible devices found.\n"); printk("WARNING - no ppa compatible devices found.\n");
printk(" As of 31/Aug/1998 Iomega started shipping parallel\n"); printk
printk(" port ZIP drives with a different interface which is\n"); (" As of 31/Aug/1998 Iomega started shipping parallel\n");
printk(" supported by the imm (ZIP Plus) driver. If the\n"); printk
printk(" cable is marked with \"AutoDetect\", this is what has\n"); (" port ZIP drives with a different interface which is\n");
printk
(" supported by the imm (ZIP Plus) driver. If the\n");
printk
(" cable is marked with \"AutoDetect\", this is what has\n");
printk(" happened.\n"); printk(" happened.\n");
return 0; return 0;
} }
...@@ -270,8 +278,7 @@ static inline int ppa_proc_write(int hostno, char *buffer, int length) ...@@ -270,8 +278,7 @@ static inline int ppa_proc_write(int hostno, char *buffer, int length)
return (-EINVAL); return (-EINVAL);
} }
int ppa_proc_info(struct Scsi_Host *host, char *buffer, char **start, off_t offset, static int ppa_proc_info(struct Scsi_Host *host, char *buffer, char **start, off_t offset, int length, int inout)
int length, int inout)
{ {
int i; int i;
int len = 0; int len = 0;
...@@ -284,10 +291,15 @@ int ppa_proc_info(struct Scsi_Host *host, char *buffer, char **start, off_t offs ...@@ -284,10 +291,15 @@ int ppa_proc_info(struct Scsi_Host *host, char *buffer, char **start, off_t offs
return ppa_proc_write(i, buffer, length); return ppa_proc_write(i, buffer, length);
len += sprintf(buffer + len, "Version : %s\n", PPA_VERSION); len += sprintf(buffer + len, "Version : %s\n", PPA_VERSION);
len += sprintf(buffer + len, "Parport : %s\n", ppa_hosts[i].dev->port->name); len +=
len += sprintf(buffer + len, "Mode : %s\n", PPA_MODE_STRING[ppa_hosts[i].mode]); sprintf(buffer + len, "Parport : %s\n",
ppa_hosts[i].dev->port->name);
len +=
sprintf(buffer + len, "Mode : %s\n",
PPA_MODE_STRING[ppa_hosts[i].mode]);
#if PPA_DEBUG > 0 #if PPA_DEBUG > 0
len += sprintf(buffer + len, "recon_tmo : %lu\n", ppa_hosts[i].recon_tmo); len +=
sprintf(buffer + len, "recon_tmo : %lu\n", ppa_hosts[i].recon_tmo);
#endif #endif
/* Request for beyond end of buffer */ /* Request for beyond end of buffer */
...@@ -333,9 +345,9 @@ static unsigned char ppa_wait(int host_no) ...@@ -333,9 +345,9 @@ static unsigned char ppa_wait(int host_no)
k = PPA_SPIN_TMO; k = PPA_SPIN_TMO;
/* Wait for bit 6 and 7 - PJC */ /* Wait for bit 6 and 7 - PJC */
for (r = r_str (ppb); ((r & 0xc0)!=0xc0) && (k); k--) { for (r = r_str(ppb); ((r & 0xc0) != 0xc0) && (k); k--) {
udelay (1); udelay(1);
r = r_str (ppb); r = r_str(ppb);
} }
/* /*
...@@ -371,9 +383,10 @@ static inline void epp_reset(unsigned short ppb) ...@@ -371,9 +383,10 @@ static inline void epp_reset(unsigned short ppb)
*/ */
static inline void ecp_sync(unsigned short hostno) static inline void ecp_sync(unsigned short hostno)
{ {
int i, ppb_hi=ppa_hosts[hostno].dev->port->base_hi; int i, ppb_hi = ppa_hosts[hostno].dev->port->base_hi;
if (ppb_hi == 0) return; if (ppb_hi == 0)
return;
if ((r_ecr(ppb_hi) & 0xe0) == 0x60) { /* mode 011 == ECP fifo mode */ if ((r_ecr(ppb_hi) & 0xe0) == 0x60) { /* mode 011 == ECP fifo mode */
for (i = 0; i < 100; i++) { for (i = 0; i < 100; i++) {
...@@ -558,8 +571,7 @@ static inline void ppa_connect(int host_no, int flag) ...@@ -558,8 +571,7 @@ static inline void ppa_connect(int host_no, int flag)
ppa_c_pulse(ppb, 0); ppa_c_pulse(ppb, 0);
ppa_c_pulse(ppb, 0x3c); ppa_c_pulse(ppb, 0x3c);
ppa_c_pulse(ppb, 0x20); ppa_c_pulse(ppb, 0x20);
if ((flag == CONNECT_EPP_MAYBE) && if ((flag == CONNECT_EPP_MAYBE) && IN_EPP_MODE(ppa_hosts[host_no].mode))
IN_EPP_MODE(ppa_hosts[host_no].mode))
ppa_c_pulse(ppb, 0xcf); ppa_c_pulse(ppb, 0xcf);
else else
ppa_c_pulse(ppb, 0x8f); ppa_c_pulse(ppb, 0x8f);
...@@ -683,9 +695,7 @@ static int ppa_completion(Scsi_Cmnd * cmd) ...@@ -683,9 +695,7 @@ static int ppa_completion(Scsi_Cmnd * cmd)
v = cmd->cmnd[0]; v = cmd->cmnd[0];
bulk = ((v == READ_6) || bulk = ((v == READ_6) ||
(v == READ_10) || (v == READ_10) || (v == WRITE_6) || (v == WRITE_10));
(v == WRITE_6) ||
(v == WRITE_10));
/* /*
* We only get here if the drive is ready to comunicate, * We only get here if the drive is ready to comunicate,
...@@ -721,10 +731,11 @@ static int ppa_completion(Scsi_Cmnd * cmd) ...@@ -721,10 +731,11 @@ static int ppa_completion(Scsi_Cmnd * cmd)
* jiffy/2 = 5ms = 5000 loops * jiffy/2 = 5ms = 5000 loops
*/ */
unsigned long k = ppa_hosts[host_no].recon_tmo; unsigned long k = ppa_hosts[host_no].recon_tmo;
for (; k && ((r = (r_str(ppb) & 0xf0)) & 0xc0) != 0xc0; k--) for (; k && ((r = (r_str(ppb) & 0xf0)) & 0xc0) != 0xc0;
k--)
udelay(1); udelay(1);
if(!k) if (!k)
return 0; return 0;
} }
...@@ -748,8 +759,11 @@ static int ppa_completion(Scsi_Cmnd * cmd) ...@@ -748,8 +759,11 @@ static int ppa_completion(Scsi_Cmnd * cmd)
/* if scatter/gather, advance to the next segment */ /* if scatter/gather, advance to the next segment */
if (cmd->SCp.buffers_residual--) { if (cmd->SCp.buffers_residual--) {
cmd->SCp.buffer++; cmd->SCp.buffer++;
cmd->SCp.this_residual = cmd->SCp.buffer->length; cmd->SCp.this_residual =
cmd->SCp.ptr = page_address(cmd->SCp.buffer->page) + cmd->SCp.buffer->offset; cmd->SCp.buffer->length;
cmd->SCp.ptr =
page_address(cmd->SCp.buffer->page) +
cmd->SCp.buffer->offset;
} }
} }
/* Now check to see if the drive is ready to comunicate */ /* Now check to see if the drive is ready to comunicate */
...@@ -811,7 +825,8 @@ static void ppa_interrupt(void *data) ...@@ -811,7 +825,8 @@ static void ppa_interrupt(void *data)
printk("ppa: bad interrupt (???)\n"); printk("ppa: bad interrupt (???)\n");
break; break;
default: default:
printk("ppa: bad return code (%02x)\n", (cmd->result >> 16) & 0xff); printk("ppa: bad return code (%02x)\n",
(cmd->result >> 16) & 0xff);
} }
#endif #endif
...@@ -868,7 +883,8 @@ static int ppa_engine(ppa_struct * tmp, Scsi_Cmnd * cmd) ...@@ -868,7 +883,8 @@ static int ppa_engine(ppa_struct * tmp, Scsi_Cmnd * cmd)
if (retv) { if (retv) {
if ((jiffies - tmp->jstart) > (1 * HZ)) { if ((jiffies - tmp->jstart) > (1 * HZ)) {
printk("ppa: Parallel port cable is unplugged!!\n"); printk
("ppa: Parallel port cable is unplugged!!\n");
ppa_fail(host_no, DID_BUS_BUSY); ppa_fail(host_no, DID_BUS_BUSY);
return 0; return 0;
} else { } else {
...@@ -898,9 +914,12 @@ static int ppa_engine(ppa_struct * tmp, Scsi_Cmnd * cmd) ...@@ -898,9 +914,12 @@ static int ppa_engine(ppa_struct * tmp, Scsi_Cmnd * cmd)
case 4: /* Phase 4 - Setup scatter/gather buffers */ case 4: /* Phase 4 - Setup scatter/gather buffers */
if (cmd->use_sg) { if (cmd->use_sg) {
/* if many buffers are available, start filling the first */ /* if many buffers are available, start filling the first */
cmd->SCp.buffer = (struct scatterlist *) cmd->request_buffer; cmd->SCp.buffer =
(struct scatterlist *) cmd->request_buffer;
cmd->SCp.this_residual = cmd->SCp.buffer->length; cmd->SCp.this_residual = cmd->SCp.buffer->length;
cmd->SCp.ptr = page_address(cmd->SCp.buffer->page) + cmd->SCp.buffer->offset; cmd->SCp.ptr =
page_address(cmd->SCp.buffer->page) +
cmd->SCp.buffer->offset;
} else { } else {
/* else fill the only available buffer */ /* else fill the only available buffer */
cmd->SCp.buffer = NULL; cmd->SCp.buffer = NULL;
...@@ -933,7 +952,8 @@ static int ppa_engine(ppa_struct * tmp, Scsi_Cmnd * cmd) ...@@ -933,7 +952,8 @@ static int ppa_engine(ppa_struct * tmp, Scsi_Cmnd * cmd)
/* Check for optional message byte */ /* Check for optional message byte */
if (ppa_wait(host_no) == (unsigned char) 0xf0) if (ppa_wait(host_no) == (unsigned char) 0xf0)
ppa_in(host_no, &h, 1); ppa_in(host_no, &h, 1);
cmd->result = (DID_OK << 16) + (h << 8) + (l & STATUS_MASK); cmd->result =
(DID_OK << 16) + (h << 8) + (l & STATUS_MASK);
} }
return 0; /* Finished */ return 0; /* Finished */
break; break;
...@@ -944,7 +964,7 @@ static int ppa_engine(ppa_struct * tmp, Scsi_Cmnd * cmd) ...@@ -944,7 +964,7 @@ static int ppa_engine(ppa_struct * tmp, Scsi_Cmnd * cmd)
return 0; return 0;
} }
int ppa_queuecommand(Scsi_Cmnd * cmd, void (*done) (Scsi_Cmnd *)) static int ppa_queuecommand(Scsi_Cmnd * cmd, void (*done) (Scsi_Cmnd *))
{ {
int host_no = cmd->device->host->unique_id; int host_no = cmd->device->host->unique_id;
...@@ -973,23 +993,23 @@ int ppa_queuecommand(Scsi_Cmnd * cmd, void (*done) (Scsi_Cmnd *)) ...@@ -973,23 +993,23 @@ int ppa_queuecommand(Scsi_Cmnd * cmd, void (*done) (Scsi_Cmnd *))
* be done in sd.c. Even if it gets fixed there, this will still * be done in sd.c. Even if it gets fixed there, this will still
* work. * work.
*/ */
int ppa_biosparam(struct scsi_device *sdev, struct block_device *dev, static int ppa_biosparam(struct scsi_device *sdev, struct block_device *dev,
sector_t capacity, int ip[]) sector_t capacity, int ip[])
{ {
ip[0] = 0x40; ip[0] = 0x40;
ip[1] = 0x20; ip[1] = 0x20;
ip[2] = ((unsigned long)capacity + 1) / (ip[0] * ip[1]); ip[2] = ((unsigned long) capacity + 1) / (ip[0] * ip[1]);
if (ip[2] > 1024) { if (ip[2] > 1024) {
ip[0] = 0xff; ip[0] = 0xff;
ip[1] = 0x3f; ip[1] = 0x3f;
ip[2] = ((unsigned long)capacity + 1) / (ip[0] * ip[1]); ip[2] = ((unsigned long) capacity + 1) / (ip[0] * ip[1]);
if (ip[2] > 1023) if (ip[2] > 1023)
ip[2] = 1023; ip[2] = 1023;
} }
return 0; return 0;
} }
int ppa_abort(Scsi_Cmnd * cmd) static int ppa_abort(Scsi_Cmnd * cmd)
{ {
int host_no = cmd->device->host->unique_id; int host_no = cmd->device->host->unique_id;
/* /*
...@@ -1017,7 +1037,7 @@ static void ppa_reset_pulse(unsigned int base) ...@@ -1017,7 +1037,7 @@ static void ppa_reset_pulse(unsigned int base)
w_ctr(base, 0xc); w_ctr(base, 0xc);
} }
int ppa_reset(Scsi_Cmnd * cmd) static int ppa_reset(Scsi_Cmnd * cmd)
{ {
int host_no = cmd->device->host->unique_id; int host_no = cmd->device->host->unique_id;
...@@ -1038,8 +1058,7 @@ static int device_check(int host_no) ...@@ -1038,8 +1058,7 @@ static int device_check(int host_no)
/* This routine looks for a device and then attempts to use EPP /* This routine looks for a device and then attempts to use EPP
to send a command. If all goes as planned then EPP is available. */ to send a command. If all goes as planned then EPP is available. */
static char cmd[6] = static char cmd[6] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
{0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
int loop, old_mode, status, k, ppb = PPA_BASE(host_no); int loop, old_mode, status, k, ppb = PPA_BASE(host_no);
unsigned char l; unsigned char l;
...@@ -1056,8 +1075,8 @@ static int device_check(int host_no) ...@@ -1056,8 +1075,8 @@ static int device_check(int host_no)
ppa_disconnect(host_no); ppa_disconnect(host_no);
continue; continue;
} }
printk("ppa: Found device at ID %i, Attempting to use %s\n", loop, printk("ppa: Found device at ID %i, Attempting to use %s\n",
PPA_MODE_STRING[ppa_hosts[host_no].mode]); loop, PPA_MODE_STRING[ppa_hosts[host_no].mode]);
/* Send SCSI command */ /* Send SCSI command */
status = 1; status = 1;
...@@ -1079,7 +1098,8 @@ static int device_check(int host_no) ...@@ -1079,7 +1098,8 @@ static int device_check(int host_no)
ppa_hosts[host_no].mode = old_mode; ppa_hosts[host_no].mode = old_mode;
goto second_pass; goto second_pass;
} }
printk("ppa: Unable to establish communication, aborting driver load.\n"); printk
("ppa: Unable to establish communication, aborting driver load.\n");
return 1; return 1;
} }
w_ctr(ppb, 0x0c); w_ctr(ppb, 0x0c);
...@@ -1103,12 +1123,13 @@ static int device_check(int host_no) ...@@ -1103,12 +1123,13 @@ static int device_check(int host_no)
ppa_hosts[host_no].mode = old_mode; ppa_hosts[host_no].mode = old_mode;
goto second_pass; goto second_pass;
} }
printk("ppa: Unable to establish communication, aborting driver load.\n"); printk
("ppa: Unable to establish communication, aborting driver load.\n");
return 1; return 1;
} }
ppa_disconnect(host_no); ppa_disconnect(host_no);
printk("ppa: Communication established with ID %i using %s\n", loop, printk("ppa: Communication established with ID %i using %s\n",
PPA_MODE_STRING[ppa_hosts[host_no].mode]); loop, PPA_MODE_STRING[ppa_hosts[host_no].mode]);
ppa_connect(host_no, CONNECT_EPP_MAYBE); ppa_connect(host_no, CONNECT_EPP_MAYBE);
ppa_reset_pulse(ppb); ppa_reset_pulse(ppb);
udelay(1000); udelay(1000);
...@@ -1119,4 +1140,5 @@ static int device_check(int host_no) ...@@ -1119,4 +1140,5 @@ static int device_check(int host_no)
printk("ppa: No devices found, aborting driver load.\n"); printk("ppa: No devices found, aborting driver load.\n");
return 1; return 1;
} }
MODULE_LICENSE("GPL"); MODULE_LICENSE("GPL");
...@@ -161,14 +161,14 @@ static int ppa_out(int, char *, int); ...@@ -161,14 +161,14 @@ static int ppa_out(int, char *, int);
#define ppa_release 0 #define ppa_release 0
#endif #endif
int ppa_detect(Scsi_Host_Template *); static int ppa_detect(Scsi_Host_Template *);
const char *ppa_info(struct Scsi_Host *); const char *ppa_info(struct Scsi_Host *);
int ppa_command(Scsi_Cmnd *); int ppa_command(Scsi_Cmnd *);
int ppa_queuecommand(Scsi_Cmnd *, void (*done) (Scsi_Cmnd *)); static int ppa_queuecommand(Scsi_Cmnd *, void (*done) (Scsi_Cmnd *));
int ppa_abort(Scsi_Cmnd *); static int ppa_abort(Scsi_Cmnd *);
int ppa_reset(Scsi_Cmnd *); static int ppa_reset(Scsi_Cmnd *);
int ppa_proc_info(struct Scsi_Host *host, char *, char **, off_t, int, int); static int ppa_proc_info(struct Scsi_Host *host, char *, char **, off_t, int, int);
int ppa_biosparam(struct scsi_device *, struct block_device *, static int ppa_biosparam(struct scsi_device *, struct block_device *,
sector_t, int *); sector_t, int *);
#endif /* _PPA_H */ #endif /* _PPA_H */
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment