Commit 8e840158 authored by Alexander Viro's avatar Alexander Viro Committed by Linus Torvalds

[PATCH] scsi/imm.c cleanup and fixes (1/8)

	* imm.c fed through Lindent, functions unused elsewhere (by now -
	  all of them) made static.
parent 0968e60c
......@@ -14,14 +14,13 @@
#include <linux/config.h>
/* The following #define is to avoid a clash with hosts.c */
#define IMM_CODE 1
#define IMM_PROBE_SPP 0x0001
#define IMM_PROBE_PS2 0x0002
#define IMM_PROBE_ECR 0x0010
#define IMM_PROBE_EPP17 0x0100
#define IMM_PROBE_EPP19 0x0200
void imm_reset_pulse(unsigned int base);
static void imm_reset_pulse(unsigned int base);
static int device_check(int host_no);
#include <linux/blkdev.h>
......@@ -55,15 +54,14 @@ typedef struct {
#include "imm.h"
#define NO_HOSTS 4
static imm_struct imm_hosts[NO_HOSTS] =
{IMM_EMPTY, IMM_EMPTY, IMM_EMPTY, IMM_EMPTY};
{ IMM_EMPTY, IMM_EMPTY, IMM_EMPTY, IMM_EMPTY };
#define IMM_BASE(x) imm_hosts[(x)].base
#define IMM_BASE_HI(x) imm_hosts[(x)].base_hi
int parbus_base[NO_HOSTS] =
{0x03bc, 0x0378, 0x0278, 0x0000};
int parbus_base[NO_HOSTS] = { 0x03bc, 0x0378, 0x0278, 0x0000 };
void imm_wakeup(void *ref)
static void imm_wakeup(void *ref)
{
imm_struct *imm_dev = (imm_struct *) ref;
......@@ -81,7 +79,7 @@ void imm_wakeup(void *ref)
return;
}
int imm_release(struct Scsi_Host *host)
static int imm_release(struct Scsi_Host *host)
{
int host_no = host->unique_id;
......@@ -124,9 +122,10 @@ static Scsi_Host_Template driver_template = {
.cmd_per_lun = 1,
.use_clustering = ENABLE_CLUSTERING,
};
#include "scsi_module.c"
int imm_detect(Scsi_Host_Template * host)
static int imm_detect(Scsi_Host_Template * host)
{
struct Scsi_Host *hreg;
int ports;
......@@ -162,10 +161,12 @@ int imm_detect(Scsi_Host_Template * host)
while (imm_hosts[i].p_busy) {
schedule(); /* We are safe to schedule here */
if (time_after(jiffies, now + 3 * HZ)) {
printk(KERN_ERR "imm%d: failed to claim parport because a "
printk(KERN_ERR
"imm%d: failed to claim parport because a "
"pardevice is owning the port for too longtime!\n",
i);
parport_unregister_device (imm_hosts[i].dev);
parport_unregister_device(imm_hosts[i].
dev);
return 0;
}
}
......@@ -213,7 +214,7 @@ int imm_detect(Scsi_Host_Template * host)
host->can_queue = IMM_CAN_QUEUE;
host->sg_tablesize = imm_sg;
hreg = scsi_register(host, 0);
if(hreg == NULL)
if (hreg == NULL)
continue;
hreg->io_port = pb->base;
hreg->n_io_port = ports;
......@@ -253,8 +254,8 @@ static inline int imm_proc_write(int hostno, char *buffer, int length)
return (-EINVAL);
}
int imm_proc_info(struct Scsi_Host *host, char *buffer, char **start, off_t offset,
int length, int inout)
static int imm_proc_info(struct Scsi_Host *host, char *buffer, char **start,
off_t offset, int length, int inout)
{
int i;
int len = 0;
......@@ -267,8 +268,12 @@ int imm_proc_info(struct Scsi_Host *host, char *buffer, char **start, off_t offs
return imm_proc_write(i, buffer, length);
len += sprintf(buffer + len, "Version : %s\n", IMM_VERSION);
len += sprintf(buffer + len, "Parport : %s\n", imm_hosts[i].dev->port->name);
len += sprintf(buffer + len, "Mode : %s\n", IMM_MODE_STRING[imm_hosts[i].mode]);
len +=
sprintf(buffer + len, "Parport : %s\n",
imm_hosts[i].dev->port->name);
len +=
sprintf(buffer + len, "Mode : %s\n",
IMM_MODE_STRING[imm_hosts[i].mode]);
/* Request for beyond end of buffer */
if (offset > len)
......@@ -284,9 +289,11 @@ int imm_proc_info(struct Scsi_Host *host, char *buffer, char **start, off_t offs
#if IMM_DEBUG > 0
#define imm_fail(x,y) printk("imm: imm_fail(%i) from %s at line %d\n",\
y, __FUNCTION__, __LINE__); imm_fail_func(x,y);
static inline void imm_fail_func(int host_no, int error_code)
static inline void
imm_fail_func(int host_no, int error_code)
#else
static inline void imm_fail(int host_no, int error_code)
static inline void
imm_fail(int host_no, int error_code)
#endif
{
/* If we fail a device then we trash status / message bytes */
......@@ -389,7 +396,8 @@ static int imm_negotiate(imm_struct * tmp)
w_ctr(base, 0x06);
if (a) {
printk("IMM: IEEE1284 negotiate indicates no data available.\n");
printk
("IMM: IEEE1284 negotiate indicates no data available.\n");
imm_fail(tmp->host, DID_ERROR);
}
return a;
......@@ -412,9 +420,10 @@ static inline void epp_reset(unsigned short ppb)
*/
static inline void ecp_sync(unsigned short hostno)
{
int i, ppb_hi=IMM_BASE_HI(hostno);
int i, ppb_hi = IMM_BASE_HI(hostno);
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++) {
......@@ -748,7 +757,7 @@ static int imm_init(int host_no)
return 1;
}
static inline int imm_send_command(Scsi_Cmnd * cmd)
static inline int imm_send_command(Scsi_Cmnd *cmd)
{
int host_no = cmd->device->host->unique_id;
int k;
......@@ -768,7 +777,7 @@ static inline int imm_send_command(Scsi_Cmnd * cmd)
* The driver appears to remain stable if we speed up the parallel port
* i/o in this function, but not elsewhere.
*/
static int imm_completion(Scsi_Cmnd * cmd)
static int imm_completion(Scsi_Cmnd *cmd)
{
/* Return codes:
* -1 Error
......@@ -784,9 +793,7 @@ static int imm_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,
......@@ -818,10 +825,14 @@ static int imm_completion(Scsi_Cmnd * cmd)
}
/* determine if we should use burst I/O */
if (imm_hosts[host_no].rd == 0) {
fast = (bulk && (cmd->SCp.this_residual >= IMM_BURST_SIZE)) ? IMM_BURST_SIZE : 2;
fast = (bulk
&& (cmd->SCp.this_residual >=
IMM_BURST_SIZE)) ? IMM_BURST_SIZE : 2;
status = imm_out(host_no, cmd->SCp.ptr, fast);
} else {
fast = (bulk && (cmd->SCp.this_residual >= IMM_BURST_SIZE)) ? IMM_BURST_SIZE : 1;
fast = (bulk
&& (cmd->SCp.this_residual >=
IMM_BURST_SIZE)) ? IMM_BURST_SIZE : 1;
status = imm_in(host_no, cmd->SCp.ptr, fast);
}
......@@ -836,8 +847,11 @@ static int imm_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;
/*
* Make sure that we transfer even number of bytes
......@@ -875,7 +889,7 @@ static void imm_interrupt(void *data)
return;
}
if (imm_engine(tmp, cmd)) {
INIT_WORK(&tmp->imm_tq, imm_interrupt, (void *)tmp);
INIT_WORK(&tmp->imm_tq, imm_interrupt, (void *) tmp);
schedule_delayed_work(&tmp->imm_tq, 1);
return;
}
......@@ -909,7 +923,8 @@ static void imm_interrupt(void *data)
printk("imm: bad interrupt (???)\n");
break;
default:
printk("imm: bad return code (%02x)\n", (cmd->result >> 16) & 0xff);
printk("imm: bad return code (%02x)\n",
(cmd->result >> 16) & 0xff);
}
#endif
......@@ -925,7 +940,7 @@ static void imm_interrupt(void *data)
return;
}
static int imm_engine(imm_struct * tmp, Scsi_Cmnd * cmd)
static int imm_engine(imm_struct *tmp, Scsi_Cmnd *cmd)
{
int host_no = cmd->device->host->unique_id;
unsigned short ppb = IMM_BASE(host_no);
......@@ -976,9 +991,12 @@ static int imm_engine(imm_struct * tmp, Scsi_Cmnd * cmd)
case 4:
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;
......@@ -1064,7 +1082,7 @@ static int imm_engine(imm_struct * tmp, Scsi_Cmnd * cmd)
return 0;
}
int imm_queuecommand(Scsi_Cmnd * cmd, void (*done) (Scsi_Cmnd *))
static int imm_queuecommand(Scsi_Cmnd *cmd, void (*done)(Scsi_Cmnd *))
{
int host_no = cmd->device->host->unique_id;
......@@ -1081,7 +1099,8 @@ int imm_queuecommand(Scsi_Cmnd * cmd, void (*done) (Scsi_Cmnd *))
imm_pb_claim(host_no);
INIT_WORK(&imm_hosts[host_no].imm_tq, imm_interrupt, imm_hosts + host_no);
INIT_WORK(&imm_hosts[host_no].imm_tq, imm_interrupt,
imm_hosts + host_no);
schedule_work(&imm_hosts[host_no].imm_tq);
return 0;
......@@ -1093,21 +1112,21 @@ int imm_queuecommand(Scsi_Cmnd * cmd, void (*done) (Scsi_Cmnd *))
* be done in sd.c. Even if it gets fixed there, this will still
* work.
*/
int imm_biosparam(struct scsi_device *sdev, struct block_device *dev,
static int imm_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]);
}
return 0;
}
int imm_abort(Scsi_Cmnd * cmd)
static int imm_abort(Scsi_Cmnd *cmd)
{
int host_no = cmd->device->host->unique_id;
/*
......@@ -1127,7 +1146,7 @@ int imm_abort(Scsi_Cmnd * cmd)
}
}
void imm_reset_pulse(unsigned int base)
static void imm_reset_pulse(unsigned int base)
{
w_ctr(base, 0x04);
w_dtr(base, 0x40);
......@@ -1139,7 +1158,7 @@ void imm_reset_pulse(unsigned int base)
w_ctr(base, 0x04);
}
int imm_reset(Scsi_Cmnd * cmd)
static int imm_reset(Scsi_Cmnd *cmd)
{
int host_no = cmd->device->host->unique_id;
......@@ -1160,8 +1179,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 = IMM_BASE(host_no);
unsigned char l;
......@@ -1178,8 +1196,8 @@ static int device_check(int host_no)
imm_disconnect(host_no);
continue;
}
printk("imm: Found device at ID %i, Attempting to use %s\n", loop,
IMM_MODE_STRING[imm_hosts[host_no].mode]);
printk("imm: Found device at ID %i, Attempting to use %s\n",
loop, IMM_MODE_STRING[imm_hosts[host_no].mode]);
/* Send SCSI command */
status = 1;
......@@ -1198,7 +1216,8 @@ static int device_check(int host_no)
imm_hosts[host_no].mode = old_mode;
goto second_pass;
}
printk("imm: Unable to establish communication, aborting driver load.\n");
printk
("imm: Unable to establish communication, aborting driver load.\n");
return 1;
}
w_ctr(ppb, 0x0c);
......@@ -1223,12 +1242,14 @@ static int device_check(int host_no)
imm_hosts[host_no].mode = old_mode;
goto second_pass;
}
printk("imm: Unable to establish communication, aborting driver load.\n");
printk
("imm: Unable to establish communication, aborting driver load.\n");
return 1;
}
imm_disconnect(host_no);
printk("imm: Communication established at 0x%x with ID %i using %s\n", ppb, loop,
IMM_MODE_STRING[imm_hosts[host_no].mode]);
printk
("imm: Communication established at 0x%x with ID %i using %s\n",
ppb, loop, IMM_MODE_STRING[imm_hosts[host_no].mode]);
imm_connect(host_no, CONNECT_EPP_MAYBE);
imm_reset_pulse(IMM_BASE(host_no));
udelay(1000);
......@@ -1239,4 +1260,5 @@ static int device_check(int host_no)
printk("imm: No devices found, aborting driver load.\n");
return 1;
}
MODULE_LICENSE("GPL");
......@@ -66,7 +66,6 @@
*/
/* ------ END OF USER CONFIGURABLE PARAMETERS ----- */
#ifdef IMM_CODE
#include <linux/config.h>
#include <linux/stddef.h>
#include <linux/module.h>
......@@ -150,18 +149,12 @@ static int imm_init(int);
static void imm_interrupt(void *);
static int imm_out(int, char *, int);
#else
#define imm_release 0
#endif
int imm_detect(Scsi_Host_Template *);
const char *imm_info(struct Scsi_Host *);
int imm_command(Scsi_Cmnd *);
int imm_queuecommand(Scsi_Cmnd *, void (*done) (Scsi_Cmnd *));
int imm_abort(Scsi_Cmnd *);
int imm_reset(Scsi_Cmnd *);
int imm_proc_info(struct Scsi_Host *, char *, char **, off_t, int, int);
int imm_biosparam(struct scsi_device *, struct block_device *,
static int imm_detect(Scsi_Host_Template *);
static int imm_queuecommand(Scsi_Cmnd *, void (*done) (Scsi_Cmnd *));
static int imm_abort(Scsi_Cmnd *);
static int imm_reset(Scsi_Cmnd *);
static int imm_proc_info(struct Scsi_Host *, char *, char **, off_t, int, int);
static int imm_biosparam(struct scsi_device *, struct block_device *,
sector_t, int *);
#endif /* _IMM_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