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 @@
#include <linux/workqueue.h>
#include "scsi.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);
typedef struct {
......@@ -49,11 +49,11 @@ typedef struct {
#define NO_HOSTS 4
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
void ppa_wakeup(void *ref)
static void ppa_wakeup(void *ref)
{
ppa_struct *ppa_dev = (ppa_struct *) ref;
......@@ -71,7 +71,7 @@ void ppa_wakeup(void *ref)
return;
}
int ppa_release(struct Scsi_Host *host)
static int ppa_release(struct Scsi_Host *host)
{
int host_no = host->unique_id;
......@@ -114,13 +114,14 @@ static Scsi_Host_Template driver_template = {
.cmd_per_lun = 1,
.use_clustering = ENABLE_CLUSTERING,
};
#include "scsi_module.c"
/*
* Start of Chipset kludges
*/
int ppa_detect(Scsi_Host_Template * host)
static int ppa_detect(Scsi_Host_Template * host)
{
struct Scsi_Host *hreg = NULL;
int ports;
......@@ -160,11 +161,14 @@ int ppa_detect(Scsi_Host_Template * host)
while (ppa_hosts[i].p_busy) {
schedule(); /* We are safe to schedule here */
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",
i);
parport_unregister_device(ppa_hosts[i].dev);
spin_lock_irq(ppa_hosts[i].cur_cmd->device->host->host_lock);
parport_unregister_device(ppa_hosts[i].
dev);
spin_lock_irq(ppa_hosts[i].cur_cmd->
device->host->host_lock);
return 0;
}
}
......@@ -218,7 +222,7 @@ int ppa_detect(Scsi_Host_Template * host)
host->can_queue = PPA_CAN_QUEUE;
host->sg_tablesize = ppa_sg;
hreg = scsi_register(host, 0);
if(hreg == NULL)
if (hreg == NULL)
continue;
hreg->io_port = pb->base;
hreg->n_io_port = ports;
......@@ -230,10 +234,14 @@ int ppa_detect(Scsi_Host_Template * host)
if (nhosts == 0) {
if (try_again == 1) {
printk("WARNING - no ppa compatible devices found.\n");
printk(" As of 31/Aug/1998 Iomega started shipping parallel\n");
printk(" 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
(" As of 31/Aug/1998 Iomega started shipping parallel\n");
printk
(" 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");
return 0;
}
......@@ -270,8 +278,7 @@ static inline int ppa_proc_write(int hostno, char *buffer, int length)
return (-EINVAL);
}
int ppa_proc_info(struct Scsi_Host *host, char *buffer, char **start, off_t offset,
int length, int inout)
static int ppa_proc_info(struct Scsi_Host *host, char *buffer, char **start, off_t offset, int length, int inout)
{
int i;
int len = 0;
......@@ -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);
len += sprintf(buffer + len, "Version : %s\n", PPA_VERSION);
len += 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]);
len +=
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
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
/* Request for beyond end of buffer */
......@@ -333,9 +345,9 @@ static unsigned char ppa_wait(int host_no)
k = PPA_SPIN_TMO;
/* Wait for bit 6 and 7 - PJC */
for (r = r_str (ppb); ((r & 0xc0)!=0xc0) && (k); k--) {
udelay (1);
r = r_str (ppb);
for (r = r_str(ppb); ((r & 0xc0) != 0xc0) && (k); k--) {
udelay(1);
r = r_str(ppb);
}
/*
......@@ -371,9 +383,10 @@ static inline void epp_reset(unsigned short ppb)
*/
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 */
for (i = 0; i < 100; i++) {
......@@ -558,8 +571,7 @@ static inline void ppa_connect(int host_no, int flag)
ppa_c_pulse(ppb, 0);
ppa_c_pulse(ppb, 0x3c);
ppa_c_pulse(ppb, 0x20);
if ((flag == CONNECT_EPP_MAYBE) &&
IN_EPP_MODE(ppa_hosts[host_no].mode))
if ((flag == CONNECT_EPP_MAYBE) && IN_EPP_MODE(ppa_hosts[host_no].mode))
ppa_c_pulse(ppb, 0xcf);
else
ppa_c_pulse(ppb, 0x8f);
......@@ -683,9 +695,7 @@ static int ppa_completion(Scsi_Cmnd * cmd)
v = cmd->cmnd[0];
bulk = ((v == READ_6) ||
(v == READ_10) ||
(v == WRITE_6) ||
(v == WRITE_10));
(v == READ_10) || (v == WRITE_6) || (v == WRITE_10));
/*
* We only get here if the drive is ready to comunicate,
......@@ -721,10 +731,11 @@ static int ppa_completion(Scsi_Cmnd * cmd)
* jiffy/2 = 5ms = 5000 loops
*/
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);
if(!k)
if (!k)
return 0;
}
......@@ -748,8 +759,11 @@ static int ppa_completion(Scsi_Cmnd * cmd)
/* if scatter/gather, advance to the next segment */
if (cmd->SCp.buffers_residual--) {
cmd->SCp.buffer++;
cmd->SCp.this_residual = cmd->SCp.buffer->length;
cmd->SCp.ptr = page_address(cmd->SCp.buffer->page) + cmd->SCp.buffer->offset;
cmd->SCp.this_residual =
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 */
......@@ -811,7 +825,8 @@ static void ppa_interrupt(void *data)
printk("ppa: bad interrupt (???)\n");
break;
default:
printk("ppa: bad return code (%02x)\n", (cmd->result >> 16) & 0xff);
printk("ppa: bad return code (%02x)\n",
(cmd->result >> 16) & 0xff);
}
#endif
......@@ -868,7 +883,8 @@ static int ppa_engine(ppa_struct * tmp, Scsi_Cmnd * cmd)
if (retv) {
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);
return 0;
} else {
......@@ -898,9 +914,12 @@ static int ppa_engine(ppa_struct * tmp, Scsi_Cmnd * cmd)
case 4: /* Phase 4 - Setup scatter/gather buffers */
if (cmd->use_sg) {
/* 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.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 fill the only available buffer */
cmd->SCp.buffer = NULL;
......@@ -933,7 +952,8 @@ static int ppa_engine(ppa_struct * tmp, Scsi_Cmnd * cmd)
/* Check for optional message byte */
if (ppa_wait(host_no) == (unsigned char) 0xf0)
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 */
break;
......@@ -944,7 +964,7 @@ static int ppa_engine(ppa_struct * tmp, Scsi_Cmnd * cmd)
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;
......@@ -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
* 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[])
{
ip[0] = 0x40;
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) {
ip[0] = 0xff;
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)
ip[2] = 1023;
}
return 0;
}
int ppa_abort(Scsi_Cmnd * cmd)
static int ppa_abort(Scsi_Cmnd * cmd)
{
int host_no = cmd->device->host->unique_id;
/*
......@@ -1017,7 +1037,7 @@ static void ppa_reset_pulse(unsigned int base)
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;
......@@ -1038,8 +1058,7 @@ static int device_check(int host_no)
/* 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. */
static char cmd[6] =
{0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
static char cmd[6] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
int loop, old_mode, status, k, ppb = PPA_BASE(host_no);
unsigned char l;
......@@ -1056,8 +1075,8 @@ static int device_check(int host_no)
ppa_disconnect(host_no);
continue;
}
printk("ppa: Found device at ID %i, Attempting to use %s\n", loop,
PPA_MODE_STRING[ppa_hosts[host_no].mode]);
printk("ppa: Found device at ID %i, Attempting to use %s\n",
loop, PPA_MODE_STRING[ppa_hosts[host_no].mode]);
/* Send SCSI command */
status = 1;
......@@ -1079,7 +1098,8 @@ static int device_check(int host_no)
ppa_hosts[host_no].mode = old_mode;
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;
}
w_ctr(ppb, 0x0c);
......@@ -1103,12 +1123,13 @@ static int device_check(int host_no)
ppa_hosts[host_no].mode = old_mode;
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;
}
ppa_disconnect(host_no);
printk("ppa: Communication established with ID %i using %s\n", loop,
PPA_MODE_STRING[ppa_hosts[host_no].mode]);
printk("ppa: Communication established with ID %i using %s\n",
loop, PPA_MODE_STRING[ppa_hosts[host_no].mode]);
ppa_connect(host_no, CONNECT_EPP_MAYBE);
ppa_reset_pulse(ppb);
udelay(1000);
......@@ -1119,4 +1140,5 @@ static int device_check(int host_no)
printk("ppa: No devices found, aborting driver load.\n");
return 1;
}
MODULE_LICENSE("GPL");
......@@ -161,14 +161,14 @@ static int ppa_out(int, char *, int);
#define ppa_release 0
#endif
int ppa_detect(Scsi_Host_Template *);
static int ppa_detect(Scsi_Host_Template *);
const char *ppa_info(struct Scsi_Host *);
int ppa_command(Scsi_Cmnd *);
int ppa_queuecommand(Scsi_Cmnd *, void (*done) (Scsi_Cmnd *));
int ppa_abort(Scsi_Cmnd *);
int ppa_reset(Scsi_Cmnd *);
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_queuecommand(Scsi_Cmnd *, void (*done) (Scsi_Cmnd *));
static int ppa_abort(Scsi_Cmnd *);
static int ppa_reset(Scsi_Cmnd *);
static int ppa_proc_info(struct Scsi_Host *host, char *, char **, off_t, int, int);
static int ppa_biosparam(struct scsi_device *, struct block_device *,
sector_t, int *);
#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