patch-2.4.10 linux/drivers/char/tpqic02.c

Next file: linux/drivers/char/tty_io.c
Previous file: linux/drivers/char/toshiba.c
Back to the patch index
Back to the overall index

diff -u --recursive --new-file v2.4.9/linux/drivers/char/tpqic02.c linux/drivers/char/tpqic02.c
@@ -92,7 +92,7 @@
 #include <linux/slab.h>
 #include <linux/init.h>
 #include <linux/smp_lock.h>
-#include <linux/devfs_fs_kernel.h> 
+#include <linux/devfs_fs_kernel.h>
 
 #include <asm/dma.h>
 #include <asm/system.h>
@@ -116,8 +116,8 @@
  * card+drive info if runtime configuration has been selected.
  */
 
-static struct mtconfiginfo qic02_tape_dynconf = 	/* user settable */
-    { 0, 0, BOGUS_IRQ, 0, 0, TPQD_DEFAULT_FLAGS, };
+static struct mtconfiginfo qic02_tape_dynconf =	/* user settable */
+{ 0, 0, BOGUS_IRQ, 0, 0, TPQD_DEFAULT_FLAGS, };
 static struct qic02_ccb qic02_tape_ccb;	/* private stuff */
 
 #else
@@ -127,11 +127,11 @@
 # if ((QIC02_TAPE_IFC!=WANGTEK) && (QIC02_TAPE_IFC!=ARCHIVE) && (QIC02_TAPE_IFC!=MOUNTAIN))
 #  error No valid interface card specified
 # endif
-#endif /* CONFIG_QIC02_DYNCONF */
+#endif				/* CONFIG_QIC02_DYNCONF */
 
-static volatile int ctlbits;     /* control reg bits for tape interface */
+static volatile int ctlbits;	/* control reg bits for tape interface */
 
-static wait_queue_head_t qic02_tape_transfer; /* sync rw with interrupts */
+static wait_queue_head_t qic02_tape_transfer;	/* sync rw with interrupts */
 
 static volatile struct mtget ioctl_status;	/* current generic status */
 
@@ -146,15 +146,15 @@
  * by an interrupt.
  */
 static volatile flag status_dead = YES;	/* device is legally dead until proven alive */
-static 		flag status_zombie = YES; /* it's `zombie' until irq/dma allocated */
+static flag status_zombie = YES;	/* it's `zombie' until irq/dma allocated */
 
 static volatile flag status_bytes_wr = NO;	/* write FM at close or not */
 static volatile flag status_bytes_rd = NO;	/* (rd|wr) used for rewinding */
 
-static volatile unsigned long status_cmd_pending; /* cmd in progress */
+static volatile unsigned long status_cmd_pending;	/* cmd in progress */
 static volatile flag status_expect_int = NO;	/* ready for interrupts */
-static volatile flag status_timer_on = NO; 	/* using time-out */
-static volatile int  status_error;		/* int handler may detect error */
+static volatile flag status_timer_on = NO;	/* using time-out */
+static volatile int status_error;	/* int handler may detect error */
 static volatile flag status_eof_detected = NO;	/* end of file */
 static volatile flag status_eom_detected = NO;	/* end of recorded media */
 static volatile flag status_eot_detected = NO;	/* end of tape */
@@ -163,8 +163,8 @@
 
 static volatile unsigned long dma_bytes_todo;
 static volatile unsigned long dma_bytes_done;
-static volatile unsigned dma_mode;		/* !=0 also means DMA in use */
-static 		flag need_rewind = YES;
+static volatile unsigned dma_mode;	/* !=0 also means DMA in use */
+static flag need_rewind = YES;
 
 static kdev_t current_tape_dev;
 static int extra_blocks_left = BLOCKS_BEYOND_EW;
@@ -198,7 +198,7 @@
  * mode is allowed as long as no actual writing has been done. After writing
  * the File Mark, repositioning and reading are allowed again.
  */
-static int  mode_access;	/* access mode: READ or WRITE */
+static int mode_access;		/* access mode: READ or WRITE */
 
 static int qic02_get_resources(void);
 static void qic02_release_resources(void);
@@ -210,17 +210,17 @@
  * must ensure that a large enough buffer is passed to the kernel, in order
  * to reduce tape repositioning wear and tear.
  */
-static void *buffaddr;	/* virtual address of buffer */
+static void *buffaddr;		/* virtual address of buffer */
 
 /* This translates minor numbers to the corresponding recording format: */
 static const char *format_names[] = {
-	"not set",	/* for dumb drives unable to handle format selection */
-	"11",		/* extinct */
+	"not set",		/* for dumb drives unable to handle format selection */
+	"11",			/* extinct */
 	"24",
 	"120",
 	"150",
-	"300",		/* untested. */
-	"600"		/* untested. */
+	"300",			/* untested. */
+	"600"			/* untested. */
 };
 
 
@@ -248,52 +248,72 @@
 	const char *msg;
 	/* EXC_nr attribute should match with tpqic02.h */
 } exception_list[] = {
-	{0, 0,
-		"Unknown exception status code",		/* extra: 0 */},
-	{~(0), TP_ST0|TP_CNI|TP_USL|TP_WRP,
-		"Drive not online"				/* 1 */},
-		/* Drive presence goes before cartridge presence. */
-	{~(TP_WRP|TP_USL), TP_ST0|TP_CNI,
-		/* My Wangtek 5150EQ sometimes reports a status code
-		 * of 0x00e0, which is not a valid exception code, but
-		 * I think it should be recognized as "NO CARTRIDGE".
-		 */
-		"Cartridge not in place"			/* 2 */},
-	{(unsigned short) ~(TP_ST1|TP_BOM), (TP_ST0|TP_WRP),
-		"Write protected cartridge"			/* 3 */},
-	{(unsigned short) ~(TP_ST1|TP_EOR), (TP_ST0|TP_EOM),
-		"End of media"					/* 4 */},
-	{~TP_WRP, TP_ST0|TP_UDA| TP_ST1|TP_BOM,
-		"Read or Write abort. Rewind tape."		/* 5 */},
-	{~TP_WRP, TP_ST0|TP_UDA,
-		"Read error. Bad block transferred."		/* 6 */},
-	{~TP_WRP, TP_ST0|TP_UDA|TP_BNL,
-		"Read error. Filler block transferred."		/* 7 */},
-	{~TP_WRP, TP_ST0|TP_UDA|TP_BNL |TP_ST1|TP_NDT,
-		"Read error. No data detected."			/* 8 */},
-	{~TP_WRP, TP_ST0|TP_EOM|TP_UDA|TP_BNL |TP_ST1|TP_NDT,
-		"Read error. No data detected. EOM."		/* 9 */},
-	{~(TP_WRP|TP_MBD|TP_PAR|TP_EOR), TP_ST0|TP_UDA|TP_BNL |TP_ST1|TP_NDT|TP_BOM,
-		"Read error. No data detected. BOM."		/* 10 */},
-	{~(TP_WRP|TP_EOM), TP_ST0|TP_FIL,
-		/* Status 0x0089 (EOM & FM) is viewed as an FM,
-		 * because it can only happen during a read.
-		 * EOM is checked separately for an FM condition.
-		 */
-		"File mark detected"				/* 11 */},
-	{~(TP_ST0|TP_CNI|TP_USL|TP_WRP|TP_BOM), TP_ST1|TP_ILL,
-		"Illegal command"				/* 12 */},
-	{~(TP_ST0|TP_CNI|TP_USL|TP_WRP|TP_BOM), TP_ST1|TP_POR,
-		"Reset occurred"					/* 13 */},
-	{~TP_WRP, TP_ST0|TP_FIL|TP_MBD,		/* NOTE: ST1 not set! */
-		"Marginal block detected"			/* 14 */},
-	{~(TP_ST0|TP_WRP|TP_EOM|TP_UDA|TP_BNL|TP_FIL |TP_NDT), TP_ST1|TP_EOR,
+	{
+	0, 0, "Unknown exception status code", /* extra: 0 */ },
+	{
+	~(0), TP_ST0 | TP_CNI | TP_USL | TP_WRP,
+		    "Drive not online" /* 1 */ },
+	    /* Drive presence goes before cartridge presence. */
+	{
+		~(TP_WRP | TP_USL), TP_ST0 | TP_CNI,
+		    /* My Wangtek 5150EQ sometimes reports a status code
+		     * of 0x00e0, which is not a valid exception code, but
+		     * I think it should be recognized as "NO CARTRIDGE".
+		     */
+	"Cartridge not in place" /* 2 */ },
+	{
+	(unsigned short) ~(TP_ST1 | TP_BOM), (TP_ST0 | TP_WRP),
+		    "Write protected cartridge" /* 3 */ },
+	{
+	(unsigned short) ~(TP_ST1 | TP_EOR), (TP_ST0 | TP_EOM),
+		    "End of media" /* 4 */ },
+	{
+	~TP_WRP, TP_ST0 | TP_UDA | TP_ST1 | TP_BOM,
+		    "Read or Write abort. Rewind tape." /* 5 */ },
+	{
+	~TP_WRP, TP_ST0 | TP_UDA,
+		    "Read error. Bad block transferred." /* 6 */ },
+	{
+	~TP_WRP, TP_ST0 | TP_UDA | TP_BNL,
+		    "Read error. Filler block transferred." /* 7 */ },
+	{
+	~TP_WRP, TP_ST0 | TP_UDA | TP_BNL | TP_ST1 | TP_NDT,
+		    "Read error. No data detected." /* 8 */ },
+	{
+	~TP_WRP,
+		    TP_ST0 | TP_EOM | TP_UDA | TP_BNL | TP_ST1 |
+		    TP_NDT, "Read error. No data detected. EOM." /* 9 */ },
+	{
+	~(TP_WRP | TP_MBD | TP_PAR | TP_EOR),
+		    TP_ST0 | TP_UDA | TP_BNL | TP_ST1 | TP_NDT |
+		    TP_BOM,
+		    "Read error. No data detected. BOM." /* 10 */ },
+	{
+		~(TP_WRP | TP_EOM), TP_ST0 | TP_FIL,
+		    /* Status 0x0089 (EOM & FM) is viewed as an FM,
+		     * because it can only happen during a read.
+		     * EOM is checked separately for an FM condition.
+		     */
+	"File mark detected" /* 11 */ },
+	{
+	~(TP_ST0 | TP_CNI | TP_USL | TP_WRP | TP_BOM),
+		    TP_ST1 | TP_ILL, "Illegal command" /* 12 */ },
+	{
+	~(TP_ST0 | TP_CNI | TP_USL | TP_WRP | TP_BOM),
+		    TP_ST1 | TP_POR, "Reset occurred" /* 13 */ },
+	{
+		~TP_WRP, TP_ST0 | TP_FIL | TP_MBD,	/* NOTE: ST1 not set! */
+	"Marginal block detected" /* 14 */ },
+	{
+		~(TP_ST0 | TP_WRP | TP_EOM | TP_UDA | TP_BNL | TP_FIL |
+		  TP_NDT), TP_ST1 | TP_EOR,
 		/********** Is the extra TP_NDT really needed Eddy? **********/
-		"End of recorded media"				/* extra: 15 */},
-		/* 15 is returned when SEEKEOD completes successfully */
-	{~(TP_WRP|TP_ST0), TP_ST1|TP_BOM,
-		"Beginning of media"				/* extra: 16 */}
+	"End of recorded media" /* extra: 15 */ },
+	    /* 15 is returned when SEEKEOD completes successfully */
+	{
+	~(TP_WRP | TP_ST0), TP_ST1 | TP_BOM, "Beginning of media" /* extra: 16 */ }
 };
+
 #define NR_OF_EXC	(sizeof(exception_list)/sizeof(struct exception_list_type))
 
 /* Compare expected struct size and actual struct size. This
@@ -310,7 +330,7 @@
 {
 	if ((flags & TPQD_ALWAYS) || (flags & QIC02_TAPE_DEBUG))
 		printk(TPQIC02_NAME ": %s\n", s);
-} /* tpqputs */
+}				/* tpqputs */
 
 
 /* Perform byte order swapping for a 16-bit word.
@@ -318,11 +338,10 @@
  * [FIXME] This should probably be in include/asm/
  * ([FIXME] i486 can do this faster)
  */
-static inline void byte_swap_w(volatile unsigned short * w)
+static inline void byte_swap_w(volatile unsigned short *w)
 {
 	int t = *w;
-
-	*w = (t>>8) | ((t & 0xff)<<8);
+	*w = (t >> 8) | ((t & 0xff) << 8);
 }
 
 
@@ -334,37 +353,32 @@
  */
 static void ifc_init(void)
 {
-    if (QIC02_TAPE_IFC == WANGTEK) /* || (QIC02_TAPE_IFC == EVEREX) */
-    {
-	ctlbits = WT_CTL_ONLINE;	/* online */
-	outb_p(ctlbits, QIC02_CTL_PORT);
-    }
-    else if (QIC02_TAPE_IFC == ARCHIVE)
-    {
-	ctlbits = 0;			/* no interrupts yet */
-	outb_p(ctlbits, QIC02_CTL_PORT);
-	outb_p(0, AR_RESET_DMA_PORT);	/* dummy write to reset DMA */
-    }
-    else /* MOUNTAIN */
-    {
-	ctlbits = MTN_CTL_ONLINE;       /* online, and logic enabled */
-	outb_p(ctlbits, QIC02_CTL_PORT);
-    }
-} /* ifc_init */
+	if (QIC02_TAPE_IFC == WANGTEK) {	/* || (QIC02_TAPE_IFC == EVEREX) */
+		ctlbits = WT_CTL_ONLINE;	/* online */
+		outb_p(ctlbits, QIC02_CTL_PORT);
+	} else if (QIC02_TAPE_IFC == ARCHIVE) {
+		ctlbits = 0;	/* no interrupts yet */
+		outb_p(ctlbits, QIC02_CTL_PORT);
+		outb_p(0, AR_RESET_DMA_PORT);	/* dummy write to reset DMA */
+	} else {		/* MOUNTAIN */
+
+		ctlbits = MTN_CTL_ONLINE;	/* online, and logic enabled */
+		outb_p(ctlbits, QIC02_CTL_PORT);
+	}
+}				/* ifc_init */
 
 
 static void report_qic_exception(unsigned n)
 {
-    if (n >= NR_OF_EXC)
-    {
-	tpqputs(TPQD_ALWAYS, "Oops -- report_qic_exception");
-	n = 0;
-    }
-    if (TPQDBG(SENSE_TEXT) || n==0)
-    {
-	printk(TPQIC02_NAME ": sense: %s\n", exception_list[n].msg);
-    }
-} /* report_qic_exception */
+	if (n >= NR_OF_EXC) {
+		tpqputs(TPQD_ALWAYS, "Oops -- report_qic_exception");
+		n = 0;
+	}
+	if (TPQDBG(SENSE_TEXT) || n == 0) {
+		printk(TPQIC02_NAME ": sense: %s\n",
+		       exception_list[n].msg);
+	}
+}				/* report_qic_exception */
 
 
 /* Try to map the drive-exception bits `s' to a predefined "exception number",
@@ -374,18 +388,18 @@
  */
 static int decode_qic_exception_nr(unsigned s)
 {
-    int i;
+	int i;
 
-    for (i=1; i<NR_OF_EXC; i++)
-    {
-	if ((s & exception_list[i].mask)==exception_list[i].code)
-	{
-	    return i;
+	for (i = 1; i < NR_OF_EXC; i++) {
+		if ((s & exception_list[i].mask) == exception_list[i].code) {
+			return i;
+		}
 	}
-    }
-    printk(TPQIC02_NAME ": decode_qic_exception_nr: exception(%x) not recognized\n", s);
-    return 0;
-} /* decode_qic_exception_nr */
+	printk(TPQIC02_NAME
+	       ": decode_qic_exception_nr: exception(%x) not recognized\n",
+	       s);
+	return 0;
+}				/* decode_qic_exception_nr */
 
 
 
@@ -394,44 +408,36 @@
  */
 static void handle_qic_exception(int exnr, int exbits)
 {
-    if (exnr==EXC_NCART)
-    {
-	/* Cartridge was changed. Redo sense().
-	 * EXC_NCART should be handled in open().
-	 * It is not permitted to remove the tape while
-	 * the tape driver has open files. 
-	 */
-	need_rewind = YES;
-	status_eof_detected = NO;
-	status_eom_detected = NO;
-    }
-    else if (exnr==EXC_XFILLER)
-    {
-	tpqputs(TPQD_ALWAYS, "[Bad block -- filler data transferred.]");
-    }
-    else if (exnr==EXC_XBAD)
-    {
-	tpqputs(TPQD_ALWAYS, "[CRC failed!]");
-    }
-    else if (exnr==EXC_MARGINAL)
-    {
-	/* A marginal block behaves much like a FM.
-	 * User may continue reading, if desired.
-	 */
-	tpqputs(TPQD_ALWAYS, "[Marginal block]");
-	doing_read = NO;
-    }
-    else if (exnr==EXC_FM)
-    {
-	doing_read = NO;
-    }
-} /* handle_qic_exception */
+	if (exnr == EXC_NCART) {
+		/* Cartridge was changed. Redo sense().
+		 * EXC_NCART should be handled in open().
+		 * It is not permitted to remove the tape while
+		 * the tape driver has open files. 
+		 */
+		need_rewind = YES;
+		status_eof_detected = NO;
+		status_eom_detected = NO;
+	} else if (exnr == EXC_XFILLER) {
+		tpqputs(TPQD_ALWAYS,
+			"[Bad block -- filler data transferred.]");
+	} else if (exnr == EXC_XBAD) {
+		tpqputs(TPQD_ALWAYS, "[CRC failed!]");
+	} else if (exnr == EXC_MARGINAL) {
+		/* A marginal block behaves much like a FM.
+		 * User may continue reading, if desired.
+		 */
+		tpqputs(TPQD_ALWAYS, "[Marginal block]");
+		doing_read = NO;
+	} else if (exnr == EXC_FM) {
+		doing_read = NO;
+	}
+}				/* handle_qic_exception */
 
 
 static inline int is_exception(void)
 {
-    return (inb(QIC02_STAT_PORT) & QIC02_STAT_EXCEPTION) == 0;
-} /* is_exception */
+	return (inb(QIC02_STAT_PORT) & QIC02_STAT_EXCEPTION) == 0;
+}				/* is_exception */
 
 
 /* Reset the tape drive and controller.
@@ -440,54 +446,49 @@
  */
 static int tape_reset(int verbose)
 {
-    ifc_init();				/* reset interface card */
+	ifc_init();		/* reset interface card */
 
-    /* assert reset */
-    if (QIC02_TAPE_IFC == MOUNTAIN)
-    {
-	outb_p(ctlbits & ~MTN_QIC02_CTL_RESET_NOT, QIC02_CTL_PORT);
-    }
-    else /* WANGTEK, ARCHIVE */
-    {
-	outb_p(ctlbits | QIC02_CTL_RESET, QIC02_CTL_PORT);
-    }
-    
-    /* Next, we need to wait >=25 usec. */
-    udelay(30);
-
-    /* after reset, we will be at BOT (modulo an automatic rewind) */
-    status_eof_detected = NO;
-    status_eom_detected = NO;
-    status_cmd_pending = 0;
-    need_rewind = YES;
-    doing_read = doing_write = NO;
-    ioctl_status.mt_fileno = ioctl_status.mt_blkno = 0;
-    
-    /* de-assert reset */
-    if (QIC02_TAPE_IFC == MOUNTAIN)
-    {
-	outb_p(ctlbits | MTN_QIC02_CTL_RESET_NOT, QIC02_CTL_PORT);
-    }
-    else
-    {
-	outb_p(ctlbits & ~QIC02_CTL_RESET, QIC02_CTL_PORT);
-    }
-    
-    /* KLUDGE FOR G++ BUG */
-    { int stat = inb_p(QIC02_STAT_PORT);
-	status_dead = ((stat & QIC02_STAT_RESETMASK) != QIC02_STAT_RESETVAL); }
-    /* if successful, inb(STAT) returned RESETVAL */
-    if (status_dead == YES)
-    {
-	printk(TPQIC02_NAME ": reset failed!\n");
-    }
-    else if (verbose)
-    {
-	printk(TPQIC02_NAME ": reset successful\n");
-    }
-    
-    return (status_dead == YES)? TE_DEAD : TE_OK;
-} /* tape_reset */
+	/* assert reset */
+	if (QIC02_TAPE_IFC == MOUNTAIN) {
+		outb_p(ctlbits & ~MTN_QIC02_CTL_RESET_NOT, QIC02_CTL_PORT);
+	} else {		/* WANGTEK, ARCHIVE */
+
+		outb_p(ctlbits | QIC02_CTL_RESET, QIC02_CTL_PORT);
+	}
+
+	/* Next, we need to wait >=25 usec. */
+	udelay(30);
+
+	/* after reset, we will be at BOT (modulo an automatic rewind) */
+	status_eof_detected = NO;
+	status_eom_detected = NO;
+	status_cmd_pending = 0;
+	need_rewind = YES;
+	doing_read = doing_write = NO;
+	ioctl_status.mt_fileno = ioctl_status.mt_blkno = 0;
+
+	/* de-assert reset */
+	if (QIC02_TAPE_IFC == MOUNTAIN) {
+		outb_p(ctlbits | MTN_QIC02_CTL_RESET_NOT, QIC02_CTL_PORT);
+	} else {
+		outb_p(ctlbits & ~QIC02_CTL_RESET, QIC02_CTL_PORT);
+	}
+
+	/* KLUDGE FOR G++ BUG */
+	{
+		int stat = inb_p(QIC02_STAT_PORT);
+		status_dead =
+		    ((stat & QIC02_STAT_RESETMASK) != QIC02_STAT_RESETVAL);
+	}
+	/* if successful, inb(STAT) returned RESETVAL */
+	if (status_dead == YES) {
+		printk(TPQIC02_NAME ": reset failed!\n");
+	} else if (verbose) {
+		printk(TPQIC02_NAME ": reset successful\n");
+	}
+
+	return (status_dead == YES) ? TE_DEAD : TE_OK;
+}				/* tape_reset */
 
 
 
@@ -504,7 +505,7 @@
 {
 	int i;
 
-	outb_p(cmd, QIC02_CMD_PORT);    /* output the command */
+	outb_p(cmd, QIC02_CMD_PORT);	/* output the command */
 
 	/* wait 1 usec before asserting /REQUEST */
 	udelay(1);
@@ -512,7 +513,7 @@
 	if ((!ignore_ex) && is_exception()) {
 		tpqputs(TPQD_ALWAYS, "*** exception detected in notify_cmd");
 		/** force a reset here **/
-		if (tape_reset(1)==TE_DEAD)
+		if (tape_reset(1) == TE_DEAD)
 			return TE_DEAD;
 		if (is_exception()) {
 			tpqputs(TPQD_ALWAYS, "exception persists after reset.");
@@ -520,33 +521,36 @@
 		}
 	}
 
-	outb_p(ctlbits | QIC02_CTL_REQUEST, QIC02_CTL_PORT);  /* set request bit */
+	outb_p(ctlbits | QIC02_CTL_REQUEST, QIC02_CTL_PORT);	/* set request bit */
 	i = TAPE_NOTIFY_TIMEOUT;
 	/* The specs say this takes about 500 usec, but there is no upper limit!
 	 * If the drive were busy retensioning or something like that,
 	 * it could be *much* longer!
 	 */
-	while ((inb_p(QIC02_STAT_PORT) & QIC02_STAT_READY) && (--i>0))
-		/*skip*/;			  /* wait for ready */
-	if (i==0) {
-		tpqputs(TPQD_ALWAYS, "timed out waiting for ready in notify_cmd");
+	while ((inb_p(QIC02_STAT_PORT) & QIC02_STAT_READY) && (--i > 0))
+		/*skip */ ;
+	/* wait for ready */
+	if (i == 0) {
+		tpqputs(TPQD_ALWAYS,
+			"timed out waiting for ready in notify_cmd");
 		status_dead = YES;
 		return TE_TIM;
 	}
 
-	outb_p(ctlbits & ~QIC02_CTL_REQUEST, QIC02_CTL_PORT); /* reset request bit */
+	outb_p(ctlbits & ~QIC02_CTL_REQUEST, QIC02_CTL_PORT);	/* reset request bit */
 	i = TAPE_NOTIFY_TIMEOUT;
 	/* according to the specs this one should never time-out */
-	while (((inb_p(QIC02_STAT_PORT) & QIC02_STAT_READY) == 0) && (--i>0))
-		/*skip*/;			  /* wait for not ready */
-	if (i==0) {
+	while (((inb_p(QIC02_STAT_PORT) & QIC02_STAT_READY) == 0) && (--i > 0))
+		/*skip */ ;
+	/* wait for not ready */
+	if (i == 0) {
 		tpqputs(TPQD_ALWAYS, "timed out waiting for !ready in notify_cmd");
 		status_dead = YES;
 		return TE_TIM;
 	}
 	/* command accepted */
 	return TE_OK;
-} /* notify_cmd */
+}				/* notify_cmd */
 
 
 
@@ -563,20 +567,22 @@
 	 * First, busy wait a few usec:
 	 */
 	spin_t = 50;
-	while (((stat = inb_p(QIC02_STAT_PORT) & QIC02_STAT_MASK) == QIC02_STAT_MASK) && (--spin_t>0))
+	while (((stat = inb_p(QIC02_STAT_PORT) & QIC02_STAT_MASK) == QIC02_STAT_MASK) && (--spin_t > 0))
 		/*SKIP*/;
 	if ((stat & QIC02_STAT_READY) == 0)
-		return TE_OK;			/* covers 99.99% of all calls */
+		return TE_OK;	/* covers 99.99% of all calls */
 
 	/* Then use schedule() a few times */
-	spin_t = 3;	/* max 0.03 sec busy waiting */
+	spin_t = 3;		/* max 0.03 sec busy waiting */
 	if (spin_t > timeout)
 		spin_t = timeout;
 	timeout -= spin_t;
 	spin_t += jiffies;
 
-	while (((stat = inb_p(QIC02_STAT_PORT) & QIC02_STAT_MASK) == QIC02_STAT_MASK) && time_before(jiffies, spin_t))
-		schedule();		/* don't waste all the CPU time */
+	/* FIXME...*/
+	while (((stat = inb_p(QIC02_STAT_PORT) & QIC02_STAT_MASK) == QIC02_STAT_MASK) 
+		&& time_before(jiffies, spin_t))
+		schedule();	/* don't waste all the CPU time */
 	if ((stat & QIC02_STAT_READY) == 0)
 		return TE_OK;
 
@@ -589,13 +595,13 @@
 	spin_t += timeout;
 	TPQDEB({printk("wait_for_ready: additional timeout: %d\n", spin_t);})
 
-		/* not ready and no exception && timeout not expired yet */
+	    /* not ready and no exception && timeout not expired yet */
 	while (((stat = inb_p(QIC02_STAT_PORT) & QIC02_STAT_MASK) == QIC02_STAT_MASK) && time_before(jiffies, spin_t)) {
 		/* be `nice` to other processes on long operations... */
 		current->state = TASK_INTERRUPTIBLE;
 		/* nap 0.30 sec between checks, */
 		/* but could be woken up earlier by signals... */
-		schedule_timeout(3*HZ/10);
+		schedule_timeout(3 * HZ / 10);
 	}
 
 	/* don't use jiffies for this test because it may have changed by now */
@@ -605,12 +611,13 @@
 	}
 
 	if ((stat & QIC02_STAT_EXCEPTION) == 0) {
-		tpqputs(TPQD_ALWAYS, "exception detected after waiting_for_ready");
+		tpqputs(TPQD_ALWAYS,
+			"exception detected after waiting_for_ready");
 		return TE_EX;
 	} else {
 		return TE_OK;
 	}
-} /* wait_for_ready */
+}				/* wait_for_ready */
 
 
 
@@ -619,7 +626,7 @@
 {
 	int i, stat;
 
-	for (i=0; i<size; i++) {
+	for (i = 0; i < size; i++) {
 
 		stat = wait_for_ready(TIM_S);
 		if (stat != TE_OK)
@@ -630,8 +637,8 @@
 			return stat;
 	}
 	return TE_OK;
-	
-} /* send_qic02_data */
+
+}				/* send_qic02_data */
 
 
 /* Send a QIC-02 command (`cmd') to the tape drive, with
@@ -650,7 +657,7 @@
 		tpqputs(TPQD_ALWAYS, "send_qic02_cmd: Exception!");
 		return TE_EX;
 	}
-	if (stat & QIC02_STAT_READY) {			/* if not ready */
+	if (stat & QIC02_STAT_READY) {	/* if not ready */
 		tpqputs(TPQD_ALWAYS, "send_qic02_cmd: not Ready!");
 		return TE_ERR;
 	}
@@ -662,8 +669,8 @@
 	 */
 	status_cmd_pending = cmd;
 
-	stat = notify_cmd(cmd, ignore_ex); /* tell drive new command was loaded, */
-					   /* inherit exception check. */
+	stat = notify_cmd(cmd, ignore_ex);	/* tell drive new command was loaded, */
+	/* inherit exception check. */
 	if (TP_HAVE_SEEK && (cmd == AR_QCMDV_SEEK_BLK)) {
 		/* This one needs to send 3 more bytes, MSB first */
 		stat = send_qic02_data(seek_addr_buf, sizeof(seek_addr_buf), ignore_ex);
@@ -673,7 +680,7 @@
 		tpqputs(TPQD_ALWAYS, "send_qic02_cmd failed");
 	}
 	return stat;
-} /* send_qic02_cmd */
+}				/* send_qic02_cmd */
 
 
 
@@ -683,8 +690,8 @@
  */
 static int rdstatus(char *stp, unsigned size, char qcmd)
 {
-	int	s, n;
-	char	*q = stp;
+	int s, n;
+	char *q = stp;
 
 	/* Try to busy-wait a few (700) usec, after that de-schedule.
 	 *
@@ -693,21 +700,22 @@
 	 * de-schedule immediately, we waste a lot of time because a
 	 * task switch is much longer than we usually have to wait here.
 	 */
-	n = 1000;	/* 500 is not enough on a 486/33 */
-	while ((n>0) && ((inb_p(QIC02_STAT_PORT) & QIC02_STAT_MASK) == QIC02_STAT_MASK))
-		n--;  /* wait for ready or exception or timeout */
-	if (n==0) {
+	n = 1000;		/* 500 is not enough on a 486/33 */
+	while ((n > 0) && ((inb_p(QIC02_STAT_PORT) & QIC02_STAT_MASK) == QIC02_STAT_MASK))
+		n--;		/* wait for ready or exception or timeout */
+	if (n == 0) {
 		/* n (above) should be chosen such that on your machine
 		 * you rarely ever see the message below, and it should
 		 * be small enough to give reasonable response time.]
 		 */
+	 	/* FIXME */
 		tpqputs(TPQD_ALWAYS, "waiting looong in rdstatus() -- drive dead?");
 		while ((inb_p(QIC02_STAT_PORT) & QIC02_STAT_MASK) == QIC02_STAT_MASK)
 			schedule();
 		tpqputs(TPQD_ALWAYS, "finished waiting in rdstatus()");
 	}
 
-	(void) notify_cmd(qcmd, 1);			/* send read status command */
+	(void) notify_cmd(qcmd, 1);	/* send read status command */
 	/* ignore return code -- should always be ok, STAT may contain 
 	 * exception flag from previous exception which we are trying to clear.
 	 */
@@ -715,21 +723,22 @@
 	if (TP_DIAGS(current_tape_dev))
 		printk(TPQIC02_NAME ": reading status bytes: ");
 
-	for (q=stp; q<stp+size; q++)
-	{
-		do s = inb_p(QIC02_STAT_PORT);
+	for (q = stp; q < stp + size; q++) {
+		do
+			s = inb_p(QIC02_STAT_PORT);
 		while ((s & QIC02_STAT_MASK) == QIC02_STAT_MASK);	/* wait for ready or exception */
 
-		if ((s & QIC02_STAT_EXCEPTION) == 0) {		/* if exception */
+		if ((s & QIC02_STAT_EXCEPTION) == 0) {	/* if exception */
 			tpqputs(TPQD_ALWAYS, "rdstatus: exception error");
-			ioctl_status.mt_erreg = 0;		/* dunno... */
-			return TE_NS;				/* error, shouldn't happen... */
+			ioctl_status.mt_erreg = 0;	/* dunno... */
+			return TE_NS;	/* error, shouldn't happen... */
 		}
 
-		*q = inb_p(QIC02_DATA_PORT);			/* read status byte */
+		*q = inb_p(QIC02_DATA_PORT);	/* read status byte */
 
 		if (TP_DIAGS(current_tape_dev))
-			printk("[%1d]=0x%x  ", q-stp, (unsigned) (*q) & 0xff);
+			printk("[%1d]=0x%x  ", q - stp,
+			       (unsigned) (*q) & 0xff);
 
 		outb_p(ctlbits | QIC02_CTL_REQUEST, QIC02_CTL_PORT);	/* set request */
 
@@ -745,13 +754,14 @@
 	 * My drive doesn't seem to need it here yet, but others do?
 	 */
 	while (inb_p(QIC02_STAT_PORT) & QIC02_STAT_READY)
-		/*skip*/;			  /* wait for ready */
+		/*skip */ ;
+	/* wait for ready */
 
 	if (TP_DIAGS(current_tape_dev))
 		printk("\n");
 
 	return TE_OK;
-} /* rdstatus */
+}				/* rdstatus */
 
 
 
@@ -762,14 +772,15 @@
 static int get_status(volatile struct tpstatus *stp)
 {
 	int stat = rdstatus((char *) stp, TPSTATSIZE, QCMD_RD_STAT);
-#ifdef __i386__
+#if defined(__i386__) || defined (__x86_64__)
 	byte_swap_w(&(stp->dec));
 	byte_swap_w(&(stp->urc));
 #else
+#warning Undefined architecture
 	/* should probably swap status bytes #definition */
 #endif
 	return stat;
-} /* get_status */
+}				/* get_status */
 
 
 #if 0
@@ -782,7 +793,7 @@
  */
 static int get_ext_status3(void)
 {
-	char vus[64];	/* vendor unique status */
+	char vus[64];		/* vendor unique status */
 	int stat, i;
 
 	tpqputs(TPQD_ALWAYS, "Attempting to read Extended Status 3...");
@@ -791,15 +802,15 @@
 		return stat;
 
 	tpqputs(TPQD_ALWAYS, "Returned status bytes:");
-	for (i=0; i<sizeof(vus); i++) {
-		if ( i % 8 == 0 )
+	for (i = 0; i < sizeof(vus); i++) {
+		if (i % 8 == 0)
 			printk("\n" TPQIC02_NAME ": %2d:");
 		printk(" %2x", vus[i] & 0xff);
 	}
 	printk("\n");
 
 	return TE_OK;
-} /* get_ext_status3 */
+}				/* get_ext_status3 */
 #endif
 
 
@@ -812,13 +823,14 @@
 	static void finish_rw(int cmd);
 
 	if (TPQDBG(SENSE_TEXT))
-		printk(TPQIC02_NAME ": tp_sense(ignore=0x%x) enter\n", ignore);
+		printk(TPQIC02_NAME ": tp_sense(ignore=0x%x) enter\n",
+		       ignore);
 
 	/* sense() is not allowed during a read or write cycle */
 	if (doing_write == YES)
 		tpqputs(TPQD_ALWAYS, "Warning: File Mark inserted because of sense() request");
 	/* The extra test is to avoid calling finish_rw during booting */
-	if ((doing_read!=NO) || (doing_write!=NO))
+	if ((doing_read != NO) || (doing_write != NO))
 		finish_rw(QCMD_RD_STAT);
 
 	if (get_status(&tperror) != TE_OK) {
@@ -827,27 +839,29 @@
 	}
 
 	err = tperror.exs;	/* get exception status bits */
-	if (err & (TP_ST0|TP_ST1))
+	if (err & (TP_ST0 | TP_ST1))
 		printk(TPQIC02_NAME ": tp_sense: status: %x, error count: %d, underruns: %d\n",
-			tperror.exs, tperror.dec, tperror.urc);
-	else if ((tperror.dec!=0) || (tperror.urc!=0) || TPQDBG(SENSE_CNTS))
-		printk(TPQIC02_NAME ": tp_sense: no hard errors, soft error count: %d, underruns: %d\n",
-			tperror.dec, tperror.urc);
+		       tperror.exs, tperror.dec, tperror.urc);
+	else if ((tperror.dec != 0) || (tperror.urc != 0)
+		 || TPQDBG(SENSE_CNTS))
+		printk(TPQIC02_NAME
+		       ": tp_sense: no hard errors, soft error count: %d, underruns: %d\n",
+		       tperror.dec, tperror.urc);
 
 	/* Set generic status. HP-UX defines these, but some extra would 
 	 * be useful. Problem is to remain compatible. [Do we want to be
 	 * compatible??]
 	 */
 	if (err & TP_ST0) {
-		if (err & TP_CNI)		/* no cartridge */
+		if (err & TP_CNI)	/* no cartridge */
 			gs |= GMT_DR_OPEN(-1);
 		if (status_dead == NO)
 			gs |= GMT_ONLINE(-1);	/* always online */
-		if (err & TP_USL)		/* not online */
+		if (err & TP_USL)	/* not online */
 			gs &= ~GMT_ONLINE(-1);
 		if (err & TP_WRP)
 			gs |= GMT_WR_PROT(-1);
-		if (err & TP_EOM) {		/* end of media */
+		if (err & TP_EOM) {	/* end of media */
 			gs |= GMT_EOT(-1);	/* not sure this is correct for writes */
 			status_eom_detected = YES;
 			/* I don't know whether drive always reports EOF at or before EOM. */
@@ -871,10 +885,10 @@
 	ioctl_status.mt_dsreg = tperror.exs;	/* "drive status" */
 	ioctl_status.mt_erreg = tperror.dec;	/* "sense key error" */
 
-	if (err & (TP_ST0|TP_ST1)) {
+	if (err & (TP_ST0 | TP_ST1)) {
 		/* My Wangtek occasionally reports `status' 1212 which should be ignored. */
 		exnr = decode_qic_exception_nr(err);
-		handle_qic_exception(exnr, err);		/* update driver state wrt drive status */
+		handle_qic_exception(exnr, err);	/* update driver state wrt drive status */
 		report_qic_exception(exnr);
 	}
 	err &= ~ignore;		/* mask unwanted errors -- not the correct way, use exception nrs?? */
@@ -882,7 +896,7 @@
 	    ((err & TP_ST1) && (err & REPORT_ERR1)))
 		return TE_ERR;
 	return TE_OK;
-} /* tp_sense */
+}				/* tp_sense */
 
 
 
@@ -895,15 +909,17 @@
 
 	stat = inb(QIC02_STAT_PORT) & QIC02_STAT_MASK;
 	if (TPQDBG(REWIND))
-		printk(TPQIC02_NAME ": Waiting for (re-)wind to finish: stat=0x%x\n", stat);
+		printk(TPQIC02_NAME
+		       ": Waiting for (re-)wind to finish: stat=0x%x\n",
+		       stat);
 
 	stat = wait_for_ready(timeout);
 
 	if (stat != TE_OK) {
-			tpqputs(TPQD_ALWAYS, "(re-) winding failed\n");
+		tpqputs(TPQD_ALWAYS, "(re-) winding failed\n");
 	}
 	return stat;
-} /* wait_for_rewind */
+}				/* wait_for_rewind */
 
 
 
@@ -919,22 +935,21 @@
 
 	if (status_dead == YES) {
 		tpqputs(TPQD_ALWAYS, "Drive is dead. Do a `mt reset`.");
-		return -ENXIO;			/* User should do an MTRESET. */
+		return -ENXIO;	/* User should do an MTRESET. */
 	}
 
-	stat = wait_for_ready(timeout);		/* wait for ready or exception */
+	stat = wait_for_ready(timeout);	/* wait for ready or exception */
 	if (stat == TE_EX) {
-		if (tp_sense(TP_WRP|TP_BOM|TP_EOM|TP_FIL)!=TE_OK)
+		if (tp_sense(TP_WRP | TP_BOM | TP_EOM | TP_FIL) != TE_OK)
 			return -EIO;
 		/* else nothing to worry about, I hope */
 		stat = TE_OK;
 	}
 	if (stat != TE_OK) {
-		printk(TPQIC02_NAME ": ll_do_qic_cmd(%x, %ld) failed\n", cmd, (long) timeout);
+		printk(TPQIC02_NAME ": ll_do_qic_cmd(%x, %ld) failed\n",
+		       cmd, (long) timeout);
 		return -EIO;
 	}
-
-
 #if OBSOLETE
 	/* wait for ready since it may not be active immediately after reading status */
 	while ((inb_p(QIC02_STAT_PORT) & QIC02_STAT_READY) != 0);
@@ -942,16 +957,17 @@
 
 	stat = send_qic02_cmd(cmd, timeout, 0);	/* (checks for exceptions) */
 
-	if (cmd==QCMD_RD_FM) {
+	if (cmd == QCMD_RD_FM) {
 		status_eof_detected = NO;
 		ioctl_status.mt_fileno++;
 		/* Should update block count as well, but can't.
 		 * Can do a `read address' for some drives, when MTNOP is done.
 		 */
-	} else if (cmd==QCMD_WRT_FM) {
+	} else if (cmd == QCMD_WRT_FM) {
 		status_eof_detected = NO;
 		ioctl_status.mt_fileno++;
-	} else if ((cmd==QCMD_REWIND) || (cmd==QCMD_ERASE) || (cmd==QCMD_RETEN)) {
+	} else if ((cmd == QCMD_REWIND) || (cmd == QCMD_ERASE)
+		   || (cmd == QCMD_RETEN)) {
 		status_eof_detected = NO;
 		status_eom_detected = NO;
 		status_eot_detected = NO;
@@ -964,16 +980,19 @@
 		reported_write_eof = NO;
 	}
 	/* sense() will set eof/eom as required */
-	if (stat==TE_EX) {
-		if (tp_sense(TP_WRP|TP_BOM|TP_EOM|TP_FIL)!=TE_OK) {
-			printk(TPQIC02_NAME ": Exception persist in ll_do_qic_cmd[1](%x, %ld)", cmd, (long) timeout);
+	if (stat == TE_EX) {
+		if (tp_sense(TP_WRP | TP_BOM | TP_EOM | TP_FIL) != TE_OK) {
+			printk(TPQIC02_NAME
+			       ": Exception persist in ll_do_qic_cmd[1](%x, %ld)",
+			       cmd, (long) timeout);
 			status_dead = YES;
 			return -ENXIO;
 			/* if rdstatus fails too, we're in trouble */
 		}
-	}
-	else if (stat!=TE_OK) {
-		printk(TPQIC02_NAME ": ll_do_qic_cmd: send_qic02_cmd failed, stat = 0x%x\n", stat);
+	} else if (stat != TE_OK) {
+		printk(TPQIC02_NAME
+		       ": ll_do_qic_cmd: send_qic02_cmd failed, stat = 0x%x\n",
+		       stat);
 		return -EIO;	/*** -EIO is probably not always appropriate */
 	}
 
@@ -983,23 +1002,27 @@
 	else
 		stat = wait_for_ready(timeout);
 
-	if (stat==TE_EX) {
-		if (tp_sense((cmd==QCMD_SEEK_EOD ?		/*****************************/
-		      TP_EOR|TP_NDT|TP_UDA|TP_BNL|TP_WRP|TP_BOM|TP_EOM|TP_FIL :
-		      TP_WRP|TP_BOM|TP_EOM|TP_FIL))!=TE_OK) {
-			printk(TPQIC02_NAME ": Exception persist in ll_do_qic_cmd[2](%x, %ld)\n", cmd, (long) timeout);
-			if (cmd!=QCMD_RD_FM)
+	if (stat == TE_EX) {
+		if (tp_sense((cmd == QCMD_SEEK_EOD ?		/*****************************/
+			      TP_EOR | TP_NDT | TP_UDA | TP_BNL | TP_WRP |
+			      TP_BOM | TP_EOM | TP_FIL : TP_WRP | TP_BOM |
+			      TP_EOM | TP_FIL)) != TE_OK) {
+			printk(TPQIC02_NAME
+			       ": Exception persist in ll_do_qic_cmd[2](%x, %ld)\n",
+			       cmd, (long) timeout);
+			if (cmd != QCMD_RD_FM)
 				status_dead = YES;
 			return -ENXIO;
 			/* if rdstatus fails too, we're in trouble */
 		}
-	}
-	else if (stat!=TE_OK) {
-		printk(TPQIC02_NAME ": ll_do_qic_cmd %x: wait failed, stat == 0x%x\n", cmd, stat);
+	} else if (stat != TE_OK) {
+		printk(TPQIC02_NAME
+		       ": ll_do_qic_cmd %x: wait failed, stat == 0x%x\n",
+		       cmd, stat);
 		return -EIO;
 	}
 	return 0;
-} /* ll_do_qic_cmd */
+}				/* ll_do_qic_cmd */
 
 
 /* 
@@ -1042,17 +1065,20 @@
 				/* Mountain reference says can terminate by de-asserting online */
 				ctlbits &= ~MTN_QIC02_CTL_ONLINE;
 			}
- 
-			if (tp_sense(TP_FIL|TP_EOM|TP_WRP) != TE_OK) {
-				tpqputs(TPQD_ALWAYS, "finish_rw[read1]: ignore the 2 lines above");
+
+			if (tp_sense(TP_FIL | TP_EOM | TP_WRP) != TE_OK) {
+				tpqputs(TPQD_ALWAYS,
+					"finish_rw[read1]: ignore the 2 lines above");
 				if (is_exception()) {
-					if (tp_sense(TP_ILL|TP_FIL|TP_EOM|TP_WRP) != TE_OK)
-						tpqputs(TPQD_ALWAYS, "finish_rw[read2]: read cycle error");
+					if (tp_sense
+					    (TP_ILL | TP_FIL | TP_EOM |
+					     TP_WRP) != TE_OK)
+						tpqputs(TPQD_ALWAYS,"finish_rw[read2]: read cycle error");
 				}
 			}
 		}
 	}
-} /* terminate_read */
+}				/* terminate_read */
 
 
 static void terminate_write(int cmd)
@@ -1066,28 +1092,30 @@
 			/* finish off write cycle */
 			stat = ll_do_qic_cmd(QCMD_WRT_FM, TIM_M);
 			if (stat != TE_OK)
-				tpqputs(TPQD_ALWAYS, "Couldn't finish write cycle properly");
+				tpqputs(TPQD_ALWAYS,
+					"Couldn't finish write cycle properly");
 			(void) tp_sense(0);
 		}
 		/* If there is an EOF token waiting to be returned to
 		 * the (writing) application, discard it now.
 		 * We could be at EOT, so don't reset return_write_eof.
 		 */
-		reported_write_eof=YES;
+		reported_write_eof = YES;
 	}
-} /* terminate_write */
+}				/* terminate_write */
 
 
 /* terminate read or write cycle because of command `cmd' */
 static void finish_rw(int cmd)
 {
 	if (wait_for_ready(TIM_S) != TE_OK) {
-		tpqputs(TPQD_ALWAYS, "error: drive not ready in finish_rw() !");
+		tpqputs(TPQD_ALWAYS,
+			"error: drive not ready in finish_rw() !");
 		return;
 	}
 	terminate_read(cmd);
 	terminate_write(cmd);
-} /* finish_rw */
+}				/* finish_rw */
 
 
 /* Perform a QIC command through ll_do_qic_cmd().
@@ -1109,12 +1137,12 @@
 			return stat;
 		}
 		need_rewind = NO;
-		if (cmd==QCMD_REWIND)	/* don't wind beyond BOT ;-) */
+		if (cmd == QCMD_REWIND)	/* don't wind beyond BOT ;-) */
 			return 0;
 	}
 
 	return ll_do_qic_cmd(cmd, timeout);
-} /* do_qic_cmd */
+}				/* do_qic_cmd */
 
 
 /* Not all ioctls are supported for all drives. Some rely on
@@ -1132,217 +1160,218 @@
 	 */
 
 	switch (cmd) {
-		case MTRESET:
-			/* reset verbose */
-			return (tape_reset(1)==TE_OK)? 0 : -EIO;
-
-		case MTFSF:
-			tpqputs(TPQD_IOCTLS, "MTFSF forward searching filemark");
-			if ((mode_access==WRITE) && status_bytes_wr)
+	case MTRESET:
+		/* reset verbose */
+		return (tape_reset(1) == TE_OK) ? 0 : -EIO;
+
+	case MTFSF:
+		tpqputs(TPQD_IOCTLS, "MTFSF forward searching filemark");
+		if ((mode_access == WRITE) && status_bytes_wr)
+			return -EACCES;
+		return do_qic_cmd(QCMD_RD_FM, TIM_F);
+
+	case MTBSF:
+		if (TP_HAVE_BSF) {
+			tpqputs(TPQD_IOCTLS,
+				"MTBSF backward searching filemark -- optional command");
+			if ((mode_access == WRITE) && status_bytes_wr)
 				return -EACCES;
-			return do_qic_cmd(QCMD_RD_FM, TIM_F);
-
-		case MTBSF:
-			if (TP_HAVE_BSF) {
-				tpqputs(TPQD_IOCTLS, "MTBSF backward searching filemark -- optional command");
-				if ((mode_access==WRITE) && status_bytes_wr)
-					return -EACCES;
-				stat = do_qic_cmd(QCMD_RD_FM_BCK, TIM_F);
-			} else {
-				stat = -ENXIO;
-			}
-			status_eom_detected = status_eof_detected = NO;
-			return stat;
-
-		case MTFSR:
-			if (TP_HAVE_FSR) { /* This is an optional QIC-02 command */
-				tpqputs(TPQD_IOCTLS, "MTFSR forward space record");
-				if ((mode_access==WRITE) && status_bytes_wr)
-					return -EACCES;
-				stat = do_qic_cmd(QCMD_SPACE_FWD, TIM_F);
-			} else {
-				/**** fake it by doing a read data block command? ******/
-				tpqputs(TPQD_IOCTLS, "MTFSR not supported");
-				stat = -ENXIO;
-			}
-			return stat;
-
-		case MTBSR:
-			if (TP_HAVE_BSR) { /* This is an optional QIC-02 command */
-				/* we need this for appending files with GNU tar!! */
-				tpqputs(TPQD_IOCTLS, "MTFSR backward space record");
-				if ((mode_access==WRITE) && status_bytes_wr)
-					return -EACCES;
-				stat = do_qic_cmd(QCMD_SPACE_BCK, TIM_F);
-			} else {
-				tpqputs(TPQD_IOCTLS, "MTBSR not supported");
-				stat = -ENXIO;
-			}
-			status_eom_detected = status_eof_detected = NO;
-			return stat;
+			stat = do_qic_cmd(QCMD_RD_FM_BCK, TIM_F);
+		} else {
+			stat = -ENXIO;
+		}
+		status_eom_detected = status_eof_detected = NO;
+		return stat;
 
-		case MTWEOF:
-			tpqputs(TPQD_IOCTLS, "MTWEOF write eof mark");
-			/* Plain GNU mt(1) 2.2 uses read-only mode for writing FM. :-( */
-			if (mode_access==READ)
+	case MTFSR:
+		if (TP_HAVE_FSR) {	/* This is an optional QIC-02 command */
+			tpqputs(TPQD_IOCTLS, "MTFSR forward space record");
+			if ((mode_access == WRITE) && status_bytes_wr)
 				return -EACCES;
+			stat = do_qic_cmd(QCMD_SPACE_FWD, TIM_F);
+		} else {
+				/**** fake it by doing a read data block command? ******/
+			tpqputs(TPQD_IOCTLS, "MTFSR not supported");
+			stat = -ENXIO;
+		}
+		return stat;
 
-			/* allow tape movement after writing FM */
-			status_bytes_rd = status_bytes_wr;	/* Kludge-O-Matic */
-			status_bytes_wr = NO;
-			return do_qic_cmd(QCMD_WRT_FM, TIM_M);
-			/* not sure what to do with status_bytes when WFM should fail */
-
-		case MTREW:
-			tpqputs(TPQD_IOCTLS, "MTREW rewinding tape");
-			if ((mode_access==WRITE) && status_bytes_wr)
+	case MTBSR:
+		if (TP_HAVE_BSR) {	/* This is an optional QIC-02 command */
+			/* we need this for appending files with GNU tar!! */
+			tpqputs(TPQD_IOCTLS, "MTFSR backward space record");
+			if ((mode_access == WRITE) && status_bytes_wr)
 				return -EACCES;
-			status_eom_detected = status_eof_detected = NO;
-			return do_qic_cmd(QCMD_REWIND, TIM_R);
+			stat = do_qic_cmd(QCMD_SPACE_BCK, TIM_F);
+		} else {
+			tpqputs(TPQD_IOCTLS, "MTBSR not supported");
+			stat = -ENXIO;
+		}
+		status_eom_detected = status_eof_detected = NO;
+		return stat;
 
-		case MTOFFL:
-			tpqputs(TPQD_IOCTLS, "MTOFFL rewinding & going offline");
-			/* Doing a drive select will clear (unlock) the current drive.
-			 * But that requires support for multiple drives and locking.
-			 */
-			if ((mode_access==WRITE) && status_bytes_wr)
-				return -EACCES;
-			status_eom_detected = status_eof_detected = NO;
+	case MTWEOF:
+		tpqputs(TPQD_IOCTLS, "MTWEOF write eof mark");
+		/* Plain GNU mt(1) 2.2 uses read-only mode for writing FM. :-( */
+		if (mode_access == READ)
+			return -EACCES;
+
+		/* allow tape movement after writing FM */
+		status_bytes_rd = status_bytes_wr;	/* Kludge-O-Matic */
+		status_bytes_wr = NO;
+		return do_qic_cmd(QCMD_WRT_FM, TIM_M);
+		/* not sure what to do with status_bytes when WFM should fail */
+
+	case MTREW:
+		tpqputs(TPQD_IOCTLS, "MTREW rewinding tape");
+		if ((mode_access == WRITE) && status_bytes_wr)
+			return -EACCES;
+		status_eom_detected = status_eof_detected = NO;
+		return do_qic_cmd(QCMD_REWIND, TIM_R);
+
+	case MTOFFL:
+		tpqputs(TPQD_IOCTLS, "MTOFFL rewinding & going offline");
+		/* Doing a drive select will clear (unlock) the current drive.
+		 * But that requires support for multiple drives and locking.
+		 */
+		if ((mode_access == WRITE) && status_bytes_wr)
+			return -EACCES;
+		status_eom_detected = status_eof_detected = NO;
 			/**** do rewind depending on minor bits??? ***/
-			stat = do_qic_cmd(QCMD_REWIND, TIM_R);
-			return stat;
+		stat = do_qic_cmd(QCMD_REWIND, TIM_R);
+		return stat;
 
-		case MTNOP:
-			tpqputs(TPQD_IOCTLS, "MTNOP setting status only");
+	case MTNOP:
+		tpqputs(TPQD_IOCTLS, "MTNOP setting status only");
 			/********** should do `read position' for drives that support it **********/
-			return (tp_sense(-1)==TE_OK)? 0 : -EIO;	/**** check return codes ****/
-
-		case MTRETEN:
-			tpqputs(TPQD_IOCTLS, "MTRETEN retension tape");
-			if ((mode_access==WRITE) && status_bytes_wr)
-				return -EACCES;
-			status_eom_detected = status_eof_detected = NO;
-			return do_qic_cmd(QCMD_RETEN, TIM_R);
+		return (tp_sense(-1) == TE_OK) ? 0 : -EIO;	/**** check return codes ****/
 
-		case MTBSFM:
-			/* Think think is like MTBSF, except that
-			 * we shouldn't skip the FM. Tricky.
-			 * Maybe use RD_FM_BCK, then do a SPACE_FWD?
-			 */
-			tpqputs(TPQD_IOCTLS, "MTBSFM not supported");
-			if ((mode_access==WRITE) && status_bytes_wr)
-				return -EACCES;
-			return -ENXIO;
+	case MTRETEN:
+		tpqputs(TPQD_IOCTLS, "MTRETEN retension tape");
+		if ((mode_access == WRITE) && status_bytes_wr)
+			return -EACCES;
+		status_eom_detected = status_eof_detected = NO;
+		return do_qic_cmd(QCMD_RETEN, TIM_R);
+
+	case MTBSFM:
+		/* Think think is like MTBSF, except that
+		 * we shouldn't skip the FM. Tricky.
+		 * Maybe use RD_FM_BCK, then do a SPACE_FWD?
+		 */
+		tpqputs(TPQD_IOCTLS, "MTBSFM not supported");
+		if ((mode_access == WRITE) && status_bytes_wr)
+			return -EACCES;
+		return -ENXIO;
 
-		case MTFSFM:
-			/* I think this is like MTFSF, except that
-			 * we shouldn't skip the FM. Tricky.
-			 * Maybe use QCMD_RD_DATA until we get a TP_FIL exception?
-			 * But then the FM will have been skipped...
-			 * Maybe use RD_FM, then RD_FM_BCK, but not all
-			 * drives will support that!
-			 */
-			tpqputs(TPQD_IOCTLS, "MTFSFM not supported");
-			if ((mode_access==WRITE) && status_bytes_wr)
-				return -EACCES;
-			return -ENXIO;
+	case MTFSFM:
+		/* I think this is like MTFSF, except that
+		 * we shouldn't skip the FM. Tricky.
+		 * Maybe use QCMD_RD_DATA until we get a TP_FIL exception?
+		 * But then the FM will have been skipped...
+		 * Maybe use RD_FM, then RD_FM_BCK, but not all
+		 * drives will support that!
+		 */
+		tpqputs(TPQD_IOCTLS, "MTFSFM not supported");
+		if ((mode_access == WRITE) && status_bytes_wr)
+			return -EACCES;
+		return -ENXIO;
 
-		case MTEOM:
-			/* This should leave the tape ready for appending
-			 * another file to the end, such that it would append
-			 * after the last FM on tape.
+	case MTEOM:
+		/* This should leave the tape ready for appending
+		 * another file to the end, such that it would append
+		 * after the last FM on tape.
+		 */
+		tpqputs(TPQD_IOCTLS, "MTEOM search for End Of recorded Media");
+		if ((mode_access == WRITE) && status_bytes_wr)
+			return -EACCES;
+		if (TP_HAVE_EOD) {
+			/* Use faster seeking when possible.
+			 * This requires the absence of data beyond the EOM.
+			 * It seems that my drive does not always perform the
+			 * SEEK_EOD correctly, unless it is preceded by a
+			 * rewind command.
 			 */
-			tpqputs(TPQD_IOCTLS, "MTEOM search for End Of recorded Media");
-			if ((mode_access==WRITE) && status_bytes_wr)
-				return -EACCES;
-			if (TP_HAVE_EOD) {
-				/* Use faster seeking when possible.
-				 * This requires the absence of data beyond the EOM.
-				 * It seems that my drive does not always perform the
-				 * SEEK_EOD correctly, unless it is preceded by a
-				 * rewind command.
-				 */
 # if 0
-				status_eom_detected = status_eof_detected = NO;
+			status_eom_detected = status_eof_detected = NO;
 # endif
-				stat = do_qic_cmd(QCMD_REWIND, TIM_R);
-				if (stat)
-					return stat;
-				stat = do_qic_cmd(QCMD_SEEK_EOD, TIM_F);
-				/* After a successful seek, TP_EOR should be returned */
-			} else {
-				/* else just seek until the drive returns exception "No Data" */
-				stat = 0;
-				while ((stat==0) && (!status_eom_detected)) {
-					stat = do_qic_cmd(QCMD_RD_FM, TIM_F); /***** should use MTFSFM here???? ******/
-				}
-				if (tperror.exs & TP_NDT)
-					return 0;
-			}
-			return stat;
-
-		case MTERASE:
-			tpqputs(TPQD_IOCTLS, "MTERASE -- ERASE TAPE !");
-			if  ((tperror.exs & TP_ST0) && (tperror.exs & TP_WRP)) {
-				tpqputs(TPQD_ALWAYS, "Cartridge is write-protected.");
-				return -EACCES;
-			} else {
-				time_t t = jiffies;
-
-				/* Plain GNU mt(1) 2.2 erases a tape in O_RDONLY. :-( */
-				if (mode_access==READ) 
-					return -EACCES;
-
-				/* give user a few seconds to pull out tape */
-				while (jiffies - t < 4*HZ)
-					schedule();
+			stat = do_qic_cmd(QCMD_REWIND, TIM_R);
+			if (stat)
+				return stat;
+			stat = do_qic_cmd(QCMD_SEEK_EOD, TIM_F);
+			/* After a successful seek, TP_EOR should be returned */
+		} else {
+			/* else just seek until the drive returns exception "No Data" */
+			stat = 0;
+			while ((stat == 0) && (!status_eom_detected)) {
+				stat = do_qic_cmd(QCMD_RD_FM, TIM_F);	      /***** should use MTFSFM here???? ******/
 			}
+			if (tperror.exs & TP_NDT)
+				return 0;
+		}
+		return stat;
 
-			/* don't bother writing filemark first */
-			status_eom_detected = status_eof_detected = NO;
-			return do_qic_cmd(QCMD_ERASE, TIM_R);
+	case MTERASE:
+		tpqputs(TPQD_IOCTLS, "MTERASE -- ERASE TAPE !");
+		if ((tperror.exs & TP_ST0) && (tperror.exs & TP_WRP)) {
+			tpqputs(TPQD_ALWAYS, "Cartridge is write-protected.");
+			return -EACCES;
+		} else {
+			time_t t = jiffies;
 
-		case MTRAS1:
-			if (TP_HAVE_RAS1) {
-				tpqputs(TPQD_IOCTLS, "MTRAS1: non-destructive self test");
-				stat = do_qic_cmd(QCMD_SELF_TST1, TIM_R);
-				if (stat != 0) {
-					tpqputs(TPQD_ALWAYS, "RAS1 failed");
-					return stat;
-				}
-				return (tp_sense(0)==TE_OK)? 0 : -EIO; /* get_ext_status3(); */
-			}
-			tpqputs(TPQD_IOCTLS, "RAS1 not supported");
-			return -ENXIO;
+			/* Plain GNU mt(1) 2.2 erases a tape in O_RDONLY. :-( */
+			if (mode_access == READ)
+				return -EACCES;
 
-		case MTRAS2:
-			if (TP_HAVE_RAS2) {
-				tpqputs(TPQD_IOCTLS, "MTRAS2: destructive self test");
-				stat = do_qic_cmd(QCMD_SELF_TST2, TIM_R);
-				if (stat != 0) {
-					tpqputs(TPQD_ALWAYS, "RAS2 failed");
-					return stat;
-				}
-				return (tp_sense(0)==TE_OK)? 0 : -EIO; /* get_ext_status3(); */
+			/* FIXME */
+			/* give user a few seconds to pull out tape */
+			while (jiffies - t < 4 * HZ)
+				schedule();
+		}
+
+		/* don't bother writing filemark first */
+		status_eom_detected = status_eof_detected = NO;
+		return do_qic_cmd(QCMD_ERASE, TIM_R);
+
+	case MTRAS1:
+		if (TP_HAVE_RAS1) {
+			tpqputs(TPQD_IOCTLS, "MTRAS1: non-destructive self test");
+			stat = do_qic_cmd(QCMD_SELF_TST1, TIM_R);
+			if (stat != 0) {
+				tpqputs(TPQD_ALWAYS, "RAS1 failed");
+				return stat;
 			}
-			tpqputs(TPQD_IOCTLS, "RAS2 not supported");
-			return -ENXIO;
+			return (tp_sense(0) == TE_OK) ? 0 : -EIO;	/* get_ext_status3(); */
+		}
+		tpqputs(TPQD_IOCTLS, "RAS1 not supported");
+		return -ENXIO;
 
-		case MTSEEK:
-			if (TP_HAVE_SEEK && (QIC02_TAPE_IFC==ARCHIVE)) {
-				tpqputs(TPQD_IOCTLS, "MTSEEK seeking block");
-				if ((mode_access==WRITE) && status_bytes_wr)
-					return -EACCES;
-				/* NOTE: address (24 bits) is in seek_addr_buf[] */
-				return do_qic_cmd(AR_QCMDV_SEEK_BLK, TIM_F);
+	case MTRAS2:
+		if (TP_HAVE_RAS2) {
+			tpqputs(TPQD_IOCTLS, "MTRAS2: destructive self test");
+			stat = do_qic_cmd(QCMD_SELF_TST2, TIM_R);
+			if (stat != 0) {
+				tpqputs(TPQD_ALWAYS, "RAS2 failed");
+				return stat;
 			}
-			else
-				return -ENOTTY;
+			return (tp_sense(0) == TE_OK) ? 0 : -EIO;	/* get_ext_status3(); */
+		}
+		tpqputs(TPQD_IOCTLS, "RAS2 not supported");
+		return -ENXIO;
 
-		default:
+	case MTSEEK:
+		if (TP_HAVE_SEEK && (QIC02_TAPE_IFC == ARCHIVE)) {
+			tpqputs(TPQD_IOCTLS, "MTSEEK seeking block");
+			if ((mode_access == WRITE) && status_bytes_wr)
+				return -EACCES;
+			/* NOTE: address (24 bits) is in seek_addr_buf[] */
+			return do_qic_cmd(AR_QCMDV_SEEK_BLK, TIM_F);
+		} else
 			return -ENOTTY;
+
+	default:
+		return -ENOTTY;
 	}
-} /* do_ioctl_cmd */
+}				/* do_ioctl_cmd */
 
 
 /* dma_transfer(): This routine is called for every 512 bytes to be read
@@ -1362,40 +1391,43 @@
  *	- adjust the timeout
  *	- tell the tape controller to start transferring
  * We assume the dma address and mode are, and remain, valid.
- */ 
+ */
 static inline void dma_transfer(void)
 {
 	unsigned long flags;
 
-	if (QIC02_TAPE_IFC == WANGTEK) /* or EVEREX */
+	if (QIC02_TAPE_IFC == WANGTEK)	/* or EVEREX */
 		outb_p(WT_CTL_ONLINE, QIC02_CTL_PORT);	/* back to normal */
 	else if (QIC02_TAPE_IFC == ARCHIVE)
 		outb_p(0, AR_RESET_DMA_PORT);
-	else /* QIC02_TAPE_IFC == MOUNTAIN */
+	else			/* QIC02_TAPE_IFC == MOUNTAIN */
 		outb_p(ctlbits, QIC02_CTL_PORT);
 
 
-	flags=claim_dma_lock();
+	flags = claim_dma_lock();
 	clear_dma_ff(QIC02_TAPE_DMA);
 	set_dma_mode(QIC02_TAPE_DMA, dma_mode);
-	set_dma_addr(QIC02_TAPE_DMA, virt_to_bus(buffaddr) + dma_bytes_done);
+	set_dma_addr(QIC02_TAPE_DMA,
+		     virt_to_bus(buffaddr) + dma_bytes_done);
 	set_dma_count(QIC02_TAPE_DMA, TAPE_BLKSIZE);
 
 	/* start tape DMA controller */
-	if (QIC02_TAPE_IFC == WANGTEK) /* or EVEREX */
-		outb_p(WT_CTL_DMA | WT_CTL_ONLINE, QIC02_CTL_PORT); /* trigger DMA transfer */
+	if (QIC02_TAPE_IFC == WANGTEK)	/* or EVEREX */
+		outb_p(WT_CTL_DMA | WT_CTL_ONLINE, QIC02_CTL_PORT);	/* trigger DMA transfer */
 
 	else if (QIC02_TAPE_IFC == ARCHIVE) {
-		outb_p(AR_CTL_IEN | AR_CTL_DNIEN, QIC02_CTL_PORT);  /* enable interrupts again */
-		outb_p(0, AR_START_DMA_PORT);			  /* start DMA transfer */
+		outb_p(AR_CTL_IEN | AR_CTL_DNIEN, QIC02_CTL_PORT);	/* enable interrupts again */
+		outb_p(0, AR_START_DMA_PORT);	/* start DMA transfer */
 		/* In dma_end() AR_RESET_DMA_PORT is written too. */
 
-	} else /* QIC02_TAPE_IFC == MOUNTAIN */ {
+	} else {		/* QIC02_TAPE_IFC == MOUNTAIN */
+
 		inb(MTN_R_DESELECT_DMA_PORT);
-		outb_p(ctlbits | (MTN_CTL_EXC_IEN | MTN_CTL_DNIEN), QIC02_CTL_PORT);
-		outb_p(0, MTN_W_SELECT_DMA_PORT);	 /* start DMA transfer */
+		outb_p(ctlbits | (MTN_CTL_EXC_IEN | MTN_CTL_DNIEN),
+		       QIC02_CTL_PORT);
+		outb_p(0, MTN_W_SELECT_DMA_PORT);	/* start DMA transfer */
 		if (dma_mode == DMA_MODE_WRITE)
-			outb_p(0, MTN_W_DMA_WRITE_PORT); /* start DMA transfer */
+			outb_p(0, MTN_W_DMA_WRITE_PORT);	/* start DMA transfer */
 	}
 
 	/* start computer DMA controller */
@@ -1406,7 +1438,7 @@
 	/* block transfer should start now, jumping to the 
 	 * interrupt routine when done or an exception was detected.
 	 */
-} /* dma_transfer */
+}				/* dma_transfer */
 
 
 /* start_dma() sets a DMA transfer up between the tape controller and
@@ -1421,15 +1453,16 @@
 {
 	int stat;
 	unsigned long flags;
-	
+
 	tpqputs(TPQD_DEBUG, "start_dma() enter");
-	TPQDEB({printk(TPQIC02_NAME ": doing_read==%d, doing_write==%d\n", doing_read, doing_write);})
+	TPQDEB( {printk(TPQIC02_NAME ": doing_read==%d, doing_write==%d\n",
+		      doing_read, doing_write);})
 
-	dma_bytes_done = 0;
+	    dma_bytes_done = 0;
 	dma_bytes_todo = bytes_todo;
 	status_error = NO;
 	/* dma_mode!=0 indicates that the dma controller is in use */
-	dma_mode = (mode == WRITE)? DMA_MODE_WRITE : DMA_MODE_READ;	
+	dma_mode = (mode == WRITE) ? DMA_MODE_WRITE : DMA_MODE_READ;
 
 	/* Only give READ/WRITE DATA command to tape drive if we haven't
 	 * done that already. Otherwise the drive will rewind to the beginning
@@ -1443,22 +1476,25 @@
 
 #if 0
 		/* Next dummy get status is to make sure CNI is valid,
-                   since we're only just starting a read/write it doesn't
-                   matter some exceptions are cleared by reading the status;
-                   we're only interested in CNI and WRP. -Eddy */
+		   since we're only just starting a read/write it doesn't
+		   matter some exceptions are cleared by reading the status;
+		   we're only interested in CNI and WRP. -Eddy */
 		get_status(&tperror);
 #else
 		/* TP_CNI should now be handled in open(). -Hennus */
 #endif
 
-		stat = tp_sense(((mode == WRITE)? 0 : TP_WRP) | TP_BOM | TP_FIL);
+		stat =
+		    tp_sense(((mode ==
+			       WRITE) ? 0 : TP_WRP) | TP_BOM | TP_FIL);
 		if (stat != TE_OK)
 			return stat;
 
 #if OBSOLETE
 		/************* not needed iff rd_status() would wait for ready!!!!!! **********/
 		if (wait_for_ready(TIM_S) != TE_OK) {	/*** not sure this is needed ***/
-			tpqputs(TPQD_ALWAYS, "wait_for_ready failed in start_dma");
+			tpqputs(TPQD_ALWAYS,
+				"wait_for_ready failed in start_dma");
 			return -EIO;
 		}
 #endif
@@ -1471,10 +1507,11 @@
 		/* Tell the controller the data direction */
 
 		/* r/w, timeout medium, check exceptions, sets status_cmd_pending. */
-		stat = send_qic02_cmd((mode == WRITE)? QCMD_WRT_DATA : QCMD_RD_DATA, TIM_M, 0);
-		if (stat!=TE_OK) {
+		stat = send_qic02_cmd((mode == WRITE) 
+					? QCMD_WRT_DATA : QCMD_RD_DATA, TIM_M, 0);
+		if (stat != TE_OK) {
 			printk(TPQIC02_NAME ": start_dma: init %s failed\n",
-				(mode == WRITE)? "write" : "read");
+			       (mode == WRITE) ? "write" : "read");
 			(void) tp_sense(0);
 			return stat;
 		}
@@ -1485,15 +1522,17 @@
 		if (wait_for_ready(TIM_M) != TE_OK)
 			return -EIO;
 		switch (mode) {
-			case READ:
-				doing_read = YES;
-				break;
-			case WRITE:
-				doing_write = YES;
-				break;
-			default:
-				printk(TPQIC02_NAME ": requested unknown mode %d\n", mode);
-				panic(TPQIC02_NAME ": invalid mode in start_dma()");
+		case READ:
+			doing_read = YES;
+			break;
+		case WRITE:
+			doing_write = YES;
+			break;
+		default:
+			printk(TPQIC02_NAME
+			       ": requested unknown mode %d\n", mode);
+			panic(TPQIC02_NAME
+			      ": invalid mode in start_dma()");
 		}
 
 	} else if (is_exception()) {
@@ -1502,7 +1541,8 @@
 		 *
 		 * ******** this also affects EOF/EOT handling! ************
 		 */
-		tpqputs(TPQD_ALWAYS, "detected exception in start_dma() while transfer in progress");
+		tpqputs(TPQD_ALWAYS,
+			"detected exception in start_dma() while transfer in progress");
 		status_error = YES;
 		return TE_END;
 	}
@@ -1513,7 +1553,7 @@
 	/* This assumes tape is already positioned, but these
 	 * semi-'intelligent' drives are unpredictable...
 	 */
-	TIMERON(TIM_M*2);
+	TIMERON(TIM_M * 2);
 
 	/* initiate first data block read from/write to the tape controller */
 
@@ -1524,7 +1564,7 @@
 
 	TPQPUTS("start_dma() end");
 	return TE_OK;
-} /* start_dma */
+}				/* start_dma */
 
 
 /* This cleans up after the dma transfer has completed
@@ -1533,7 +1573,7 @@
  * sense() will set `status_eof_detected' and
  * `status_eom_detected', as required.
  */
-static void end_dma(unsigned long * bytes_done)
+static void end_dma(unsigned long *bytes_done)
 {
 	int stat = TE_OK;
 	unsigned long flags;
@@ -1542,35 +1582,37 @@
 
 	TPQPUTS("end_dma() enter");
 
-	flags=claim_dma_lock();
-	
+	flags = claim_dma_lock();
+
 	disable_dma(QIC02_TAPE_DMA);
 	clear_dma_ff(QIC02_TAPE_DMA);
-	
+
 	release_dma_lock(flags);
 
-	if (QIC02_TAPE_IFC == WANGTEK) /* or EVEREX */
+	if (QIC02_TAPE_IFC == WANGTEK)	/* or EVEREX */
 		outb_p(WT_CTL_ONLINE, QIC02_CTL_PORT);	/* back to normal */
 	else if (QIC02_TAPE_IFC == ARCHIVE)
 		outb_p(0, AR_RESET_DMA_PORT);
-	else /* QIC02_TAPE_IFC == MOUNTAIN */ {
+	else {			/* QIC02_TAPE_IFC == MOUNTAIN */
+
 		/* Clear control bits, de-select ONLINE during tp_sense */
 		ctlbits &= ~MTN_QIC02_CTL_ONLINE;
 	}
 
 	stat = wait_for_ready(TIM_M);
-	if (status_error || (stat!=TE_OK)) {
+	if (status_error || (stat != TE_OK)) {
 		tpqputs(TPQD_DMAX, "DMA transfer exception");
-		stat = tp_sense((dma_mode==READ)? TP_WRP : 0);
+		stat = tp_sense((dma_mode == READ) ? TP_WRP : 0);
 		/* no return here -- got to clean up first! */
-	} else /* if (QIC02_TAPE_IFC == MOUNTAIN) */ {
+	} else {		/* if (QIC02_TAPE_IFC == MOUNTAIN) */
+
 		outb_p(ctlbits, QIC02_CTL_PORT);
 	}
 
 	if (QIC02_TAPE_IFC == MOUNTAIN)
 		inb(MTN_R_DESELECT_DMA_PORT);
 
- 	/* take the tape controller offline */
+	/* take the tape controller offline */
 
 	/* finish off DMA stuff */
 
@@ -1588,7 +1630,7 @@
 
 	TPQPUTS("end_dma() exit");
 	/*** could return stat here ***/
-} /* end_dma */
+}				/* end_dma */
 
 /*********** Below are the (public) OS-interface procedures ***********/
 
@@ -1602,7 +1644,7 @@
 static void qic02_tape_times_out(unsigned long dummy)
 {
 	printk("time-out in %s driver\n", TPQIC02_NAME);
-	if ((status_cmd_pending>0) || dma_mode) {
+	if ((status_cmd_pending > 0) || dma_mode) {
 		/* takes tooo long, shut it down */
 		status_dead = YES;
 		status_cmd_pending = 0;
@@ -1614,7 +1656,7 @@
 			wake_up(&qic02_tape_transfer);
 		}
 	}
-} /* qic02_tape_times_out */
+}				/* qic02_tape_times_out */
 
 /*
  * Interrupt handling:
@@ -1647,7 +1689,8 @@
  * When we are finished, set flags to indicate end, disable timer.
  * NOTE: This *must* be fast! 
  */
-static void qic02_tape_interrupt(int irq, void *dev_id, struct pt_regs *regs)
+static void qic02_tape_interrupt(int irq, void *dev_id,
+				 struct pt_regs *regs)
 {
 	int stat, r, i;
 	unsigned long flags;
@@ -1662,20 +1705,21 @@
 		stat = inb(QIC02_STAT_PORT);	/* Knock, knock */
 		if (QIC02_TAPE_IFC == ARCHIVE) {	/* "Who's there?" */
 			if (((stat & (AR_STAT_DMADONE)) == 0) &&
-        	              ((stat & (QIC02_STAT_EXCEPTION)) != 0)) {
+			    ((stat & (QIC02_STAT_EXCEPTION)) != 0)) {
 				TIMERCONT;
-				return;			/* "Linux with IRQ sharing" */
+				return;	/* "Linux with IRQ sharing" */
 			}
 		}
 
 		if ((stat & QIC02_STAT_EXCEPTION) == 0) {	/* exception occurred */
 			/* Possible causes for an exception during a transfer:
-			 * 	- during a write-cycle: end of tape (EW) hole detected.
-			 *	- during a read-cycle: filemark or EOD detected.
-			 *	- something went wrong
+			 *      - during a write-cycle: end of tape (EW) hole detected.
+			 *      - during a read-cycle: filemark or EOD detected.
+			 *      - something went wrong
 			 * So don't continue with the next block.
 			 */
-			tpqputs(TPQD_ALWAYS, "isr: exception on tape controller");
+			tpqputs(TPQD_ALWAYS,
+				"isr: exception on tape controller");
 			printk("      status %02x\n", stat);
 			status_error = TE_EX;
 
@@ -1691,25 +1735,27 @@
 		 */
 		r = 0;
 
-	    /* Skip next ready check for Archive controller because
-	     * it may be busy reading ahead. Weird. --hhb
-	     */
+		/* Skip next ready check for Archive controller because
+		 * it may be busy reading ahead. Weird. --hhb
+		 */
 		if (QIC02_TAPE_IFC == WANGTEK)	/* I think this is a drive-dependency, not IFC -- hhb */
-			if (stat & QIC02_STAT_READY) {		/* not ready */
-				tpqputs(TPQD_ALWAYS, "isr: ? Tape controller not ready");
+			if (stat & QIC02_STAT_READY) {	/* not ready */
+				tpqputs(TPQD_ALWAYS,
+					"isr: ? Tape controller not ready");
 				r = 1;
 			}
 
-		flags=claim_dma_lock();
-		
-		if ( (i = get_dma_residue(QIC02_TAPE_DMA)) != 0 ) {
-			printk(TPQIC02_NAME ": dma_residue == %x !!!\n", i);
+		flags = claim_dma_lock();
+
+		if ((i = get_dma_residue(QIC02_TAPE_DMA)) != 0) {
+			printk(TPQIC02_NAME ": dma_residue == %x !!!\n",
+			       i);
 			r = 1;	/* big trouble, but can't do much about it... */
 		}
-		
+
 		release_dma_lock(flags);
 
-		if (r) 
+		if (r)
 			return;
 
 		/* finish DMA cycle */
@@ -1724,14 +1770,14 @@
 			wake_up(&qic02_tape_transfer);
 		} else {
 			/* start next transfer, account for track-switching time */
-			mod_timer(&tp_timer, jiffies + 6*HZ);
+			mod_timer(&tp_timer, jiffies + 6 * HZ);
 			dma_transfer();
 		}
 	} else {
 		printk(TPQIC02_NAME ": Unexpected interrupt, stat == %x\n",
 		       inb(QIC02_STAT_PORT));
 	}
-} /* qic02_tape_interrupt */
+}				/* qic02_tape_interrupt */
 
 
 /* read/write routines:
@@ -1766,190 +1812,173 @@
  * request would return the EOF flag for the previous file.
  */
 
-static ssize_t qic02_tape_read(struct file * filp, char * buf, size_t count, loff_t *ppos)
+static ssize_t qic02_tape_read(struct file *filp, char *buf, size_t count,
+			       loff_t * ppos)
 {
-    int err;
-    kdev_t dev = filp->f_dentry->d_inode->i_rdev;
-    unsigned short flags = filp->f_flags;
-    unsigned long bytes_todo, bytes_done, total_bytes_done = 0;
-    int stat;
-
-    if (status_zombie==YES)
-    {
-	tpqputs(TPQD_ALWAYS, "configs not set");		
-	return -ENXIO;
-    }
-
-    if (TP_DIAGS(current_tape_dev))
-      /* can't print a ``long long'' (for filp->f_pos), so chop it */
-      printk(TPQIC02_NAME ": request READ, minor=%x, buf=%p, count=%lx"
-	                  ", pos=%lx, flags=%x\n",
-	     MINOR(dev), buf, (long) count,
-	     (unsigned long) filp->f_pos, flags);
-    
-    if (count % TAPE_BLKSIZE)	/* Only allow mod 512 bytes at a time. */
-    {
-	tpqputs(TPQD_BLKSZ, "Wrong block size");
-	return -EINVAL;
-    }
+	int err;
+	kdev_t dev = filp->f_dentry->d_inode->i_rdev;
+	unsigned short flags = filp->f_flags;
+	unsigned long bytes_todo, bytes_done, total_bytes_done = 0;
+	int stat;
+
+	if (status_zombie == YES) {
+		tpqputs(TPQD_ALWAYS, "configs not set");
+		return -ENXIO;
+	}
 
-    /* Just assume everything is ok. Controller will scream if not. */
+	if (TP_DIAGS(current_tape_dev))
+		/* can't print a ``long long'' (for filp->f_pos), so chop it */
+		printk(TPQIC02_NAME
+		       ": request READ, minor=%x, buf=%p, count=%lx"
+		       ", pos=%lx, flags=%x\n", MINOR(dev), buf,
+		       (long) count, (unsigned long) filp->f_pos, flags);
 
-    if (status_bytes_wr)	/* Once written, no more reads, 'till after WFM. */
-    {
-	return -EACCES;
-    }
-    
-    /* This is rather ugly because it has to implement a finite state
-     * machine in order to handle the EOF situations properly.
-     */
-    while ((signed)count>=0)
-    {
-	bytes_done = 0;
-	/* see how much fits in the kernel buffer */
-	bytes_todo = TPQBUF_SIZE;
-	if (bytes_todo>count)
-	{
-	    bytes_todo = count;
+	if (count % TAPE_BLKSIZE) {	/* Only allow mod 512 bytes at a time. */
+		tpqputs(TPQD_BLKSZ, "Wrong block size");
+		return -EINVAL;
 	}
-	
-	/* Must ensure that user program sees exactly one EOF token (==0) */
-	if (return_read_eof==YES)
-	{
-	    if (TPQDBG(DEBUG))
-	    {
-		printk("read: return_read_eof==%d, reported_read_eof==%d, total_bytes_done==%lu\n", return_read_eof, reported_read_eof, total_bytes_done);
-	    }
-	    
-	    if (reported_read_eof==NO)
-	    {
-		/* have not yet returned EOF to user program */
-		if (total_bytes_done>0)
-		{
-		    return total_bytes_done; /* next time return EOF */
-		}
-		else
-		{
-		    reported_read_eof = YES; /* move on next time */
-		    return 0;		 /* return EOF */
-		}				
-	    }
-	    else
-	    {
-		/* Application program has already received EOF
-		 * (above), now continue with next file on tape,
-		 * if possible.
-		 * When the FM is reached, EXCEPTION is set,
-		 * causing a sense(). Subsequent read/writes will
-		 * continue after the FM.
-		 */
+
+	/* Just assume everything is ok. Controller will scream if not. */
+
+	if (status_bytes_wr) {	/* Once written, no more reads, 'till after WFM. */
+		return -EACCES;
+	}
+
+	/* This is rather ugly because it has to implement a finite state
+	 * machine in order to handle the EOF situations properly.
+	 */
+	while ((signed) count >= 0) {
+		bytes_done = 0;
+		/* see how much fits in the kernel buffer */
+		bytes_todo = TPQBUF_SIZE;
+		if (bytes_todo > count) {
+			bytes_todo = count;
+		}
+
+		/* Must ensure that user program sees exactly one EOF token (==0) */
+		if (return_read_eof == YES) {
+			if (TPQDBG(DEBUG)) {
+				printk
+				    ("read: return_read_eof==%d, reported_read_eof==%d, total_bytes_done==%lu\n",
+				     return_read_eof, reported_read_eof,
+				     total_bytes_done);
+			}
+
+			if (reported_read_eof == NO) {
+				/* have not yet returned EOF to user program */
+				if (total_bytes_done > 0) {
+					return total_bytes_done;	/* next time return EOF */
+				} else {
+					reported_read_eof = YES;	/* move on next time */
+					return 0;	/* return EOF */
+				}
+			} else {
+				/* Application program has already received EOF
+				 * (above), now continue with next file on tape,
+				 * if possible.
+				 * When the FM is reached, EXCEPTION is set,
+				 * causing a sense(). Subsequent read/writes will
+				 * continue after the FM.
+				 */
 		/*********** ?????????? this should check for (EOD|NDT), not EOM, 'cause we can read past EW: ************/
-		if (status_eom_detected)
-		{
-		    /* If EOM, nothing left to read, so keep returning EOFs.
-		     *** should probably set some flag to avoid clearing
-		     *** status_eom_detected through ioctls or something
-		     */
-		    return 0;
-		}
-		else
-		{
-		    /* just eof, there may be more files ahead... */
-		    return_read_eof = NO;
-		    reported_read_eof = NO;
-		    status_eof_detected = NO; /* reset this too */
-		    /*fall through*/
+				if (status_eom_detected) {
+					/* If EOM, nothing left to read, so keep returning EOFs.
+					 *** should probably set some flag to avoid clearing
+					 *** status_eom_detected through ioctls or something
+					 */
+					return 0;
+				} else {
+					/* just eof, there may be more files ahead... */
+					return_read_eof = NO;
+					reported_read_eof = NO;
+					status_eof_detected = NO;	/* reset this too */
+					/*fall through */
+				}
+			}
 		}
-	    }
-	}
-	
+
 	/*****************************/
-	if (bytes_todo==0)
-	{
-	    return total_bytes_done;
-	}
-	
-	if (bytes_todo>0)
-	{
-	    /* start reading data */
-	    if (is_exception())	/****************************************/
-	    {
-		tpqputs(TPQD_DMAX, "is_exception() before start_dma()!");
-	    }
-	    
+		if (bytes_todo == 0) {
+			return total_bytes_done;
+		}
+
+		if (bytes_todo > 0) {
+			/* start reading data */
+			if (is_exception()) {
+/****************************************/
+				tpqputs(TPQD_DMAX,
+					"is_exception() before start_dma()!");
+			}
+
 /******************************************************************
  ***** if start_dma() fails because the head is positioned 0 bytes
  ***** before the FM, (causing EXCEPTION to be set) return_read_eof should
  ***** be set to YES, and we should return total_bytes_done, rather than -ENXIO.
  ***** The app should recognize this as an EOF condition.
  ***************************************************************************/
-	    stat = start_dma(READ, bytes_todo);
-	    if (stat == TE_OK)
-	    {
-		/* Wait for transfer to complete, interrupt should wake us */
-		while (dma_mode != 0)
-		{
-		    sleep_on(&qic02_tape_transfer);
-		}
-		if (status_error)
-		{
-		    return_read_eof = YES;
-		}
-		
-	    }
-	    else if (stat != TE_END)
-	    {
-		/* should do sense() on error here */
+			stat = start_dma(READ, bytes_todo);
+			if (stat == TE_OK) {
+				/* Wait for transfer to complete, interrupt should wake us */
+				while (dma_mode != 0) {
+					sleep_on(&qic02_tape_transfer);
+				}
+				if (status_error) {
+					return_read_eof = YES;
+				}
+
+			} else if (stat != TE_END) {
+				/* should do sense() on error here */
 #if 0
-		return -ENXIO;
+				return -ENXIO;
 #else
-		printk("Trouble: stat==%02x\n", stat);
-		return_read_eof = YES;
+				printk("Trouble: stat==%02x\n", stat);
+				return_read_eof = YES;
 		/*************** check EOF/EOT handling!!!!!! **/
 #endif
-	    }
-	    end_dma(&bytes_done);
-	    if (bytes_done>bytes_todo)
-	    {
-		tpqputs(TPQD_ALWAYS, "read: Oops, read more bytes than requested");
-		return -EIO;
-	    }
-	    /* copy buffer to user-space in one go */
-	    if (bytes_done>0)
-	    {
-		err = copy_to_user(buf, buffaddr, bytes_done);
-		if (err)
-		{
-		    return -EFAULT;
-		}
-	    }
+			}
+			end_dma(&bytes_done);
+			if (bytes_done > bytes_todo) {
+				tpqputs(TPQD_ALWAYS,
+					"read: Oops, read more bytes than requested");
+				return -EIO;
+			}
+			/* copy buffer to user-space in one go */
+			if (bytes_done > 0) {
+				err =
+				    copy_to_user(buf, buffaddr,
+						 bytes_done);
+				if (err) {
+					return -EFAULT;
+				}
+			}
 #if 1
-	    /* Checks Ton's patch below */
-	    if ((return_read_eof == NO) && (status_eof_detected == YES))
-	    {
-		printk(TPQIC02_NAME ": read(): return_read_eof=%d, status_eof_detected=YES. return_read_eof:=YES\n", return_read_eof);
-	    }
+			/* Checks Ton's patch below */
+			if ((return_read_eof == NO)
+			    && (status_eof_detected == YES)) {
+				printk(TPQIC02_NAME
+				       ": read(): return_read_eof=%d, status_eof_detected=YES. return_read_eof:=YES\n",
+				       return_read_eof);
+			}
 #endif
-	    if ((bytes_todo != bytes_done) || (status_eof_detected == YES))
-	    {
-		/* EOF or EOM detected. return EOF next time. */
-		return_read_eof = YES;
-	    }
-	    
-	} /* else: ignore read request for 0 bytes */
+			if ((bytes_todo != bytes_done)
+			    || (status_eof_detected == YES)) {
+				/* EOF or EOM detected. return EOF next time. */
+				return_read_eof = YES;
+			}
 
-	if (bytes_done>0)
-	{
-	    status_bytes_rd = YES;
-	    buf += bytes_done;
-	    *ppos += bytes_done;
-	    total_bytes_done += bytes_done;
-	    count -= bytes_done;
-	}
-    }
-    tpqputs(TPQD_ALWAYS, "read request for <0 bytes");
-    return -EINVAL;
-} /* qic02_tape_read */
+		}
+		/* else: ignore read request for 0 bytes */
+		if (bytes_done > 0) {
+			status_bytes_rd = YES;
+			buf += bytes_done;
+			*ppos += bytes_done;
+			total_bytes_done += bytes_done;
+			count -= bytes_done;
+		}
+	}
+	tpqputs(TPQD_ALWAYS, "read request for <0 bytes");
+	return -EINVAL;
+}				/* qic02_tape_read */
 
 
 
@@ -1981,100 +2010,85 @@
  * tape device again. The driver will detect an exception status in (No Cartridge)
  * and force a rewind. After that tar may continue writing.
  */
-static ssize_t qic02_tape_write( struct file * filp,  const char * buf, 
-		size_t count, loff_t *ppos)
+static ssize_t qic02_tape_write(struct file *filp, const char *buf,
+				size_t count, loff_t * ppos)
 {
-    int err;
-    kdev_t dev = filp->f_dentry->d_inode->i_rdev;
-    unsigned short flags = filp->f_flags;
-    unsigned long bytes_todo, bytes_done, total_bytes_done = 0;
-    
-    if (status_zombie==YES)
-    {
-	tpqputs(TPQD_ALWAYS, "configs not set");		
-	return -ENXIO;
-    }
-
-    if (TP_DIAGS(current_tape_dev))
-    {
-	/* can't print a ``long long'' (for filp->f_pos), so chop it */
-	printk(TPQIC02_NAME ": request WRITE, minor=%x, buf=%p"
-	                    ", count=%lx, pos=%lx, flags=%x\n",
-	       MINOR(dev), buf,
-	       (long) count, (unsigned long) filp->f_pos, flags);
-    }
-    
-    if (count % TAPE_BLKSIZE) 	/* only allow mod 512 bytes at a time */
-    {
-	tpqputs(TPQD_BLKSZ, "Wrong block size");
-	return -EINVAL;
-    }
+	int err;
+	kdev_t dev = filp->f_dentry->d_inode->i_rdev;
+	unsigned short flags = filp->f_flags;
+	unsigned long bytes_todo, bytes_done, total_bytes_done = 0;
 
-    if (mode_access==READ)
-    {
-	tpqputs(TPQD_ALWAYS, "Not in write mode");
-	return -EACCES;
-    }
-
-    /* open() does a sense() and we can assume the tape isn't changed
-     * between open() and release(), so the tperror.exs bits will still
-     * be valid.
-     */
-    if ((tperror.exs & TP_ST0) && (tperror.exs & TP_WRP))
-    {
-	tpqputs(TPQD_ALWAYS, "Cartridge is write-protected.");
-	return -EACCES;	/* don't even try when write protected */
-    }
-      
-    if (doing_read == YES)
-    {
-	terminate_read(0);
-    }
-    
-    while ((signed)count>=0)
-    {
-	/* see how much fits in the kernel buffer */
-	bytes_done = 0;
-	bytes_todo = TPQBUF_SIZE;
-	if (bytes_todo>count)
-	{
-	    bytes_todo = count;
+	if (status_zombie == YES) {
+		tpqputs(TPQD_ALWAYS, "configs not set");
+		return -ENXIO;
 	}
-	
-	if (return_write_eof == YES)
-	{
-	    /* return_write_eof should be reset on reverse tape movements. */
-	    
-	    if (reported_write_eof==NO)
-	    {
-		if (bytes_todo>0)
-		{
-		    tpqputs(TPQD_ALWAYS, "partial write");
-		    /* partial write signals EOF to user program */
-		}
-		reported_write_eof = YES;
-		return total_bytes_done;
-	    }
-	    else
-	    {
-		return -ENOSPC;		 /* return error */
-	    }	
-	}
-	
-	/* Quit when done. */
-	if (bytes_todo==0)
-	{
-	    return total_bytes_done;
+
+	if (TP_DIAGS(current_tape_dev)) {
+		/* can't print a ``long long'' (for filp->f_pos), so chop it */
+		printk(TPQIC02_NAME ": request WRITE, minor=%x, buf=%p"
+		       ", count=%lx, pos=%lx, flags=%x\n",
+		       MINOR(dev), buf,
+		       (long) count, (unsigned long) filp->f_pos, flags);
+	}
+
+	if (count % TAPE_BLKSIZE) {	/* only allow mod 512 bytes at a time */
+		tpqputs(TPQD_BLKSZ, "Wrong block size");
+		return -EINVAL;
+	}
+
+	if (mode_access == READ) {
+		tpqputs(TPQD_ALWAYS, "Not in write mode");
+		return -EACCES;
+	}
+
+	/* open() does a sense() and we can assume the tape isn't changed
+	 * between open() and release(), so the tperror.exs bits will still
+	 * be valid.
+	 */
+	if ((tperror.exs & TP_ST0) && (tperror.exs & TP_WRP)) {
+		tpqputs(TPQD_ALWAYS, "Cartridge is write-protected.");
+		return -EACCES;	/* don't even try when write protected */
+	}
+
+	if (doing_read == YES) {
+		terminate_read(0);
 	}
-	
-	/* copy from user to DMA buffer and initiate transfer. */
-	if (bytes_todo>0)
-	{
-	    err = copy_from_user(buffaddr, buf, bytes_todo);
-	    if (err)
-	    {
-		return -EFAULT;
-	    }
+
+	while ((signed) count >= 0) {
+		/* see how much fits in the kernel buffer */
+		bytes_done = 0;
+		bytes_todo = TPQBUF_SIZE;
+		if (bytes_todo > count) {
+			bytes_todo = count;
+		}
+
+		if (return_write_eof == YES) {
+			/* return_write_eof should be reset on reverse tape movements. */
+
+			if (reported_write_eof == NO) {
+				if (bytes_todo > 0) {
+					tpqputs(TPQD_ALWAYS,
+						"partial write");
+					/* partial write signals EOF to user program */
+				}
+				reported_write_eof = YES;
+				return total_bytes_done;
+			} else {
+				return -ENOSPC;	/* return error */
+			}
+		}
+
+		/* Quit when done. */
+		if (bytes_todo == 0) {
+			return total_bytes_done;
+		}
+
+		/* copy from user to DMA buffer and initiate transfer. */
+		if (bytes_todo > 0) {
+			err = copy_from_user(buffaddr, buf, bytes_todo);
+			if (err) {
+				return -EFAULT;
+			}
 
 /****************** similar problem with read() at FM could happen here at EOT.
  ******************/
@@ -2082,78 +2096,74 @@
 /***** if at EOT, 0 bytes can be written. start_dma() will
  ***** fail and write() will return ENXIO error
  *****/
-	    if (start_dma(WRITE, bytes_todo) != TE_OK)
-	    {
-		tpqputs(TPQD_ALWAYS, "write: start_dma() failed");
-		/* should do sense() on error here */
-		return -ENXIO;	/*********** FIXTHIS **************/
-	    }
-
-	    /* Wait for write to complete, interrupt should wake us. */
-	    while ((status_error == 0) && (dma_mode != 0))
-	    {
-		sleep_on(&qic02_tape_transfer);
-	    }
-
-	    end_dma(&bytes_done);
-	    if (bytes_done>bytes_todo)
-	    {
-		tpqputs(TPQD_ALWAYS, "write: Oops, wrote more bytes than requested");
-		return -EIO;
-	    }
-	    /* If the dma-transfer was aborted because of an exception,
-	     * status_error will have been set in the interrupt handler.
-	     * Then end_dma() will do a sense().
-	     * If the exception was EXC_EOM, the EW-hole was encountered
-	     * and two more blocks could be written. For the time being we'll
-	     * just consider this to be the EOT.
-	     * Otherwise, something Bad happened, such as the maximum number
-	     * of block-rewrites was exceeded. [e.g. A very bad spot on tape was
-	     * encountered. Normally short dropouts are compensated for by
-	     * rewriting the block in error, up to 16 times. I'm not sure
-	     * QIC-24 drives can do this.]
-	     */
-	    if (status_error)
-	    {
-		if (status_eom_detected == YES)
-		{
-		    tpqputs(TPQD_ALWAYS, "write: EW detected");
-		    return_write_eof = YES;
-		}
-		else
-		{
-		    /* probably EXC_RWA */
-		    tpqputs(TPQD_ALWAYS, "write: dma: error in writing");
-		    return -EIO;
-		}
-	    }
-	    if (bytes_todo != bytes_done)
-	    {
-		/* EOF or EOM detected. return EOT next time. */
-		return_write_eof = YES;
-	    }
-	}
-	/* else: ignore write request for 0 bytes. */
-	
-	if (bytes_done>0)
-	{
-	    status_bytes_wr = YES;
-	    buf += bytes_done;
-	    *ppos += bytes_done;
-	    total_bytes_done += bytes_done;
-	    count -= bytes_done;
-	}
-    }
-    
-    tpqputs(TPQD_ALWAYS, "write request for <0 bytes");
-    if (TPQDBG(DEBUG))
-    {
-	printk(TPQIC02_NAME ": status_bytes_wr %x, buf %p"
-	                    ", total_bytes_done %lx, count %lx\n",
-	       status_bytes_wr, buf, total_bytes_done, (long) count);
-    }
-    return -EINVAL;
-} /* qic02_tape_write */
+			if (start_dma(WRITE, bytes_todo) != TE_OK) {
+				tpqputs(TPQD_ALWAYS,
+					"write: start_dma() failed");
+				/* should do sense() on error here */
+				return -ENXIO;
+				/*********** FIXTHIS **************/
+			}
+
+			/* Wait for write to complete, interrupt should wake us. */
+			while ((status_error == 0) && (dma_mode != 0)) {
+				sleep_on(&qic02_tape_transfer);
+			}
+
+			end_dma(&bytes_done);
+			if (bytes_done > bytes_todo) {
+				tpqputs(TPQD_ALWAYS,
+					"write: Oops, wrote more bytes than requested");
+				return -EIO;
+			}
+			/* If the dma-transfer was aborted because of an exception,
+			 * status_error will have been set in the interrupt handler.
+			 * Then end_dma() will do a sense().
+			 * If the exception was EXC_EOM, the EW-hole was encountered
+			 * and two more blocks could be written. For the time being we'll
+			 * just consider this to be the EOT.
+			 * Otherwise, something Bad happened, such as the maximum number
+			 * of block-rewrites was exceeded. [e.g. A very bad spot on tape was
+			 * encountered. Normally short dropouts are compensated for by
+			 * rewriting the block in error, up to 16 times. I'm not sure
+			 * QIC-24 drives can do this.]
+			 */
+			if (status_error) {
+				if (status_eom_detected == YES) {
+					tpqputs(TPQD_ALWAYS,
+						"write: EW detected");
+					return_write_eof = YES;
+				} else {
+					/* probably EXC_RWA */
+					tpqputs(TPQD_ALWAYS,
+						"write: dma: error in writing");
+					return -EIO;
+				}
+			}
+			if (bytes_todo != bytes_done) {
+				/* EOF or EOM detected. return EOT next time. */
+				return_write_eof = YES;
+			}
+		}
+		/* else: ignore write request for 0 bytes. */
+
+		if (bytes_done > 0) {
+			status_bytes_wr = YES;
+			buf += bytes_done;
+			*ppos += bytes_done;
+			total_bytes_done += bytes_done;
+			count -= bytes_done;
+		}
+	}
+
+	tpqputs(TPQD_ALWAYS, "write request for <0 bytes");
+	if (TPQDBG(DEBUG)) {
+		printk(TPQIC02_NAME ": status_bytes_wr %x, buf %p"
+		       ", total_bytes_done %lx, count %lx\n",
+		       status_bytes_wr, buf, total_bytes_done,
+		       (long) count);
+	}
+	return -EINVAL;
+}				/* qic02_tape_write */
 
 
 
@@ -2169,846 +2179,810 @@
  * Don't rewind if the minor bits specify density 0.
  */
 
-static int qic02_tape_open(struct inode * inode, struct file * filp)
+static int qic02_tape_open(struct inode *inode, struct file *filp)
 {
-    static int qic02_tape_open_no_use_count(struct inode *, struct file *);
-    int open_error;
+	static int qic02_tape_open_no_use_count(struct inode *,
+						struct file *);
+	int open_error;
 
-    open_error = qic02_tape_open_no_use_count(inode, filp);
-    return open_error;
+	open_error = qic02_tape_open_no_use_count(inode, filp);
+	return open_error;
 }
 
-static int qic02_tape_open_no_use_count(struct inode * inode, struct file * filp)
+static int qic02_tape_open_no_use_count(struct inode *inode,
+					struct file *filp)
 {
-    kdev_t dev = inode->i_rdev;
-    unsigned short flags = filp->f_flags;
-    unsigned short dens = 0;
-    int s;
-
-
-    if (TP_DIAGS(dev))
-    {
-	printk("qic02_tape_open: dev=%s, flags=%x     ",
-	       kdevname(dev), flags);
-    }
-
-    if (MINOR(dev)==255)	/* special case for resetting */
-    {
-	if (capable(CAP_SYS_ADMIN))
-	{
-	    return (tape_reset(1)==TE_OK) ? -EAGAIN : -ENXIO;
+	kdev_t dev = inode->i_rdev;
+	unsigned short flags = filp->f_flags;
+	unsigned short dens = 0;
+	int s;
+
+
+	if (TP_DIAGS(dev)) {
+		printk("qic02_tape_open: dev=%s, flags=%x     ",
+		       kdevname(dev), flags);
 	}
-	else
-	{
-	    return -EPERM;
+
+	if (MINOR(dev) == 255) {	/* special case for resetting */
+		if (capable(CAP_SYS_ADMIN)) {
+			return (tape_reset(1) == TE_OK) ? -EAGAIN : -ENXIO;
+		} else {
+			return -EPERM;
+		}
 	}
-    }
-    
-    if (status_dead==YES)
-    {
-	/* Allow `mt reset' ioctl() even when already open()ed. */
-	return 0;
-    }
-    
+
+	if (status_dead == YES) {
+		/* Allow `mt reset' ioctl() even when already open()ed. */
+		return 0;
+	}
+
 	/* Only one at a time from here on... */
-    if (file_count(filp)>1) 	/* filp->f_count==1 for the first open() */
-    {
-	return -EBUSY;
-    }
-
-    if (status_zombie==YES)
-    {
-	/* no irq/dma/port stuff allocated yet, no reset done
-	 * yet, so return until MTSETCONFIG has been done.
+	if (file_count(filp) > 1) {	/* filp->f_count==1 for the first open() */
+		return -EBUSY;
+	}
+
+	if (status_zombie == YES) {
+		/* no irq/dma/port stuff allocated yet, no reset done
+		 * yet, so return until MTSETCONFIG has been done.
+		 */
+		return 0;
+	}
+
+	status_bytes_rd = NO;
+	status_bytes_wr = NO;
+
+	return_read_eof = NO;	/********????????????????*****/
+	return_write_eof = (status_eot_detected) ? YES : NO;
+
+	/* Clear this in case user app close()d before reading EOF token */
+	status_eof_detected = NO;
+
+	reported_read_eof = NO;
+	reported_write_eof = NO;
+
+
+	switch (flags & O_ACCMODE) {
+	case O_RDONLY:
+		mode_access = READ;
+		break;
+	case O_WRONLY:		/* Fallthru... Strictly speaking this is not correct... */
+	case O_RDWR:		/* Reads are allowed as long as nothing is written */
+		mode_access = WRITE;
+		break;
+	}
+
+	/* This is to avoid tape-changed problems (TP_CNI exception).
+	 *
+	 * Since removing the cartridge will not raise an exception,
+	 * we always do a tp_sense() to make sure we have the proper
+	 * CNI status, the 2150L may need an additional sense.... - Eddy
 	 */
-	return 0;
-    }
-    
-    status_bytes_rd = NO;
-    status_bytes_wr = NO;
-    
-    return_read_eof = NO;	/********????????????????*****/
-    return_write_eof = (status_eot_detected)? YES : NO;
-
-    /* Clear this in case user app close()d before reading EOF token */
-    status_eof_detected = NO;
-
-    reported_read_eof = NO;
-    reported_write_eof = NO;
-
-
-    switch (flags & O_ACCMODE)
-    {
-     case O_RDONLY:
-	mode_access = READ;
-	break;
-     case O_WRONLY:	/* Fallthru... Strictly speaking this is not correct... */
-     case O_RDWR:	/* Reads are allowed as long as nothing is written */
-	mode_access = WRITE;
-	break;
-    }
-    
-    /* This is to avoid tape-changed problems (TP_CNI exception).
-     *
-     * Since removing the cartridge will not raise an exception,
-     * we always do a tp_sense() to make sure we have the proper
-     * CNI status, the 2150L may need an additional sense.... - Eddy
-     */
-    s = tp_sense(TP_WRP|TP_EOM|TP_BOM|TP_CNI|TP_EOR);
-    
-    if (s == TE_OK)
-    {
-	/* Try to clear cartridge-changed status for Archive-2150L */
-	if ((tperror.exs & TP_ST0) && (tperror.exs & TP_CNI))
-	{
-	    s = tp_sense(TP_WRP|TP_EOM|TP_BOM|TP_CNI|TP_EOR);
+	s = tp_sense(TP_WRP | TP_EOM | TP_BOM | TP_CNI | TP_EOR);
+
+	if (s == TE_OK) {
+		/* Try to clear cartridge-changed status for Archive-2150L */
+		if ((tperror.exs & TP_ST0) && (tperror.exs & TP_CNI)) {
+			s = tp_sense(TP_WRP | TP_EOM | TP_BOM | TP_CNI |
+				     TP_EOR);
+		}
+	}
+
+	if (s != TE_OK) {
+		tpqputs(TPQD_ALWAYS, "open: sense() failed");
+		return -EIO;
 	}
-    }
-    
-    if (s != TE_OK)
-    {
-	tpqputs(TPQD_ALWAYS, "open: sense() failed");
-	return -EIO;
-    }
-
-    /* exception bits should be up-to-date now, so check for
-     * tape presence and exit if absent.
-     * Even `mt stat' will fail without a tape.
-     */
-    if ((tperror.exs & TP_ST0) && (tperror.exs & TP_CNI))
-    {
-	tpqputs(TPQD_ALWAYS, "No tape present.");
-	return -EIO;
-    }
-
-    /* At this point we can assume that a tape is present and
-     * that it will remain present until release() is called.
-     */
-
-    /* not allowed to do QCMD_DENS_* unless tape is rewound */
-    if ((TP_DENS(dev)!=0) && (TP_DENS(current_tape_dev) != TP_DENS(dev)))
-    {
-	/* force rewind if minor bits have changed,
-	 * i.e. user wants to use tape in different format.
-	 * [assuming single drive operation]
+
+	/* exception bits should be up-to-date now, so check for
+	 * tape presence and exit if absent.
+	 * Even `mt stat' will fail without a tape.
 	 */
-	if (TP_HAVE_DENS)
-	{
-	    tpqputs(TPQD_REWIND, "Density minor bits have changed. Forcing rewind.");
-	    need_rewind = YES;
+	if ((tperror.exs & TP_ST0) && (tperror.exs & TP_CNI)) {
+		tpqputs(TPQD_ALWAYS, "No tape present.");
+		return -EIO;
 	}
-    }
-    else
-    {
-	/* density bits still the same, but TP_DIAGS bit 
-	 * may have changed.
+
+	/* At this point we can assume that a tape is present and
+	 * that it will remain present until release() is called.
 	 */
-	current_tape_dev = dev;
-    }
-    
-    if (need_rewind == YES)  /***************** CHECK THIS!!!!!!!! **********/
-    {
-	s = do_qic_cmd(QCMD_REWIND, TIM_R);
-	if (s != 0)
-	{
-	    tpqputs(TPQD_ALWAYS, "open: rewind failed");
-	    return -EIO;
+
+	/* not allowed to do QCMD_DENS_* unless tape is rewound */
+	if ((TP_DENS(dev) != 0)
+	    && (TP_DENS(current_tape_dev) != TP_DENS(dev))) {
+		/* force rewind if minor bits have changed,
+		 * i.e. user wants to use tape in different format.
+		 * [assuming single drive operation]
+		 */
+		if (TP_HAVE_DENS) {
+			tpqputs(TPQD_REWIND,
+				"Density minor bits have changed. Forcing rewind.");
+			need_rewind = YES;
+		}
+	} else {
+		/* density bits still the same, but TP_DIAGS bit 
+		 * may have changed.
+		 */
+		current_tape_dev = dev;
+	}
+
+	if (need_rewind == YES) {
+/***************** CHECK THIS!!!!!!!! **********/
+		s = do_qic_cmd(QCMD_REWIND, TIM_R);
+		if (s != 0) {
+			tpqputs(TPQD_ALWAYS, "open: rewind failed");
+			return -EIO;
+		}
 	}
-    }
 
 
 /* Note: After a reset command, the controller will rewind the tape
  *	 just before performing any tape movement operation! ************ SO SET need_rewind flag!!!!!
- */ 
-    if (status_dead==YES)
-    {
-	tpqputs(TPQD_ALWAYS, "open: tape dead, attempting reset");
-	if (tape_reset(1)!=TE_OK)
-	{
-	    return -ENXIO;
+ */
+	if (status_dead == YES) {
+		tpqputs(TPQD_ALWAYS, "open: tape dead, attempting reset");
+		if (tape_reset(1) != TE_OK) {
+			return -ENXIO;
+		} else {
+			status_dead = NO;
+			if (tp_sense(~(TP_ST1 | TP_ILL)) != TE_OK) {
+				tpqputs(TPQD_ALWAYS,
+					"open: tp_sense() failed\n");
+				status_dead = YES;	/* try reset next time */
+				return -EIO;
+			}
+		}
 	}
-	else
-	{
-	    status_dead = NO;
-	    if (tp_sense(~(TP_ST1|TP_ILL)) != TE_OK)
-	    {
-		tpqputs(TPQD_ALWAYS, "open: tp_sense() failed\n");
-		status_dead = YES;	/* try reset next time */
+
+	/* things should be ok, once we get here */
+
+
+	/* set density: only allowed when TP_BOM status bit is set,
+	 * so we must have done a rewind by now. If not, just skip over.
+	 * Only give set density command when minor bits have changed.
+	 */
+	if (TP_DENS(current_tape_dev) == TP_DENS(dev)) {
+		return 0;
+	}
+
+	current_tape_dev = dev;
+	need_rewind = NO;
+	if (TP_HAVE_DENS) {
+		dens = TP_DENS(dev);
+	}
+
+	if (dens < sizeof(format_names) / sizeof(char *)) {
+		printk(TPQIC02_NAME ": format: %s%s\n",
+		       (dens != 0) ? "QIC-" : "", format_names[dens]);
+	} else {
+		tpqputs(TPQD_REWIND, "Wait for retensioning...");
+	}
+
+	switch (TP_DENS(dev)) {
+	case 0:		/* Minor 0 is for drives without set-density support */
+		s = 0;
+		break;
+	case 1:
+		s = do_qic_cmd(QCMD_DENS_11, TIM_S);
+		break;
+	case 2:
+		s = do_qic_cmd(QCMD_DENS_24, TIM_S);
+		break;
+	case 3:
+		s = do_qic_cmd(QCMD_DENS_120, TIM_S);
+		break;
+	case 4:
+		s = do_qic_cmd(QCMD_DENS_150, TIM_S);
+		break;
+	case 5:
+		s = do_qic_cmd(QCMD_DENS_300, TIM_S);
+		break;
+	case 6:
+		s = do_qic_cmd(QCMD_DENS_600, TIM_S);
+		break;
+	default:		/* otherwise do a retension before anything else */
+		s = do_qic_cmd(QCMD_RETEN, TIM_R);
+	}
+	if (s != 0) {
+		status_dead = YES;	/* force reset */
+		current_tape_dev = 0;	/* earlier 0xff80 */
 		return -EIO;
-	    }
 	}
-    }
-    
-    /* things should be ok, once we get here */
-    
-
-    /* set density: only allowed when TP_BOM status bit is set,
-     * so we must have done a rewind by now. If not, just skip over.
-     * Only give set density command when minor bits have changed.
-     */
-    if (TP_DENS(current_tape_dev) == TP_DENS(dev) )
-    {
+
 	return 0;
-    }
-    
-    current_tape_dev = dev;
-    need_rewind = NO;
-    if (TP_HAVE_DENS)
-    {
-	dens = TP_DENS(dev);
-    }
-    
-    if (dens < sizeof(format_names)/sizeof(char *))
-    {
-	printk(TPQIC02_NAME ": format: %s%s\n", (dens!=0)? "QIC-" : "", format_names[dens]);
-    }
-    else
-    {
-	tpqputs(TPQD_REWIND, "Wait for retensioning...");
-    }
-    
-    switch (TP_DENS(dev))
-    {
-     case 0: /* Minor 0 is for drives without set-density support */
-	s = 0;
-	break;
-     case 1:
-	s = do_qic_cmd(QCMD_DENS_11, TIM_S);
-	break;
-     case 2:
-	s = do_qic_cmd(QCMD_DENS_24, TIM_S);
-	break;
-     case 3:
-	s = do_qic_cmd(QCMD_DENS_120, TIM_S);
-	break;
-     case 4:
-	s = do_qic_cmd(QCMD_DENS_150, TIM_S);
-	break;
-     case 5:
-	s = do_qic_cmd(QCMD_DENS_300, TIM_S);
-	break;
-     case 6:
-	s = do_qic_cmd(QCMD_DENS_600, TIM_S);
-	break;
-     default:  /* otherwise do a retension before anything else */
-	s = do_qic_cmd(QCMD_RETEN, TIM_R);
-    }
-    if (s != 0)
-    {
-	status_dead = YES;	/* force reset */
-	current_tape_dev = 0; /* earlier 0xff80 */
-	return -EIO;
-    }
-    
-    return 0;
-} /* qic02_tape_open */
-
-
-static int qic02_tape_release(struct inode * inode, struct file * filp)
-{
-    kdev_t dev = inode->i_rdev;
-
-    lock_kernel();
-    if (TP_DIAGS(dev))
-    {
-	printk("qic02_tape_release: dev=%s\n",  kdevname(dev));
-    }
-    
-    if (status_zombie==NO)		/* don't rewind in zombie mode */
-    {
-	/* Terminate any pending write cycle. Terminating the read-cycle
-	 * is delayed until it is required to do so for a new command.
-	 */
-	terminate_write(-1);
-	
-	if (status_dead==YES)
-	{
-	    tpqputs(TPQD_ALWAYS, "release: device dead!?");
+}				/* qic02_tape_open */
+
+
+static int qic02_tape_release(struct inode *inode, struct file *filp)
+{
+	kdev_t dev = inode->i_rdev;
+
+	lock_kernel();
+	if (TP_DIAGS(dev)) {
+		printk("qic02_tape_release: dev=%s\n", kdevname(dev));
 	}
-	
-	/* Rewind only if minor number requires it AND 
-	 * read/writes have been done. ************* IS THIS CORRECT??????????
-	 */
-	if ((TP_REWCLOSE(dev)) && (status_bytes_rd | status_bytes_wr))
-	{
-	    tpqputs(TPQD_REWIND, "release: Doing rewind...");
-	    (void) do_qic_cmd(QCMD_REWIND, TIM_R);
+
+	if (status_zombie == NO) {	/* don't rewind in zombie mode */
+		/* Terminate any pending write cycle. Terminating the read-cycle
+		 * is delayed until it is required to do so for a new command.
+		 */
+		terminate_write(-1);
+
+		if (status_dead == YES) {
+			tpqputs(TPQD_ALWAYS, "release: device dead!?");
+		}
+
+		/* Rewind only if minor number requires it AND 
+		 * read/writes have been done. ************* IS THIS CORRECT??????????
+		 */
+		if ((TP_REWCLOSE(dev))
+		    && (status_bytes_rd | status_bytes_wr)) {
+			tpqputs(TPQD_REWIND, "release: Doing rewind...");
+			(void) do_qic_cmd(QCMD_REWIND, TIM_R);
+		}
 	}
-    }
-    unlock_kernel();
-    return 0;
-} /* qic02_tape_release */
+	unlock_kernel();
+	return 0;
+}				/* qic02_tape_release */
 
 
 #ifdef CONFIG_QIC02_DYNCONF
 /* Set masks etc. based on the interface card type. */
 static int update_ifc_masks(int ifc)
 {
-    QIC02_TAPE_IFC = ifc;
+	QIC02_TAPE_IFC = ifc;
 
-    if ((QIC02_TAPE_IFC == WANGTEK) || (QIC02_TAPE_IFC == EVEREX))
-    {
-	QIC02_STAT_PORT = QIC02_TAPE_PORT;
-	QIC02_CTL_PORT = QIC02_TAPE_PORT;
-	QIC02_CMD_PORT = QIC02_TAPE_PORT+1;
-	QIC02_DATA_PORT = QIC02_TAPE_PORT+1;
-	QIC02_STAT_READY = WT_QIC02_STAT_READY;
-	QIC02_STAT_EXCEPTION = WT_QIC02_STAT_EXCEPTION;
-	QIC02_STAT_MASK = WT_QIC02_STAT_MASK;
-	
-	QIC02_STAT_RESETMASK = WT_QIC02_STAT_RESETMASK;
-	QIC02_STAT_RESETVAL = WT_QIC02_STAT_RESETVAL;
-	
-	QIC02_CTL_RESET = WT_QIC02_CTL_RESET;
-	QIC02_CTL_REQUEST = WT_QIC02_CTL_REQUEST;
- 
-	if (QIC02_TAPE_DMA == 3)
-	{
-	    WT_CTL_DMA = WT_CTL_DMA3;
-	}
-	else if (QIC02_TAPE_DMA == 1)
-	{
-	    WT_CTL_DMA = WT_CTL_DMA1;
-	}
-	else
-	{
-	    tpqputs(TPQD_ALWAYS, "Unsupported or incorrect DMA channel");
-	    return -EIO;
-	} 
+	if ((QIC02_TAPE_IFC == WANGTEK) || (QIC02_TAPE_IFC == EVEREX)) {
+		QIC02_STAT_PORT = QIC02_TAPE_PORT;
+		QIC02_CTL_PORT = QIC02_TAPE_PORT;
+		QIC02_CMD_PORT = QIC02_TAPE_PORT + 1;
+		QIC02_DATA_PORT = QIC02_TAPE_PORT + 1;
+		QIC02_STAT_READY = WT_QIC02_STAT_READY;
+		QIC02_STAT_EXCEPTION = WT_QIC02_STAT_EXCEPTION;
+		QIC02_STAT_MASK = WT_QIC02_STAT_MASK;
+
+		QIC02_STAT_RESETMASK = WT_QIC02_STAT_RESETMASK;
+		QIC02_STAT_RESETVAL = WT_QIC02_STAT_RESETVAL;
+
+		QIC02_CTL_RESET = WT_QIC02_CTL_RESET;
+		QIC02_CTL_REQUEST = WT_QIC02_CTL_REQUEST;
+
+		if (QIC02_TAPE_DMA == 3) {
+			WT_CTL_DMA = WT_CTL_DMA3;
+		} else if (QIC02_TAPE_DMA == 1) {
+			WT_CTL_DMA = WT_CTL_DMA1;
+		} else {
+			tpqputs(TPQD_ALWAYS,
+				"Unsupported or incorrect DMA channel");
+			return -EIO;
+		}
 
-	if (QIC02_TAPE_IFC == EVEREX)
-	{
-	    /* Everex is a special case for Wangtek (actually
-	     * it's the other way 'round, but I saw Wangtek first)
-	     */
-	    if (QIC02_TAPE_DMA==3)
-	    {
-		WT_CTL_DMA = WT_CTL_DMA1;
-	    }
-	    
-	    /* Fixup the kernel copy of the IFC type to that
-	     * we don't have to distinguish between Wangtek and
-	     * and Everex at runtime.
-	     */
-	    QIC02_TAPE_IFC = WANGTEK;
-	}
-    }
-    else if (QIC02_TAPE_IFC == ARCHIVE)
-    {
-	QIC02_STAT_PORT = QIC02_TAPE_PORT+1;
-	QIC02_CTL_PORT = QIC02_TAPE_PORT+1;
-	QIC02_CMD_PORT = QIC02_TAPE_PORT;
-	QIC02_DATA_PORT = QIC02_TAPE_PORT;
-	QIC02_STAT_READY = AR_QIC02_STAT_READY;
-	QIC02_STAT_EXCEPTION  = AR_QIC02_STAT_EXCEPTION;
-	QIC02_STAT_MASK = AR_QIC02_STAT_MASK;
-	
-	QIC02_STAT_RESETMASK = AR_QIC02_STAT_RESETMASK;
-	QIC02_STAT_RESETVAL = AR_QIC02_STAT_RESETVAL;
-	
-	QIC02_CTL_RESET = AR_QIC02_CTL_RESET;
-	QIC02_CTL_REQUEST = AR_QIC02_CTL_REQUEST;
-	
-	if (QIC02_TAPE_DMA > 3)
-	{
-	    tpqputs(TPQD_ALWAYS, "Unsupported or incorrect DMA channel");
-	    return -EIO;
-	} 
-    }
-    else if (QIC02_TAPE_IFC == MOUNTAIN)
-    {
-	QIC02_STAT_PORT = QIC02_TAPE_PORT+1;
-	QIC02_CTL_PORT = QIC02_TAPE_PORT+1;
-	QIC02_CMD_PORT = QIC02_TAPE_PORT;
-	QIC02_DATA_PORT = QIC02_TAPE_PORT;
-	
-	QIC02_STAT_READY = MTN_QIC02_STAT_READY;
-	QIC02_STAT_EXCEPTION  = MTN_QIC02_STAT_EXCEPTION;
-	QIC02_STAT_MASK = MTN_QIC02_STAT_MASK;
-	
-	QIC02_STAT_RESETMASK = MTN_QIC02_STAT_RESETMASK;
-	QIC02_STAT_RESETVAL = MTN_QIC02_STAT_RESETVAL;
-	
-	QIC02_CTL_RESET = MTN_QIC02_CTL_RESET;
-	QIC02_CTL_REQUEST = MTN_QIC02_CTL_REQUEST;
-	
-	if (QIC02_TAPE_DMA > 3)
-	{
-	    tpqputs(TPQD_ALWAYS, "Unsupported or incorrect DMA channel");
-	    return -EIO;
-	} 
-    }
-    else
-    {
-	tpqputs(TPQD_ALWAYS, "Invalid interface type");
-	return -ENXIO;
-    }
-    return qic02_get_resources();
-} /* update_ifc_masks */
+		if (QIC02_TAPE_IFC == EVEREX) {
+			/* Everex is a special case for Wangtek (actually
+			 * it's the other way 'round, but I saw Wangtek first)
+			 */
+			if (QIC02_TAPE_DMA == 3) {
+				WT_CTL_DMA = WT_CTL_DMA1;
+			}
+
+			/* Fixup the kernel copy of the IFC type to that
+			 * we don't have to distinguish between Wangtek and
+			 * and Everex at runtime.
+			 */
+			QIC02_TAPE_IFC = WANGTEK;
+		}
+	} else if (QIC02_TAPE_IFC == ARCHIVE) {
+		QIC02_STAT_PORT = QIC02_TAPE_PORT + 1;
+		QIC02_CTL_PORT = QIC02_TAPE_PORT + 1;
+		QIC02_CMD_PORT = QIC02_TAPE_PORT;
+		QIC02_DATA_PORT = QIC02_TAPE_PORT;
+		QIC02_STAT_READY = AR_QIC02_STAT_READY;
+		QIC02_STAT_EXCEPTION = AR_QIC02_STAT_EXCEPTION;
+		QIC02_STAT_MASK = AR_QIC02_STAT_MASK;
+
+		QIC02_STAT_RESETMASK = AR_QIC02_STAT_RESETMASK;
+		QIC02_STAT_RESETVAL = AR_QIC02_STAT_RESETVAL;
+
+		QIC02_CTL_RESET = AR_QIC02_CTL_RESET;
+		QIC02_CTL_REQUEST = AR_QIC02_CTL_REQUEST;
+
+		if (QIC02_TAPE_DMA > 3) {
+			tpqputs(TPQD_ALWAYS,
+				"Unsupported or incorrect DMA channel");
+			return -EIO;
+		}
+	} else if (QIC02_TAPE_IFC == MOUNTAIN) {
+		QIC02_STAT_PORT = QIC02_TAPE_PORT + 1;
+		QIC02_CTL_PORT = QIC02_TAPE_PORT + 1;
+		QIC02_CMD_PORT = QIC02_TAPE_PORT;
+		QIC02_DATA_PORT = QIC02_TAPE_PORT;
+
+		QIC02_STAT_READY = MTN_QIC02_STAT_READY;
+		QIC02_STAT_EXCEPTION = MTN_QIC02_STAT_EXCEPTION;
+		QIC02_STAT_MASK = MTN_QIC02_STAT_MASK;
+
+		QIC02_STAT_RESETMASK = MTN_QIC02_STAT_RESETMASK;
+		QIC02_STAT_RESETVAL = MTN_QIC02_STAT_RESETVAL;
+
+		QIC02_CTL_RESET = MTN_QIC02_CTL_RESET;
+		QIC02_CTL_REQUEST = MTN_QIC02_CTL_REQUEST;
+
+		if (QIC02_TAPE_DMA > 3) {
+			tpqputs(TPQD_ALWAYS,
+				"Unsupported or incorrect DMA channel");
+			return -EIO;
+		}
+	} else {
+		tpqputs(TPQD_ALWAYS, "Invalid interface type");
+		return -ENXIO;
+	}
+	return qic02_get_resources();
+}				/* update_ifc_masks */
 #endif
 
 
 /* ioctl allows user programs to rewind the tape and stuff like that */
-static int qic02_tape_ioctl(struct inode * inode, struct file * filp, 
-		     unsigned int iocmd, unsigned long ioarg)
+static int qic02_tape_ioctl(struct inode *inode, struct file *filp,
+			    unsigned int iocmd, unsigned long ioarg)
 {
-    int error;
-    int dev_maj = MAJOR(inode->i_rdev);
-    int c;
-    struct mtop operation;
-    unsigned char blk_addr[6];
-    struct mtpos ioctl_tell;
-    
-
-    if (TP_DIAGS(current_tape_dev))
-    {
-	printk(TPQIC02_NAME ": ioctl(%4x, %4x, %4lx)\n", dev_maj, iocmd, ioarg);
-    }
-    
-    if (!inode || !ioarg)
-    {
-	return -EINVAL;
-    }
-    
-    /* check iocmd first */
-
-    if (dev_maj != QIC02_TAPE_MAJOR)
-    {
-	printk(TPQIC02_NAME ": Oops! Wrong device?\n");
-	/* A panic() would be appropriate here */
-	return -ENODEV;
-    }
-
-    c = _IOC_NR(iocmd);
+	int error;
+	int dev_maj = MAJOR(inode->i_rdev);
+	int c;
+	struct mtop operation;
+	unsigned char blk_addr[6];
+	struct mtpos ioctl_tell;
 
-#ifdef CONFIG_QIC02_DYNCONF
-    if (c == _IOC_NR(MTIOCGETCONFIG))
-    {
-	CHECK_IOC_SIZE(mtconfiginfo);
 
-	if (copy_to_user((char *) ioarg, (char *) &qic02_tape_dynconf, sizeof(qic02_tape_dynconf)))
-	{
-	    return -EFAULT;
+	if (TP_DIAGS(current_tape_dev)) {
+		printk(TPQIC02_NAME ": ioctl(%4x, %4x, %4lx)\n", dev_maj,
+		       iocmd, ioarg);
 	}
-	return 0;
 
-    }
-    else if (c == _IOC_NR(MTIOCSETCONFIG))
-    {
-	/* One should always do a MTIOCGETCONFIG first, then update
-	 * user-settings, then write back with MTIOCSETCONFIG.
-	 * The qic02conf program should re-open() the device before actual
-	 * use, to make sure everything is initialized.
-	 */
-	
-	CHECK_IOC_SIZE(mtconfiginfo);
-	
-	if (!capable(CAP_SYS_ADMIN))
-	{
-	    return -EPERM;
+	if (!inode || !ioarg) {
+		return -EINVAL;
 	}
-	
-	if ((doing_read!=NO) || (doing_write!=NO))
-	{
-	    return -EBUSY;
+
+	/* check iocmd first */
+
+	if (dev_maj != QIC02_TAPE_MAJOR) {
+		printk(TPQIC02_NAME ": Oops! Wrong device?\n");
+		/* A panic() would be appropriate here */
+		return -ENODEV;
 	}
-	
-	if (status_zombie==NO)
-	{
-	    qic02_release_resources();	/* and go zombie */
+
+	c = _IOC_NR(iocmd);
+
+#ifdef CONFIG_QIC02_DYNCONF
+	if (c == _IOC_NR(MTIOCGETCONFIG)) {
+		CHECK_IOC_SIZE(mtconfiginfo);
+
+		if (copy_to_user
+		    ((char *) ioarg, (char *) &qic02_tape_dynconf,
+		     sizeof(qic02_tape_dynconf))) {
+			return -EFAULT;
+		}
+		return 0;
+
+	} else if (c == _IOC_NR(MTIOCSETCONFIG)) {
+		/* One should always do a MTIOCGETCONFIG first, then update
+		 * user-settings, then write back with MTIOCSETCONFIG.
+		 * The qic02conf program should re-open() the device before actual
+		 * use, to make sure everything is initialized.
+		 */
+
+		CHECK_IOC_SIZE(mtconfiginfo);
+
+		if (!capable(CAP_SYS_ADMIN)) {
+			return -EPERM;
+		}
+
+		if ((doing_read != NO) || (doing_write != NO)) {
+			return -EBUSY;
+		}
+
+		if (status_zombie == NO) {
+			qic02_release_resources();	/* and go zombie */
+		}
+
+		/* copy struct from user space to kernel space */
+		if (copy_from_user
+		    ((char *) &qic02_tape_dynconf, (char *) ioarg,
+		     sizeof(qic02_tape_dynconf))) {
+			return -EFAULT;
+		}
+		return update_ifc_masks(qic02_tape_dynconf.ifc_type);
 	}
-	
-	/* copy struct from user space to kernel space */
-	if (copy_from_user((char *) &qic02_tape_dynconf, (char *) ioarg, sizeof(qic02_tape_dynconf)))
-	{
-	    return -EFAULT;
+	if (status_zombie == YES) {
+		tpqputs(TPQD_ALWAYS, "Configs not set");
+		return -ENXIO;
 	}
-	return update_ifc_masks(qic02_tape_dynconf.ifc_type);
-    }
-    if (status_zombie==YES)
-    {
-	tpqputs(TPQD_ALWAYS, "Configs not set");
-	return -ENXIO;
-    }
 #endif
-    if (c == _IOC_NR(MTIOCTOP))
-    {
-	CHECK_IOC_SIZE(mtop);
+	if (c == _IOC_NR(MTIOCTOP)) {
+		CHECK_IOC_SIZE(mtop);
 
-	/* copy mtop struct from user space to kernel space */
-	if (copy_from_user((char *) &operation, (char *) ioarg, sizeof(operation)))
-	{
-	    return -EFAULT;
-	}
+		/* copy mtop struct from user space to kernel space */
+		if (copy_from_user
+		    ((char *) &operation, (char *) ioarg,
+		     sizeof(operation))) {
+			return -EFAULT;
+		}
 
-	/* ---note: mt_count is signed, negative seeks must be
-	 * ---	    translated to seeks in opposite direction!
-	 * (only needed for Sun-programs, I think.)
-	 */
-	/* ---note: MTFSF with count 0 should position the
-	 * ---	    tape at the beginning of the current file.
-	 */
+		/* ---note: mt_count is signed, negative seeks must be
+		 * ---      translated to seeks in opposite direction!
+		 * (only needed for Sun-programs, I think.)
+		 */
+		/* ---note: MTFSF with count 0 should position the
+		 * ---      tape at the beginning of the current file.
+		 */
 
-	if (TP_DIAGS(current_tape_dev))
-	{
-	    printk("OP op=%4x, count=%4x\n", operation.mt_op, operation.mt_count);
-	}
-	
-	if (operation.mt_count < 0)
-	{
-	    tpqputs(TPQD_ALWAYS, "Warning: negative mt_count ignored");
-	}
-	
-	ioctl_status.mt_resid = operation.mt_count;
-	if (operation.mt_op == MTSEEK)
-	{
-	    if (!TP_HAVE_SEEK)
-	    {
-		return -ENOTTY;
-	    }
-	    
-	    seek_addr_buf[0] = (operation.mt_count>>16)&0xff;
-	    seek_addr_buf[1] = (operation.mt_count>>8)&0xff;
-	    seek_addr_buf[2] = (operation.mt_count)&0xff;
-	    if (operation.mt_count>>24)
-	    {
-		return -EINVAL;
-	    }
-	    if ((error = do_ioctl_cmd(operation.mt_op)) != 0)
-	    {
-		return error;
-	    }
-	    
-	    ioctl_status.mt_resid = 0;
-	}
-	else
-	{
-	    while (operation.mt_count > 0)
-	    {
-		operation.mt_count--;
-		if ((error = do_ioctl_cmd(operation.mt_op)) != 0)
-		{
-		    return error;
+		if (TP_DIAGS(current_tape_dev)) {
+			printk("OP op=%4x, count=%4x\n", operation.mt_op,
+			       operation.mt_count);
+		}
+
+		if (operation.mt_count < 0) {
+			tpqputs(TPQD_ALWAYS,
+				"Warning: negative mt_count ignored");
 		}
-		
+
 		ioctl_status.mt_resid = operation.mt_count;
-	    }
-	}
-	return 0;
-	
-    }
-    else if (c == _IOC_NR(MTIOCGET))
-    {
-	if (TP_DIAGS(current_tape_dev))
-	{
-	    printk("GET ");
-	}
-	
-	CHECK_IOC_SIZE(mtget);
+		if (operation.mt_op == MTSEEK) {
+			if (!TP_HAVE_SEEK) {
+				return -ENOTTY;
+			}
 
-	/* It appears (gmt(1)) that it is normal behaviour to
-	 * first set the status with MTNOP, and then to read
-	 * it out with MTIOCGET
-	 */
+			seek_addr_buf[0] =
+			    (operation.mt_count >> 16) & 0xff;
+			seek_addr_buf[1] =
+			    (operation.mt_count >> 8) & 0xff;
+			seek_addr_buf[2] = (operation.mt_count) & 0xff;
+			if (operation.mt_count >> 24) {
+				return -EINVAL;
+			}
+			if ((error = do_ioctl_cmd(operation.mt_op)) != 0) {
+				return error;
+			}
 
-	/* copy results to user space */
-	if (copy_to_user((char *) ioarg, (char *) &ioctl_status, sizeof(ioctl_status)))
-	{
-	    return -EFAULT;
-	}	
-	return 0;
-    }
-    else if (TP_HAVE_TELL && (c == _IOC_NR(MTIOCPOS)))
-    {
-	if (TP_DIAGS(current_tape_dev))
-	{
-	    printk("POS ");
-	}
-	
-	CHECK_IOC_SIZE(mtpos);
-	
-	tpqputs(TPQD_IOCTLS, "MTTELL reading block address");
-	if ((doing_read==YES) || (doing_write==YES))
-	{
-	    finish_rw(AR_QCMDV_TELL_BLK);
-	}
-	
-	c = rdstatus((char *) blk_addr, sizeof(blk_addr), AR_QCMDV_TELL_BLK);
-	if (c!=TE_OK)
-	{
-	    return -EIO;
-	}
-	
-	ioctl_tell.mt_blkno = (blk_addr[3] << 16) | (blk_addr[4] << 8) | blk_addr[5];
+			ioctl_status.mt_resid = 0;
+		} else {
+			while (operation.mt_count > 0) {
+				operation.mt_count--;
+				if ((error =
+				     do_ioctl_cmd(operation.mt_op)) != 0) {
+					return error;
+				}
 
-	/* copy results to user space */
-	if (copy_to_user((char *) ioarg, (char *) &ioctl_tell, sizeof(ioctl_tell)))
-	{
-	    return -EFAULT;
-	}
-	return 0;
+				ioctl_status.mt_resid = operation.mt_count;
+			}
+		}
+		return 0;
+
+	} else if (c == _IOC_NR(MTIOCGET)) {
+		if (TP_DIAGS(current_tape_dev)) {
+			printk("GET ");
+		}
+
+		CHECK_IOC_SIZE(mtget);
 
-    }
-    else
-    {
-	return -ENOTTY;	/* Other cmds not supported. */
-    }
-} /* qic02_tape_ioctl */
+		/* It appears (gmt(1)) that it is normal behaviour to
+		 * first set the status with MTNOP, and then to read
+		 * it out with MTIOCGET
+		 */
+
+		/* copy results to user space */
+		if (copy_to_user
+		    ((char *) ioarg, (char *) &ioctl_status,
+		     sizeof(ioctl_status))) {
+			return -EFAULT;
+		}
+		return 0;
+	} else if (TP_HAVE_TELL && (c == _IOC_NR(MTIOCPOS))) {
+		if (TP_DIAGS(current_tape_dev)) {
+			printk("POS ");
+		}
+
+		CHECK_IOC_SIZE(mtpos);
+
+		tpqputs(TPQD_IOCTLS, "MTTELL reading block address");
+		if ((doing_read == YES) || (doing_write == YES)) {
+			finish_rw(AR_QCMDV_TELL_BLK);
+		}
+
+		c = rdstatus((char *) blk_addr, sizeof(blk_addr),
+			     AR_QCMDV_TELL_BLK);
+		if (c != TE_OK) {
+			return -EIO;
+		}
+
+		ioctl_tell.mt_blkno =
+		    (blk_addr[3] << 16) | (blk_addr[4] << 8) | blk_addr[5];
+
+		/* copy results to user space */
+		if (copy_to_user
+		    ((char *) ioarg, (char *) &ioctl_tell,
+		     sizeof(ioctl_tell))) {
+			return -EFAULT;
+		}
+		return 0;
+
+	} else {
+		return -ENOTTY;	/* Other cmds not supported. */
+	}
+}				/* qic02_tape_ioctl */
 
 
 
 /* These are (most) of the interface functions: */
 static struct file_operations qic02_tape_fops = {
-	owner:		THIS_MODULE,
-	llseek:		no_llseek,
-	read:		qic02_tape_read,
-	write:		qic02_tape_write,
-	ioctl:		qic02_tape_ioctl,
-	open:		qic02_tape_open,
-	release:	qic02_tape_release,
+	owner:THIS_MODULE,
+	llseek:no_llseek,
+	read:qic02_tape_read,
+	write:qic02_tape_write,
+	ioctl:qic02_tape_ioctl,
+	open:qic02_tape_open,
+	release:qic02_tape_release,
 };
 
 
 static void qic02_release_resources(void)
 {
-    free_irq(QIC02_TAPE_IRQ, NULL);
-    free_dma(QIC02_TAPE_DMA);
-    release_region(QIC02_TAPE_PORT, QIC02_TAPE_PORT_RANGE);
-    if (buffaddr)
-    {
-	free_pages((unsigned long)buffaddr, get_order(TPQBUF_SIZE));
-    }
-    buffaddr = 0; /* Better to cause a panic than overwite someone else */
-    status_zombie = YES;
-} /* qic02_release_resources */
+	free_irq(QIC02_TAPE_IRQ, NULL);
+	free_dma(QIC02_TAPE_DMA);
+	release_region(QIC02_TAPE_PORT, QIC02_TAPE_PORT_RANGE);
+	if (buffaddr) {
+		free_pages((unsigned long) buffaddr,
+			   get_order(TPQBUF_SIZE));
+	}
+	buffaddr = 0;		/* Better to cause a panic than overwite someone else */
+	status_zombie = YES;
+}				/* qic02_release_resources */
 
 
 static int qic02_get_resources(void)
 {
-    /* First perform some checks. If one of them fails,
-     * the tape driver will not be registered to the system.
-     */
-    if (QIC02_TAPE_IRQ>16)
-    {
-	tpqputs(TPQD_ALWAYS, "Bogus interrupt number.");
-	return -ENXIO;
-    }
-
-    /* for DYNCONF, allocating IO, DMA and IRQ should not be done until 
-     * the config parameters have been set using MTSETCONFIG.
-     */
-
-    if (check_region(QIC02_TAPE_PORT, QIC02_TAPE_PORT_RANGE))
-    {
-	printk(TPQIC02_NAME ": IO space at 0x%x [%d ports] already reserved\n",
-	       QIC02_TAPE_PORT, QIC02_TAPE_PORT_RANGE);
-	return -ENXIO;
-    }
-
-    /* get IRQ */
-    if (request_irq(QIC02_TAPE_IRQ, qic02_tape_interrupt, SA_INTERRUPT, "QIC-02", NULL))
-    {
-	printk(TPQIC02_NAME ": can't allocate IRQ%d for QIC-02 tape\n",
-	       QIC02_TAPE_IRQ);
-	return -EBUSY;
-    }
-
-    /* After IRQ, allocate DMA channel */
-    if (request_dma(QIC02_TAPE_DMA,"QIC-02"))
-    {
-	printk(TPQIC02_NAME ": can't allocate DMA%d for QIC-02 tape\n",
-	       QIC02_TAPE_DMA);
-	free_irq(QIC02_TAPE_IRQ, NULL);
-	return -EBUSY;
-    }
+	/* First perform some checks. If one of them fails,
+	 * the tape driver will not be registered to the system.
+	 */
+	if (QIC02_TAPE_IRQ > 16) {
+		tpqputs(TPQD_ALWAYS, "Bogus interrupt number.");
+		return -ENXIO;
+	}
+
+	/* for DYNCONF, allocating IO, DMA and IRQ should not be done until 
+	 * the config parameters have been set using MTSETCONFIG.
+	 */
 
-    /* Grab the IO region. We already made sure it's available. */
-    request_region(QIC02_TAPE_PORT, QIC02_TAPE_PORT_RANGE, TPQIC02_NAME);
-    
-    /* Setup the page-address for the dma transfer. */
-    buffaddr = (void *)__get_dma_pages(GFP_KERNEL, get_order(TPQBUF_SIZE));
-    
-    if (!buffaddr)
-    {
-	qic02_release_resources();
-	return -EBUSY; /* Not ideal, EAGAIN perhaps? */
-    }
-    
-    memset(buffaddr, 0, TPQBUF_SIZE);
-    
-    printk(TPQIC02_NAME ": Settings: IRQ %d, DMA %d, IO 0x%x, IFC %s\n",
-	   QIC02_TAPE_IRQ, QIC02_TAPE_DMA,
-	   ((QIC02_TAPE_IFC==ARCHIVE) || (QIC02_TAPE_IFC==MOUNTAIN))?
-	   QIC02_CMD_PORT : QIC02_STAT_PORT,
-	   (QIC02_TAPE_IFC==MOUNTAIN)? "Mountain" :
-	   ((QIC02_TAPE_IFC==ARCHIVE)? "Archive" : "Wangtek"));
-    
-    if (tape_reset(0)!=TE_OK || tp_sense(TP_WRP|TP_POR|TP_CNI)!=TE_OK)
-    {
-	/* No drive detected, so vanish */
-	tpqputs(TPQD_ALWAYS, "No drive detected -- releasing IO/IRQ/DMA.");
-	status_dead = YES;
-	qic02_release_resources();
-	return -EIO;
-    }
-
-    /* All should be ok now */
-    status_zombie = NO;
-    return 0;
-} /* qic02_get_resources */
+	if (check_region(QIC02_TAPE_PORT, QIC02_TAPE_PORT_RANGE)) {
+		printk(TPQIC02_NAME
+		       ": IO space at 0x%x [%d ports] already reserved\n",
+		       QIC02_TAPE_PORT, QIC02_TAPE_PORT_RANGE);
+		return -ENXIO;
+	}
+
+	/* get IRQ */
+	if (request_irq
+	    (QIC02_TAPE_IRQ, qic02_tape_interrupt, SA_INTERRUPT, "QIC-02",
+	     NULL)) {
+		printk(TPQIC02_NAME
+		       ": can't allocate IRQ%d for QIC-02 tape\n",
+		       QIC02_TAPE_IRQ);
+		return -EBUSY;
+	}
+
+	/* After IRQ, allocate DMA channel */
+	if (request_dma(QIC02_TAPE_DMA, "QIC-02")) {
+		printk(TPQIC02_NAME
+		       ": can't allocate DMA%d for QIC-02 tape\n",
+		       QIC02_TAPE_DMA);
+		free_irq(QIC02_TAPE_IRQ, NULL);
+		return -EBUSY;
+	}
+
+	/* Grab the IO region. We already made sure it's available. */
+	request_region(QIC02_TAPE_PORT, QIC02_TAPE_PORT_RANGE,
+		       TPQIC02_NAME);
+
+	/* Setup the page-address for the dma transfer. */
+	buffaddr =
+	    (void *) __get_dma_pages(GFP_KERNEL, get_order(TPQBUF_SIZE));
+
+	if (!buffaddr) {
+		qic02_release_resources();
+		return -EBUSY;	/* Not ideal, EAGAIN perhaps? */
+	}
+
+	memset(buffaddr, 0, TPQBUF_SIZE);
+
+	printk(TPQIC02_NAME
+	       ": Settings: IRQ %d, DMA %d, IO 0x%x, IFC %s\n",
+	       QIC02_TAPE_IRQ, QIC02_TAPE_DMA, ((QIC02_TAPE_IFC == ARCHIVE)
+						|| (QIC02_TAPE_IFC ==
+						    MOUNTAIN)) ?
+	       QIC02_CMD_PORT : QIC02_STAT_PORT,
+	       (QIC02_TAPE_IFC ==
+		MOUNTAIN) ? "Mountain" : ((QIC02_TAPE_IFC ==
+					   ARCHIVE) ? "Archive" :
+					  "Wangtek"));
+
+	if (tape_reset(0) != TE_OK
+	    || tp_sense(TP_WRP | TP_POR | TP_CNI) != TE_OK) {
+		/* No drive detected, so vanish */
+		tpqputs(TPQD_ALWAYS,
+			"No drive detected -- releasing IO/IRQ/DMA.");
+		status_dead = YES;
+		qic02_release_resources();
+		return -EIO;
+	}
+
+	/* All should be ok now */
+	status_zombie = NO;
+	return 0;
+}				/* qic02_get_resources */
 
 int __init qic02_tape_init(void)
 {
-    if (TPSTATSIZE != 6)
-    {
-	printk(TPQIC02_NAME ": internal error: tpstatus struct incorrect!\n");
-	return -ENODEV;
-    }
-    if ((TPQBUF_SIZE<512) || (TPQBUF_SIZE>=0x10000))
-    {
-	printk(TPQIC02_NAME ": internal error: DMA buffer size out of range\n");
-	return -ENODEV;
-    }
+	if (TPSTATSIZE != 6) {
+		printk(TPQIC02_NAME
+		       ": internal error: tpstatus struct incorrect!\n");
+		return -ENODEV;
+	}
+	if ((TPQBUF_SIZE < 512) || (TPQBUF_SIZE >= 0x10000)) {
+		printk(TPQIC02_NAME
+		       ": internal error: DMA buffer size out of range\n");
+		return -ENODEV;
+	}
 
-    current_tape_dev = MKDEV(QIC02_TAPE_MAJOR, 0);
+	current_tape_dev = MKDEV(QIC02_TAPE_MAJOR, 0);
 
 #ifndef CONFIG_QIC02_DYNCONF
-    printk(TPQIC02_NAME ": IRQ %d, DMA %d, IO 0x%x, IFC %s, %s, %s\n",
-	   QIC02_TAPE_IRQ, QIC02_TAPE_DMA,
+	printk(TPQIC02_NAME ": IRQ %d, DMA %d, IO 0x%x, IFC %s, %s, %s\n",
+	       QIC02_TAPE_IRQ, QIC02_TAPE_DMA,
 # if QIC02_TAPE_IFC == WANGTEK
-	   QIC02_STAT_PORT, "Wangtek",
+	       QIC02_STAT_PORT, "Wangtek",
 # elif QIC02_TAPE_IFC == ARCHIVE
-	   QIC02_CMD_PORT, "Archive",
+	       QIC02_CMD_PORT, "Archive",
 # elif QIC02_TAPE_IFC == MOUNTAIN
-	   QIC02_CMD_PORT, "Mountain",
+	       QIC02_CMD_PORT, "Mountain",
 # else
 #  error
 # endif
-	   rcs_revision, rcs_date);
-    if (qic02_get_resources())
-    {
-	return -ENODEV;
-    }
+	       rcs_revision, rcs_date);
+	if (qic02_get_resources()) {
+		return -ENODEV;
+	}
 #else
-    printk(TPQIC02_NAME ": Runtime config, %s, %s\n", 
-	   rcs_revision, rcs_date);
+	printk(TPQIC02_NAME ": Runtime config, %s, %s\n",
+	       rcs_revision, rcs_date);
 #endif
-    printk(TPQIC02_NAME ": DMA buffers: %u blocks\n", NR_BLK_BUF);
-    /* If we got this far, install driver functions */
-    if (devfs_register_chrdev(QIC02_TAPE_MAJOR, TPQIC02_NAME, &qic02_tape_fops))
-    {
-	printk(TPQIC02_NAME ": Unable to get chrdev major %d\n", QIC02_TAPE_MAJOR);
+	printk(TPQIC02_NAME ": DMA buffers: %u blocks\n", NR_BLK_BUF);
+	/* If we got this far, install driver functions */
+	if (devfs_register_chrdev
+	    (QIC02_TAPE_MAJOR, TPQIC02_NAME, &qic02_tape_fops)) {
+		printk(TPQIC02_NAME ": Unable to get chrdev major %d\n",
+		       QIC02_TAPE_MAJOR);
 #ifndef CONFIG_QIC02_DYNCONF
-	qic02_release_resources();
+		qic02_release_resources();
 #endif
-	return -ENODEV;
-    }
-    devfs_register (NULL, "ntpqic11", DEVFS_FL_DEFAULT,
-		    QIC02_TAPE_MAJOR, 2,
-		    S_IFCHR | S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP,
-		    &qic02_tape_fops, NULL);
-    devfs_register (NULL, "tpqic11", DEVFS_FL_DEFAULT,
-		    QIC02_TAPE_MAJOR, 3,
-		    S_IFCHR | S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP,
-		    &qic02_tape_fops, NULL);
-    devfs_register (NULL, "ntpqic24", DEVFS_FL_DEFAULT,
-		    QIC02_TAPE_MAJOR, 4,
-		    S_IFCHR | S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP,
-		    &qic02_tape_fops, NULL);
-    devfs_register (NULL, "tpqic24", DEVFS_FL_DEFAULT,
-		    QIC02_TAPE_MAJOR, 5,
-		    S_IFCHR | S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP,
-		    &qic02_tape_fops, NULL);
-    devfs_register (NULL, "ntpqic120", DEVFS_FL_DEFAULT,
-		    QIC02_TAPE_MAJOR, 6,
-		    S_IFCHR | S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP,
-		    &qic02_tape_fops, NULL);
-    devfs_register (NULL, "tpqic120", DEVFS_FL_DEFAULT,
-		    QIC02_TAPE_MAJOR, 7,
-		    S_IFCHR | S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP,
-		    &qic02_tape_fops, NULL);
-    devfs_register (NULL, "ntpqic150", DEVFS_FL_DEFAULT,
-		    QIC02_TAPE_MAJOR, 8,
-		    S_IFCHR | S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP,
-		    &qic02_tape_fops, NULL);
-    devfs_register (NULL, "tpqic150", DEVFS_FL_DEFAULT,
-		    QIC02_TAPE_MAJOR, 9,
-		    S_IFCHR | S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP,
-		    &qic02_tape_fops, NULL);
-    init_waitqueue_head(&qic02_tape_transfer);
-    /* prepare timer */
-    TIMEROFF;
-    init_timer(&tp_timer);
-    tp_timer.function = qic02_tape_times_out;
-    
+		return -ENODEV;
+	}
+	devfs_register(NULL, "ntpqic11", DEVFS_FL_DEFAULT,
+		       QIC02_TAPE_MAJOR, 2,
+		       S_IFCHR | S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP,
+		       &qic02_tape_fops, NULL);
+	devfs_register(NULL, "tpqic11", DEVFS_FL_DEFAULT,
+		       QIC02_TAPE_MAJOR, 3,
+		       S_IFCHR | S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP,
+		       &qic02_tape_fops, NULL);
+	devfs_register(NULL, "ntpqic24", DEVFS_FL_DEFAULT,
+		       QIC02_TAPE_MAJOR, 4,
+		       S_IFCHR | S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP,
+		       &qic02_tape_fops, NULL);
+	devfs_register(NULL, "tpqic24", DEVFS_FL_DEFAULT,
+		       QIC02_TAPE_MAJOR, 5,
+		       S_IFCHR | S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP,
+		       &qic02_tape_fops, NULL);
+	devfs_register(NULL, "ntpqic120", DEVFS_FL_DEFAULT,
+		       QIC02_TAPE_MAJOR, 6,
+		       S_IFCHR | S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP,
+		       &qic02_tape_fops, NULL);
+	devfs_register(NULL, "tpqic120", DEVFS_FL_DEFAULT,
+		       QIC02_TAPE_MAJOR, 7,
+		       S_IFCHR | S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP,
+		       &qic02_tape_fops, NULL);
+	devfs_register(NULL, "ntpqic150", DEVFS_FL_DEFAULT,
+		       QIC02_TAPE_MAJOR, 8,
+		       S_IFCHR | S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP,
+		       &qic02_tape_fops, NULL);
+	devfs_register(NULL, "tpqic150", DEVFS_FL_DEFAULT,
+		       QIC02_TAPE_MAJOR, 9,
+		       S_IFCHR | S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP,
+		       &qic02_tape_fops, NULL);
+	init_waitqueue_head(&qic02_tape_transfer);
+	/* prepare timer */
+	TIMEROFF;
+	init_timer(&tp_timer);
+	tp_timer.function = qic02_tape_times_out;
+
 #ifndef CONFIG_QIC02_DYNCONF
-    if (tape_reset(0)!=TE_OK || tp_sense(TP_WRP|TP_POR|TP_CNI)!=TE_OK)
-    {
-	/* No drive detected, so vanish */
-	tpqputs(TPQD_ALWAYS, "No drive detected -- driver going on vacation...");
-	qic02_release_resources();
-	status_dead = YES;
-	return -ENODEV;
-    }
-    else
-    {
-	if (is_exception())
-	{
-	    tpqputs(TPQD_ALWAYS, "exception detected\n");
-	    (void) tp_sense(TP_WRP|TP_POR|TP_CNI);
+	if (tape_reset(0) != TE_OK
+	    || tp_sense(TP_WRP | TP_POR | TP_CNI) != TE_OK) {
+		/* No drive detected, so vanish */
+		tpqputs(TPQD_ALWAYS,
+			"No drive detected -- driver going on vacation...");
+		qic02_release_resources();
+		status_dead = YES;
+		return -ENODEV;
+	} else {
+		if (is_exception()) {
+			tpqputs(TPQD_ALWAYS, "exception detected\n");
+			(void) tp_sense(TP_WRP | TP_POR | TP_CNI);
+		}
 	}
-    }
 #endif
 
-    /* initialize generic status for ioctl requests */
-    
-    ioctl_status.mt_type	= QIC02_TAPE_DRIVE;	/* MT_IS* id nr */
-    
-    ioctl_status.mt_resid	= 0;	/* ---residual count */
-    ioctl_status.mt_gstat	= 0;	/* ---generic status */
-    ioctl_status.mt_erreg	= 0;	/* not used */
-    ioctl_status.mt_fileno	= 0;	/* number of current file on tape */
-    ioctl_status.mt_blkno	= 0;	/* number of current (logical) block */
+	/* initialize generic status for ioctl requests */
+
+	ioctl_status.mt_type = QIC02_TAPE_DRIVE;	/* MT_IS* id nr */
 
-    return 0;
-} /* qic02_tape_init */
+	ioctl_status.mt_resid = 0;	/* ---residual count */
+	ioctl_status.mt_gstat = 0;	/* ---generic status */
+	ioctl_status.mt_erreg = 0;	/* not used */
+	ioctl_status.mt_fileno = 0;	/* number of current file on tape */
+	ioctl_status.mt_blkno = 0;	/* number of current (logical) block */
+
+	return 0;
+}				/* qic02_tape_init */
 
 #ifdef MODULE
 
 void cleanup_module(void)
 {
-    if (status_zombie == NO)
-    {
-	qic02_release_resources();
-    }
-    devfs_unregister_chrdev(QIC02_TAPE_MAJOR, TPQIC02_NAME);
-    devfs_unregister(devfs_find_handle(NULL, "ntpqic11", QIC02_TAPE_MAJOR, 2, DEVFS_SPECIAL_CHR, 0));
-    devfs_unregister(devfs_find_handle(NULL, "tpqic11", QIC02_TAPE_MAJOR, 3, DEVFS_SPECIAL_CHR, 0));
-    devfs_unregister(devfs_find_handle(NULL, "ntpqic24", QIC02_TAPE_MAJOR, 4, DEVFS_SPECIAL_CHR, 0));
-    devfs_unregister(devfs_find_handle(NULL, "tpqic24", QIC02_TAPE_MAJOR, 5, DEVFS_SPECIAL_CHR, 0));
-    devfs_unregister(devfs_find_handle(NULL, "ntpqic120", QIC02_TAPE_MAJOR, 6, DEVFS_SPECIAL_CHR, 0));
-    devfs_unregister(devfs_find_handle(NULL, "tpqic120", QIC02_TAPE_MAJOR, 7, DEVFS_SPECIAL_CHR, 0));
-    devfs_unregister(devfs_find_handle(NULL, "ntpqic150", QIC02_TAPE_MAJOR, 8, DEVFS_SPECIAL_CHR, 0));
-    devfs_unregister(devfs_find_handle(NULL, "tpqic150", QIC02_TAPE_MAJOR, 9, DEVFS_SPECIAL_CHR, 0));
+	if (status_zombie == NO) {
+		qic02_release_resources();
+	}
+	devfs_unregister_chrdev(QIC02_TAPE_MAJOR, TPQIC02_NAME);
+	devfs_unregister(devfs_find_handle
+			 (NULL, "ntpqic11", QIC02_TAPE_MAJOR, 2,
+			  DEVFS_SPECIAL_CHR, 0));
+	devfs_unregister(devfs_find_handle
+			 (NULL, "tpqic11", QIC02_TAPE_MAJOR, 3,
+			  DEVFS_SPECIAL_CHR, 0));
+	devfs_unregister(devfs_find_handle
+			 (NULL, "ntpqic24", QIC02_TAPE_MAJOR, 4,
+			  DEVFS_SPECIAL_CHR, 0));
+	devfs_unregister(devfs_find_handle
+			 (NULL, "tpqic24", QIC02_TAPE_MAJOR, 5,
+			  DEVFS_SPECIAL_CHR, 0));
+	devfs_unregister(devfs_find_handle
+			 (NULL, "ntpqic120", QIC02_TAPE_MAJOR, 6,
+			  DEVFS_SPECIAL_CHR, 0));
+	devfs_unregister(devfs_find_handle
+			 (NULL, "tpqic120", QIC02_TAPE_MAJOR, 7,
+			  DEVFS_SPECIAL_CHR, 0));
+	devfs_unregister(devfs_find_handle
+			 (NULL, "ntpqic150", QIC02_TAPE_MAJOR, 8,
+			  DEVFS_SPECIAL_CHR, 0));
+	devfs_unregister(devfs_find_handle
+			 (NULL, "tpqic150", QIC02_TAPE_MAJOR, 9,
+			  DEVFS_SPECIAL_CHR, 0));
 }
 
 int init_module(void)
 {
-    int retval;
-    retval=qic02_tape_init();
+	int retval;
+	retval = qic02_tape_init();
 # ifdef CONFIG_QIC02_DYNCONF
-    /* This allows the dynamic config program to setup the card
-     * by presetting qic02_tape_dynconf via insmod
-     */
-    if (!retval && qic02_tape_dynconf.ifc_type)
-    {
-	retval=update_ifc_masks(qic02_tape_dynconf.ifc_type);
-	if (retval)
-	{
-	  cleanup_module();
+	/* This allows the dynamic config program to setup the card
+	 * by presetting qic02_tape_dynconf via insmod
+	 */
+	if (!retval && qic02_tape_dynconf.ifc_type) {
+		retval = update_ifc_masks(qic02_tape_dynconf.ifc_type);
+		if (retval) {
+			cleanup_module();
+		}
 	}
-    }
 # endif
-    return retval;
+	return retval;
 }
 #endif
+
+MODULE_LICENSE("GPL");
+EXPORT_NO_SYMBOLS;

FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen (who was at: slshen@lbl.gov)