vserver 1.9.5.x5
[linux-2.6.git] / drivers / scsi / st.c
index 5fa0153..4388fc8 100644 (file)
@@ -17,7 +17,7 @@
    Last modified: 18-JAN-1998 Richard Gooch <rgooch@atnf.csiro.au> Devfs support
  */
 
-static char *verstr = "20040403";
+static char *verstr = "20041025";
 
 #include <linux/module.h>
 
@@ -40,6 +40,16 @@ static char *verstr = "20040403";
 #include <asm/dma.h>
 #include <asm/system.h>
 
+#include <scsi/scsi.h>
+#include <scsi/scsi_dbg.h>
+#include <scsi/scsi_device.h>
+#include <scsi/scsi_driver.h>
+#include <scsi/scsi_eh.h>
+#include <scsi/scsi_host.h>
+#include <scsi/scsi_ioctl.h>
+#include <scsi/scsi_request.h>
+
+
 /* The driver prints some debugging information on the console if DEBUG
    is defined and non-zero. */
 #define DEBUG 0
@@ -56,13 +66,6 @@ static char *verstr = "20040403";
 #define DEBC(a)
 #endif
 
-
-#include "scsi.h"
-#include <scsi/scsi_host.h>
-
-#include <scsi/scsi_driver.h>
-#include <scsi/scsi_ioctl.h>
-
 #define ST_KILOBYTE 1024
 
 #include "st_options.h"
@@ -71,8 +74,8 @@ static char *verstr = "20040403";
 static int buffer_kbs;
 static int max_sg_segs;
 static int try_direct_io = TRY_DIRECT_IO;
-static int try_rdio = TRUE;
-static int try_wdio = TRUE;
+static int try_rdio = 1;
+static int try_wdio = 1;
 
 static int st_dev_max;
 static int st_nr_dev;
@@ -164,22 +167,22 @@ DEB( static int debugging = DEBUG; )
    24 bits) */
 #define SET_DENS_AND_BLK 0x10001
 
-static rwlock_t st_dev_arr_lock = RW_LOCK_UNLOCKED;
+static DEFINE_RWLOCK(st_dev_arr_lock);
 
 static int st_fixed_buffer_size = ST_FIXED_BUFFER_SIZE;
 static int st_max_sg_segs = ST_MAX_SG;
 
-static Scsi_Tape **scsi_tapes = NULL;
+static struct scsi_tape **scsi_tapes = NULL;
 
 static int modes_defined;
 
-static ST_buffer *new_tape_buffer(int, int, int);
-static int enlarge_buffer(ST_buffer *, int, int);
-static void normalize_buffer(ST_buffer *);
-static int append_to_buffer(const char __user *, ST_buffer *, int);
-static int from_buffer(ST_buffer *, char __user *, int);
-static void move_buffer_data(ST_buffer *, int);
-static void buf_to_sg(ST_buffer *, unsigned int);
+static struct st_buffer *new_tape_buffer(int, int, int);
+static int enlarge_buffer(struct st_buffer *, int, int);
+static void normalize_buffer(struct st_buffer *);
+static int append_to_buffer(const char __user *, struct st_buffer *, int);
+static int from_buffer(struct st_buffer *, char __user *, int);
+static void move_buffer_data(struct st_buffer *, int);
+static void buf_to_sg(struct st_buffer *, unsigned int);
 
 static int st_map_user_pages(struct scatterlist *, const unsigned int, 
                             unsigned long, size_t, int, unsigned long);
@@ -193,7 +196,7 @@ static int st_init_command(struct scsi_cmnd *);
 
 static void do_create_driverfs_files(void);
 static void do_remove_driverfs_files(void);
-static void do_create_class_files(Scsi_Tape *, int, int);
+static void do_create_class_files(struct scsi_tape *, int, int);
 
 static struct scsi_driver st_template = {
        .owner                  = THIS_MODULE,
@@ -205,12 +208,12 @@ static struct scsi_driver st_template = {
        .init_command           = st_init_command,
 };
 
-static int st_compression(Scsi_Tape *, int);
+static int st_compression(struct scsi_tape *, int);
 
-static int find_partition(Scsi_Tape *);
-static int switch_partition(Scsi_Tape *);
+static int find_partition(struct scsi_tape *);
+static int switch_partition(struct scsi_tape *);
 
-static int st_int_ioctl(Scsi_Tape *, unsigned int, unsigned long);
+static int st_int_ioctl(struct scsi_tape *, unsigned int, unsigned long);
 
 \f
 #include "osst_detect.h"
@@ -237,7 +240,7 @@ static struct st_reject_data reject_list[] = {
 
 /* If the device signature is on the list of incompatible drives, the
    function returns a pointer to the name of the correct driver (if known) */
-static char * st_incompatible(Scsi_Device* SDp)
+static char * st_incompatible(struct scsi_device* SDp)
 {
        struct st_reject_data *rp;
 
@@ -254,13 +257,13 @@ static char * st_incompatible(Scsi_Device* SDp)
 }
 \f
 
-static inline char *tape_name(Scsi_Tape *tape)
+static inline char *tape_name(struct scsi_tape *tape)
 {
        return tape->disk->disk_name;
 }
 
 /* Convert the result to success code */
-static int st_chk_result(Scsi_Tape *STp, Scsi_Request * SRpnt)
+static int st_chk_result(struct scsi_tape *STp, struct scsi_request * SRpnt)
 {
        int result = SRpnt->sr_result;
        unsigned char *sense = SRpnt->sr_sense_buffer, scode;
@@ -287,7 +290,7 @@ static int st_chk_result(Scsi_Tape *STp, Scsi_Request * SRpnt)
                       SRpnt->sr_cmnd[3], SRpnt->sr_cmnd[4], SRpnt->sr_cmnd[5],
                       SRpnt->sr_bufflen);
                if (driver_byte(result) & DRIVER_SENSE)
-                       print_req_sense("st", SRpnt);
+                       scsi_print_req_sense("st", SRpnt);
        } else ) /* end DEB */
                if (!(driver_byte(result) & DRIVER_SENSE) ||
                    ((sense[0] & 0x70) == 0x70 &&
@@ -300,7 +303,7 @@ static int st_chk_result(Scsi_Tape *STp, Scsi_Request * SRpnt)
                     SRpnt->sr_cmnd[0] != TEST_UNIT_READY)) {   /* Abnormal conditions for tape */
                if (driver_byte(result) & DRIVER_SENSE) {
                        printk(KERN_WARNING "%s: Error with sense data: ", name);
-                       print_req_sense("st", SRpnt);
+                       scsi_print_req_sense("st", SRpnt);
                } else
                        printk(KERN_WARNING
                               "%s: Error %x (sugg. bt 0x%x, driver bt 0x%x, host bt 0x%x).\n",
@@ -351,11 +354,11 @@ static int st_chk_result(Scsi_Tape *STp, Scsi_Request * SRpnt)
 
 
 /* Wakeup from interrupt */
-static void st_sleep_done(Scsi_Cmnd * SCpnt)
+static void st_sleep_done(struct scsi_cmnd * SCpnt)
 {
        int remainder;
-       Scsi_Tape *STp = container_of(SCpnt->request->rq_disk->private_data,
-                                   Scsi_Tape, driver);
+       struct scsi_tape *STp = container_of(SCpnt->request->rq_disk->private_data,
+                                            struct scsi_tape, driver);
 
        if ((STp->buffer)->writing &&
            (SCpnt->sense_buffer[0] & 0x70) == 0x70 &&
@@ -385,9 +388,9 @@ static void st_sleep_done(Scsi_Cmnd * SCpnt)
 /* Do the scsi command. Waits until command performed if do_wait is true.
    Otherwise write_behind_check() is used to check that the command
    has finished. */
-static Scsi_Request *
- st_do_scsi(Scsi_Request * SRpnt, Scsi_Tape * STp, unsigned char *cmd, int bytes,
-           int direction, int timeout, int retries, int do_wait)
+static struct scsi_request *
+st_do_scsi(struct scsi_request * SRpnt, struct scsi_tape * STp, unsigned char *cmd,
+          int bytes, int direction, int timeout, int retries, int do_wait)
 {
        unsigned char *bp;
 
@@ -432,10 +435,10 @@ static Scsi_Request *
 
 
 /* Handle the write-behind checking (downs the semaphore) */
-static void write_behind_check(Scsi_Tape * STp)
+static void write_behind_check(struct scsi_tape * STp)
 {
-       ST_buffer *STbuffer;
-       ST_partstat *STps;
+       struct st_buffer *STbuffer;
+       struct st_partstat *STps;
 
        STbuffer = STp->buffer;
 
@@ -468,9 +471,9 @@ static void write_behind_check(Scsi_Tape * STp)
 
 /* Step over EOF if it has been inadvertently crossed (ioctl not used because
    it messes up the block number). */
-static int cross_eof(Scsi_Tape * STp, int forward)
+static int cross_eof(struct scsi_tape * STp, int forward)
 {
-       Scsi_Request *SRpnt;
+       struct scsi_request *SRpnt;
        unsigned char cmd[MAX_COMMAND_SIZE];
 
        cmd[0] = SPACE;
@@ -485,8 +488,8 @@ static int cross_eof(Scsi_Tape * STp, int forward)
         DEBC(printk(ST_DEB_MSG "%s: Stepping over filemark %s.\n",
                   tape_name(STp), forward ? "forward" : "backward"));
 
-       SRpnt = st_do_scsi(NULL, STp, cmd, 0, SCSI_DATA_NONE,
-                          STp->device->timeout, MAX_RETRIES, TRUE);
+       SRpnt = st_do_scsi(NULL, STp, cmd, 0, DMA_NONE,
+                          STp->device->timeout, MAX_RETRIES, 1);
        if (!SRpnt)
                return (STp->buffer)->syscall_result;
 
@@ -502,13 +505,13 @@ static int cross_eof(Scsi_Tape * STp, int forward)
 
 
 /* Flush the write buffer (never need to write if variable blocksize). */
-static int flush_write_buffer(Scsi_Tape * STp)
+static int flush_write_buffer(struct scsi_tape * STp)
 {
        int offset, transfer, blks;
        int result;
        unsigned char cmd[MAX_COMMAND_SIZE];
-       Scsi_Request *SRpnt;
-       ST_partstat *STps;
+       struct scsi_request *SRpnt;
+       struct st_partstat *STps;
 
        if ((STp->buffer)->writing) {
                write_behind_check(STp);
@@ -543,8 +546,8 @@ static int flush_write_buffer(Scsi_Tape * STp)
                cmd[3] = blks >> 8;
                cmd[4] = blks;
 
-               SRpnt = st_do_scsi(NULL, STp, cmd, transfer, SCSI_DATA_WRITE,
-                                  STp->device->timeout, MAX_WRITE_RETRIES, TRUE);
+               SRpnt = st_do_scsi(NULL, STp, cmd, transfer, DMA_TO_DEVICE,
+                                  STp->device->timeout, MAX_WRITE_RETRIES, 1);
                if (!SRpnt)
                        return (STp->buffer)->syscall_result;
 
@@ -577,11 +580,11 @@ static int flush_write_buffer(Scsi_Tape * STp)
 
 /* Flush the tape buffer. The tape will be positioned correctly unless
    seek_next is true. */
-static int flush_buffer(Scsi_Tape *STp, int seek_next)
+static int flush_buffer(struct scsi_tape *STp, int seek_next)
 {
        int backspace, result;
-       ST_buffer *STbuffer;
-       ST_partstat *STps;
+       struct st_buffer *STbuffer;
+       struct st_partstat *STps;
 
        STbuffer = STp->buffer;
 
@@ -610,7 +613,7 @@ static int flush_buffer(Scsi_Tape *STp, int seek_next)
        result = 0;
        if (!seek_next) {
                if (STps->eof == ST_FM_HIT) {
-                       result = cross_eof(STp, FALSE); /* Back over the EOF hit */
+                       result = cross_eof(STp, 0);     /* Back over the EOF hit */
                        if (!result)
                                STps->eof = ST_NOEOF;
                        else {
@@ -632,9 +635,9 @@ static int flush_buffer(Scsi_Tape *STp, int seek_next)
 }
 \f
 /* Set the mode parameters */
-static int set_mode_densblk(Scsi_Tape * STp, ST_mode * STm)
+static int set_mode_densblk(struct scsi_tape * STp, struct st_modedef * STm)
 {
-       int set_it = FALSE;
+       int set_it = 0;
        unsigned long arg;
        char *name = tape_name(STp);
 
@@ -642,7 +645,7 @@ static int set_mode_densblk(Scsi_Tape * STp, ST_mode * STm)
            STm->default_density >= 0 &&
            STm->default_density != STp->density) {
                arg = STm->default_density;
-               set_it = TRUE;
+               set_it = 1;
        } else
                arg = STp->density;
        arg <<= MT_ST_DENSITY_SHIFT;
@@ -650,7 +653,7 @@ static int set_mode_densblk(Scsi_Tape * STp, ST_mode * STm)
            STm->default_blksize >= 0 &&
            STm->default_blksize != STp->block_size) {
                arg |= STm->default_blksize;
-               set_it = TRUE;
+               set_it = 1;
        } else
                arg |= STp->block_size;
        if (set_it &&
@@ -665,8 +668,8 @@ static int set_mode_densblk(Scsi_Tape * STp, ST_mode * STm)
 }
 
 
-/* Lock or unlock the drive door. Don't use when Scsi_Request allocated. */
-static int do_door_lock(Scsi_Tape * STp, int do_lock)
+/* Lock or unlock the drive door. Don't use when scsi_request allocated. */
+static int do_door_lock(struct scsi_tape * STp, int do_lock)
 {
        int retval, cmd;
        DEB(char *name = tape_name(STp);)
@@ -687,10 +690,10 @@ static int do_door_lock(Scsi_Tape * STp, int do_lock)
 
 
 /* Set the internal state after reset */
-static void reset_state(Scsi_Tape *STp)
+static void reset_state(struct scsi_tape *STp)
 {
        int i;
-       ST_partstat *STps;
+       struct st_partstat *STps;
 
        STp->pos_unknown = 0;
        for (i = 0; i < ST_NBR_PARTITIONS; i++) {
@@ -698,7 +701,7 @@ static void reset_state(Scsi_Tape *STp)
                STps->rw = ST_IDLE;
                STps->eof = ST_NOEOF;
                STps->at_sm = 0;
-               STps->last_block_valid = FALSE;
+               STps->last_block_valid = 0;
                STps->drv_block = -1;
                STps->drv_file = -1;
        }
@@ -719,20 +722,20 @@ static void reset_state(Scsi_Tape *STp)
 
 #define MAX_ATTENTIONS    10
 
-static int test_ready(Scsi_Tape *STp, int do_wait)
+static int test_ready(struct scsi_tape *STp, int do_wait)
 {
        int attentions, waits, max_wait, scode;
-       int retval = CHKRES_READY, new_session = FALSE;
+       int retval = CHKRES_READY, new_session = 0;
        unsigned char cmd[MAX_COMMAND_SIZE];
-       Scsi_Request *SRpnt = NULL;
+       struct scsi_request *SRpnt = NULL;
 
        max_wait = do_wait ? ST_BLOCK_SECONDS : 0;
 
        for (attentions=waits=0; ; ) {
                memset((void *) &cmd[0], 0, MAX_COMMAND_SIZE);
                cmd[0] = TEST_UNIT_READY;
-               SRpnt = st_do_scsi(SRpnt, STp, cmd, 0, SCSI_DATA_NONE,
-                                  STp->long_timeout, MAX_READY_RETRIES, TRUE);
+               SRpnt = st_do_scsi(SRpnt, STp, cmd, 0, DMA_NONE,
+                                  STp->long_timeout, MAX_READY_RETRIES, 1);
 
                if (!SRpnt) {
                        retval = (STp->buffer)->syscall_result;
@@ -744,7 +747,7 @@ static int test_ready(Scsi_Tape *STp, int do_wait)
                        scode = (SRpnt->sr_sense_buffer[2] & 0x0f);
 
                        if (scode == UNIT_ATTENTION) { /* New media? */
-                               new_session = TRUE;
+                               new_session = 1;
                                if (attentions < MAX_ATTENTIONS) {
                                        attentions++;
                                        continue;
@@ -794,14 +797,14 @@ static int test_ready(Scsi_Tape *STp, int do_wait)
    0     drive ready
    1     drive not ready (possibly no tape)
 */
-static int check_tape(Scsi_Tape *STp, struct file *filp)
+static int check_tape(struct scsi_tape *STp, struct file *filp)
 {
-       int i, retval, new_session = FALSE, do_wait;
+       int i, retval, new_session = 0, do_wait;
        unsigned char cmd[MAX_COMMAND_SIZE], saved_cleaning;
        unsigned short st_flags = filp->f_flags;
-       Scsi_Request *SRpnt = NULL;
-       ST_mode *STm;
-       ST_partstat *STps;
+       struct scsi_request *SRpnt = NULL;
+       struct st_modedef *STm;
+       struct st_partstat *STps;
        char *name = tape_name(STp);
        struct inode *inode = filp->f_dentry->d_inode;
        int mode = TAPE_MODE(inode);
@@ -811,7 +814,7 @@ static int check_tape(Scsi_Tape *STp, struct file *filp)
        if (mode != STp->current_mode) {
                 DEBC(printk(ST_DEB_MSG "%s: Mode change from %d to %d.\n",
                               name, STp->current_mode, mode));
-               new_session = TRUE;
+               new_session = 1;
                STp->current_mode = mode;
        }
        STm = &(STp->modes[STp->current_mode]);
@@ -836,11 +839,11 @@ static int check_tape(Scsi_Tape *STp, struct file *filp)
                        STps->rw = ST_IDLE;
                        STps->eof = ST_NOEOF;
                        STps->at_sm = 0;
-                       STps->last_block_valid = FALSE;
+                       STps->last_block_valid = 0;
                        STps->drv_block = 0;
                        STps->drv_file = 0;
                }
-               new_session = TRUE;
+               new_session = 1;
        }
        else {
                STp->cleaning_req |= saved_cleaning;
@@ -867,8 +870,8 @@ static int check_tape(Scsi_Tape *STp, struct file *filp)
                memset((void *) &cmd[0], 0, MAX_COMMAND_SIZE);
                cmd[0] = READ_BLOCK_LIMITS;
 
-               SRpnt = st_do_scsi(SRpnt, STp, cmd, 6, SCSI_DATA_READ, STp->device->timeout,
-                                  MAX_READY_RETRIES, TRUE);
+               SRpnt = st_do_scsi(SRpnt, STp, cmd, 6, DMA_FROM_DEVICE,
+                                  STp->device->timeout, MAX_READY_RETRIES, 1);
                if (!SRpnt) {
                        retval = (STp->buffer)->syscall_result;
                        goto err_out;
@@ -894,8 +897,8 @@ static int check_tape(Scsi_Tape *STp, struct file *filp)
        cmd[0] = MODE_SENSE;
        cmd[4] = 12;
 
-       SRpnt = st_do_scsi(SRpnt, STp, cmd, 12, SCSI_DATA_READ, STp->device->timeout,
-                          MAX_READY_RETRIES, TRUE);
+       SRpnt = st_do_scsi(SRpnt, STp, cmd, 12, DMA_FROM_DEVICE,
+                       STp->device->timeout, MAX_READY_RETRIES, 1);
        if (!SRpnt) {
                retval = (STp->buffer)->syscall_result;
                goto err_out;
@@ -928,7 +931,7 @@ static int check_tape(Scsi_Tape *STp, struct file *filp)
        }
        scsi_release_request(SRpnt);
        SRpnt = NULL;
-        STp->inited = TRUE;
+        STp->inited = 1;
 
        if (STp->block_size > 0)
                (STp->buffer)->buffer_blocks =
@@ -970,8 +973,8 @@ static int check_tape(Scsi_Tape *STp, struct file *filp)
        }
 
        if (new_session) {      /* Change the drive parameters for the new mode */
-               STp->density_changed = STp->blksize_changed = FALSE;
-               STp->compression_changed = FALSE;
+               STp->density_changed = STp->blksize_changed = 0;
+               STp->compression_changed = 0;
                if (!(STm->defaults_for_writes) &&
                    (retval = set_mode_densblk(STp, STm)) < 0)
                    goto err_out;
@@ -996,8 +999,8 @@ static int check_tape(Scsi_Tape *STp, struct file *filp)
 static int st_open(struct inode *inode, struct file *filp)
 {
        int i, retval = (-EIO);
-       Scsi_Tape *STp;
-       ST_partstat *STps;
+       struct scsi_tape *STp;
+       struct st_partstat *STps;
        int dev = TAPE_NR(inode);
        char *name;
 
@@ -1076,10 +1079,10 @@ static int st_flush(struct file *filp)
 {
        int result = 0, result2;
        unsigned char cmd[MAX_COMMAND_SIZE];
-       Scsi_Request *SRpnt;
-       Scsi_Tape *STp = filp->private_data;
-       ST_mode *STm = &(STp->modes[STp->current_mode]);
-       ST_partstat *STps = &(STp->ps[STp->partition]);
+       struct scsi_request *SRpnt;
+       struct scsi_tape *STp = filp->private_data;
+       struct st_modedef *STm = &(STp->modes[STp->current_mode]);
+       struct st_partstat *STps = &(STp->ps[STp->partition]);
        char *name = tape_name(STp);
 
        if (file_count(filp) > 1)
@@ -1106,8 +1109,8 @@ static int st_flush(struct file *filp)
 
        if (STps->rw == ST_WRITING && !STp->pos_unknown) {
 
-                DEBC(printk(ST_DEB_MSG "%s: File length %ld bytes.\n",
-                            name, (long) (filp->f_pos));
+                DEBC(printk(ST_DEB_MSG "%s: File length %lld bytes.\n",
+                            name, (long long)filp->f_pos);
                      printk(ST_DEB_MSG "%s: Async write waits %d, finished %d.\n",
                             name, STp->nbr_waits, STp->nbr_finished);
                )
@@ -1116,8 +1119,8 @@ static int st_flush(struct file *filp)
                cmd[0] = WRITE_FILEMARKS;
                cmd[4] = 1 + STp->two_fm;
 
-               SRpnt = st_do_scsi(NULL, STp, cmd, 0, SCSI_DATA_NONE,
-                                  STp->device->timeout, MAX_WRITE_RETRIES, TRUE);
+               SRpnt = st_do_scsi(NULL, STp, cmd, 0, DMA_NONE,
+                                  STp->device->timeout, MAX_WRITE_RETRIES, 1);
                if (!SRpnt) {
                        result = (STp->buffer)->syscall_result;
                        goto out;
@@ -1143,7 +1146,7 @@ static int st_flush(struct file *filp)
                                STps->drv_file++;
                        STps->drv_block = 0;
                        if (STp->two_fm)
-                               cross_eof(STp, FALSE);
+                               cross_eof(STp, 0);
                        STps->eof = ST_FM;
                }
 
@@ -1155,7 +1158,7 @@ static int st_flush(struct file *filp)
                        if (STp->can_bsr)
                                result = flush_buffer(STp, 0);
                        else if (STps->eof == ST_FM_HIT) {
-                               result = cross_eof(STp, FALSE);
+                               result = cross_eof(STp, 0);
                                if (result) {
                                        if (STps->drv_file >= 0)
                                                STps->drv_file++;
@@ -1165,7 +1168,7 @@ static int st_flush(struct file *filp)
                                        STps->eof = ST_NOEOF;
                        }
                } else if ((STps->eof == ST_NOEOF &&
-                           !(result = cross_eof(STp, TRUE))) ||
+                           !(result = cross_eof(STp, 1))) ||
                           STps->eof == ST_FM_HIT) {
                        if (STps->drv_file >= 0)
                                STps->drv_file++;
@@ -1189,7 +1192,7 @@ static int st_flush(struct file *filp)
 static int st_release(struct inode *inode, struct file *filp)
 {
        int result = 0;
-       Scsi_Tape *STp = filp->private_data;
+       struct scsi_tape *STp = filp->private_data;
 
        if (STp->door_locked == ST_LOCKED_AUTO)
                do_door_lock(STp, 0);
@@ -1204,7 +1207,7 @@ static int st_release(struct inode *inode, struct file *filp)
 }
 \f
 /* The checks common to both reading and writing */
-static ssize_t rw_checks(Scsi_Tape *STp, struct file *filp, size_t count)
+static ssize_t rw_checks(struct scsi_tape *STp, struct file *filp, size_t count)
 {
        ssize_t retval = 0;
 
@@ -1271,10 +1274,11 @@ static ssize_t rw_checks(Scsi_Tape *STp, struct file *filp, size_t count)
 }
 
 
-static int setup_buffering(Scsi_Tape *STp, const char __user *buf, size_t count, int is_read)
+static int setup_buffering(struct scsi_tape *STp, const char __user *buf,
+                          size_t count, int is_read)
 {
        int i, bufsize, retval = 0;
-       ST_buffer *STbp = STp->buffer;
+       struct st_buffer *STbp = STp->buffer;
 
        if (is_read)
                i = STp->try_dio && try_rdio;
@@ -1290,7 +1294,7 @@ static int setup_buffering(Scsi_Tape *STp, const char __user *buf, size_t count,
                        STbp->buffer_bytes = 0;   /* can be used as transfer counter */
                }
                else
-                       STbp->do_dio = FALSE;  /* fall back to buffering with any error */
+                       STbp->do_dio = 0;  /* fall back to buffering with any error */
                STbp->sg_segs = STbp->do_dio;
                STbp->frp_sg_current = 0;
                DEB(
@@ -1303,7 +1307,7 @@ static int setup_buffering(Scsi_Tape *STp, const char __user *buf, size_t count,
                     }
                )
        } else
-               STbp->do_dio = FALSE;
+               STbp->do_dio = 0;
        DEB( STp->nbr_requests++; )
 
        if (!STbp->do_dio) {
@@ -1329,13 +1333,13 @@ static int setup_buffering(Scsi_Tape *STp, const char __user *buf, size_t count,
 
 
 /* Can be called more than once after each setup_buffer() */
-static void release_buffering(Scsi_Tape *STp)
+static void release_buffering(struct scsi_tape *STp)
 {
-       ST_buffer *STbp;
+       struct st_buffer *STbp;
 
        STbp = STp->buffer;
        if (STbp->do_dio) {
-               sgl_unmap_user_pages(&(STbp->sg[0]), STbp->do_dio, FALSE);
+               sgl_unmap_user_pages(&(STbp->sg[0]), STbp->do_dio, 0);
                STbp->do_dio = 0;
        }
 }
@@ -1352,11 +1356,11 @@ st_write(struct file *filp, const char __user *buf, size_t count, loff_t * ppos)
        int async_write;
        unsigned char cmd[MAX_COMMAND_SIZE];
        const char __user *b_point;
-       Scsi_Request *SRpnt = NULL;
-       Scsi_Tape *STp = filp->private_data;
-       ST_mode *STm;
-       ST_partstat *STps;
-       ST_buffer *STbp;
+       struct scsi_request *SRpnt = NULL;
+       struct scsi_tape *STp = filp->private_data;
+       struct st_modedef *STm;
+       struct st_partstat *STps;
+       struct st_buffer *STbp;
        char *name = tape_name(STp);
 
        if (down_interruptible(&STp->lock))
@@ -1438,7 +1442,7 @@ st_write(struct file *filp, const char __user *buf, size_t count, loff_t * ppos)
                goto out;
        }
 
-       retval = setup_buffering(STp, buf, count, FALSE);
+       retval = setup_buffering(STp, buf, count, 0);
        if (retval)
                goto out;
 
@@ -1482,7 +1486,7 @@ st_write(struct file *filp, const char __user *buf, size_t count, loff_t * ppos)
                if (STp->block_size != 0 && STm->do_buffer_writes &&
                    !(STp->try_dio && try_wdio) && STps->eof < ST_EOM_OK &&
                    STbp->buffer_bytes < STbp->buffer_size) {
-                       STp->dirty = TRUE;
+                       STp->dirty = 1;
                        /* Don't write a buffer that is not full enough. */
                        if (!async_write && count == 0)
                                break;
@@ -1503,7 +1507,7 @@ st_write(struct file *filp, const char __user *buf, size_t count, loff_t * ppos)
                cmd[3] = blks >> 8;
                cmd[4] = blks;
 
-               SRpnt = st_do_scsi(SRpnt, STp, cmd, transfer, SCSI_DATA_WRITE,
+               SRpnt = st_do_scsi(SRpnt, STp, cmd, transfer, DMA_TO_DEVICE,
                                   STp->device->timeout, MAX_WRITE_RETRIES, !async_write);
                if (!SRpnt) {
                        retval = STbp->syscall_result;
@@ -1559,7 +1563,7 @@ st_write(struct file *filp, const char __user *buf, size_t count, loff_t * ppos)
                                        if (!retry_eot && (SRpnt->sr_sense_buffer[0] & 1) == 0 &&
                                            (scode == NO_SENSE || scode == RECOVERED_ERROR)) {
                                                move_buffer_data(STp->buffer, transfer - undone);
-                                               retry_eot = TRUE;
+                                               retry_eot = 1;
                                                if (STps->drv_block >= 0) {
                                                        STps->drv_block += (transfer - undone) /
                                                                STp->block_size;
@@ -1630,14 +1634,15 @@ st_write(struct file *filp, const char __user *buf, size_t count, loff_t * ppos)
 
    Does release user buffer mapping if it is set.
 */
-static long read_tape(Scsi_Tape *STp, long count, Scsi_Request ** aSRpnt)
+static long read_tape(struct scsi_tape *STp, long count,
+                     struct scsi_request ** aSRpnt)
 {
        int transfer, blks, bytes;
        unsigned char cmd[MAX_COMMAND_SIZE];
-       Scsi_Request *SRpnt;
-       ST_mode *STm;
-       ST_partstat *STps;
-       ST_buffer *STbp;
+       struct scsi_request *SRpnt;
+       struct st_modedef *STm;
+       struct st_partstat *STps;
+       struct st_buffer *STbp;
        int retval = 0;
        char *name = tape_name(STp);
 
@@ -1673,8 +1678,8 @@ static long read_tape(Scsi_Tape *STp, long count, Scsi_Request ** aSRpnt)
        cmd[4] = blks;
 
        SRpnt = *aSRpnt;
-       SRpnt = st_do_scsi(SRpnt, STp, cmd, bytes, SCSI_DATA_READ,
-                          STp->device->timeout, MAX_RETRIES, TRUE);
+       SRpnt = st_do_scsi(SRpnt, STp, cmd, bytes, DMA_FROM_DEVICE,
+                          STp->device->timeout, MAX_RETRIES, 1);
        release_buffering(STp);
        *aSRpnt = SRpnt;
        if (!SRpnt)
@@ -1818,11 +1823,11 @@ st_read(struct file *filp, char __user *buf, size_t count, loff_t * ppos)
        ssize_t retval = 0;
        ssize_t i, transfer;
        int special, do_dio = 0;
-       Scsi_Request *SRpnt = NULL;
-       Scsi_Tape *STp = filp->private_data;
-       ST_mode *STm;
-       ST_partstat *STps;
-       ST_buffer *STbp = STp->buffer;
+       struct scsi_request *SRpnt = NULL;
+       struct scsi_tape *STp = filp->private_data;
+       struct st_modedef *STm;
+       struct st_partstat *STps;
+       struct st_buffer *STbp = STp->buffer;
        DEB( char *name = tape_name(STp); )
 
        if (down_interruptible(&STp->lock))
@@ -1852,7 +1857,7 @@ st_read(struct file *filp, char __user *buf, size_t count, loff_t * ppos)
                       STps->eof, STbp->buffer_bytes);
         ) /* end DEB */
 
-       retval = setup_buffering(STp, buf, count, TRUE);
+       retval = setup_buffering(STp, buf, count, 1);
        if (retval)
                goto out;
        do_dio = STbp->do_dio;
@@ -1960,7 +1965,7 @@ st_read(struct file *filp, char __user *buf, size_t count, loff_t * ppos)
 
 DEB(
 /* Set the driver options */
-static void st_log_options(Scsi_Tape * STp, ST_mode * STm, char *name)
+static void st_log_options(struct scsi_tape * STp, struct st_modedef * STm, char *name)
 {
        if (debugging) {
                printk(KERN_INFO
@@ -1983,20 +1988,20 @@ static void st_log_options(Scsi_Tape * STp, ST_mode * STm, char *name)
        )
 
 
-static int st_set_options(Scsi_Tape *STp, long options)
+static int st_set_options(struct scsi_tape *STp, long options)
 {
        int value;
        long code;
-       ST_mode *STm;
+       struct st_modedef *STm;
        char *name = tape_name(STp);
        struct cdev *cd0, *cd1;
 
        STm = &(STp->modes[STp->current_mode]);
        if (!STm->defined) {
                cd0 = STm->cdevs[0]; cd1 = STm->cdevs[1];
-               memcpy(STm, &(STp->modes[0]), sizeof(ST_mode));
+               memcpy(STm, &(STp->modes[0]), sizeof(struct st_modedef));
                STm->cdevs[0] = cd0; STm->cdevs[1] = cd1;
-               modes_defined = TRUE;
+               modes_defined = 1;
                 DEBC(printk(ST_DEB_MSG
                             "%s: Initialized mode %d definition from mode 0\n",
                             name, STp->current_mode));
@@ -2065,7 +2070,7 @@ static int st_set_options(Scsi_Tape *STp, long options)
                        DEBC( printk(KERN_INFO "%s: Default block size set to %d bytes.\n",
                               name, STm->default_blksize));
                        if (STp->ready == ST_READY) {
-                               STp->blksize_changed = FALSE;
+                               STp->blksize_changed = 0;
                                set_mode_densblk(STp, STm);
                        }
                }
@@ -2104,7 +2109,7 @@ static int st_set_options(Scsi_Tape *STp, long options)
                                DEBC( printk(KERN_INFO "%s: Density default set to %x\n",
                                       name, STm->default_density));
                                if (STp->ready == ST_READY) {
-                                       STp->density_changed = FALSE;
+                                       STp->density_changed = 0;
                                        set_mode_densblk(STp, STm);
                                }
                        }
@@ -2137,7 +2142,7 @@ static int st_set_options(Scsi_Tape *STp, long options)
                                        DEBC( printk(KERN_INFO "%s: Compression default set to %x\n",
                                               name, (value & 1)));
                                        if (STp->ready == ST_READY) {
-                                               STp->compression_changed = FALSE;
+                                               STp->compression_changed = 0;
                                                st_compression(STp, (STm->default_compression == ST_YES));
                                        }
                                }
@@ -2171,10 +2176,10 @@ static int st_set_options(Scsi_Tape *STp, long options)
 /* Read a mode page into the tape buffer. The block descriptors are included
    if incl_block_descs is true. The page control is ored to the page number
    parameter, if necessary. */
-static int read_mode_page(Scsi_Tape *STp, int page, int omit_block_descs)
+static int read_mode_page(struct scsi_tape *STp, int page, int omit_block_descs)
 {
        unsigned char cmd[MAX_COMMAND_SIZE];
-       Scsi_Request *SRpnt = NULL;
+       struct scsi_request *SRpnt = NULL;
 
        memset(cmd, 0, MAX_COMMAND_SIZE);
        cmd[0] = MODE_SENSE;
@@ -2183,8 +2188,8 @@ static int read_mode_page(Scsi_Tape *STp, int page, int omit_block_descs)
        cmd[2] = page;
        cmd[4] = 255;
 
-       SRpnt = st_do_scsi(SRpnt, STp, cmd, cmd[4], SCSI_DATA_READ,
-                          STp->device->timeout, 0, TRUE);
+       SRpnt = st_do_scsi(SRpnt, STp, cmd, cmd[4], DMA_FROM_DEVICE,
+                          STp->device->timeout, 0, 1);
        if (SRpnt == NULL)
                return (STp->buffer)->syscall_result;
 
@@ -2196,11 +2201,11 @@ static int read_mode_page(Scsi_Tape *STp, int page, int omit_block_descs)
 
 /* Send the mode page in the tape buffer to the drive. Assumes that the mode data
    in the buffer is correctly formatted. The long timeout is used if slow is non-zero. */
-static int write_mode_page(Scsi_Tape *STp, int page, int slow)
+static int write_mode_page(struct scsi_tape *STp, int page, int slow)
 {
        int pgo;
        unsigned char cmd[MAX_COMMAND_SIZE];
-       Scsi_Request *SRpnt = NULL;
+       struct scsi_request *SRpnt = NULL;
 
        memset(cmd, 0, MAX_COMMAND_SIZE);
        cmd[0] = MODE_SELECT;
@@ -2214,8 +2219,8 @@ static int write_mode_page(Scsi_Tape *STp, int page, int slow)
        (STp->buffer)->b_data[MH_OFF_DEV_SPECIFIC] &= ~MH_BIT_WP;
        (STp->buffer)->b_data[pgo + MP_OFF_PAGE_NBR] &= MP_MSK_PAGE_NBR;
 
-       SRpnt = st_do_scsi(SRpnt, STp, cmd, cmd[4], SCSI_DATA_WRITE,
-                          (slow ? STp->long_timeout : STp->device->timeout), 0, TRUE);
+       SRpnt = st_do_scsi(SRpnt, STp, cmd, cmd[4], DMA_TO_DEVICE,
+                          (slow ? STp->long_timeout : STp->device->timeout), 0, 1);
        if (SRpnt == NULL)
                return (STp->buffer)->syscall_result;
 
@@ -2242,7 +2247,7 @@ static int write_mode_page(Scsi_Tape *STp, int page, int slow)
    work without this (suggestion from Michael Schaefer <Michael.Schaefer@dlr.de>).
    Including block descriptors should not cause any harm to other drives. */
 
-static int st_compression(Scsi_Tape * STp, int state)
+static int st_compression(struct scsi_tape * STp, int state)
 {
        int retval;
        int mpoffs;  /* Offset to mode page start */
@@ -2253,7 +2258,7 @@ static int st_compression(Scsi_Tape * STp, int state)
                return (-EIO);
 
        /* Read the current page contents */
-       retval = read_mode_page(STp, COMPRESSION_PAGE, FALSE);
+       retval = read_mode_page(STp, COMPRESSION_PAGE, 0);
        if (retval) {
                 DEBC(printk(ST_DEB_MSG "%s: Compression mode page not supported.\n",
                             name));
@@ -2282,7 +2287,7 @@ static int st_compression(Scsi_Tape * STp, int state)
                        b_data[mpoffs + CP_OFF_C_ALGO] = 0; /* no compression */
        }
 
-       retval = write_mode_page(STp, COMPRESSION_PAGE, FALSE);
+       retval = write_mode_page(STp, COMPRESSION_PAGE, 0);
        if (retval) {
                 DEBC(printk(ST_DEB_MSG "%s: Compression change failed.\n", name));
                return (-EIO);
@@ -2290,19 +2295,19 @@ static int st_compression(Scsi_Tape * STp, int state)
         DEBC(printk(ST_DEB_MSG "%s: Compression state changed to %d.\n",
                       name, state));
 
-       STp->compression_changed = TRUE;
+       STp->compression_changed = 1;
        return 0;
 }
 
 
 /* Process the load and unload commands (does unload if the load code is zero) */
-static int do_load_unload(Scsi_Tape *STp, struct file *filp, int load_code)
+static int do_load_unload(struct scsi_tape *STp, struct file *filp, int load_code)
 {
        int retval = (-EIO), timeout;
        DEB( char *name = tape_name(STp); )
        unsigned char cmd[MAX_COMMAND_SIZE];
-       ST_partstat *STps;
-       Scsi_Request *SRpnt;
+       struct st_partstat *STps;
+       struct scsi_request *SRpnt;
 
        if (STp->ready != ST_READY && !load_code) {
                if (STp->ready == ST_NO_TAPE)
@@ -2339,8 +2344,8 @@ static int do_load_unload(Scsi_Tape *STp, struct file *filp, int load_code)
                printk(ST_DEB_MSG "%s: Loading tape.\n", name);
                );
 
-       SRpnt = st_do_scsi(NULL, STp, cmd, 0, SCSI_DATA_NONE,
-                          timeout, MAX_RETRIES, TRUE);
+       SRpnt = st_do_scsi(NULL, STp, cmd, 0, DMA_NONE,
+                          timeout, MAX_RETRIES, 1);
        if (!SRpnt)
                return (STp->buffer)->syscall_result;
 
@@ -2370,17 +2375,17 @@ static int do_load_unload(Scsi_Tape *STp, struct file *filp, int load_code)
 \f
 
 /* Internal ioctl function */
-static int st_int_ioctl(Scsi_Tape *STp, unsigned int cmd_in, unsigned long arg)
+static int st_int_ioctl(struct scsi_tape *STp, unsigned int cmd_in, unsigned long arg)
 {
        int timeout;
        long ltmp;
        int ioctl_result;
-       int chg_eof = TRUE;
+       int chg_eof = 1;
        unsigned char cmd[MAX_COMMAND_SIZE];
-       Scsi_Request *SRpnt;
-       ST_partstat *STps;
+       struct scsi_request *SRpnt;
+       struct st_partstat *STps;
        int fileno, blkno, at_sm, undone;
-       int datalen = 0, direction = SCSI_DATA_NONE;
+       int datalen = 0, direction = DMA_NONE;
        char *name = tape_name(STp);
 
        WARN_ON(STp->buffer->do_dio != 0);
@@ -2399,7 +2404,7 @@ static int st_int_ioctl(Scsi_Tape *STp, unsigned int cmd_in, unsigned long arg)
        memset(cmd, 0, MAX_COMMAND_SIZE);
        switch (cmd_in) {
        case MTFSFM:
-               chg_eof = FALSE;        /* Changed from the FSF after this */
+               chg_eof = 0;    /* Changed from the FSF after this */
        case MTFSF:
                cmd[0] = SPACE;
                cmd[1] = 0x01;  /* Space FileMarks */
@@ -2414,7 +2419,7 @@ static int st_int_ioctl(Scsi_Tape *STp, unsigned int cmd_in, unsigned long arg)
                at_sm &= (arg == 0);
                break;
        case MTBSFM:
-               chg_eof = FALSE;        /* Changed from the FSF after this */
+               chg_eof = 0;    /* Changed from the FSF after this */
        case MTBSF:
                cmd[0] = SPACE;
                cmd[1] = 0x01;  /* Space FileMarks */
@@ -2583,7 +2588,7 @@ static int st_int_ioctl(Scsi_Tape *STp, unsigned int cmd_in, unsigned long arg)
        case MTSETDENSITY:      /* Set tape density */
        case MTSETDRVBUFFER:    /* Set drive buffering */
        case SET_DENS_AND_BLK:  /* Set density and block size */
-               chg_eof = FALSE;
+               chg_eof = 0;
                if (STp->dirty || (STp->buffer)->buffer_bytes != 0)
                        return (-EIO);  /* Not allowed if data in buffer */
                if ((cmd_in == MTSETBLK || cmd_in == SET_DENS_AND_BLK) &&
@@ -2598,7 +2603,7 @@ static int st_int_ioctl(Scsi_Tape *STp, unsigned int cmd_in, unsigned long arg)
                if ((STp->use_pf & USE_PF))
                        cmd[1] = MODE_SELECT_PAGE_FORMAT;
                cmd[4] = datalen = 12;
-               direction = SCSI_DATA_WRITE;
+               direction = DMA_TO_DEVICE;
 
                memset((STp->buffer)->b_data, 0, 12);
                if (cmd_in == MTSETDRVBUFFER)
@@ -2609,7 +2614,7 @@ static int st_int_ioctl(Scsi_Tape *STp, unsigned int cmd_in, unsigned long arg)
                (STp->buffer)->b_data[3] = 8;   /* block descriptor length */
                if (cmd_in == MTSETDENSITY) {
                        (STp->buffer)->b_data[4] = arg;
-                       STp->density_changed = TRUE;    /* At least we tried ;-) */
+                       STp->density_changed = 1;       /* At least we tried ;-) */
                } else if (cmd_in == SET_DENS_AND_BLK)
                        (STp->buffer)->b_data[4] = arg >> 24;
                else
@@ -2617,7 +2622,7 @@ static int st_int_ioctl(Scsi_Tape *STp, unsigned int cmd_in, unsigned long arg)
                if (cmd_in == MTSETBLK || cmd_in == SET_DENS_AND_BLK) {
                        ltmp = arg & MT_ST_BLKSIZE_MASK;
                        if (cmd_in == MTSETBLK)
-                               STp->blksize_changed = TRUE; /* At least we tried ;-) */
+                               STp->blksize_changed = 1; /* At least we tried ;-) */
                } else
                        ltmp = STp->block_size;
                (STp->buffer)->b_data[9] = (ltmp >> 16);
@@ -2646,7 +2651,7 @@ static int st_int_ioctl(Scsi_Tape *STp, unsigned int cmd_in, unsigned long arg)
        }
 
        SRpnt = st_do_scsi(NULL, STp, cmd, datalen, direction,
-                          timeout, MAX_RETRIES, TRUE);
+                          timeout, MAX_RETRIES, 1);
        if (!SRpnt)
                return (STp->buffer)->syscall_result;
 
@@ -2784,12 +2789,12 @@ static int st_int_ioctl(Scsi_Tape *STp, unsigned int cmd_in, unsigned long arg)
 /* Get the tape position. If bt == 2, arg points into a kernel space mt_loc
    structure. */
 
-static int get_location(Scsi_Tape *STp, unsigned int *block, int *partition,
+static int get_location(struct scsi_tape *STp, unsigned int *block, int *partition,
                        int logical)
 {
        int result;
        unsigned char scmd[MAX_COMMAND_SIZE];
-       Scsi_Request *SRpnt;
+       struct scsi_request *SRpnt;
        DEB( char *name = tape_name(STp); )
 
        if (STp->ready != ST_READY)
@@ -2804,8 +2809,8 @@ static int get_location(Scsi_Tape *STp, unsigned int *block, int *partition,
                if (!logical && !STp->scsi2_logical)
                        scmd[1] = 1;
        }
-       SRpnt = st_do_scsi(NULL, STp, scmd, 20, SCSI_DATA_READ, STp->device->timeout,
-                          MAX_READY_RETRIES, TRUE);
+       SRpnt = st_do_scsi(NULL, STp, scmd, 20, DMA_FROM_DEVICE,
+                       STp->device->timeout, MAX_READY_RETRIES, 1);
        if (!SRpnt)
                return (STp->buffer)->syscall_result;
 
@@ -2844,15 +2849,15 @@ static int get_location(Scsi_Tape *STp, unsigned int *block, int *partition,
 
 /* Set the tape block and partition. Negative partition means that only the
    block should be set in vendor specific way. */
-static int set_location(Scsi_Tape *STp, unsigned int block, int partition,
+static int set_location(struct scsi_tape *STp, unsigned int block, int partition,
                        int logical)
 {
-       ST_partstat *STps;
+       struct st_partstat *STps;
        int result, p;
        unsigned int blk;
        int timeout;
        unsigned char scmd[MAX_COMMAND_SIZE];
-       Scsi_Request *SRpnt;
+       struct scsi_request *SRpnt;
        DEB( char *name = tape_name(STp); )
 
        if (STp->ready != ST_READY)
@@ -2871,9 +2876,9 @@ static int set_location(Scsi_Tape *STp, unsigned int block, int partition,
                return (-EINVAL);
        if (partition != STp->partition) {
                if (get_location(STp, &blk, &p, 1))
-                       STps->last_block_valid = FALSE;
+                       STps->last_block_valid = 0;
                else {
-                       STps->last_block_valid = TRUE;
+                       STps->last_block_valid = 1;
                        STps->last_block_visited = blk;
                         DEBC(printk(ST_DEB_MSG
                                     "%s: Visited block %d for partition %d saved.\n",
@@ -2909,8 +2914,8 @@ static int set_location(Scsi_Tape *STp, unsigned int block, int partition,
                timeout = STp->device->timeout;
        }
 
-       SRpnt = st_do_scsi(NULL, STp, scmd, 0, SCSI_DATA_NONE,
-                          timeout, MAX_READY_RETRIES, TRUE);
+       SRpnt = st_do_scsi(NULL, STp, scmd, 0, DMA_NONE,
+                          timeout, MAX_READY_RETRIES, 1);
        if (!SRpnt)
                return (STp->buffer)->syscall_result;
 
@@ -2947,7 +2952,7 @@ static int set_location(Scsi_Tape *STp, unsigned int block, int partition,
 
 /* Find the current partition number for the drive status. Called from open and
    returns either partition number of negative error code. */
-static int find_partition(Scsi_Tape *STp)
+static int find_partition(struct scsi_tape *STp)
 {
        int i, partition;
        unsigned int block;
@@ -2961,9 +2966,9 @@ static int find_partition(Scsi_Tape *STp)
 
 
 /* Change the partition if necessary */
-static int switch_partition(Scsi_Tape *STp)
+static int switch_partition(struct scsi_tape *STp)
 {
-       ST_partstat *STps;
+       struct st_partstat *STps;
 
        if (STp->partition == STp->new_partition)
                return 0;
@@ -2989,7 +2994,7 @@ static int switch_partition(Scsi_Tape *STp)
 
 /* Get the number of partitions on the tape. As a side effect reads the
    mode page into the tape buffer. */
-static int nbr_partitions(Scsi_Tape *STp)
+static int nbr_partitions(struct scsi_tape *STp)
 {
        int result;
        DEB( char *name = tape_name(STp); )
@@ -2997,7 +3002,7 @@ static int nbr_partitions(Scsi_Tape *STp)
        if (STp->ready != ST_READY)
                return (-EIO);
 
-       result = read_mode_page(STp, PART_PAGE, TRUE);
+       result = read_mode_page(STp, PART_PAGE, 1);
 
        if (result) {
                 DEBC(printk(ST_DEB_MSG "%s: Can't read medium partition page.\n",
@@ -3032,14 +3037,14 @@ static int nbr_partitions(Scsi_Tape *STp)
    is acceptable also to some other old drives and enforced if the first partition
    size field is used for the first additional partition size.
  */
-static int partition_tape(Scsi_Tape *STp, int size)
+static int partition_tape(struct scsi_tape *STp, int size)
 {
        char *name = tape_name(STp);
        int result;
        int pgo, psd_cnt, psdo;
        unsigned char *bp;
 
-       result = read_mode_page(STp, PART_PAGE, FALSE);
+       result = read_mode_page(STp, PART_PAGE, 0);
        if (result) {
                DEBC(printk(ST_DEB_MSG "%s: Can't read partition mode page.\n", name));
                return result;
@@ -3082,7 +3087,7 @@ static int partition_tape(Scsi_Tape *STp, int size)
        bp[pgo + PP_OFF_RESERVED] = 0;
        bp[pgo + PP_OFF_FLAGS] = PP_BIT_IDP | PP_MSK_PSUM_MB;
 
-       result = write_mode_page(STp, PART_PAGE, TRUE);
+       result = write_mode_page(STp, PART_PAGE, 1);
        if (result) {
                printk(KERN_INFO "%s: Partitioning of tape failed.\n", name);
                result = (-EIO);
@@ -3100,9 +3105,9 @@ static int st_ioctl(struct inode *inode, struct file *file,
        int i, cmd_nr, cmd_type, bt;
        int retval = 0;
        unsigned int blk;
-       Scsi_Tape *STp = file->private_data;
-       ST_mode *STm;
-       ST_partstat *STps;
+       struct scsi_tape *STp = file->private_data;
+       struct st_modedef *STm;
+       struct st_partstat *STps;
        char *name = tape_name(STp);
        void __user *p = (void __user *)arg;
 
@@ -3125,10 +3130,11 @@ static int st_ioctl(struct inode *inode, struct file *file,
         * may try and take the device offline, in which case all further
         * access to the device is prohibited.
         */
-       if (!scsi_block_when_processing_errors(STp->device)) {
-               retval = (-ENXIO);
+       retval = scsi_nonblockable_ioctl(STp->device, cmd_in, p, file);
+       if (!scsi_block_when_processing_errors(STp->device) || retval != -ENODEV)
                goto out;
-       }
+       retval = 0;
+
        cmd_type = _IOC_TYPE(cmd_in);
        cmd_nr = _IOC_NR(cmd_in);
 
@@ -3259,7 +3265,7 @@ static int st_ioctl(struct inode *inode, struct file *file,
                        for (i = 0; i < ST_NBR_PARTITIONS; i++) {
                                STp->ps[i].rw = ST_IDLE;
                                STp->ps[i].at_sm = 0;
-                               STp->ps[i].last_block_valid = FALSE;
+                               STp->ps[i].last_block_valid = 0;
                        }
                        STp->partition = STp->new_partition = 0;
                        STp->nbr_partitions = 1;        /* Bad guess ?-) */
@@ -3308,7 +3314,7 @@ static int st_ioctl(struct inode *inode, struct file *file,
                goto out;
        }
 
-       if ((i = flush_buffer(STp, FALSE)) < 0) {
+       if ((i = flush_buffer(STp, 0)) < 0) {
                retval = i;
                goto out;
        }
@@ -3423,18 +3429,18 @@ static int st_ioctl(struct inode *inode, struct file *file,
 
 /* Try to allocate a new tape buffer. Calling function must not hold
    dev_arr_lock. */
-static ST_buffer *
+static struct st_buffer *
  new_tape_buffer(int from_initialization, int need_dma, int max_sg)
 {
        int i, priority, got = 0, segs = 0;
-       ST_buffer *tb;
+       struct st_buffer *tb;
 
        if (from_initialization)
                priority = GFP_ATOMIC;
        else
                priority = GFP_KERNEL;
 
-       i = sizeof(ST_buffer) + (max_sg - 1) * sizeof(struct scatterlist) +
+       i = sizeof(struct st_buffer) + (max_sg - 1) * sizeof(struct scatterlist) +
                max_sg * sizeof(struct st_buf_fragment);
        tb = kmalloc(i, priority);
        if (!tb) {
@@ -3448,7 +3454,7 @@ static ST_buffer *
                tb->b_data = page_address(tb->sg[0].page);
        tb->frp = (struct st_buf_fragment *)(&(tb->sg[0]) + max_sg);
 
-       tb->in_use = TRUE;
+       tb->in_use = 1;
        tb->dma = need_dma;
        tb->buffer_size = got;
 
@@ -3457,12 +3463,12 @@ static ST_buffer *
 
 
 /* Try to allocate enough space in the tape buffer */
-static int enlarge_buffer(ST_buffer * STbuffer, int new_size, int need_dma)
+static int enlarge_buffer(struct st_buffer * STbuffer, int new_size, int need_dma)
 {
        int segs, nbr, max_segs, b_size, priority, order, got;
 
        if (new_size <= STbuffer->buffer_size)
-               return TRUE;
+               return 1;
 
        if (STbuffer->buffer_size <= PAGE_SIZE)
                normalize_buffer(STbuffer);  /* Avoid extra segment */
@@ -3470,7 +3476,7 @@ static int enlarge_buffer(ST_buffer * STbuffer, int new_size, int need_dma)
        max_segs = STbuffer->use_sg;
        nbr = max_segs - STbuffer->frp_segs;
        if (nbr <= 0)
-               return FALSE;
+               return 0;
 
        priority = GFP_KERNEL | __GFP_NOWARN;
        if (need_dma)
@@ -3491,7 +3497,7 @@ static int enlarge_buffer(ST_buffer * STbuffer, int new_size, int need_dma)
                        }
                        DEB(STbuffer->buffer_size = got);
                        normalize_buffer(STbuffer);
-                       return FALSE;
+                       return 0;
                }
                STbuffer->frp[segs].length = b_size;
                STbuffer->frp_segs += 1;
@@ -3501,12 +3507,12 @@ static int enlarge_buffer(ST_buffer * STbuffer, int new_size, int need_dma)
        }
        STbuffer->b_data = page_address(STbuffer->frp[0].page);
 
-       return TRUE;
+       return 1;
 }
 
 
 /* Release the extra buffer */
-static void normalize_buffer(ST_buffer * STbuffer)
+static void normalize_buffer(struct st_buffer * STbuffer)
 {
        int i, order;
 
@@ -3522,7 +3528,7 @@ static void normalize_buffer(ST_buffer * STbuffer)
 
 /* Move data from the user buffer to the tape buffer. Returns zero (success) or
    negative error code. */
-static int append_to_buffer(const char __user *ubp, ST_buffer * st_bp, int do_count)
+static int append_to_buffer(const char __user *ubp, struct st_buffer * st_bp, int do_count)
 {
        int i, cnt, res, offset;
 
@@ -3553,7 +3559,7 @@ static int append_to_buffer(const char __user *ubp, ST_buffer * st_bp, int do_co
 
 /* Move data from the tape buffer to the user buffer. Returns zero (success) or
    negative error code. */
-static int from_buffer(ST_buffer * st_bp, char __user *ubp, int do_count)
+static int from_buffer(struct st_buffer * st_bp, char __user *ubp, int do_count)
 {
        int i, cnt, res, offset;
 
@@ -3584,7 +3590,7 @@ static int from_buffer(ST_buffer * st_bp, char __user *ubp, int do_count)
 
 
 /* Move data towards start of buffer */
-static void move_buffer_data(ST_buffer * st_bp, int offset)
+static void move_buffer_data(struct st_buffer * st_bp, int offset)
 {
        int src_seg, dst_seg, src_offset = 0, dst_offset;
        int count, total;
@@ -3622,7 +3628,7 @@ static void move_buffer_data(ST_buffer * st_bp, int offset)
 
 
 /* Fill the s/g list up to the length required for this transfer */
-static void buf_to_sg(ST_buffer *STbp, unsigned int length)
+static void buf_to_sg(struct st_buffer *STbp, unsigned int length)
 {
        int i;
        unsigned int count;
@@ -3720,10 +3726,10 @@ static int st_probe(struct device *dev)
        struct scsi_device *SDp = to_scsi_device(dev);
        struct gendisk *disk = NULL;
        struct cdev *cdev = NULL;
-       Scsi_Tape *tpnt = NULL;
-       ST_mode *STm;
-       ST_partstat *STps;
-       ST_buffer *buffer;
+       struct scsi_tape *tpnt = NULL;
+       struct st_modedef *STm;
+       struct st_partstat *STps;
+       struct st_buffer *buffer;
        int i, j, mode, dev_num, error;
        char *stp;
        u64 bounce_limit;
@@ -3741,9 +3747,10 @@ static int st_probe(struct device *dev)
        i = SDp->host->sg_tablesize;
        if (st_max_sg_segs < i)
                i = st_max_sg_segs;
-       buffer = new_tape_buffer(TRUE, (SDp->host)->unchecked_isa_dma, i);
+       buffer = new_tape_buffer(1, (SDp->host)->unchecked_isa_dma, i);
        if (buffer == NULL) {
-               printk(KERN_ERR "st: Can't allocate new tape buffer. Device not attached.\n");
+               printk(KERN_ERR
+                      "st: Can't allocate new tape buffer. Device not attached.\n");
                goto out;
        }
 
@@ -3755,7 +3762,7 @@ static int st_probe(struct device *dev)
 
        write_lock(&st_dev_arr_lock);
        if (st_nr_dev >= st_dev_max) {
-               Scsi_Tape **tmp_da;
+               struct scsi_tape **tmp_da;
                int tmp_dev_max;
 
                tmp_dev_max = max(st_nr_dev * 2, 8);
@@ -3768,17 +3775,17 @@ static int st_probe(struct device *dev)
                        goto out_put_disk;
                }
 
-               tmp_da = kmalloc(tmp_dev_max * sizeof(Scsi_Tape *), GFP_ATOMIC);
+               tmp_da = kmalloc(tmp_dev_max * sizeof(struct scsi_tape *), GFP_ATOMIC);
                if (tmp_da == NULL) {
                        write_unlock(&st_dev_arr_lock);
                        printk(KERN_ERR "st: Can't extend device array.\n");
                        goto out_put_disk;
                }
 
-               memset(tmp_da, 0, tmp_dev_max * sizeof(Scsi_Tape *));
+               memset(tmp_da, 0, tmp_dev_max * sizeof(struct scsi_tape *));
                if (scsi_tapes != NULL) {
                        memcpy(tmp_da, scsi_tapes,
-                              st_dev_max * sizeof(Scsi_Tape *));
+                              st_dev_max * sizeof(struct scsi_tape *));
                        kfree(scsi_tapes);
                }
                scsi_tapes = tmp_da;
@@ -3792,13 +3799,13 @@ static int st_probe(struct device *dev)
        if (i >= st_dev_max)
                panic("scsi_devices corrupt (st)");
 
-       tpnt = kmalloc(sizeof(Scsi_Tape), GFP_ATOMIC);
+       tpnt = kmalloc(sizeof(struct scsi_tape), GFP_ATOMIC);
        if (tpnt == NULL) {
                write_unlock(&st_dev_arr_lock);
                printk(KERN_ERR "st: Can't allocate device descriptor.\n");
                goto out_put_disk;
        }
-       memset(tpnt, 0, sizeof(Scsi_Tape));
+       memset(tpnt, 0, sizeof(struct scsi_tape));
        tpnt->disk = disk;
        sprintf(disk->disk_name, "st%d", i);
        disk->private_data = &tpnt->driver;
@@ -3844,7 +3851,7 @@ static int st_probe(struct device *dev)
 
        for (i = 0; i < ST_NBR_MODES; i++) {
                STm = &(tpnt->modes[i]);
-               STm->defined = FALSE;
+               STm->defined = 0;
                STm->sysv = ST_SYSV;
                STm->defaults_for_writes = 0;
                STm->do_async_writes = ST_ASYNC_WRITES;
@@ -3860,16 +3867,16 @@ static int st_probe(struct device *dev)
                STps->rw = ST_IDLE;
                STps->eof = ST_NOEOF;
                STps->at_sm = 0;
-               STps->last_block_valid = FALSE;
+               STps->last_block_valid = 0;
                STps->drv_block = (-1);
                STps->drv_file = (-1);
        }
 
        tpnt->current_mode = 0;
-       tpnt->modes[0].defined = TRUE;
+       tpnt->modes[0].defined = 1;
 
        tpnt->density_changed = tpnt->compression_changed =
-           tpnt->blksize_changed = FALSE;
+           tpnt->blksize_changed = 0;
        init_MUTEX(&tpnt->lock);
 
        st_nr_dev++;
@@ -3961,8 +3968,8 @@ out:
 
 static int st_remove(struct device *dev)
 {
-       Scsi_Device *SDp = to_scsi_device(dev);
-       Scsi_Tape *tpnt;
+       struct scsi_device *SDp = to_scsi_device(dev);
+       struct scsi_tape *tpnt;
        int i, j, mode;
 
        write_lock(&st_dev_arr_lock);
@@ -4136,7 +4143,7 @@ static void do_remove_driverfs_files(void)
 /* The sysfs simple class interface */
 static ssize_t st_defined_show(struct class_device *class_dev, char *buf)
 {
-       ST_mode *STm = (ST_mode *)class_get_devdata(class_dev);
+       struct st_modedef *STm = (struct st_modedef *)class_get_devdata(class_dev);
        ssize_t l = 0;
 
        l = snprintf(buf, PAGE_SIZE, "%d\n", STm->defined);
@@ -4147,7 +4154,7 @@ CLASS_DEVICE_ATTR(defined, S_IRUGO, st_defined_show, NULL);
 
 static ssize_t st_defblk_show(struct class_device *class_dev, char *buf)
 {
-       ST_mode *STm = (ST_mode *)class_get_devdata(class_dev);
+       struct st_modedef *STm = (struct st_modedef *)class_get_devdata(class_dev);
        ssize_t l = 0;
 
        l = snprintf(buf, PAGE_SIZE, "%d\n", STm->default_blksize);
@@ -4158,7 +4165,7 @@ CLASS_DEVICE_ATTR(default_blksize, S_IRUGO, st_defblk_show, NULL);
 
 static ssize_t st_defdensity_show(struct class_device *class_dev, char *buf)
 {
-       ST_mode *STm = (ST_mode *)class_get_devdata(class_dev);
+       struct st_modedef *STm = (struct st_modedef *)class_get_devdata(class_dev);
        ssize_t l = 0;
        char *fmt;
 
@@ -4171,7 +4178,7 @@ CLASS_DEVICE_ATTR(default_density, S_IRUGO, st_defdensity_show, NULL);
 
 static ssize_t st_defcompression_show(struct class_device *class_dev, char *buf)
 {
-       ST_mode *STm = (ST_mode *)class_get_devdata(class_dev);
+       struct st_modedef *STm = (struct st_modedef *)class_get_devdata(class_dev);
        ssize_t l = 0;
 
        l = snprintf(buf, PAGE_SIZE, "%d\n", STm->default_compression - 1);
@@ -4180,7 +4187,7 @@ static ssize_t st_defcompression_show(struct class_device *class_dev, char *buf)
 
 CLASS_DEVICE_ATTR(default_compression, S_IRUGO, st_defcompression_show, NULL);
 
-static void do_create_class_files(Scsi_Tape *STp, int dev_num, int mode)
+static void do_create_class_files(struct scsi_tape *STp, int dev_num, int mode)
 {
        int i, rew, error;
        char name[10];
@@ -4253,7 +4260,7 @@ static int st_map_user_pages(struct scatterlist *sgl, const unsigned int max_pag
        return nr_pages;
 
  out_unmap:
-       sgl_unmap_user_pages(sgl, nr_pages, FALSE);
+       sgl_unmap_user_pages(sgl, nr_pages, 0);
        return 0;
 }