patch-2.4.21 linux-2.4.21/drivers/ide/ide-tape.c
Next file: linux-2.4.21/drivers/ide/ide-taskfile.c
Previous file: linux-2.4.21/drivers/ide/ide-sibyte.c
Back to the patch index
Back to the overall index
- Lines: 4927
- Date:
2003-06-13 07:51:33.000000000 -0700
- Orig file:
linux-2.4.20/drivers/ide/ide-tape.c
- Orig date:
2002-08-02 17:39:44.000000000 -0700
diff -urN linux-2.4.20/drivers/ide/ide-tape.c linux-2.4.21/drivers/ide/ide-tape.c
@@ -1,5 +1,5 @@
/*
- * linux/drivers/ide/ide-tape.c Version 1.17a Jan, 2001
+ * linux/drivers/ide/ide-tape.c Version 1.17b Dec, 2002
*
* Copyright (C) 1995 - 1999 Gadi Oxman <gadio@netvision.net.il>
*
@@ -291,6 +291,28 @@
* Ver 1.17a Apr 2001 Willem Riede osst@riede.org
* - Get drive's actual block size from mode sense block descriptor
* - Limit size of pipeline
+ * Ver 1.17b Dec 2002 Alan Stern <stern@rowland.harvard.edu>
+ * Changed IDETAPE_MIN_PIPELINE_STAGES to 1 and actually used
+ * it in the code!
+ * Actually removed aborted stages in idetape_abort_pipeline
+ * instead of just changing the command code.
+ * Made the transfer byte count for Request Sense equal to the
+ * actual length of the data transfer.
+ * Changed handling of partial data transfers: they do not
+ * cause DMA errors.
+ * Moved initiation of DMA transfers to the correct place.
+ * Removed reference to unallocated memory.
+ * Made __idetape_discard_read_pipeline return the number of
+ * sectors skipped, not the number of stages.
+ * Replaced errant kfree() calls with __idetape_kfree_stage().
+ * Fixed off-by-one error in testing the pipeline length.
+ * Fixed handling of filemarks in the read pipeline.
+ * Small code optimization for MTBSF and MTBSFM ioctls.
+ * Don't try to unlock the door during device close if is
+ * already unlocked!
+ * Cosmetic fixes to miscellaneous debugging output messages.
+ * Set the minimum /proc/ide/hd?/settings values for "pipeline",
+ * "pipeline_min", and "pipeline_max" to 1.
*
* Here are some words from the first releases of hd.c, which are quoted
* in ide.c and apply here as well:
@@ -400,7 +422,7 @@
* sharing a (fast) ATA-2 disk with any (slow) new ATAPI device.
*/
-#define IDETAPE_VERSION "1.17a"
+#define IDETAPE_VERSION "1.17b-ac1"
#include <linux/config.h>
#include <linux/module.h>
@@ -416,7 +438,6 @@
#include <linux/errno.h>
#include <linux/genhd.h>
#include <linux/slab.h>
-#include <linux/pci.h>
#include <linux/ide.h>
#include <linux/smp_lock.h>
#include <linux/completion.h>
@@ -429,8 +450,6 @@
#include <asm/bitops.h>
-#define NO_LONGER_REQUIRED (1)
-
/*
* OnStream support
*/
@@ -577,9 +596,10 @@
* whenever we sense that the pipeline is empty, until we reach
* the optimum value or until we reach MAX.
*
- * Setting the following parameter to 0 will disable the pipelined mode.
+ * Setting the following parameter to 0 is illegal: the pipelined mode
+ * cannot be disabled (calculate_speeds() divides by tape->max_stages.)
*/
-#define IDETAPE_MIN_PIPELINE_STAGES 200
+#define IDETAPE_MIN_PIPELINE_STAGES 1
#define IDETAPE_MAX_PIPELINE_STAGES 400
#define IDETAPE_INCREASE_STAGES_RATE 20
@@ -601,8 +621,8 @@
* is verified to be stable enough. This will make it much more
* esthetic.
*/
-#define IDETAPE_DEBUG_INFO 1
-#define IDETAPE_DEBUG_LOG 1
+#define IDETAPE_DEBUG_INFO 0
+#define IDETAPE_DEBUG_LOG 0
#define IDETAPE_DEBUG_LOG_VERBOSE 0
#define IDETAPE_DEBUG_BUGS 1
@@ -724,22 +744,28 @@
struct buffer_head *bh;
char *b_data;
int b_count;
- byte *buffer; /* Data buffer */
- byte *current_position; /* Pointer into the above buffer */
+ u8 *buffer; /* Data buffer */
+ u8 *current_position; /* Pointer into the above buffer */
ide_startstop_t (*callback) (ide_drive_t *); /* Called when this packet command is completed */
- byte pc_buffer[IDETAPE_PC_BUFFER_SIZE]; /* Temporary buffer */
+ u8 pc_buffer[IDETAPE_PC_BUFFER_SIZE]; /* Temporary buffer */
unsigned long flags; /* Status/Action bit flags: long for set_bit */
} idetape_pc_t;
/*
* Packet command flag bits.
*/
-#define PC_ABORT 0 /* Set when an error is considered normal - We won't retry */
-#define PC_WAIT_FOR_DSC 1 /* 1 When polling for DSC on a media access command */
-#define PC_DMA_RECOMMENDED 2 /* 1 when we prefer to use DMA if possible */
-#define PC_DMA_IN_PROGRESS 3 /* 1 while DMA in progress */
-#define PC_DMA_ERROR 4 /* 1 when encountered problem during DMA */
-#define PC_WRITING 5 /* Data direction */
+/* Set when an error is considered normal - We won't retry */
+#define PC_ABORT 0
+/* 1 When polling for DSC on a media access command */
+#define PC_WAIT_FOR_DSC 1
+/* 1 when we prefer to use DMA if possible */
+#define PC_DMA_RECOMMENDED 2
+/* 1 while DMA in progress */
+#define PC_DMA_IN_PROGRESS 3
+/* 1 when encountered problem during DMA */
+#define PC_DMA_ERROR 4
+/* Data direction */
+#define PC_WRITING 5
/*
* Capabilities and Mechanical Status Page
@@ -814,6 +840,7 @@
* REQUEST SENSE packet command result - Data Format.
*/
typedef struct {
+#if defined(__LITTLE_ENDIAN_BITFIELD)
unsigned error_code :7; /* Current of deferred errors */
unsigned valid :1; /* The information field conforms to QIC-157C */
__u8 reserved1 :8; /* Segment Number - Reserved */
@@ -822,6 +849,18 @@
unsigned ili :1; /* Incorrect Length Indicator */
unsigned eom :1; /* End Of Medium */
unsigned filemark :1; /* Filemark */
+#elif defined(__BIG_ENDIAN_BITFIELD)
+ unsigned valid :1;
+ unsigned error_code :7;
+ __u8 reserved1 :8;
+ unsigned filemark :1;
+ unsigned eom :1;
+ unsigned ili :1;
+ unsigned reserved2_4 :1;
+ unsigned sense_key :4;
+#else
+#error "Please fix <asm/byteorder.h>"
+#endif
__u32 information __attribute__ ((packed));
__u8 asl; /* Additional sense length (n-7) */
__u32 command_specific; /* Additional command specific information */
@@ -860,12 +899,17 @@
* required since an additional packet command is needed before the
* retry, to get detailed information on what went wrong.
*/
- idetape_pc_t *pc; /* Current packet command */
- idetape_pc_t *failed_pc; /* Last failed packet command */
- idetape_pc_t pc_stack[IDETAPE_PC_STACK];/* Packet command stack */
- int pc_stack_index; /* Next free packet command storage space */
+ /* Current packet command */
+ idetape_pc_t *pc;
+ /* Last failed packet command */
+ idetape_pc_t *failed_pc;
+ /* Packet command stack */
+ idetape_pc_t pc_stack[IDETAPE_PC_STACK];
+ /* Next free packet command storage space */
+ int pc_stack_index;
struct request rq_stack[IDETAPE_PC_STACK];
- int rq_stack_index; /* We implement a circular array */
+ /* We implement a circular array */
+ int rq_stack_index;
/*
* DSC polling variables.
@@ -879,38 +923,48 @@
* to ide.c only one at a time.
*/
struct request *postponed_rq;
- unsigned long dsc_polling_start; /* The time in which we started polling for DSC */
- struct timer_list dsc_timer; /* Timer used to poll for dsc */
- unsigned long best_dsc_rw_frequency; /* Read/Write dsc polling frequency */
- unsigned long dsc_polling_frequency; /* The current polling frequency */
- unsigned long dsc_timeout; /* Maximum waiting time */
+ /* The time in which we started polling for DSC */
+ unsigned long dsc_polling_start;
+ /* Timer used to poll for dsc */
+ struct timer_list dsc_timer;
+ /* Read/Write dsc polling frequency */
+ unsigned long best_dsc_rw_frequency;
+ /* The current polling frequency */
+ unsigned long dsc_polling_frequency;
+ /* Maximum waiting time */
+ unsigned long dsc_timeout;
/*
* Read position information
*/
- byte partition;
- unsigned int first_frame_position; /* Current block */
+ u8 partition;
+ /* Current block */
+ unsigned int first_frame_position;
unsigned int last_frame_position;
unsigned int blocks_in_buffer;
/*
* Last error information
*/
- byte sense_key, asc, ascq;
+ u8 sense_key, asc, ascq;
/*
* Character device operation
*/
unsigned int minor;
- char name[4]; /* device name */
- idetape_chrdev_direction_t chrdev_direction; /* Current character device data transfer direction */
+ /* device name */
+ char name[4];
+ /* Current character device data transfer direction */
+ idetape_chrdev_direction_t chrdev_direction;
/*
* Device information
*/
- unsigned short tape_block_size; /* Usually 512 or 1024 bytes */
+ /* Usually 512 or 1024 bytes */
+ unsigned short tape_block_size;
int user_bs_factor;
- idetape_capabilities_page_t capabilities; /* Copy of the tape's Capabilities and Mechanical Page */
+ /* Copy of the tape's Capabilities and Mechanical Page */
+ idetape_capabilities_page_t capabilities;
/*
* Active data transfer request parameters.
@@ -925,8 +979,10 @@
* The data buffer size is chosen based on the tape's
* recommendation.
*/
- struct request *active_data_request; /* Pointer to the request which is waiting in the device request queue */
- int stage_size; /* Data buffer size (chosen based on the tape's recommendation */
+ /* Pointer to the request, waiting in the device request queue */
+ struct request *active_data_request;
+ /* Data buffer size (chosen based on the tape's recommendation */
+ int stage_size;
idetape_stage_t *merge_stage;
int merge_stage_size;
struct buffer_head *bh;
@@ -939,19 +995,30 @@
* To accomplish non-pipelined mode, we simply set the following
* variables to zero (or NULL, where appropriate).
*/
- int nr_stages; /* Number of currently used stages */
- int nr_pending_stages; /* Number of pending stages */
- int max_stages, min_pipeline, max_pipeline; /* We will not allocate more than this number of stages */
- idetape_stage_t *first_stage; /* The first stage which will be removed from the pipeline */
- idetape_stage_t *active_stage; /* The currently active stage */
- idetape_stage_t *next_stage; /* Will be serviced after the currently active request */
- idetape_stage_t *last_stage; /* New requests will be added to the pipeline here */
- idetape_stage_t *cache_stage; /* Optional free stage which we can use */
+ /* Number of currently used stages */
+ int nr_stages;
+ /* Number of pending stages */
+ int nr_pending_stages;
+ /* We will not allocate more than this number of stages */
+ int max_stages, min_pipeline, max_pipeline;
+ /* The first stage which will be removed from the pipeline */
+ idetape_stage_t *first_stage;
+ /* The currently active stage */
+ idetape_stage_t *active_stage;
+ /* Will be serviced after the currently active request */
+ idetape_stage_t *next_stage;
+ /* New requests will be added to the pipeline here */
+ idetape_stage_t *last_stage;
+ /* Optional free stage which we can use */
+ idetape_stage_t *cache_stage;
int pages_per_stage;
- int excess_bh_size; /* Wasted space in each stage */
+ /* Wasted space in each stage */
+ int excess_bh_size;
- unsigned long flags; /* Status/Action flags: long for set_bit */
- spinlock_t spinlock; /* protects the ide-tape queue */
+ /* Status/Action flags: long for set_bit */
+ unsigned long flags;
+ /* protects the ide-tape queue */
+ spinlock_t spinlock;
/*
* Measures average tape speed
@@ -960,31 +1027,44 @@
int avg_size;
int avg_speed;
- idetape_request_sense_result_t sense; /* last sense information */
+ /* last sense information */
+ idetape_request_sense_result_t sense;
char vendor_id[10];
char product_id[18];
char firmware_revision[6];
int firmware_revision_num;
- int door_locked; /* the door is currently locked */
+ /* the door is currently locked */
+ int door_locked;
/*
* OnStream flags
*/
- int onstream; /* the tape is an OnStream tape */
- int raw; /* OnStream raw access (32.5KB block size) */
- int cur_frames; /* current number of frames in internal buffer */
- int max_frames; /* max number of frames in internal buffer */
- int logical_blk_num; /* logical block number */
- __u16 wrt_pass_cntr; /* write pass counter */
- __u32 update_frame_cntr; /* update frame counter */
+ /* the tape is an OnStream tape */
+ int onstream;
+ /* OnStream raw access (32.5KB block size) */
+ int raw;
+ /* current number of frames in internal buffer */
+ int cur_frames;
+ /* max number of frames in internal buffer */
+ int max_frames;
+ /* logical block number */
+ int logical_blk_num;
+ /* write pass counter */
+ __u16 wrt_pass_cntr;
+ /* update frame counter */
+ __u32 update_frame_cntr;
struct completion *waiting;
- int onstream_write_error; /* write error recovery active */
- int header_ok; /* header frame verified ok */
- int linux_media; /* reading linux-specifc media */
+ /* write error recovery active */
+ int onstream_write_error;
+ /* header frame verified ok */
+ int header_ok;
+ /* reading linux-specifc media */
+ int linux_media;
int linux_media_version;
- char application_sig[5]; /* application signature */
+ /* application signature */
+ char application_sig[5];
int filemark_cnt;
int first_mark_addr;
int last_mark_addr;
@@ -997,8 +1077,10 @@
* Optimize the number of "buffer filling"
* mode sense commands.
*/
- unsigned long last_buffer_fill; /* last time in which we issued fill cmd */
- int req_buffer_fill; /* buffer fill command requested */
+ /* last time in which we issued fill cmd */
+ unsigned long last_buffer_fill;
+ /* buffer fill command requested */
+ int req_buffer_fill;
int writes_since_buffer_fill;
int reads_since_buffer_fill;
@@ -1007,7 +1089,8 @@
* be postponed, to avoid an infinite postpone
* deadlock.
*/
- int postpone_cnt; /* request postpone count limit */
+ /* request postpone count limit */
+ int postpone_cnt;
/*
* Measures number of frames:
@@ -1040,11 +1123,17 @@
* Speed regulation negative feedback loop
*/
int speed_control;
- int pipeline_head_speed, controlled_pipeline_head_speed, uncontrolled_pipeline_head_speed;
- int controlled_last_pipeline_head, uncontrolled_last_pipeline_head;
- unsigned long uncontrolled_pipeline_head_time, controlled_pipeline_head_time;
- int controlled_previous_pipeline_head, uncontrolled_previous_pipeline_head;
- unsigned long controlled_previous_head_time, uncontrolled_previous_head_time;
+ int pipeline_head_speed;
+ int controlled_pipeline_head_speed;
+ int uncontrolled_pipeline_head_speed;
+ int controlled_last_pipeline_head;
+ int uncontrolled_last_pipeline_head;
+ unsigned long uncontrolled_pipeline_head_time;
+ unsigned long controlled_pipeline_head_time;
+ int controlled_previous_pipeline_head;
+ int uncontrolled_previous_pipeline_head;
+ unsigned long controlled_previous_head_time;
+ unsigned long uncontrolled_previous_head_time;
int restart_speed_control_req;
/*
@@ -1164,101 +1253,6 @@
#define IDETAPE_ERROR_EOD 103
/*
- * The ATAPI Status Register.
- */
-typedef union {
- unsigned all :8;
- struct {
- unsigned check :1; /* Error occurred */
- unsigned idx :1; /* Reserved */
- unsigned corr :1; /* Correctable error occurred */
- unsigned drq :1; /* Data is request by the device */
- unsigned dsc :1; /* Buffer availability / Media access command finished */
- unsigned reserved5 :1; /* Reserved */
- unsigned drdy :1; /* Ignored for ATAPI commands (ready to accept ATA command) */
- unsigned bsy :1; /* The device has access to the command block */
- } b;
-} idetape_status_reg_t;
-
-/*
- * The ATAPI error register.
- */
-typedef union {
- unsigned all :8;
- struct {
- unsigned ili :1; /* Illegal Length Indication */
- unsigned eom :1; /* End Of Media Detected */
- unsigned abrt :1; /* Aborted command - As defined by ATA */
- unsigned mcr :1; /* Media Change Requested - As defined by ATA */
- unsigned sense_key :4; /* Sense key of the last failed packet command */
- } b;
-} idetape_error_reg_t;
-
-/*
- * ATAPI Feature Register
- */
-typedef union {
- unsigned all :8;
- struct {
- unsigned dma :1; /* Using DMA or PIO */
- unsigned reserved321 :3; /* Reserved */
- unsigned reserved654 :3; /* Reserved (Tag Type) */
- unsigned reserved7 :1; /* Reserved */
- } b;
-} idetape_feature_reg_t;
-
-/*
- * ATAPI Byte Count Register.
- */
-typedef union {
- unsigned all :16;
- struct {
- unsigned low :8; /* LSB */
- unsigned high :8; /* MSB */
- } b;
-} idetape_bcount_reg_t;
-
-/*
- * ATAPI Interrupt Reason Register.
- */
-typedef union {
- unsigned all :8;
- struct {
- unsigned cod :1; /* Information transferred is command (1) or data (0) */
- unsigned io :1; /* The device requests us to read (1) or write (0) */
- unsigned reserved :6; /* Reserved */
- } b;
-} idetape_ireason_reg_t;
-
-/*
- * ATAPI Drive Select Register
- */
-typedef union {
- unsigned all :8;
- struct {
- unsigned sam_lun :4; /* Should be zero with ATAPI (not used) */
- unsigned drv :1; /* The responding drive will be drive 0 (0) or drive 1 (1) */
- unsigned one5 :1; /* Should be set to 1 */
- unsigned reserved6 :1; /* Reserved */
- unsigned one7 :1; /* Should be set to 1 */
- } b;
-} idetape_drivesel_reg_t;
-
-/*
- * ATAPI Device Control Register
- */
-typedef union {
- unsigned all :8;
- struct {
- unsigned zero0 :1; /* Should be set to zero */
- unsigned nien :1; /* Device interrupt is disabled (1) or enabled (0) */
- unsigned srst :1; /* ATA software reset. ATAPI devices should use the new ATAPI srst. */
- unsigned one3 :1; /* Should be set to 1 */
- unsigned reserved4567 :4; /* Reserved */
- } b;
-} idetape_control_reg_t;
-
-/*
* idetape_chrdev_t provides the link between out character device
* interface and our block device interface and the corresponding
* ide_drive_t structure.
@@ -1432,41 +1426,60 @@
* DO NOT REMOVE, BUILDING A VERBOSE DEBUG SCHEME FOR ATAPI
*/
-char *idetape_sense_key_verbose (byte idetape_sense_key)
+char *idetape_sense_key_verbose (u8 idetape_sense_key)
{
switch (idetape_sense_key) {
default: {
char buf[22];
- sprintf(buf, "IDETAPE_SENSE (0x%02x)", idetape_sense_key);
+ sprintf(buf, "IDETAPE_SENSE (0x%02x)",
+ idetape_sense_key);
return(buf);
}
}
}
-char *idetape_command_key_verbose (byte idetape_command_key)
+char *idetape_command_key_verbose (u8 idetape_command_key)
{
switch (idetape_command_key) {
- case IDETAPE_TEST_UNIT_READY_CMD: return("TEST_UNIT_READY_CMD");
- case IDETAPE_REWIND_CMD: return("REWIND_CMD");
- case IDETAPE_REQUEST_SENSE_CMD: return("REQUEST_SENSE_CMD");
- case IDETAPE_READ_CMD: return("READ_CMD");
- case IDETAPE_WRITE_CMD: return("WRITE_CMD");
- case IDETAPE_WRITE_FILEMARK_CMD: return("WRITE_FILEMARK_CMD");
- case IDETAPE_SPACE_CMD: return("SPACE_CMD");
- case IDETAPE_INQUIRY_CMD: return("INQUIRY_CMD");
- case IDETAPE_ERASE_CMD: return("ERASE_CMD");
- case IDETAPE_MODE_SENSE_CMD: return("MODE_SENSE_CMD");
- case IDETAPE_MODE_SELECT_CMD: return("MODE_SELECT_CMD");
- case IDETAPE_LOAD_UNLOAD_CMD: return("LOAD_UNLOAD_CMD");
- case IDETAPE_PREVENT_CMD: return("PREVENT_CMD");
- case IDETAPE_LOCATE_CMD: return("LOCATE_CMD");
- case IDETAPE_READ_POSITION_CMD: return("READ_POSITION_CMD");
- case IDETAPE_READ_BUFFER_CMD: return("READ_BUFFER_CMD");
- case IDETAPE_SET_SPEED_CMD: return("SET_SPEED_CMD");
+ case IDETAPE_TEST_UNIT_READY_CMD:
+ return("TEST_UNIT_READY_CMD");
+ case IDETAPE_REWIND_CMD:
+ return("REWIND_CMD");
+ case IDETAPE_REQUEST_SENSE_CMD:
+ return("REQUEST_SENSE_CMD");
+ case IDETAPE_READ_CMD:
+ return("READ_CMD");
+ case IDETAPE_WRITE_CMD:
+ return("WRITE_CMD");
+ case IDETAPE_WRITE_FILEMARK_CMD:
+ return("WRITE_FILEMARK_CMD");
+ case IDETAPE_SPACE_CMD:
+ return("SPACE_CMD");
+ case IDETAPE_INQUIRY_CMD:
+ return("INQUIRY_CMD");
+ case IDETAPE_ERASE_CMD:
+ return("ERASE_CMD");
+ case IDETAPE_MODE_SENSE_CMD:
+ return("MODE_SENSE_CMD");
+ case IDETAPE_MODE_SELECT_CMD:
+ return("MODE_SELECT_CMD");
+ case IDETAPE_LOAD_UNLOAD_CMD:
+ return("LOAD_UNLOAD_CMD");
+ case IDETAPE_PREVENT_CMD:
+ return("PREVENT_CMD");
+ case IDETAPE_LOCATE_CMD:
+ return("LOCATE_CMD");
+ case IDETAPE_READ_POSITION_CMD:
+ return("READ_POSITION_CMD");
+ case IDETAPE_READ_BUFFER_CMD:
+ return("READ_BUFFER_CMD");
+ case IDETAPE_SET_SPEED_CMD:
+ return("SET_SPEED_CMD");
default: {
char buf[20];
- sprintf(buf, "CMD (0x%02x)", idetape_command_key);
+ sprintf(buf, "CMD (0x%02x)",
+ idetape_command_key);
return(buf);
}
}
@@ -1482,13 +1495,13 @@
static void idetape_write_release (struct inode *inode);
/*
- * Too bad. The drive wants to send us data which we are not ready to accept.
- * Just throw it away.
+ * Too bad. The drive wants to send us data which we are not ready to accept.
+ * Just throw it away.
*/
static void idetape_discard_data (ide_drive_t *drive, unsigned int bcount)
{
while (bcount--)
- IN_BYTE (IDE_DATA_REG);
+ (void) HWIF(drive)->INB(IDE_DATA_REG);
}
static void idetape_input_buffers (ide_drive_t *drive, idetape_pc_t *pc, unsigned int bcount)
@@ -1499,13 +1512,14 @@
while (bcount) {
#if IDETAPE_DEBUG_BUGS
if (bh == NULL) {
- printk (KERN_ERR "ide-tape: bh == NULL in idetape_input_buffers\n");
- idetape_discard_data (drive, bcount);
+ printk(KERN_ERR "ide-tape: bh == NULL in %s\n",
+ __FUNCTION__);
+ idetape_discard_data(drive, bcount);
return;
}
#endif /* IDETAPE_DEBUG_BUGS */
- count = IDE_MIN (bh->b_size - atomic_read(&bh->b_count), bcount);
- atapi_input_bytes (drive, bh->b_data + atomic_read(&bh->b_count), count);
+ count = IDE_MIN(bh->b_size - atomic_read(&bh->b_count), bcount);
+ HWIF(drive)->atapi_input_bytes(drive, bh->b_data + atomic_read(&bh->b_count), count);
bcount -= count;
atomic_add(count, &bh->b_count);
if (atomic_read(&bh->b_count) == bh->b_size) {
@@ -1525,12 +1539,13 @@
while (bcount) {
#if IDETAPE_DEBUG_BUGS
if (bh == NULL) {
- printk (KERN_ERR "ide-tape: bh == NULL in idetape_output_buffers\n");
+ printk(KERN_ERR "ide-tape: bh == NULL in %s\n",
+ __FUNCTION__);
return;
}
#endif /* IDETAPE_DEBUG_BUGS */
- count = IDE_MIN (pc->b_count, bcount);
- atapi_output_bytes (drive, pc->b_data, count);
+ count = IDE_MIN(pc->b_count, bcount);
+ HWIF(drive)->atapi_output_bytes(drive, pc->b_data, count);
bcount -= count;
pc->b_data += count;
pc->b_count -= count;
@@ -1550,16 +1565,17 @@
struct buffer_head *bh = pc->bh;
int count, bcount = pc->actually_transferred;
- if (test_bit (PC_WRITING, &pc->flags))
+ if (test_bit(PC_WRITING, &pc->flags))
return;
while (bcount) {
#if IDETAPE_DEBUG_BUGS
if (bh == NULL) {
- printk (KERN_ERR "ide-tape: bh == NULL in idetape_update_buffers\n");
+ printk(KERN_ERR "ide-tape: bh == NULL in %s\n",
+ __FUNCTION__);
return;
}
#endif /* IDETAPE_DEBUG_BUGS */
- count = IDE_MIN (bh->b_size, bcount);
+ count = IDE_MIN(bh->b_size, bcount);
atomic_set(&bh->b_count, count);
if (atomic_read(&bh->b_count) == bh->b_size)
bh = bh->b_reqnext;
@@ -1581,9 +1597,10 @@
#if IDETAPE_DEBUG_LOG
if (tape->debug_level >= 5)
- printk (KERN_INFO "ide-tape: pc_stack_index=%d\n",tape->pc_stack_index);
+ printk(KERN_INFO "ide-tape: pc_stack_index=%d\n",
+ tape->pc_stack_index);
#endif /* IDETAPE_DEBUG_LOG */
- if (tape->pc_stack_index==IDETAPE_PC_STACK)
+ if (tape->pc_stack_index == IDETAPE_PC_STACK)
tape->pc_stack_index=0;
return (&tape->pc_stack[tape->pc_stack_index++]);
}
@@ -1607,9 +1624,10 @@
#if IDETAPE_DEBUG_LOG
if (tape->debug_level >= 5)
- printk (KERN_INFO "ide-tape: rq_stack_index=%d\n",tape->rq_stack_index);
+ printk(KERN_INFO "ide-tape: rq_stack_index=%d\n",
+ tape->rq_stack_index);
#endif /* IDETAPE_DEBUG_LOG */
- if (tape->rq_stack_index==IDETAPE_PC_STACK)
+ if (tape->rq_stack_index == IDETAPE_PC_STACK)
tape->rq_stack_index=0;
return (&tape->rq_stack[tape->rq_stack_index++]);
}
@@ -1619,7 +1637,7 @@
*/
static void idetape_init_pc (idetape_pc_t *pc)
{
- memset (pc->c, 0, 12);
+ memset(pc->c, 0, 12);
pc->retries = 0;
pc->flags = 0;
pc->request_transfer = 0;
@@ -1649,19 +1667,23 @@
* give up retrying.
*/
if (tape->debug_level >= 1)
- printk (KERN_INFO "ide-tape: pc = %x, sense key = %x, asc = %x, ascq = %x\n",
- pc->c[0], result->sense_key, result->asc, result->ascq);
+ printk(KERN_INFO "ide-tape: pc = %x, sense key = %x, "
+ "asc = %x, ascq = %x\n",
+ pc->c[0], result->sense_key,
+ result->asc, result->ascq);
#if IDETAPE_DEBUG_LOG_VERBOSE
if (tape->debug_level >= 1)
- printk (KERN_INFO "ide-tape: pc = %s, sense key = %x, asc = %x, ascq = %x\n",
- idetape_command_key_verbose((byte) pc->c[0]),
+ printk (KERN_INFO "ide-tape: pc = %s, sense key = %x, "
+ "asc = %x, ascq = %x\n",
+ idetape_command_key_verbose((u8) pc->c[0]),
result->sense_key,
result->asc,
result->ascq);
#endif /* IDETAPE_DEBUG_LOG_VERBOSE */
#endif /* IDETAPE_DEBUG_LOG */
- if (tape->onstream && result->sense_key == 2 && result->asc == 0x53 && result->ascq == 2) {
+ if (tape->onstream && result->sense_key == 2 &&
+ result->asc == 0x53 && result->ascq == 2) {
clear_bit(PC_DMA_ERROR, &pc->flags);
ide_stall_queue(drive, HZ / 2);
return;
@@ -1671,49 +1693,33 @@
/*
* Correct pc->actually_transferred by asking the tape.
*/
- if (test_bit (PC_DMA_ERROR, &pc->flags)) {
- pc->actually_transferred = pc->request_transfer - tape->tape_block_size * ntohl (get_unaligned (&result->information));
- idetape_update_buffers (pc);
+ if (test_bit(PC_DMA_ERROR, &pc->flags)) {
+ pc->actually_transferred = pc->request_transfer - tape->tape_block_size * ntohl(get_unaligned (&result->information));
+ idetape_update_buffers(pc);
}
#endif /* CONFIG_BLK_DEV_IDEDMA */
if (pc->c[0] == IDETAPE_READ_CMD && result->filemark) {
pc->error = IDETAPE_ERROR_FILEMARK;
- set_bit (PC_ABORT, &pc->flags);
+ set_bit(PC_ABORT, &pc->flags);
}
if (pc->c[0] == IDETAPE_WRITE_CMD) {
- if (result->eom || (result->sense_key == 0xd && result->asc == 0x0 && result->ascq == 0x2)) {
+ if (result->eom || (result->sense_key == 0xd &&
+ result->asc == 0x0 && result->ascq == 0x2)) {
pc->error = IDETAPE_ERROR_EOD;
- set_bit (PC_ABORT, &pc->flags);
+ set_bit(PC_ABORT, &pc->flags);
}
}
if (pc->c[0] == IDETAPE_READ_CMD || pc->c[0] == IDETAPE_WRITE_CMD) {
if (result->sense_key == 8) {
pc->error = IDETAPE_ERROR_EOD;
- set_bit (PC_ABORT, &pc->flags);
+ set_bit(PC_ABORT, &pc->flags);
}
- if (!test_bit (PC_ABORT, &pc->flags) && (tape->onstream || pc->actually_transferred))
+ if (!test_bit(PC_ABORT, &pc->flags) &&
+ (tape->onstream || pc->actually_transferred))
pc->retries = IDETAPE_MAX_PC_RETRIES + 1;
}
}
-static void idetape_abort_pipeline (ide_drive_t *drive)
-{
- idetape_tape_t *tape = drive->driver_data;
- idetape_stage_t *stage = tape->next_stage;
-
-#if IDETAPE_DEBUG_LOG
- if (tape->debug_level >= 4)
- printk(KERN_INFO "ide-tape: %s: idetape_abort_pipeline called\n", tape->name);
-#endif
- while (stage) {
- if (stage->rq.cmd == IDETAPE_WRITE_RQ)
- stage->rq.cmd = IDETAPE_ABORTED_WRITE_RQ;
- else if (stage->rq.cmd == IDETAPE_READ_RQ)
- stage->rq.cmd = IDETAPE_ABORTED_READ_RQ;
- stage = stage->next;
- }
-}
-
/*
* idetape_active_next_stage will declare the next stage as "active".
*/
@@ -1725,11 +1731,12 @@
#if IDETAPE_DEBUG_LOG
if (tape->debug_level >= 4)
- printk (KERN_INFO "ide-tape: Reached idetape_active_next_stage\n");
+ printk(KERN_INFO "ide-tape: Reached %s\n", __FUNCTION__);
#endif /* IDETAPE_DEBUG_LOG */
#if IDETAPE_DEBUG_BUGS
if (stage == NULL) {
- printk (KERN_ERR "ide-tape: bug: Trying to activate a non existing stage\n");
+ printk(KERN_ERR "ide-tape: bug: Trying to activate a "
+ "non existing stage\n");
return;
}
#endif /* IDETAPE_DEBUG_BUGS */
@@ -1755,10 +1762,10 @@
#if IDETAPE_DEBUG_LOG
if (tape->debug_level >= 4)
- printk (KERN_INFO "ide-tape: Reached idetape_increase_max_pipeline_stages\n");
+ printk (KERN_INFO "ide-tape: Reached %s\n", __FUNCTION__);
#endif /* IDETAPE_DEBUG_LOG */
- tape->max_stages += increase;
+ tape->max_stages += IDE_MAX(increase, 1);
tape->max_stages = IDE_MAX(tape->max_stages, tape->min_pipeline);
tape->max_stages = IDE_MIN(tape->max_stages, tape->max_pipeline);
}
@@ -1776,21 +1783,21 @@
if (bh->b_data != NULL) {
size = (int) bh->b_size;
while (size > 0) {
- free_page ((unsigned long) bh->b_data);
+ free_page((unsigned long) bh->b_data);
size -= PAGE_SIZE;
bh->b_data += PAGE_SIZE;
}
}
prev_bh = bh;
bh = bh->b_reqnext;
- kfree (prev_bh);
+ kfree(prev_bh);
}
- kfree (stage);
+ kfree(stage);
}
static void idetape_kfree_stage (idetape_tape_t *tape, idetape_stage_t *stage)
{
- __idetape_kfree_stage (stage);
+ __idetape_kfree_stage(stage);
}
/*
@@ -1804,45 +1811,72 @@
#if IDETAPE_DEBUG_LOG
if (tape->debug_level >= 4)
- printk (KERN_INFO "ide-tape: Reached idetape_remove_stage_head\n");
+ printk(KERN_INFO "ide-tape: Reached %s\n", __FUNCTION__);
#endif /* IDETAPE_DEBUG_LOG */
#if IDETAPE_DEBUG_BUGS
if (tape->first_stage == NULL) {
- printk (KERN_ERR "ide-tape: bug: tape->first_stage is NULL\n");
+ printk(KERN_ERR "ide-tape: bug: tape->first_stage is NULL\n");
return;
}
if (tape->active_stage == tape->first_stage) {
- printk (KERN_ERR "ide-tape: bug: Trying to free our active pipeline stage\n");
+ printk(KERN_ERR "ide-tape: bug: Trying to free our "
+ "active pipeline stage\n");
return;
}
#endif /* IDETAPE_DEBUG_BUGS */
stage = tape->first_stage;
tape->first_stage = stage->next;
- idetape_kfree_stage (tape, stage);
+ idetape_kfree_stage(tape, stage);
tape->nr_stages--;
if (tape->first_stage == NULL) {
tape->last_stage = NULL;
#if IDETAPE_DEBUG_BUGS
if (tape->next_stage != NULL)
- printk (KERN_ERR "ide-tape: bug: tape->next_stage != NULL\n");
+ printk(KERN_ERR "ide-tape: bug: "
+ "tape->next_stage != NULL\n");
if (tape->nr_stages)
- printk (KERN_ERR "ide-tape: bug: nr_stages should be 0 now\n");
+ printk(KERN_ERR "ide-tape: bug: nr_stages should "
+ "be 0 now\n");
#endif /* IDETAPE_DEBUG_BUGS */
}
}
+static void idetape_abort_pipeline (ide_drive_t *drive, idetape_stage_t *last_stage)
+{
+ idetape_tape_t *tape = drive->driver_data;
+ idetape_stage_t *stage = tape->next_stage;
+ idetape_stage_t *nstage;
+
+#if IDETAPE_DEBUG_LOG
+ if (tape->debug_level >= 4)
+ printk(KERN_INFO "ide-tape: %s: %s called\n",
+ tape->name, __FUNCTION__);
+#endif
+ while (stage) {
+ nstage = stage->next;
+ idetape_kfree_stage(tape, stage);
+ --tape->nr_stages;
+ --tape->nr_pending_stages;
+ stage = nstage;
+ }
+ tape->last_stage = last_stage;
+ if (last_stage)
+ last_stage->next = NULL;
+ tape->next_stage = NULL;
+}
+
/*
* idetape_end_request is used to finish servicing a request, and to
* insert a pending pipeline request into the main device queue.
*/
-static void idetape_end_request (byte uptodate, ide_hwgroup_t *hwgroup)
+static int idetape_end_request (ide_drive_t *drive, int uptodate)
{
- ide_drive_t *drive = hwgroup->drive;
- struct request *rq = hwgroup->rq;
+ struct request *rq = HWGROUP(drive)->rq;
idetape_tape_t *tape = drive->driver_data;
unsigned long flags;
int error;
int remove_stage = 0;
+ idetape_stage_t *active_stage;
#if ONSTREAM_DEBUG
idetape_stage_t *stage;
os_aux_t *aux;
@@ -1851,7 +1885,7 @@
#if IDETAPE_DEBUG_LOG
if (tape->debug_level >= 4)
- printk (KERN_INFO "ide-tape: Reached idetape_end_request\n");
+ printk (KERN_INFO "ide-tape: Reached %s\n", __FUNCTION__);
#endif /* IDETAPE_DEBUG_LOG */
switch (uptodate) {
@@ -1864,7 +1898,9 @@
tape->failed_pc = NULL;
spin_lock_irqsave(&tape->spinlock, flags);
- if (tape->active_data_request == rq) { /* The request was a pipelined data transfer request */
+ if (tape->active_data_request == rq) {
+ /* The request was a pipelined data transfer request */
+ active_stage = tape->active_stage;
tape->active_stage = NULL;
tape->active_data_request = NULL;
tape->nr_pending_stages--;
@@ -1884,34 +1920,40 @@
if (tape->first_frame_position == OS_DATA_ENDFRAME1) {
#if ONSTREAM_DEBUG
if (tape->debug_level >= 2)
- printk("ide-tape: %s: skipping over config parition..\n", tape->name);
+ printk("ide-tape: %s: skipping over config partition.\n", tape->name);
#endif
tape->onstream_write_error = OS_PART_ERROR;
- if (tape->waiting)
+ if (tape->waiting) {
+ rq->waiting = NULL;
complete(tape->waiting);
+ }
}
}
remove_stage = 1;
if (error) {
- set_bit (IDETAPE_PIPELINE_ERROR, &tape->flags);
+ set_bit(IDETAPE_PIPELINE_ERROR, &tape->flags);
if (error == IDETAPE_ERROR_EOD)
- idetape_abort_pipeline (drive);
- if (tape->onstream && !tape->raw && error == IDETAPE_ERROR_GENERAL && tape->sense.sense_key == 3) {
- clear_bit (IDETAPE_PIPELINE_ERROR, &tape->flags);
+ idetape_abort_pipeline(drive, active_stage);
+ if (tape->onstream && !tape->raw &&
+ error == IDETAPE_ERROR_GENERAL &&
+ tape->sense.sense_key == 3) {
+ clear_bit(IDETAPE_PIPELINE_ERROR, &tape->flags);
printk(KERN_ERR "ide-tape: %s: write error, enabling error recovery\n", tape->name);
tape->onstream_write_error = OS_WRITE_ERROR;
remove_stage = 0;
tape->nr_pending_stages++;
tape->next_stage = tape->first_stage;
rq->current_nr_sectors = rq->nr_sectors;
- if (tape->waiting)
+ if (tape->waiting) {
+ rq->waiting = NULL;
complete(tape->waiting);
+ }
}
}
} else if (rq->cmd == IDETAPE_READ_RQ) {
if (error == IDETAPE_ERROR_EOD) {
- set_bit (IDETAPE_PIPELINE_ERROR, &tape->flags);
- idetape_abort_pipeline(drive);
+ set_bit(IDETAPE_PIPELINE_ERROR, &tape->flags);
+ idetape_abort_pipeline(drive, active_stage);
}
}
if (tape->next_stage != NULL && !tape->onstream_write_error) {
@@ -1920,18 +1962,19 @@
/*
* Insert the next request into the request queue.
*/
- (void) ide_do_drive_cmd (drive, tape->active_data_request, ide_end);
+ (void) ide_do_drive_cmd(drive, tape->active_data_request, ide_end);
} else if (!error) {
if (!tape->onstream)
- idetape_increase_max_pipeline_stages (drive);
+ idetape_increase_max_pipeline_stages(drive);
}
}
- ide_end_drive_cmd (drive, 0, 0);
+ ide_end_drive_cmd(drive, 0, 0);
if (remove_stage)
- idetape_remove_stage_head (drive);
+ idetape_remove_stage_head(drive);
if (tape->active_data_request == NULL)
clear_bit(IDETAPE_PIPELINE_ACTIVE, &tape->flags);
spin_unlock_irqrestore(&tape->spinlock, flags);
+ return 0;
}
static ide_startstop_t idetape_request_sense_callback (ide_drive_t *drive)
@@ -1940,24 +1983,25 @@
#if IDETAPE_DEBUG_LOG
if (tape->debug_level >= 4)
- printk (KERN_INFO "ide-tape: Reached idetape_request_sense_callback\n");
+ printk(KERN_INFO "ide-tape: Reached %s\n", __FUNCTION__);
#endif /* IDETAPE_DEBUG_LOG */
if (!tape->pc->error) {
- idetape_analyze_error (drive, (idetape_request_sense_result_t *) tape->pc->buffer);
- idetape_end_request (1, HWGROUP (drive));
+ idetape_analyze_error(drive, (idetape_request_sense_result_t *) tape->pc->buffer);
+ idetape_end_request(drive, 1);
} else {
- printk (KERN_ERR "ide-tape: Error in REQUEST SENSE itself - Aborting request!\n");
- idetape_end_request (0, HWGROUP (drive));
+ printk(KERN_ERR "ide-tape: Error in REQUEST SENSE "
+ "itself - Aborting request!\n");
+ idetape_end_request(drive, 0);
}
return ide_stopped;
}
static void idetape_create_request_sense_cmd (idetape_pc_t *pc)
{
- idetape_init_pc (pc);
+ idetape_init_pc(pc);
pc->c[0] = IDETAPE_REQUEST_SENSE_CMD;
pc->c[4] = 20;
- pc->request_transfer = 18;
+ pc->request_transfer = 20;
pc->callback = &idetape_request_sense_callback;
}
@@ -1982,10 +2026,10 @@
*/
static void idetape_queue_pc_head (ide_drive_t *drive,idetape_pc_t *pc,struct request *rq)
{
- ide_init_drive_cmd (rq);
+ ide_init_drive_cmd(rq);
rq->buffer = (char *) pc;
rq->cmd = IDETAPE_PC_RQ1;
- (void) ide_do_drive_cmd (drive, rq, ide_preempt);
+ (void) ide_do_drive_cmd(drive, rq, ide_preempt);
}
/*
@@ -1998,14 +2042,14 @@
idetape_tape_t *tape = drive->driver_data;
idetape_pc_t *pc;
struct request *rq;
- idetape_error_reg_t error;
+ atapi_error_t error;
- error.all = IN_BYTE (IDE_ERROR_REG);
+ error.all = HWIF(drive)->INB(IDE_ERROR_REG);
pc = idetape_next_pc_storage (drive);
rq = idetape_next_rq_storage (drive);
- idetape_create_request_sense_cmd (pc);
- set_bit (IDETAPE_IGNORE_DSC, &tape->flags);
- idetape_queue_pc_head (drive, pc, rq);
+ idetape_create_request_sense_cmd(pc);
+ set_bit(IDETAPE_IGNORE_DSC, &tape->flags);
+ idetape_queue_pc_head(drive, pc, rq);
return ide_stopped;
}
@@ -2037,9 +2081,9 @@
static ide_startstop_t idetape_pc_intr (ide_drive_t *drive)
{
idetape_tape_t *tape = drive->driver_data;
- idetape_status_reg_t status;
- idetape_bcount_reg_t bcount;
- idetape_ireason_reg_t ireason;
+ atapi_status_t status;
+ atapi_bcount_t bcount;
+ atapi_ireason_t ireason;
idetape_pc_t *pc = tape->pc;
unsigned int temp;
@@ -2050,14 +2094,16 @@
#if IDETAPE_DEBUG_LOG
if (tape->debug_level >= 4)
- printk (KERN_INFO "ide-tape: Reached idetape_pc_intr interrupt handler\n");
+ printk(KERN_INFO "ide-tape: Reached idetape_pc_intr "
+ "interrupt handler\n");
#endif /* IDETAPE_DEBUG_LOG */
- status.all = GET_STAT(); /* Clear the interrupt */
+ /* Clear the interrupt */
+ status.all = HWIF(drive)->INB(IDE_STATUS_REG);
#ifdef CONFIG_BLK_DEV_IDEDMA
- if (test_bit (PC_DMA_IN_PROGRESS, &pc->flags)) {
- if (HWIF(drive)->dmaproc(ide_dma_end, drive)) {
+ if (test_bit(PC_DMA_IN_PROGRESS, &pc->flags)) {
+ if (HWIF(drive)->ide_dma_end(drive) || status.b.check) {
/*
* A DMA error is sometimes expected. For example,
* if the tape is crossing a filemark during a
@@ -2069,8 +2115,18 @@
* actually transferred (we can't receive that
* information from the DMA engine on most chipsets).
*/
+
+ /*
+ * On the contrary, a DMA error is never expected;
+ * it usually indicates a hardware error or abort.
+ * If the tape crosses a filemark during a READ
+ * command, it will issue an irq and position itself
+ * after the filemark (not before). Only a partial
+ * data transfer will occur, but no DMA error.
+ * (AS, 19 Apr 2001)
+ */
set_bit (PC_DMA_ERROR, &pc->flags);
- } else if (!status.b.check) {
+ } else {
pc->actually_transferred = pc->request_transfer;
idetape_update_buffers (pc);
}
@@ -2081,106 +2137,139 @@
}
#endif /* CONFIG_BLK_DEV_IDEDMA */
- if (!status.b.drq) { /* No more interrupts */
+ if (!status.b.drq) { /* No more interrupts */
cmd_time = (jiffies - tape->cmd_start_time) * 1000 / HZ;
tape->max_cmd_time = IDE_MAX(cmd_time, tape->max_cmd_time);
#if IDETAPE_DEBUG_LOG
if (tape->debug_level >= 2)
- printk (KERN_INFO "ide-tape: Packet command completed, %d bytes transferred\n", pc->actually_transferred);
+ printk(KERN_INFO "ide-tape: Packet command completed, "
+ "%d bytes transferred\n",
+ pc->actually_transferred);
#endif /* IDETAPE_DEBUG_LOG */
- clear_bit (PC_DMA_IN_PROGRESS, &pc->flags);
+ clear_bit(PC_DMA_IN_PROGRESS, &pc->flags);
- ide__sti(); /* local CPU only */
+ local_irq_enable();
#if SIMULATE_ERRORS
- if ((pc->c[0] == IDETAPE_WRITE_CMD || pc->c[0] == IDETAPE_READ_CMD) && (++error_sim_count % 100) == 0) {
- printk(KERN_INFO "ide-tape: %s: simulating error\n", tape->name);
+ if ((pc->c[0] == IDETAPE_WRITE_CMD ||
+ pc->c[0] == IDETAPE_READ_CMD) &&
+ (++error_sim_count % 100) == 0) {
+ printk(KERN_INFO "ide-tape: %s: simulating error\n",
+ tape->name);
status.b.check = 1;
}
#endif
if (status.b.check && pc->c[0] == IDETAPE_REQUEST_SENSE_CMD)
status.b.check = 0;
- if (status.b.check || test_bit (PC_DMA_ERROR, &pc->flags)) { /* Error detected */
-#if IDETAPE_DEBUG_LOG
- if (tape->debug_level >= 1)
- printk (KERN_INFO "ide-tape: %s: I/O error, ",tape->name);
-#endif /* IDETAPE_DEBUG_LOG */
+ if (status.b.check || test_bit(PC_DMA_ERROR, &pc->flags)) {
+ /* Error detected */
if (pc->c[0] == IDETAPE_REQUEST_SENSE_CMD) {
- printk (KERN_ERR "ide-tape: I/O error in request sense command\n");
- return ide_do_reset (drive);
+ printk(KERN_ERR "ide-tape: I/O error in "
+ "request sense command\n");
+ return ide_do_reset(drive);
}
#if IDETAPE_DEBUG_LOG
if (tape->debug_level >= 1)
- printk(KERN_INFO "ide-tape: [cmd %x]: check condition\n", pc->c[0]);
+ printk(KERN_INFO "ide-tape: [cmd %x]: check "
+ "condition\n", pc->c[0]);
#endif
- return idetape_retry_pc (drive); /* Retry operation */
+ /* Retry operation */
+ return idetape_retry_pc(drive);
}
pc->error = 0;
- if (!tape->onstream && test_bit (PC_WAIT_FOR_DSC, &pc->flags) && !status.b.dsc) { /* Media access command */
+ if (!tape->onstream &&
+ test_bit(PC_WAIT_FOR_DSC, &pc->flags) &&
+ !status.b.dsc) {
+ /* Media access command */
tape->dsc_polling_start = jiffies;
tape->dsc_polling_frequency = IDETAPE_DSC_MA_FAST;
tape->dsc_timeout = jiffies + IDETAPE_DSC_MA_TIMEOUT;
- idetape_postpone_request (drive); /* Allow ide.c to handle other requests */
+ /* Allow ide.c to handle other requests */
+ idetape_postpone_request(drive);
return ide_stopped;
}
if (tape->failed_pc == pc)
tape->failed_pc = NULL;
- return pc->callback(drive); /* Command finished - Call the callback function */
+ /* Command finished - Call the callback function */
+ return pc->callback(drive);
}
#ifdef CONFIG_BLK_DEV_IDEDMA
- if (test_and_clear_bit (PC_DMA_IN_PROGRESS, &pc->flags)) {
- printk (KERN_ERR "ide-tape: The tape wants to issue more interrupts in DMA mode\n");
- printk (KERN_ERR "ide-tape: DMA disabled, reverting to PIO\n");
- (void) HWIF(drive)->dmaproc(ide_dma_off, drive);
- return ide_do_reset (drive);
+ if (test_and_clear_bit(PC_DMA_IN_PROGRESS, &pc->flags)) {
+ printk(KERN_ERR "ide-tape: The tape wants to issue more "
+ "interrupts in DMA mode\n");
+ printk(KERN_ERR "ide-tape: DMA disabled, reverting to PIO\n");
+ (void) HWIF(drive)->ide_dma_off(drive);
+ return ide_do_reset(drive);
}
#endif /* CONFIG_BLK_DEV_IDEDMA */
- bcount.b.high = IN_BYTE (IDE_BCOUNTH_REG); /* Get the number of bytes to transfer */
- bcount.b.low = IN_BYTE (IDE_BCOUNTL_REG); /* on this interrupt */
- ireason.all = IN_BYTE (IDE_IREASON_REG);
+ /* Get the number of bytes to transfer */
+ bcount.b.high = HWIF(drive)->INB(IDE_BCOUNTH_REG);
+ bcount.b.low = HWIF(drive)->INB(IDE_BCOUNTL_REG);
+ /* on this interrupt */
+ ireason.all = HWIF(drive)->INB(IDE_IREASON_REG);
if (ireason.b.cod) {
- printk (KERN_ERR "ide-tape: CoD != 0 in idetape_pc_intr\n");
- return ide_do_reset (drive);
+ printk(KERN_ERR "ide-tape: CoD != 0 in idetape_pc_intr\n");
+ return ide_do_reset(drive);
}
- if (ireason.b.io == test_bit (PC_WRITING, &pc->flags)) { /* Hopefully, we will never get here */
- printk (KERN_ERR "ide-tape: We wanted to %s, ", ireason.b.io ? "Write":"Read");
- printk (KERN_ERR "ide-tape: but the tape wants us to %s !\n",ireason.b.io ? "Read":"Write");
- return ide_do_reset (drive);
+ if (ireason.b.io == test_bit(PC_WRITING, &pc->flags)) {
+ /* Hopefully, we will never get here */
+ printk(KERN_ERR "ide-tape: We wanted to %s, ",
+ ireason.b.io ? "Write":"Read");
+ printk(KERN_ERR "ide-tape: but the tape wants us to %s !\n",
+ ireason.b.io ? "Read":"Write");
+ return ide_do_reset(drive);
}
- if (!test_bit (PC_WRITING, &pc->flags)) { /* Reading - Check that we have enough space */
+ if (!test_bit(PC_WRITING, &pc->flags)) {
+ /* Reading - Check that we have enough space */
temp = pc->actually_transferred + bcount.all;
- if ( temp > pc->request_transfer) {
+ if (temp > pc->request_transfer) {
if (temp > pc->buffer_size) {
- printk (KERN_ERR "ide-tape: The tape wants to send us more data than expected - discarding data\n");
- idetape_discard_data (drive, bcount.all);
- ide_set_handler (drive, &idetape_pc_intr, IDETAPE_WAIT_CMD, NULL);
+ printk(KERN_ERR "ide-tape: The tape wants to "
+ "send us more data than expected "
+ "- discarding data\n");
+ idetape_discard_data(drive, bcount.all);
+ if (HWGROUP(drive)->handler != NULL)
+ BUG();
+ ide_set_handler(drive,
+ &idetape_pc_intr,
+ IDETAPE_WAIT_CMD,
+ NULL);
return ide_started;
}
#if IDETAPE_DEBUG_LOG
if (tape->debug_level >= 2)
- printk (KERN_NOTICE "ide-tape: The tape wants to send us more data than expected - allowing transfer\n");
+ printk(KERN_NOTICE "ide-tape: The tape wants "
+ "to send us more data than expected "
+ "- allowing transfer\n");
#endif /* IDETAPE_DEBUG_LOG */
}
}
- if (test_bit (PC_WRITING, &pc->flags)) {
+ if (test_bit(PC_WRITING, &pc->flags)) {
if (pc->bh != NULL)
- idetape_output_buffers (drive, pc, bcount.all);
+ idetape_output_buffers(drive, pc, bcount.all);
else
- atapi_output_bytes (drive,pc->current_position,bcount.all); /* Write the current buffer */
+ /* Write the current buffer */
+ HWIF(drive)->atapi_output_bytes(drive,pc->current_position,bcount.all);
} else {
if (pc->bh != NULL)
- idetape_input_buffers (drive, pc, bcount.all);
+ idetape_input_buffers(drive, pc, bcount.all);
else
- atapi_input_bytes (drive,pc->current_position,bcount.all); /* Read the current buffer */
+ /* Read the current buffer */
+ HWIF(drive)->atapi_input_bytes(drive,pc->current_position,bcount.all);
}
- pc->actually_transferred += bcount.all; /* Update the current position */
- pc->current_position+=bcount.all;
+ /* Update the current position */
+ pc->actually_transferred += bcount.all;
+ pc->current_position += bcount.all;
#if IDETAPE_DEBUG_LOG
if (tape->debug_level >= 2)
- printk(KERN_INFO "ide-tape: [cmd %x] transferred %d bytes on that interrupt\n", pc->c[0], bcount.all);
+ printk(KERN_INFO "ide-tape: [cmd %x] done %d\n"
+ pc->c[0], bcount.all);
#endif
- ide_set_handler (drive, &idetape_pc_intr, IDETAPE_WAIT_CMD, NULL); /* And set the interrupt handler again */
+ if (HWGROUP(drive)->handler != NULL)
+ BUG();
+ /* And set the interrupt handler again */
+ ide_set_handler (drive, &idetape_pc_intr, IDETAPE_WAIT_CMD, NULL);
return ide_started;
}
@@ -2217,9 +2306,9 @@
*
* 4. When the packet command is finished, it will be checked for errors.
*
- * 5. In case an error was found, we queue a request sense packet command
- * in front of the request queue and retry the operation up to
- * IDETAPE_MAX_PC_RETRIES times.
+ * 5. In case an error was found, we queue a request sense packet
+ * command in front of the request queue and retry the operation
+ * upto IDETAPE_MAX_PC_RETRIES times.
*
* 6. In case no error was found, or we decided to give up and not
* to retry again, the callback function will be called and then
@@ -2230,108 +2319,144 @@
{
idetape_tape_t *tape = drive->driver_data;
idetape_pc_t *pc = tape->pc;
- idetape_ireason_reg_t ireason;
+ atapi_ireason_t ireason;
int retries = 100;
ide_startstop_t startstop;
- if (ide_wait_stat (&startstop,drive,DRQ_STAT,BUSY_STAT,WAIT_READY)) {
- printk (KERN_ERR "ide-tape: Strange, packet command initiated yet DRQ isn't asserted\n");
+ if (ide_wait_stat(&startstop,drive,DRQ_STAT,BUSY_STAT,WAIT_READY)) {
+ printk(KERN_ERR "ide-tape: Strange, packet command "
+ "initiated yet DRQ isn't asserted\n");
return startstop;
}
- ireason.all = IN_BYTE (IDE_IREASON_REG);
+ ireason.all = HWIF(drive)->INB(IDE_IREASON_REG);
while (retries-- && (!ireason.b.cod || ireason.b.io)) {
- printk(KERN_ERR "ide-tape: (IO,CoD != (0,1) while issuing a packet command, retrying\n");
+ printk(KERN_ERR "ide-tape: (IO,CoD != (0,1) while issuing "
+ "a packet command, retrying\n");
udelay(100);
- ireason.all = IN_BYTE(IDE_IREASON_REG);
+ ireason.all = HWIF(drive)->INB(IDE_IREASON_REG);
if (retries == 0) {
- printk(KERN_ERR "ide-tape: (IO,CoD != (0,1) while issuing a packet command, ignoring\n");
+ printk(KERN_ERR "ide-tape: (IO,CoD != (0,1) while "
+ "issuing a packet command, ignoring\n");
ireason.b.cod = 1;
ireason.b.io = 0;
}
}
if (!ireason.b.cod || ireason.b.io) {
- printk (KERN_ERR "ide-tape: (IO,CoD) != (0,1) while issuing a packet command\n");
- return ide_do_reset (drive);
+ printk(KERN_ERR "ide-tape: (IO,CoD) != (0,1) while issuing "
+ "a packet command\n");
+ return ide_do_reset(drive);
}
tape->cmd_start_time = jiffies;
- ide_set_handler(drive, &idetape_pc_intr, IDETAPE_WAIT_CMD, NULL); /* Set the interrupt routine */
- atapi_output_bytes (drive,pc->c,12); /* Send the actual packet */
+ if (HWGROUP(drive)->handler != NULL) /* paranoia check */
+ BUG();
+ /* Set the interrupt routine */
+ ide_set_handler(drive, &idetape_pc_intr, IDETAPE_WAIT_CMD, NULL);
+#ifdef CONFIG_BLK_DEV_IDEDMA
+ /* Begin DMA, if necessary */
+ if (test_bit(PC_DMA_IN_PROGRESS, &pc->flags))
+ (void) (HWIF(drive)->ide_dma_begin(drive));
+#endif
+ /* Send the actual packet */
+ HWIF(drive)->atapi_output_bytes(drive, pc->c, 12);
return ide_started;
}
static ide_startstop_t idetape_issue_packet_command (ide_drive_t *drive, idetape_pc_t *pc)
{
idetape_tape_t *tape = drive->driver_data;
- idetape_bcount_reg_t bcount;
- int dma_ok = 0;
+ atapi_feature_t feature;
+ atapi_bcount_t bcount;
#if IDETAPE_DEBUG_BUGS
- if (tape->pc->c[0] == IDETAPE_REQUEST_SENSE_CMD && pc->c[0] == IDETAPE_REQUEST_SENSE_CMD) {
- printk (KERN_ERR "ide-tape: possible ide-tape.c bug - Two request sense in serial were issued\n");
+ if (tape->pc->c[0] == IDETAPE_REQUEST_SENSE_CMD &&
+ pc->c[0] == IDETAPE_REQUEST_SENSE_CMD) {
+ printk(KERN_ERR "ide-tape: possible ide-tape.c bug - "
+ "Two request sense in serial were issued\n");
}
#endif /* IDETAPE_DEBUG_BUGS */
if (tape->failed_pc == NULL && pc->c[0] != IDETAPE_REQUEST_SENSE_CMD)
tape->failed_pc = pc;
- tape->pc = pc; /* Set the current packet command */
+ /* Set the current packet command */
+ tape->pc = pc;
- if (pc->retries > IDETAPE_MAX_PC_RETRIES || test_bit (PC_ABORT, &pc->flags)) {
+ if (pc->retries > IDETAPE_MAX_PC_RETRIES ||
+ test_bit(PC_ABORT, &pc->flags)) {
/*
* We will "abort" retrying a packet command in case
* a legitimate error code was received (crossing a
- * filemark, or DMA error in the end of media, for
- * example).
+ * filemark, or end of the media, for example).
*/
if (!test_bit (PC_ABORT, &pc->flags)) {
- if (!(pc->c[0] == IDETAPE_TEST_UNIT_READY_CMD && tape->sense_key == 2 &&
- tape->asc == 4 && (tape->ascq == 1 || tape->ascq == 8))) {
- printk (KERN_ERR "ide-tape: %s: I/O error, pc = %2x, key = %2x, asc = %2x, ascq = %2x\n",
- tape->name, pc->c[0], tape->sense_key, tape->asc, tape->ascq);
- if (tape->onstream && pc->c[0] == IDETAPE_READ_CMD && tape->sense_key == 3 && tape->asc == 0x11) /* AJN-1: 11 should be 0x11 */
+ if (!(pc->c[0] == IDETAPE_TEST_UNIT_READY_CMD &&
+ tape->sense_key == 2 && tape->asc == 4 &&
+ (tape->ascq == 1 || tape->ascq == 8))) {
+ printk(KERN_ERR "ide-tape: %s: I/O error, "
+ "pc = %2x, key = %2x, "
+ "asc = %2x, ascq = %2x\n",
+ tape->name, pc->c[0],
+ tape->sense_key, tape->asc,
+ tape->ascq);
+ if (tape->onstream &&
+ pc->c[0] == IDETAPE_READ_CMD &&
+ tape->sense_key == 3 &&
+ tape->asc == 0x11)
+ /* AJN-1: 11 should be 0x11 */
printk(KERN_ERR "ide-tape: %s: enabling read error recovery\n", tape->name);
}
- pc->error = IDETAPE_ERROR_GENERAL; /* Giving up */
+ /* Giving up */
+ pc->error = IDETAPE_ERROR_GENERAL;
}
tape->failed_pc = NULL;
return pc->callback(drive);
}
#if IDETAPE_DEBUG_LOG
if (tape->debug_level >= 2)
- printk (KERN_INFO "ide-tape: Retry number - %d\n", pc->retries);
+ printk(KERN_INFO "ide-tape: Retry number - %d, cmd = %02X\n",
+ pc->retries, pc->c[0]);
#endif /* IDETAPE_DEBUG_LOG */
pc->retries++;
- pc->actually_transferred = 0; /* We haven't transferred any data yet */
- pc->current_position=pc->buffer;
- bcount.all=pc->request_transfer; /* Request to transfer the entire buffer at once */
+ /* We haven't transferred any data yet */
+ pc->actually_transferred = 0;
+ pc->current_position = pc->buffer;
+ /* Request to transfer the entire buffer at once */
+ bcount.all = pc->request_transfer;
#ifdef CONFIG_BLK_DEV_IDEDMA
- if (test_and_clear_bit (PC_DMA_ERROR, &pc->flags)) {
- printk (KERN_WARNING "ide-tape: DMA disabled, reverting to PIO\n");
- (void) HWIF(drive)->dmaproc(ide_dma_off, drive);
+ if (test_and_clear_bit(PC_DMA_ERROR, &pc->flags)) {
+ printk(KERN_WARNING "ide-tape: DMA disabled, "
+ "reverting to PIO\n");
+ (void) HWIF(drive)->ide_dma_off(drive);
+ }
+ if (test_bit(PC_DMA_RECOMMENDED, &pc->flags) && drive->using_dma) {
+ if (test_bit(PC_WRITING, &pc->flags)) {
+ feature.b.dma = !HWIF(drive)->ide_dma_write(drive);
+ } else {
+ feature.b.dma = !HWIF(drive)->ide_dma_read(drive);
+ }
}
- if (test_bit (PC_DMA_RECOMMENDED, &pc->flags) && drive->using_dma)
- dma_ok = !HWIF(drive)->dmaproc(test_bit (PC_WRITING, &pc->flags) ? ide_dma_write : ide_dma_read, drive);
#endif /* CONFIG_BLK_DEV_IDEDMA */
if (IDE_CONTROL_REG)
- OUT_BYTE (drive->ctl, IDE_CONTROL_REG);
- OUT_BYTE (dma_ok ? 1 : 0, IDE_FEATURE_REG); /* Use PIO/DMA */
- OUT_BYTE (bcount.b.high, IDE_BCOUNTH_REG);
- OUT_BYTE (bcount.b.low, IDE_BCOUNTL_REG);
- OUT_BYTE (drive->select.all, IDE_SELECT_REG);
+ HWIF(drive)->OUTB(drive->ctl, IDE_CONTROL_REG);
+ /* Use PIO/DMA */
+ HWIF(drive)->OUTB(feature.all, IDE_FEATURE_REG);
+ HWIF(drive)->OUTB(bcount.b.high, IDE_BCOUNTH_REG);
+ HWIF(drive)->OUTB(bcount.b.low, IDE_BCOUNTL_REG);
+ HWIF(drive)->OUTB(drive->select.all, IDE_SELECT_REG);
#ifdef CONFIG_BLK_DEV_IDEDMA
- if (dma_ok) { /* Begin DMA, if necessary */
- set_bit (PC_DMA_IN_PROGRESS, &pc->flags);
- (void) (HWIF(drive)->dmaproc(ide_dma_begin, drive));
- }
+ if (feature.b.dma) /* Will begin DMA later */
+ set_bit(PC_DMA_IN_PROGRESS, &pc->flags);
#endif /* CONFIG_BLK_DEV_IDEDMA */
if (test_bit(IDETAPE_DRQ_INTERRUPT, &tape->flags)) {
- ide_set_handler(drive, &idetape_transfer_pc, IDETAPE_WAIT_CMD, NULL);
- OUT_BYTE(WIN_PACKETCMD, IDE_COMMAND_REG);
+ ide_execute_command(drive, WIN_PACKETCMD,
+ &idetape_transfer_pc,
+ IDETAPE_WAIT_CMD,
+ NULL);
return ide_started;
} else {
- OUT_BYTE(WIN_PACKETCMD, IDE_COMMAND_REG);
+ HWIF(drive)->OUTB(WIN_PACKETCMD, IDE_COMMAND_REG);
return idetape_transfer_pc(drive);
}
}
@@ -2348,22 +2473,22 @@
printk (KERN_INFO "ide-tape: Reached idetape_pc_callback\n");
#endif /* IDETAPE_DEBUG_LOG */
- idetape_end_request (tape->pc->error ? 0 : 1, HWGROUP(drive));
+ idetape_end_request(drive, tape->pc->error ? 0 : 1);
return ide_stopped;
}
/*
* A mode sense command is used to "sense" tape parameters.
*/
-static void idetape_create_mode_sense_cmd (idetape_pc_t *pc, byte page_code)
+static void idetape_create_mode_sense_cmd (idetape_pc_t *pc, u8 page_code)
{
idetape_init_pc (pc);
pc->c[0] = IDETAPE_MODE_SENSE_CMD;
if (page_code != IDETAPE_BLOCK_DESCRIPTOR)
- pc->c[1] = 8; /* DBD = 1 - Don't return block descriptors */
+ pc->c[1] = 8; /* DBD = 1 - Don't return block descriptors */
pc->c[2] = page_code;
- pc->c[3] = 255; /* Don't limit the returned information */
- pc->c[4] = 255; /* (We will just discard data in that case) */
+ pc->c[3] = 255; /* Don't limit the returned information */
+ pc->c[4] = 255; /* (We will just discard data in that case) */
if (page_code == IDETAPE_BLOCK_DESCRIPTOR)
pc->request_transfer = 12;
else if (page_code == IDETAPE_CAPABILITIES_PAGE)
@@ -2391,13 +2516,15 @@
}
tape->tape_still_time = (jiffies - tape->tape_still_time_begin) * 1000 / HZ;
#if USE_IOTRACE
- IO_trace(IO_IDETAPE_FIFO, tape->pipeline_head, tape->buffer_head, tape->tape_head, tape->minor);
+ IO_trace(IO_IDETAPE_FIFO, tape->pipeline_head, tape->buffer_head,
+ tape->tape_head, tape->minor);
#endif
#if IDETAPE_DEBUG_LOG
if (tape->debug_level >= 1)
- printk(KERN_INFO "ide-tape: buffer fill callback, %d/%d\n", tape->cur_frames, tape->max_frames);
+ printk(KERN_INFO "ide-tape: buffer fill callback, %d/%d\n",
+ tape->cur_frames, tape->max_frames);
#endif
- idetape_end_request (tape->pc->error ? 0 : 1, HWGROUP(drive));
+ idetape_end_request(drive, tape->pc->error ? 0 : 1);
return ide_stopped;
}
@@ -2429,7 +2556,8 @@
else if (time_after(jiffies, tape->controlled_previous_head_time))
tape->controlled_pipeline_head_speed = (tape->pipeline_head - tape->controlled_previous_pipeline_head) * 32 * HZ / (jiffies - tape->controlled_previous_head_time);
- if (tape->nr_pending_stages < tape->max_stages /*- 1 */) { /* -1 for read mode error recovery */
+ if (tape->nr_pending_stages < tape->max_stages /*- 1 */) {
+ /* -1 for read mode error recovery */
if (time_after(jiffies, tape->uncontrolled_previous_head_time + 10 * HZ)) {
tape->uncontrolled_pipeline_head_time = jiffies;
tape->uncontrolled_pipeline_head_speed = (tape->pipeline_head - tape->uncontrolled_previous_pipeline_head) * 32 * HZ / (jiffies - tape->uncontrolled_previous_head_time);
@@ -2465,15 +2593,24 @@
{
idetape_tape_t *tape = drive->driver_data;
idetape_pc_t *pc = tape->pc;
- idetape_status_reg_t status;
+ atapi_status_t status;
if (tape->onstream)
- printk(KERN_INFO "ide-tape: bug: onstream, media_access_finished\n");
- status.all = GET_STAT();
+ printk(KERN_INFO "ide-tape: bug: "
+ "onstream, media_access_finished\n");
+
+ status.all = HWIF(drive)->INB(IDE_STATUS_REG);
+
if (status.b.dsc) {
- if (status.b.check) { /* Error detected */
- printk (KERN_ERR "ide-tape: %s: I/O error, ",tape->name);
- return idetape_retry_pc (drive); /* Retry operation */
+ if (status.b.check) {
+ /* Error detected */
+ printk(KERN_ERR "ide-tape: %s: I/O error: "
+ "pc = %2x, key = %2x, asc = %2x, ascq = %2x\n",
+ tape->name, pc->c[0],
+ tape->sense_key, tape->asc, tape->ascq);
+
+ /* Retry operation */
+ return idetape_retry_pc(drive);
}
pc->error = 0;
if (tape->failed_pc == pc)
@@ -2510,16 +2647,16 @@
#if IDETAPE_DEBUG_LOG
if (tape->debug_level >= 4)
- printk (KERN_INFO "ide-tape: Reached idetape_rw_callback\n");
+ printk(KERN_INFO "ide-tape: Reached idetape_rw_callback\n");
#endif /* IDETAPE_DEBUG_LOG */
tape->first_frame_position += blocks;
rq->current_nr_sectors -= blocks;
if (!tape->pc->error)
- idetape_end_request (1, HWGROUP (drive));
+ idetape_end_request(drive, 1);
else
- idetape_end_request (tape->pc->error, HWGROUP (drive));
+ idetape_end_request(drive, tape->pc->error);
return ide_stopped;
}
@@ -2528,7 +2665,7 @@
struct buffer_head *p = bh;
idetape_init_pc (pc);
pc->c[0] = IDETAPE_READ_CMD;
- put_unaligned (htonl (length), (unsigned int *) &pc->c[1]);
+ put_unaligned(htonl (length), (unsigned int *) &pc->c[1]);
pc->c[1] = 1;
pc->callback = &idetape_rw_callback;
pc->bh = bh;
@@ -2543,11 +2680,11 @@
if (!tape->onstream) {
pc->request_transfer = pc->buffer_size = length * tape->tape_block_size;
if (pc->request_transfer == tape->stage_size)
- set_bit (PC_DMA_RECOMMENDED, &pc->flags);
+ set_bit(PC_DMA_RECOMMENDED, &pc->flags);
} else {
if (length) {
pc->request_transfer = pc->buffer_size = 32768 + 512;
- set_bit (PC_DMA_RECOMMENDED, &pc->flags);
+ set_bit(PC_DMA_RECOMMENDED, &pc->flags);
} else
pc->request_transfer = 0;
}
@@ -2558,7 +2695,7 @@
int size = 32768;
struct buffer_head *p = bh;
- idetape_init_pc (pc);
+ idetape_init_pc(pc);
pc->c[0] = IDETAPE_READ_BUFFER_CMD;
pc->c[1] = IDETAPE_RETRIEVE_FAULTY_BLOCK;
pc->c[7] = size >> 8;
@@ -2577,9 +2714,9 @@
static void idetape_create_write_cmd (idetape_tape_t *tape, idetape_pc_t *pc, unsigned int length, struct buffer_head *bh)
{
struct buffer_head *p = bh;
- idetape_init_pc (pc);
+ idetape_init_pc(pc);
pc->c[0] = IDETAPE_WRITE_CMD;
- put_unaligned (htonl (length), (unsigned int *) &pc->c[1]);
+ put_unaligned(htonl (length), (unsigned int *) &pc->c[1]);
pc->c[1] = 1;
pc->callback = &idetape_rw_callback;
set_bit (PC_WRITING, &pc->flags);
@@ -2596,17 +2733,49 @@
if (!tape->onstream) {
pc->request_transfer = pc->buffer_size = length * tape->tape_block_size;
if (pc->request_transfer == tape->stage_size)
- set_bit (PC_DMA_RECOMMENDED, &pc->flags);
+ set_bit(PC_DMA_RECOMMENDED, &pc->flags);
} else {
if (length) {
pc->request_transfer = pc->buffer_size = 32768 + 512;
- set_bit (PC_DMA_RECOMMENDED, &pc->flags);
+ set_bit(PC_DMA_RECOMMENDED, &pc->flags);
} else
pc->request_transfer = 0;
}
}
/*
+ * This is our end_request replacement function.
+ */
+static int idetape_do_end_request (ide_drive_t *drive, int uptodate)
+{
+ struct request *rq;
+ unsigned long flags;
+ int ret = 1;
+
+ spin_lock_irqsave(&io_request_lock, flags);
+ rq = HWGROUP(drive)->rq;
+
+ /*
+ * decide whether to reenable DMA -- 3 is a random magic for now,
+ * if we DMA timeout more than 3 times, just stay in PIO
+ */
+ if (drive->state == DMA_PIO_RETRY && drive->retry_pio <= 3) {
+ drive->state = 0;
+ HWGROUP(drive)->hwif->ide_dma_on(drive);
+ }
+
+ if (!end_that_request_first(rq, uptodate, drive->name)) {
+ add_blkdev_randomness(MAJOR(rq->rq_dev));
+ blkdev_dequeue_request(rq);
+ HWGROUP(drive)->rq = NULL;
+ end_that_request_last(rq);
+ ret = 0;
+ }
+ spin_unlock_irqrestore(&io_request_lock, flags);
+ return ret;
+}
+
+/*
* idetape_do_request is our request handling function.
*/
static ide_startstop_t idetape_do_request (ide_drive_t *drive, struct request *rq, unsigned long block)
@@ -2614,35 +2783,42 @@
idetape_tape_t *tape = drive->driver_data;
idetape_pc_t *pc;
struct request *postponed_rq = tape->postponed_rq;
- idetape_status_reg_t status;
+ atapi_status_t status;
#if IDETAPE_DEBUG_LOG
if (tape->debug_level >= 5)
- printk (KERN_INFO "ide-tape: rq_status: %d, rq_dev: %u, cmd: %d, errors: %d\n",rq->rq_status,(unsigned int) rq->rq_dev,rq->cmd,rq->errors);
+ printk(KERN_INFO "ide-tape: rq_status: %d, "
+ "rq_dev: %u, cmd: %d, errors: %d\n", rq->rq_status,
+ (unsigned int) rq->rq_dev, rq->cmd, rq->errors);
if (tape->debug_level >= 2)
- printk (KERN_INFO "ide-tape: sector: %ld, nr_sectors: %ld, current_nr_sectors: %ld\n",rq->sector,rq->nr_sectors,rq->current_nr_sectors);
+ printk(KERN_INFO "ide-tape: sector: %ld, "
+ "nr_sectors: %ld, current_nr_sectors: %ld\n",
+ rq->sector, rq->nr_sectors, rq->current_nr_sectors);
#endif /* IDETAPE_DEBUG_LOG */
- if (!IDETAPE_RQ_CMD (rq->cmd)) {
+ if (!IDETAPE_RQ_CMD(rq->cmd)) {
/*
* We do not support buffer cache originated requests.
*/
- printk (KERN_NOTICE "ide-tape: %s: Unsupported command in request queue (%d)\n", drive->name, rq->cmd);
- ide_end_request (0, HWGROUP (drive)); /* Let the common code handle it */
+ printk(KERN_NOTICE "ide-tape: %s: Unsupported command in "
+ "request queue (%d)\n", drive->name, rq->cmd);
+ idetape_do_end_request(drive, 0);
return ide_stopped;
}
/*
* Retry a failed packet command
*/
- if (tape->failed_pc != NULL && tape->pc->c[0] == IDETAPE_REQUEST_SENSE_CMD) {
- return idetape_issue_packet_command (drive, tape->failed_pc);
+ if (tape->failed_pc != NULL &&
+ tape->pc->c[0] == IDETAPE_REQUEST_SENSE_CMD) {
+ return idetape_issue_packet_command(drive, tape->failed_pc);
}
#if IDETAPE_DEBUG_BUGS
if (postponed_rq != NULL)
if (rq != postponed_rq) {
- printk (KERN_ERR "ide-tape: ide-tape.c bug - Two DSC requests were queued\n");
- idetape_end_request (0, HWGROUP (drive));
+ printk(KERN_ERR "ide-tape: ide-tape.c bug - "
+ "Two DSC requests were queued\n");
+ idetape_end_request(drive, 0);
return ide_stopped;
}
#endif /* IDETAPE_DEBUG_BUGS */
@@ -2653,7 +2829,7 @@
* If the tape is still busy, postpone our request and service
* the other device meanwhile.
*/
- status.all = GET_STAT();
+ status.all = HWIF(drive)->INB(IDE_STATUS_REG);
/*
* The OnStream tape drive doesn't support DSC. Assume
@@ -2662,7 +2838,7 @@
if (tape->onstream)
status.b.dsc = 1;
if (!drive->dsc_overlap && rq->cmd != IDETAPE_PC_RQ2)
- set_bit (IDETAPE_IGNORE_DSC, &tape->flags);
+ set_bit(IDETAPE_IGNORE_DSC, &tape->flags);
/*
* For the OnStream tape, check the current status of the tape
@@ -2674,7 +2850,8 @@
*/
if (tape->tape_still_time > 100 && tape->tape_still_time < 200)
tape->measure_insert_time = 1;
- if (tape->req_buffer_fill && (rq->cmd == IDETAPE_WRITE_RQ || rq->cmd == IDETAPE_READ_RQ)) {
+ if (tape->req_buffer_fill &&
+ (rq->cmd == IDETAPE_WRITE_RQ || rq->cmd == IDETAPE_READ_RQ)) {
tape->req_buffer_fill = 0;
tape->writes_since_buffer_fill = 0;
tape->reads_since_buffer_fill = 0;
@@ -2699,7 +2876,8 @@
tape->insert_speed > tape->max_insert_speed ) ) && rq->nr_sectors) ) ) {
#if IDETAPE_DEBUG_LOG
if (tape->debug_level >= 4)
- printk(KERN_INFO "ide-tape: postponing request, cmd %d, cur %d, max %d\n",
+ printk(KERN_INFO "ide-tape: postponing request, "
+ "cmd %d, cur %d, max %d\n",
rq->cmd, tape->cur_frames, tape->max_frames);
#endif
if (tape->postpone_cnt++ < 500) {
@@ -2708,25 +2886,28 @@
}
#if ONSTREAM_DEBUG
else if (tape->debug_level >= 4)
- printk(KERN_INFO "ide-tape: %s: postpone_cnt %d\n", tape->name, tape->postpone_cnt);
+ printk(KERN_INFO "ide-tape: %s: postpone_cnt %d\n",
+ tape->name, tape->postpone_cnt);
#endif
}
- if (!test_and_clear_bit (IDETAPE_IGNORE_DSC, &tape->flags) && !status.b.dsc) {
+ if (!test_and_clear_bit(IDETAPE_IGNORE_DSC, &tape->flags) &&
+ !status.b.dsc) {
if (postponed_rq == NULL) {
tape->dsc_polling_start = jiffies;
tape->dsc_polling_frequency = tape->best_dsc_rw_frequency;
tape->dsc_timeout = jiffies + IDETAPE_DSC_RW_TIMEOUT;
} else if ((signed long) (jiffies - tape->dsc_timeout) > 0) {
- printk (KERN_ERR "ide-tape: %s: DSC timeout\n", tape->name);
+ printk(KERN_ERR "ide-tape: %s: DSC timeout\n",
+ tape->name);
if (rq->cmd == IDETAPE_PC_RQ2) {
- idetape_media_access_finished (drive);
+ idetape_media_access_finished(drive);
return ide_stopped;
} else {
- return ide_do_reset (drive);
+ return ide_do_reset(drive);
}
} else if (jiffies - tape->dsc_polling_start > IDETAPE_DSC_MA_THRESHOLD)
tape->dsc_polling_frequency = IDETAPE_DSC_MA_SLOW;
- idetape_postpone_request (drive);
+ idetape_postpone_request(drive);
return ide_stopped;
}
switch (rq->cmd) {
@@ -2743,8 +2924,8 @@
if (time_after(jiffies, tape->last_buffer_fill + 5 * HZ / 100))
tape->req_buffer_fill = 1;
}
- pc = idetape_next_pc_storage (drive);
- idetape_create_read_cmd (tape, pc, rq->current_nr_sectors, rq->bh);
+ pc = idetape_next_pc_storage(drive);
+ idetape_create_read_cmd(tape, pc, rq->current_nr_sectors, rq->bh);
break;
case IDETAPE_WRITE_RQ:
tape->buffer_head++;
@@ -2760,39 +2941,41 @@
tape->req_buffer_fill = 1;
calculate_speeds(drive);
}
- pc = idetape_next_pc_storage (drive);
- idetape_create_write_cmd (tape, pc, rq->current_nr_sectors, rq->bh);
+ pc = idetape_next_pc_storage(drive);
+ idetape_create_write_cmd(tape, pc, rq->current_nr_sectors, rq->bh);
break;
case IDETAPE_READ_BUFFER_RQ:
tape->postpone_cnt = 0;
- pc = idetape_next_pc_storage (drive);
- idetape_create_read_buffer_cmd (tape, pc, rq->current_nr_sectors, rq->bh);
+ pc = idetape_next_pc_storage(drive);
+ idetape_create_read_buffer_cmd(tape, pc, rq->current_nr_sectors, rq->bh);
break;
case IDETAPE_ABORTED_WRITE_RQ:
rq->cmd = IDETAPE_WRITE_RQ;
- idetape_end_request (IDETAPE_ERROR_EOD, HWGROUP(drive));
+ idetape_end_request(drive, IDETAPE_ERROR_EOD);
return ide_stopped;
case IDETAPE_ABORTED_READ_RQ:
#if IDETAPE_DEBUG_LOG
if (tape->debug_level >= 2)
- printk(KERN_INFO "ide-tape: %s: detected aborted read rq\n", tape->name);
+ printk(KERN_INFO "ide-tape: %s: detected "
+ "aborted read rq\n", tape->name);
#endif
rq->cmd = IDETAPE_READ_RQ;
- idetape_end_request (IDETAPE_ERROR_EOD, HWGROUP(drive));
+ idetape_end_request(drive, IDETAPE_ERROR_EOD);
return ide_stopped;
case IDETAPE_PC_RQ1:
pc = (idetape_pc_t *) rq->buffer;
rq->cmd = IDETAPE_PC_RQ2;
break;
case IDETAPE_PC_RQ2:
- idetape_media_access_finished (drive);
+ idetape_media_access_finished(drive);
return ide_stopped;
default:
- printk (KERN_ERR "ide-tape: bug in IDETAPE_RQ_CMD macro\n");
- idetape_end_request (0, HWGROUP (drive));
+ printk(KERN_ERR "ide-tape: bug in "
+ "IDETAPE_RQ_CMD macro\n");
+ idetape_end_request(drive, 0);
return ide_stopped;
}
- return idetape_issue_packet_command (drive, pc);
+ return idetape_issue_packet_command(drive, pc);
}
/*
@@ -2826,11 +3009,11 @@
int pages = tape->pages_per_stage;
char *b_data;
- if ((stage = (idetape_stage_t *) kmalloc (sizeof (idetape_stage_t),GFP_KERNEL)) == NULL)
+ if ((stage = (idetape_stage_t *) kmalloc(sizeof(idetape_stage_t),GFP_KERNEL)) == NULL)
return NULL;
stage->next = NULL;
- bh = stage->bh = (struct buffer_head *) kmalloc (sizeof (struct buffer_head), GFP_KERNEL);
+ bh = stage->bh = (struct buffer_head *) kmalloc(sizeof(struct buffer_head), GFP_KERNEL);
if (bh == NULL)
goto abort;
bh->b_reqnext = NULL;
@@ -2840,7 +3023,7 @@
memset(bh->b_data, 0, PAGE_SIZE);
bh->b_size = PAGE_SIZE;
atomic_set(&bh->b_count, full ? bh->b_size : 0);
- set_bit (BH_Lock, &bh->b_state);
+ set_bit(BH_Lock, &bh->b_state);
while (--pages) {
if ((b_data = (char *) __get_free_page (GFP_KERNEL)) == NULL)
@@ -2861,15 +3044,15 @@
continue;
}
prev_bh = bh;
- if ((bh = (struct buffer_head *) kmalloc (sizeof (struct buffer_head), GFP_KERNEL)) == NULL) {
- free_page ((unsigned long) b_data);
+ if ((bh = (struct buffer_head *) kmalloc(sizeof(struct buffer_head), GFP_KERNEL)) == NULL) {
+ free_page((unsigned long) b_data);
goto abort;
}
bh->b_reqnext = NULL;
bh->b_data = b_data;
bh->b_size = PAGE_SIZE;
atomic_set(&bh->b_count, full ? bh->b_size : 0);
- set_bit (BH_Lock, &bh->b_state);
+ set_bit(BH_Lock, &bh->b_state);
prev_bh->b_reqnext = bh;
}
bh->b_size -= tape->excess_bh_size;
@@ -2879,7 +3062,7 @@
stage->aux = (os_aux_t *) (bh->b_data + bh->b_size - OS_AUX_SIZE);
return stage;
abort:
- __idetape_kfree_stage (stage);
+ __idetape_kfree_stage(stage);
return NULL;
}
@@ -2889,7 +3072,7 @@
#if IDETAPE_DEBUG_LOG
if (tape->debug_level >= 4)
- printk (KERN_INFO "ide-tape: Reached idetape_kmalloc_stage\n");
+ printk (KERN_INFO "ide-tape: Reached %s\n", __FUNCTION__);
#endif /* IDETAPE_DEBUG_LOG */
if (tape->nr_stages >= tape->max_stages)
@@ -2898,7 +3081,7 @@
tape->cache_stage = NULL;
return cache_stage;
}
- return __idetape_kmalloc_stage (tape, 0, 0);
+ return __idetape_kmalloc_stage(tape, 0, 0);
}
static void idetape_copy_stage_from_user (idetape_tape_t *tape, idetape_stage_t *stage, const char *buf, int n)
@@ -2909,12 +3092,13 @@
while (n) {
#if IDETAPE_DEBUG_BUGS
if (bh == NULL) {
- printk (KERN_ERR "ide-tape: bh == NULL in idetape_copy_stage_from_user\n");
+ printk(KERN_ERR "ide-tape: bh == NULL in %s\n",
+ __FUNCTION__);
return;
}
#endif /* IDETAPE_DEBUG_BUGS */
- count = IDE_MIN (bh->b_size - atomic_read(&bh->b_count), n);
- copy_from_user (bh->b_data + atomic_read(&bh->b_count), buf, count);
+ count = IDE_MIN(bh->b_size - atomic_read(&bh->b_count), n);
+ copy_from_user(bh->b_data + atomic_read(&bh->b_count), buf, count);
n -= count;
atomic_add(count, &bh->b_count);
buf += count;
@@ -2935,12 +3119,13 @@
while (n) {
#if IDETAPE_DEBUG_BUGS
if (bh == NULL) {
- printk (KERN_ERR "ide-tape: bh == NULL in idetape_copy_stage_to_user\n");
+ printk(KERN_ERR "ide-tape: bh == NULL in %s\n",
+ __FUNCTION__);
return;
}
#endif /* IDETAPE_DEBUG_BUGS */
- count = IDE_MIN (tape->b_count, n);
- copy_to_user (buf, tape->b_data, count);
+ count = IDE_MIN(tape->b_count, n);
+ copy_to_user(buf, tape->b_data, count);
n -= count;
tape->b_data += count;
tape->b_count -= count;
@@ -2960,9 +3145,9 @@
struct buffer_head *bh = tape->merge_stage->bh;
tape->bh = bh;
- if (tape->chrdev_direction == idetape_direction_write)
+ if (tape->chrdev_direction == idetape_direction_write) {
atomic_set(&bh->b_count, 0);
- else {
+ } else {
tape->b_data = bh->b_data;
tape->b_count = atomic_read(&bh->b_count);
}
@@ -2973,9 +3158,12 @@
struct buffer_head *tmp;
os_aux_t *tmp_aux;
- tmp = stage->bh; tmp_aux = stage->aux;
- stage->bh = tape->merge_stage->bh; stage->aux = tape->merge_stage->aux;
- tape->merge_stage->bh = tmp; tape->merge_stage->aux = tmp_aux;
+ tmp = stage->bh;
+ tmp_aux = stage->aux;
+ stage->bh = tape->merge_stage->bh;
+ stage->aux = tape->merge_stage->aux;
+ tape->merge_stage->bh = tmp;
+ tape->merge_stage->aux = tmp_aux;
idetape_init_merge_stage (tape);
}
@@ -2989,10 +3177,10 @@
#if IDETAPE_DEBUG_LOG
if (tape->debug_level >= 4)
- printk (KERN_INFO "ide-tape: Reached idetape_add_stage_tail\n");
+ printk(KERN_INFO "ide-tape: Reached %s\n", __FUNCTION__);
#endif /* IDETAPE_DEBUG_LOG */
spin_lock_irqsave(&tape->spinlock, flags);
- stage->next=NULL;
+ stage->next = NULL;
if (tape->last_stage != NULL)
tape->last_stage->next=stage;
else
@@ -3058,10 +3246,13 @@
else
dat->dat_list[0].flags = OS_DAT_FLAGS_DATA;
dat->dat_list[0].reserved = 0;
- }
- aux->filemark_cnt = ntohl(tape->filemark_cnt); /* shouldn't this be htonl ?? */
- aux->phys_fm = ntohl(0xffffffff); /* shouldn't this be htonl ?? */
- aux->last_mark_addr = ntohl(tape->last_mark_addr); /* shouldn't this be htonl ?? */
+ }
+ /* shouldn't this be htonl ?? */
+ aux->filemark_cnt = ntohl(tape->filemark_cnt);
+ /* shouldn't this be htonl ?? */
+ aux->phys_fm = ntohl(0xffffffff);
+ /* shouldn't this be htonl ?? */
+ aux->last_mark_addr = ntohl(tape->last_mark_addr);
}
/*
@@ -3078,7 +3269,8 @@
#if IDETAPE_DEBUG_BUGS
if (rq == NULL || !IDETAPE_RQ_CMD (rq->cmd)) {
- printk (KERN_ERR "ide-tape: bug: Trying to sleep on non-valid request\n");
+ printk(KERN_ERR "ide-tape: bug: Trying to sleep on "
+ "non-valid request\n");
return;
}
#endif /* IDETAPE_DEBUG_BUGS */
@@ -3086,7 +3278,7 @@
tape->waiting = &wait;
spin_unlock(&tape->spinlock);
wait_for_completion(&wait);
- rq->waiting = NULL;
+ /* The stage and its struct request have been deallocated */
tape->waiting = NULL;
spin_lock_irq(&tape->spinlock);
}
@@ -3098,35 +3290,39 @@
#if IDETAPE_DEBUG_LOG
if (tape->debug_level >= 4)
- printk (KERN_INFO "ide-tape: Reached idetape_read_position_callback\n");
+ printk(KERN_INFO "ide-tape: Reached %s\n", __FUNCTION__);
#endif /* IDETAPE_DEBUG_LOG */
if (!tape->pc->error) {
result = (idetape_read_position_result_t *) tape->pc->buffer;
#if IDETAPE_DEBUG_LOG
if (tape->debug_level >= 2)
- printk (KERN_INFO "ide-tape: BOP - %s\n",result->bop ? "Yes":"No");
+ printk(KERN_INFO "ide-tape: BOP - %s\n",
+ result->bop ? "Yes":"No");
if (tape->debug_level >= 2)
- printk (KERN_INFO "ide-tape: EOP - %s\n",result->eop ? "Yes":"No");
+ printk(KERN_INFO "ide-tape: EOP - %s\n",
+ result->eop ? "Yes":"No");
#endif /* IDETAPE_DEBUG_LOG */
if (result->bpu) {
- printk (KERN_INFO "ide-tape: Block location is unknown to the tape\n");
- clear_bit (IDETAPE_ADDRESS_VALID, &tape->flags);
- idetape_end_request (0, HWGROUP (drive));
+ printk(KERN_INFO "ide-tape: Block location is "
+ "unknown to the tape\n");
+ clear_bit(IDETAPE_ADDRESS_VALID, &tape->flags);
+ idetape_end_request(drive, 0);
} else {
#if IDETAPE_DEBUG_LOG
if (tape->debug_level >= 2)
- printk (KERN_INFO "ide-tape: Block Location - %u\n", ntohl (result->first_block));
+ printk(KERN_INFO "ide-tape: Block Location "
+ "- %u\n", ntohl(result->first_block));
#endif /* IDETAPE_DEBUG_LOG */
tape->partition = result->partition;
- tape->first_frame_position = ntohl (result->first_block);
- tape->last_frame_position = ntohl (result->last_block);
+ tape->first_frame_position = ntohl(result->first_block);
+ tape->last_frame_position = ntohl(result->last_block);
tape->blocks_in_buffer = result->blocks_in_buffer[2];
- set_bit (IDETAPE_ADDRESS_VALID, &tape->flags);
- idetape_end_request (1, HWGROUP (drive));
+ set_bit(IDETAPE_ADDRESS_VALID, &tape->flags);
+ idetape_end_request(drive, 1);
}
} else {
- idetape_end_request (0, HWGROUP (drive));
+ idetape_end_request(drive, 0);
}
return ide_stopped;
}
@@ -3143,12 +3339,12 @@
{
idetape_tape_t *tape = drive->driver_data;
- idetape_init_pc (pc);
+ idetape_init_pc(pc);
pc->c[0] = IDETAPE_WRITE_FILEMARK_CMD;
if (tape->onstream)
pc->c[1] = 1; /* Immed bit */
pc->c[4] = write_filemark; /* not used for OnStream ?? */
- set_bit (PC_WAIT_FOR_DSC, &pc->flags);
+ set_bit(PC_WAIT_FOR_DSC, &pc->flags);
pc->callback = &idetape_pc_callback;
}
@@ -3165,8 +3361,8 @@
* ide_do_drive_cmd from ide.c
* cdrom_queue_request and cdrom_queue_packet_command from ide-cd.c
*
- * We add a special packet command request to the tail of the request queue,
- * and wait for it to be serviced.
+ * We add a special packet command request to the tail of the request
+ * queue, and wait for it to be serviced.
*
* This is not to be called from within the request handling part
* of the driver ! We allocate here data in the stack, and it is valid
@@ -3183,17 +3379,17 @@
{
struct request rq;
- ide_init_drive_cmd (&rq);
+ ide_init_drive_cmd(&rq);
rq.buffer = (char *) pc;
rq.cmd = IDETAPE_PC_RQ1;
- return ide_do_drive_cmd (drive, &rq, ide_wait);
+ return ide_do_drive_cmd(drive, &rq, ide_wait);
}
static void idetape_create_load_unload_cmd (ide_drive_t *drive, idetape_pc_t *pc,int cmd)
{
idetape_tape_t *tape = drive->driver_data;
- idetape_init_pc (pc);
+ idetape_init_pc(pc);
pc->c[0] = IDETAPE_LOAD_UNLOAD_CMD;
pc->c[4] = cmd;
if (tape->onstream) {
@@ -3201,7 +3397,7 @@
if (cmd == !IDETAPE_LU_LOAD_MASK)
pc->c[4] = 4;
}
- set_bit (PC_WAIT_FOR_DSC, &pc->flags);
+ set_bit(PC_WAIT_FOR_DSC, &pc->flags);
pc->callback = &idetape_pc_callback;
}
@@ -3219,13 +3415,14 @@
if (!__idetape_queue_pc_tail(drive, &pc))
return 0;
if (tape->sense_key == 2 && tape->asc == 4 && tape->ascq == 2) {
- idetape_create_load_unload_cmd (drive, &pc, IDETAPE_LU_LOAD_MASK);
+ idetape_create_load_unload_cmd(drive, &pc, IDETAPE_LU_LOAD_MASK);
__idetape_queue_pc_tail(drive, &pc);
idetape_create_test_unit_ready_cmd(&pc);
if (!__idetape_queue_pc_tail(drive, &pc))
return 0;
}
- if (!(tape->sense_key == 2 && tape->asc == 4 && (tape->ascq == 1 || tape->ascq == 8)))
+ if (!(tape->sense_key == 2 && tape->asc == 4 &&
+ (tape->ascq == 1 || tape->ascq == 8)))
break;
current->state = TASK_INTERRUPTIBLE;
schedule_timeout(HZ / 10);
@@ -3241,9 +3438,13 @@
rc = __idetape_queue_pc_tail(drive, pc);
if (rc)
return rc;
- if (tape->onstream && test_bit(PC_WAIT_FOR_DSC, &pc->flags))
- rc = idetape_wait_ready(drive, 60 * 10 * HZ); /* AJN-4: Changed from 5 to 10 minutes;
- because retension takes approx. 8:20 with Onstream 30GB tape */
+ if (tape->onstream && test_bit(PC_WAIT_FOR_DSC, &pc->flags)) {
+ /* AJN-4: Changed from 5 to 10 minutes;
+ * because retension takes approx.
+ * 8:20 with Onstream 30GB tape
+ */
+ rc = idetape_wait_ready(drive, 60 * 10 * HZ);
+ }
return rc;
}
@@ -3261,7 +3462,7 @@
static void idetape_create_read_position_cmd (idetape_pc_t *pc)
{
- idetape_init_pc (pc);
+ idetape_init_pc(pc);
pc->c[0] = IDETAPE_READ_POSITION_CMD;
pc->request_transfer = 20;
pc->callback = &idetape_read_position_callback;
@@ -3275,42 +3476,27 @@
#if IDETAPE_DEBUG_LOG
if (tape->debug_level >= 4)
- printk (KERN_INFO "ide-tape: Reached idetape_read_position\n");
+ printk (KERN_INFO "ide-tape: Reached %s\n", __FUNCTION__);
#endif /* IDETAPE_DEBUG_LOG */
-#ifdef NO_LONGER_REQUIRED
- idetape_flush_tape_buffers(drive);
-#endif
idetape_create_read_position_cmd(&pc);
- if (idetape_queue_pc_tail (drive, &pc))
+ if (idetape_queue_pc_tail(drive, &pc))
return -1;
position = tape->first_frame_position;
-#ifdef NO_LONGER_REQUIRED
- if (tape->onstream) {
- if ((position != tape->last_frame_position - tape->blocks_in_buffer) &&
- (position != tape->last_frame_position + tape->blocks_in_buffer)) {
- if (tape->blocks_in_buffer == 0) {
- printk("ide-tape: %s: correcting read position %d, %d, %d\n", tape->name, position, tape->last_frame_position, tape->blocks_in_buffer);
- position = tape->last_frame_position;
- tape->first_frame_position = position;
- }
- }
- }
-#endif
return position;
}
-static void idetape_create_locate_cmd (ide_drive_t *drive, idetape_pc_t *pc, unsigned int block, byte partition, int skip)
+static void idetape_create_locate_cmd (ide_drive_t *drive, idetape_pc_t *pc, unsigned int block, u8 partition, int skip)
{
idetape_tape_t *tape = drive->driver_data;
- idetape_init_pc (pc);
+ idetape_init_pc(pc);
pc->c[0] = IDETAPE_LOCATE_CMD;
if (tape->onstream)
pc->c[1] = 1; /* Immediate bit */
else
pc->c[1] = 2;
- put_unaligned (htonl (block), (unsigned int *) &pc->c[3]);
+ put_unaligned(htonl(block), (unsigned int *) &pc->c[3]);
pc->c[8] = partition;
if (tape->onstream)
/*
@@ -3319,7 +3505,7 @@
* data in the drive to this new position!
*/
pc->c[9] = skip << 7;
- set_bit (PC_WAIT_FOR_DSC, &pc->flags);
+ set_bit(PC_WAIT_FOR_DSC, &pc->flags);
pc->callback = &idetape_pc_callback;
}
@@ -3345,11 +3531,15 @@
if (tape->chrdev_direction != idetape_direction_read)
return 0;
+ cnt = tape->merge_stage_size / tape->tape_block_size;
+ if (test_and_clear_bit(IDETAPE_FILEMARK, &tape->flags))
+ ++cnt; /* Filemarks count as 1 sector */
tape->merge_stage_size = 0;
if (tape->merge_stage != NULL) {
- __idetape_kfree_stage (tape->merge_stage);
+ __idetape_kfree_stage(tape->merge_stage);
tape->merge_stage = NULL;
}
+ clear_bit(IDETAPE_PIPELINE_ERROR, &tape->flags);
tape->chrdev_direction = idetape_direction_none;
if (tape->first_stage == NULL)
@@ -3357,13 +3547,18 @@
spin_lock_irqsave(&tape->spinlock, flags);
tape->next_stage = NULL;
- if (idetape_pipeline_active (tape))
+ if (idetape_pipeline_active(tape))
idetape_wait_for_request(drive, tape->active_data_request);
spin_unlock_irqrestore(&tape->spinlock, flags);
- cnt = tape->nr_stages - tape->nr_pending_stages;
- while (tape->first_stage != NULL)
- idetape_remove_stage_head (drive);
+ while (tape->first_stage != NULL) {
+ struct request *rq_ptr = &tape->first_stage->rq;
+
+ cnt += rq_ptr->nr_sectors - rq_ptr->current_nr_sectors;
+ if (rq_ptr->errors == IDETAPE_ERROR_FILEMARK)
+ ++cnt;
+ idetape_remove_stage_head(drive);
+ }
tape->nr_pending_stages = 0;
tape->max_stages = tape->min_pipeline;
return cnt;
@@ -3378,7 +3573,7 @@
* of the request queue and wait for their completion.
*
*/
-static int idetape_position_tape (ide_drive_t *drive, unsigned int block, byte partition, int skip)
+static int idetape_position_tape (ide_drive_t *drive, unsigned int block, u8 partition, int skip)
{
idetape_tape_t *tape = drive->driver_data;
int retval;
@@ -3387,13 +3582,13 @@
if (tape->chrdev_direction == idetape_direction_read)
__idetape_discard_read_pipeline(drive);
idetape_wait_ready(drive, 60 * 5 * HZ);
- idetape_create_locate_cmd (drive, &pc, block, partition, skip);
- retval = idetape_queue_pc_tail (drive, &pc);
+ idetape_create_locate_cmd(drive, &pc, block, partition, skip);
+ retval = idetape_queue_pc_tail(drive, &pc);
if (retval)
return (retval);
- idetape_create_read_position_cmd (&pc);
- return (idetape_queue_pc_tail (drive, &pc));
+ idetape_create_read_position_cmd(&pc);
+ return (idetape_queue_pc_tail(drive, &pc));
}
static void idetape_discard_read_pipeline (ide_drive_t *drive, int restore_position)
@@ -3407,11 +3602,13 @@
position = idetape_read_position(drive);
#if ONSTREAM_DEBUG
if (tape->debug_level >= 2)
- printk(KERN_INFO "ide-tape: address %u, nr_stages %d\n", position, cnt);
+ printk(KERN_INFO "ide-tape: address %u, nr_stages %d\n",
+ position, cnt);
#endif
seek = position > cnt ? position - cnt : 0;
if (idetape_position_tape(drive, seek, 0, 0)) {
- printk(KERN_INFO "ide-tape: %s: position_tape failed in discard_pipeline()\n", tape->name);
+ printk(KERN_INFO "ide-tape: %s: position_tape "
+ "failed in discard_pipeline()\n", tape->name);
return;
}
}
@@ -3421,7 +3618,7 @@
{
idetape_pc_t pc;
- idetape_create_mode_sense_cmd (&pc, IDETAPE_BUFFER_FILLING_PAGE);
+ idetape_create_mode_sense_cmd(&pc, IDETAPE_BUFFER_FILLING_PAGE);
pc.callback = idetape_onstream_buffer_fill_callback;
(void) idetape_queue_pc_tail(drive, &pc);
}
@@ -3437,29 +3634,30 @@
#if IDETAPE_DEBUG_LOG
if (tape->debug_level >= 2)
- printk (KERN_INFO "ide-tape: idetape_queue_rw_tail: cmd=%d\n",cmd);
+ printk(KERN_INFO "ide-tape: %s: cmd=%d\n", __FUNCTION__, cmd);
#endif /* IDETAPE_DEBUG_LOG */
#if IDETAPE_DEBUG_BUGS
if (idetape_pipeline_active (tape)) {
- printk (KERN_ERR "ide-tape: bug: the pipeline is active in idetape_queue_rw_tail\n");
+ printk(KERN_ERR "ide-tape: bug: the pipeline is active in %s\n",
+ __FUNCTION__);
return (0);
}
#endif /* IDETAPE_DEBUG_BUGS */
- ide_init_drive_cmd (&rq);
+ ide_init_drive_cmd(&rq);
rq.bh = bh;
rq.cmd = cmd;
rq.sector = tape->first_frame_position;
rq.nr_sectors = rq.current_nr_sectors = blocks;
if (tape->onstream)
tape->postpone_cnt = 600;
- (void) ide_do_drive_cmd (drive, &rq, ide_wait);
+ (void) ide_do_drive_cmd(drive, &rq, ide_wait);
if (cmd != IDETAPE_READ_RQ && cmd != IDETAPE_WRITE_RQ)
return 0;
if (tape->merge_stage)
- idetape_init_merge_stage (tape);
+ idetape_init_merge_stage(tape);
if (rq.errors == IDETAPE_ERROR_GENERAL)
return -EIO;
return (tape->tape_block_size * (blocks-rq.current_nr_sectors));
@@ -3517,7 +3715,8 @@
idetape_update_stats(drive);
#if ONSTREAM_DEBUG
if (tape->debug_level >= 2)
- printk(KERN_INFO "ide-tape: %s: frames left in buffer: %d\n", tape->name, tape->cur_frames);
+ printk(KERN_INFO "ide-tape: %s: frames left in buffer: %d\n",
+ tape->name, tape->cur_frames);
#endif
}
@@ -3578,12 +3777,12 @@
if (tape->next_stage == NULL)
return;
- if (!idetape_pipeline_active (tape)) {
+ if (!idetape_pipeline_active(tape)) {
if (tape->onstream_write_error)
idetape_onstream_write_error_recovery(drive);
set_bit(IDETAPE_PIPELINE_ACTIVE, &tape->flags);
- idetape_active_next_stage (drive);
- (void) ide_do_drive_cmd (drive, tape->active_data_request, ide_end);
+ idetape_active_next_stage(drive);
+ (void) ide_do_drive_cmd(drive, tape->active_data_request, ide_end);
}
}
@@ -3599,41 +3798,41 @@
{
idetape_tape_t *tape = drive->driver_data;
- idetape_init_pc (pc);
+ idetape_init_pc(pc);
pc->c[0] = IDETAPE_REWIND_CMD;
if (tape->onstream)
pc->c[1] = 1;
- set_bit (PC_WAIT_FOR_DSC, &pc->flags);
+ set_bit(PC_WAIT_FOR_DSC, &pc->flags);
pc->callback = &idetape_pc_callback;
}
static void idetape_create_mode_select_cmd (idetape_pc_t *pc, int length)
{
- idetape_init_pc (pc);
- set_bit (PC_WRITING, &pc->flags);
+ idetape_init_pc(pc);
+ set_bit(PC_WRITING, &pc->flags);
pc->c[0] = IDETAPE_MODE_SELECT_CMD;
pc->c[1] = 0x10;
- put_unaligned (htons(length), (unsigned short *) &pc->c[3]);
+ put_unaligned(htons(length), (unsigned short *) &pc->c[3]);
pc->request_transfer = 255;
pc->callback = &idetape_pc_callback;
}
static void idetape_create_erase_cmd (idetape_pc_t *pc)
{
- idetape_init_pc (pc);
+ idetape_init_pc(pc);
pc->c[0] = IDETAPE_ERASE_CMD;
pc->c[1] = 1;
- set_bit (PC_WAIT_FOR_DSC, &pc->flags);
+ set_bit(PC_WAIT_FOR_DSC, &pc->flags);
pc->callback = &idetape_pc_callback;
}
-static void idetape_create_space_cmd (idetape_pc_t *pc,int count,byte cmd)
+static void idetape_create_space_cmd (idetape_pc_t *pc,int count,u8 cmd)
{
- idetape_init_pc (pc);
+ idetape_init_pc(pc);
pc->c[0] = IDETAPE_SPACE_CMD;
- put_unaligned (htonl (count), (unsigned int *) &pc->c[1]);
+ put_unaligned(htonl (count), (unsigned int *) &pc->c[1]);
pc->c[1] = cmd;
- set_bit (PC_WAIT_FOR_DSC, &pc->flags);
+ set_bit(PC_WAIT_FOR_DSC, &pc->flags);
pc->callback = &idetape_pc_callback;
}
@@ -3662,48 +3861,70 @@
return 1;
}
if (rq->errors == IDETAPE_ERROR_GENERAL) {
- printk(KERN_INFO "ide-tape: %s: skipping frame %d, read error\n", tape->name, tape->first_frame_position);
+ printk(KERN_INFO "ide-tape: %s: skipping frame %d, "
+ "read error\n", tape->name, tape->first_frame_position);
return 0;
}
if (rq->errors == IDETAPE_ERROR_EOD) {
- printk(KERN_INFO "ide-tape: %s: skipping frame %d, eod\n", tape->name, tape->first_frame_position);
+ printk(KERN_INFO "ide-tape: %s: skipping frame %d, eod\n",
+ tape->name, tape->first_frame_position);
return 0;
}
if (ntohl(aux->format_id) != 0) {
- printk(KERN_INFO "ide-tape: %s: skipping frame %d, format_id %u\n", tape->name, tape->first_frame_position, ntohl(aux->format_id));
+ printk(KERN_INFO "ide-tape: %s: skipping frame %d, "
+ "format_id %u\n", tape->name,
+ tape->first_frame_position, ntohl(aux->format_id));
return 0;
}
if (memcmp(aux->application_sig, tape->application_sig, 4) != 0) {
- printk(KERN_INFO "ide-tape: %s: skipping frame %d, incorrect application signature\n", tape->name, tape->first_frame_position);
+ printk(KERN_INFO "ide-tape: %s: skipping frame %d, "
+ "incorrect application signature\n",
+ tape->name, tape->first_frame_position);
return 0;
}
if (aux->frame_type != OS_FRAME_TYPE_DATA &&
aux->frame_type != OS_FRAME_TYPE_EOD &&
aux->frame_type != OS_FRAME_TYPE_MARKER) {
- printk(KERN_INFO "ide-tape: %s: skipping frame %d, frame type %x\n", tape->name, tape->first_frame_position, aux->frame_type);
+ printk(KERN_INFO "ide-tape: %s: skipping frame %d, frame "
+ "type %x\n", tape->name,
+ tape->first_frame_position, aux->frame_type);
return 0;
}
if (par->partition_num != OS_DATA_PARTITION) {
if (!tape->linux_media || tape->linux_media_version != 2) {
- printk(KERN_INFO "ide-tape: %s: skipping frame %d, partition num %d\n", tape->name, tape->first_frame_position, par->partition_num);
+ printk(KERN_INFO "ide-tape: %s: skipping frame %d, "
+ "partition num %d\n", tape->name,
+ tape->first_frame_position, par->partition_num);
return 0;
}
}
if (par->par_desc_ver != OS_PARTITION_VERSION) {
- printk(KERN_INFO "ide-tape: %s: skipping frame %d, partition version %d\n", tape->name, tape->first_frame_position, par->par_desc_ver);
+ printk(KERN_INFO "ide-tape: %s: skipping frame %d, "
+ "partition version %d\n", tape->name,
+ tape->first_frame_position, par->par_desc_ver);
return 0;
}
if (ntohs(par->wrt_pass_cntr) != tape->wrt_pass_cntr) {
- printk(KERN_INFO "ide-tape: %s: skipping frame %d, wrt_pass_cntr %d (expected %d)(logical_blk_num %u)\n", tape->name, tape->first_frame_position, ntohs(par->wrt_pass_cntr), tape->wrt_pass_cntr, ntohl(aux->logical_blk_num));
+ printk(KERN_INFO "ide-tape: %s: skipping frame %d, "
+ "wrt_pass_cntr %d (expected %d)(logical_blk_num %u)\n",
+ tape->name, tape->first_frame_position,
+ ntohs(par->wrt_pass_cntr), tape->wrt_pass_cntr,
+ ntohl(aux->logical_blk_num));
return 0;
}
if (aux->frame_seq_num != aux->logical_blk_num) {
- printk(KERN_INFO "ide-tape: %s: skipping frame %d, seq != logical\n", tape->name, tape->first_frame_position);
+ printk(KERN_INFO "ide-tape: %s: skipping frame %d, "
+ "seq != logical\n", tape->name,
+ tape->first_frame_position);
return 0;
}
- if (logical_blk_num != -1 && ntohl(aux->logical_blk_num) != logical_blk_num) {
+ if (logical_blk_num != -1 &&
+ ntohl(aux->logical_blk_num) != logical_blk_num) {
if (!quiet)
- printk(KERN_INFO "ide-tape: %s: skipping frame %d, logical_blk_num %u (expected %d)\n", tape->name, tape->first_frame_position, ntohl(aux->logical_blk_num), logical_blk_num);
+ printk(KERN_INFO "ide-tape: %s: skipping frame %d, "
+ "logical_blk_num %u (expected %d)\n",
+ tape->name, tape->first_frame_position,
+ ntohl(aux->logical_blk_num), logical_blk_num);
return 0;
}
if (aux->frame_type == OS_FRAME_TYPE_MARKER) {
@@ -3746,7 +3967,7 @@
#if IDETAPE_DEBUG_LOG
if (tape->debug_level >= 3)
- printk (KERN_INFO "ide-tape: Reached idetape_add_chrdev_write_request\n");
+ printk(KERN_INFO "ide-tape: Reached %s\n", __FUNCTION__);
#endif /* IDETAPE_DEBUG_LOG */
/*
@@ -3755,31 +3976,32 @@
*/
while ((new_stage = idetape_kmalloc_stage (tape)) == NULL) {
spin_lock_irqsave(&tape->spinlock, flags);
- if (idetape_pipeline_active (tape)) {
+ if (idetape_pipeline_active(tape)) {
idetape_wait_for_request(drive, tape->active_data_request);
spin_unlock_irqrestore(&tape->spinlock, flags);
} else {
spin_unlock_irqrestore(&tape->spinlock, flags);
- idetape_insert_pipeline_into_queue (drive);
- if (idetape_pipeline_active (tape))
+ idetape_insert_pipeline_into_queue(drive);
+ if (idetape_pipeline_active(tape))
continue;
/*
* Linux is short on memory. Fallback to
* non-pipelined operation mode for this request.
*/
- return idetape_queue_rw_tail (drive, IDETAPE_WRITE_RQ, blocks, tape->merge_stage->bh);
+ return idetape_queue_rw_tail(drive, IDETAPE_WRITE_RQ, blocks, tape->merge_stage->bh);
}
}
rq = &new_stage->rq;
- ide_init_drive_cmd (rq);
+ ide_init_drive_cmd(rq);
rq->cmd = IDETAPE_WRITE_RQ;
- rq->sector = tape->first_frame_position; /* Doesn't actually matter - We always assume sequential access */
+ /* Doesn't actually matter - We always assume sequential access */
+ rq->sector = tape->first_frame_position;
rq->nr_sectors = rq->current_nr_sectors = blocks;
idetape_switch_buffers (tape, new_stage);
idetape_init_stage(drive, new_stage, OS_FRAME_TYPE_DATA, tape->logical_blk_num);
tape->logical_blk_num++;
- idetape_add_stage_tail (drive, new_stage);
+ idetape_add_stage_tail(drive, new_stage);
tape->pipeline_head++;
#if USE_IOTRACE
IO_trace(IO_IDETAPE_FIFO, tape->pipeline_head, tape->buffer_head, tape->tape_head, tape->minor);
@@ -3813,10 +4035,11 @@
} else if (tape->onstream) {
idetape_update_stats(drive);
if (tape->cur_frames > 5)
- idetape_insert_pipeline_into_queue (drive);
+ idetape_insert_pipeline_into_queue(drive);
}
}
- if (test_and_clear_bit (IDETAPE_PIPELINE_ERROR, &tape->flags)) /* Return a deferred error */
+ if (test_and_clear_bit(IDETAPE_PIPELINE_ERROR, &tape->flags))
+ /* Return a deferred error */
return -EIO;
return blocks;
}
@@ -3831,7 +4054,7 @@
unsigned long flags;
while (tape->next_stage || idetape_pipeline_active(tape)) {
- idetape_insert_pipeline_into_queue (drive);
+ idetape_insert_pipeline_into_queue(drive);
spin_lock_irqsave(&tape->spinlock, flags);
if (idetape_pipeline_active(tape))
idetape_wait_for_request(drive, tape->active_data_request);
@@ -3847,11 +4070,12 @@
#if IDETAPE_DEBUG_BUGS
if (tape->chrdev_direction != idetape_direction_write) {
- printk (KERN_ERR "ide-tape: bug: Trying to empty write pipeline, but we are not writing.\n");
+ printk(KERN_ERR "ide-tape: bug: Trying to empty write "
+ "pipeline, but we are not writing.\n");
return;
}
if (tape->merge_stage_size > tape->stage_size) {
- printk (KERN_ERR "ide-tape: bug: merge_buffer too big\n");
+ printk(KERN_ERR "ide-tape: bug: merge_buffer too big\n");
tape->merge_stage_size = tape->stage_size;
}
#endif /* IDETAPE_DEBUG_BUGS */
@@ -3878,15 +4102,15 @@
bh = bh->b_reqnext;
}
}
- (void) idetape_add_chrdev_write_request (drive, blocks);
+ (void) idetape_add_chrdev_write_request(drive, blocks);
tape->merge_stage_size = 0;
}
- idetape_wait_for_pipeline (drive);
+ idetape_wait_for_pipeline(drive);
if (tape->merge_stage != NULL) {
- __idetape_kfree_stage (tape->merge_stage);
+ __idetape_kfree_stage(tape->merge_stage);
tape->merge_stage = NULL;
}
- clear_bit (IDETAPE_PIPELINE_ERROR, &tape->flags);
+ clear_bit(IDETAPE_PIPELINE_ERROR, &tape->flags);
tape->chrdev_direction = idetape_direction_none;
/*
@@ -3897,10 +4121,14 @@
*/
tape->max_stages = tape->min_pipeline;
#if IDETAPE_DEBUG_BUGS
- if (tape->first_stage != NULL || tape->next_stage != NULL || tape->last_stage != NULL || tape->nr_stages != 0) {
- printk (KERN_ERR "ide-tape: ide-tape pipeline bug, "
- "first_stage %p, next_stage %p, last_stage %p, nr_stages %d\n",
- tape->first_stage, tape->next_stage, tape->last_stage, tape->nr_stages);
+ if (tape->first_stage != NULL ||
+ tape->next_stage != NULL ||
+ tape->last_stage != NULL ||
+ tape->nr_stages != 0) {
+ printk(KERN_ERR "ide-tape: ide-tape pipeline bug, "
+ "first_stage %p, next_stage %p, last_stage %p, "
+ "nr_stages %d\n", tape->first_stage,
+ tape->next_stage, tape->last_stage, tape->nr_stages);
}
#endif /* IDETAPE_DEBUG_BUGS */
}
@@ -3928,14 +4156,16 @@
int bytes_read;
int blocks = tape->capabilities.ctl;
- if (tape->chrdev_direction != idetape_direction_read) { /* Initialize read operation */
+ /* Initialize read operation */
+ if (tape->chrdev_direction != idetape_direction_read) {
if (tape->chrdev_direction == idetape_direction_write) {
- idetape_empty_write_pipeline (drive);
- idetape_flush_tape_buffers (drive);
+ idetape_empty_write_pipeline(drive);
+ idetape_flush_tape_buffers(drive);
}
#if IDETAPE_DEBUG_BUGS
if (tape->merge_stage || tape->merge_stage_size) {
- printk (KERN_ERR "ide-tape: merge_stage_size should be 0 now\n");
+ printk(KERN_ERR "ide-tape: merge_stage_size "
+ "should be 0 now\n");
tape->merge_stage_size = 0;
}
#endif /* IDETAPE_DEBUG_BUGS */
@@ -3949,9 +4179,9 @@
* is switched from completion mode to buffer available
* mode.
*/
- bytes_read = idetape_queue_rw_tail (drive, IDETAPE_READ_RQ, 0, tape->merge_stage->bh);
+ bytes_read = idetape_queue_rw_tail(drive, IDETAPE_READ_RQ, 0, tape->merge_stage->bh);
if (bytes_read < 0) {
- kfree (tape->merge_stage);
+ __idetape_kfree_stage(tape->merge_stage);
tape->merge_stage = NULL;
tape->chrdev_direction = idetape_direction_none;
return bytes_read;
@@ -3959,18 +4189,19 @@
}
if (tape->restart_speed_control_req)
idetape_restart_speed_control(drive);
- ide_init_drive_cmd (&rq);
+ ide_init_drive_cmd(&rq);
rq.cmd = IDETAPE_READ_RQ;
rq.sector = tape->first_frame_position;
rq.nr_sectors = rq.current_nr_sectors = blocks;
- if (!test_bit(IDETAPE_PIPELINE_ERROR, &tape->flags) && tape->nr_stages <= max_stages) {
- new_stage = idetape_kmalloc_stage (tape);
+ if (!test_bit(IDETAPE_PIPELINE_ERROR, &tape->flags) &&
+ tape->nr_stages < max_stages) {
+ new_stage = idetape_kmalloc_stage(tape);
while (new_stage != NULL) {
new_stage->rq = rq;
- idetape_add_stage_tail (drive, new_stage);
+ idetape_add_stage_tail(drive, new_stage);
if (tape->nr_stages >= max_stages)
break;
- new_stage = idetape_kmalloc_stage (tape);
+ new_stage = idetape_kmalloc_stage(tape);
}
}
if (!idetape_pipeline_active(tape)) {
@@ -3979,11 +4210,11 @@
tape->insert_time = jiffies;
tape->insert_size = 0;
tape->insert_speed = 0;
- idetape_insert_pipeline_into_queue (drive);
+ idetape_insert_pipeline_into_queue(drive);
} else if (tape->onstream) {
idetape_update_stats(drive);
if (tape->cur_frames < tape->max_frames - 5)
- idetape_insert_pipeline_into_queue (drive);
+ idetape_insert_pipeline_into_queue(drive);
}
}
return 0;
@@ -4000,7 +4231,9 @@
*/
while (1) {
if (cnt++ > 1000) { /* AJN: was 100 */
- printk(KERN_INFO "ide-tape: %s: couldn't find logical block %d, aborting\n", tape->name, logical_blk_num);
+ printk(KERN_INFO "ide-tape: %s: couldn't find "
+ "logical block %d, aborting\n",
+ tape->name, logical_blk_num);
return 0;
}
idetape_initiate_read(drive, max_stages);
@@ -4012,21 +4245,31 @@
#endif
clear_bit(IDETAPE_PIPELINE_ERROR, &tape->flags);
position = idetape_read_position(drive);
- printk(KERN_INFO "ide-tape: %s: blank block detected at %d\n", tape->name, position);
+ printk(KERN_INFO "ide-tape: %s: blank block "
+ "detected at %d\n", tape->name,
+ position);
if (position >= 3000 && position < 3080)
- position += 32; /* Why is this check and number ??? MM */
- if (position >= OS_DATA_ENDFRAME1 && position < 3000)
+ /* Why is this check and number ??? MM */
+ position += 32;
+ if (position >= OS_DATA_ENDFRAME1 &&
+ position < 3000)
position = 3000;
else
/*
- * compensate for write errors that generally skip 80 frames,
- * expect around 20 read errors in a row...
+ * compensate for write errors that
+ * generally skip 80 frames, expect
+ * around 20 read errors in a row...
*/
position += 60;
- if (position >= OS_DATA_ENDFRAME1 && position < 3000)
+ if (position >= OS_DATA_ENDFRAME1 &&
+ position < 3000)
position = 3000;
printk(KERN_INFO "ide-tape: %s: positioning tape to block %d\n", tape->name, position);
- if (position == 3000) /* seems to be needed to correctly position at block 3000 MM */
+
+ /* seems to be needed to correctly position
+ * at block 3000 MM
+ */
+ if (position == 3000)
idetape_position_tape(drive, 0, 0, 0);
idetape_position_tape(drive, position, 0, 0);
cnt += 40;
@@ -4069,10 +4312,17 @@
#if IDETAPE_DEBUG_LOG
if (tape->debug_level >= 4)
- printk (KERN_INFO "ide-tape: Reached idetape_add_chrdev_read_request, %d blocks\n", blocks);
+ printk(KERN_INFO "ide-tape: Reached %s, %d blocks\n",
+ __FUNCTION__, blocks);
#endif /* IDETAPE_DEBUG_LOG */
/*
+ * If we are at a filemark, return a read length of 0
+ */
+ if (test_bit(IDETAPE_FILEMARK, &tape->flags))
+ return 0;
+
+ /*
* Wait for the next logical block to be available at the head
* of the pipeline
*/
@@ -4083,38 +4333,35 @@
}
if (test_bit(IDETAPE_PIPELINE_ERROR, &tape->flags))
return 0;
- return idetape_queue_rw_tail (drive, IDETAPE_READ_RQ, blocks, tape->merge_stage->bh);
+ return idetape_queue_rw_tail(drive, IDETAPE_READ_RQ, blocks, tape->merge_stage->bh);
}
rq_ptr = &tape->first_stage->rq;
bytes_read = tape->tape_block_size * (rq_ptr->nr_sectors - rq_ptr->current_nr_sectors);
rq_ptr->nr_sectors = rq_ptr->current_nr_sectors = 0;
- if (tape->onstream && !tape->raw && tape->first_stage->aux->frame_type == OS_FRAME_TYPE_EOD) {
+ if (tape->onstream && !tape->raw &&
+ tape->first_stage->aux->frame_type == OS_FRAME_TYPE_EOD) {
#if ONSTREAM_DEBUG
if (tape->debug_level >= 2)
- printk(KERN_INFO "ide-tape: %s: EOD reached\n", tape->name);
+ printk(KERN_INFO "ide-tape: %s: EOD reached\n",
+ tape->name);
#endif
return 0;
}
if (rq_ptr->errors == IDETAPE_ERROR_EOD)
return 0;
- if (rq_ptr->errors == IDETAPE_ERROR_FILEMARK) {
- idetape_switch_buffers (tape, tape->first_stage);
- set_bit (IDETAPE_FILEMARK, &tape->flags);
-#if USE_IOTRACE
- IO_trace(IO_IDETAPE_FIFO, tape->pipeline_head, tape->buffer_head, tape->tape_head, tape->minor);
-#endif
- calculate_speeds(drive);
- } else {
- idetape_switch_buffers (tape, tape->first_stage);
+ else {
+ idetape_switch_buffers(tape, tape->first_stage);
if (rq_ptr->errors == IDETAPE_ERROR_GENERAL) {
#if ONSTREAM_DEBUG
if (tape->debug_level >= 1)
- printk(KERN_INFO "ide-tape: error detected, bytes_read %d\n", bytes_read);
+ printk(KERN_INFO "ide-tape: error detected, "
+ "bytes_read %d\n", bytes_read);
#endif
}
- clear_bit (IDETAPE_FILEMARK, &tape->flags);
+ if (rq_ptr->errors == IDETAPE_ERROR_FILEMARK)
+ set_bit(IDETAPE_FILEMARK, &tape->flags);
spin_lock_irqsave(&tape->spinlock, flags);
idetape_remove_stage_head (drive);
spin_unlock_irqrestore(&tape->spinlock, flags);
@@ -4126,9 +4373,10 @@
calculate_speeds(drive);
}
#if IDETAPE_DEBUG_BUGS
- if (bytes_read > blocks*tape->tape_block_size) {
- printk (KERN_ERR "ide-tape: bug: trying to return more bytes than requested\n");
- bytes_read=blocks*tape->tape_block_size;
+ if (bytes_read > blocks * tape->tape_block_size) {
+ printk(KERN_ERR "ide-tape: bug: trying to return more "
+ "bytes than requested\n");
+ bytes_read = blocks * tape->tape_block_size;
}
#endif /* IDETAPE_DEBUG_BUGS */
return (bytes_read);
@@ -4142,16 +4390,16 @@
while (bcount) {
bh = tape->merge_stage->bh;
- count = IDE_MIN (tape->stage_size, bcount);
+ count = IDE_MIN(tape->stage_size, bcount);
bcount -= count;
blocks = count / tape->tape_block_size;
while (count) {
atomic_set(&bh->b_count, IDE_MIN (count, bh->b_size));
- memset (bh->b_data, 0, atomic_read(&bh->b_count));
+ memset(bh->b_data, 0, atomic_read(&bh->b_count));
count -= atomic_read(&bh->b_count);
bh = bh->b_reqnext;
}
- idetape_queue_rw_tail (drive, IDETAPE_WRITE_RQ, blocks, tape->merge_stage->bh);
+ idetape_queue_rw_tail(drive, IDETAPE_WRITE_RQ, blocks, tape->merge_stage->bh);
}
}
@@ -4162,7 +4410,7 @@
struct request *rq;
int size = 0;
- idetape_wait_for_pipeline (drive);
+ idetape_wait_for_pipeline(drive);
stage = tape->first_stage;
while (stage != NULL) {
rq = &stage->rq;
@@ -4187,16 +4435,16 @@
idetape_tape_t *tape = drive->driver_data;
#if IDETAPE_DEBUG_LOG
if (tape->debug_level >= 2)
- printk (KERN_INFO "ide-tape: Reached idetape_rewind_tape\n");
+ printk(KERN_INFO "ide-tape: Reached %s\n", __FUNCTION__);
#endif /* IDETAPE_DEBUG_LOG */
- idetape_create_rewind_cmd (drive, &pc);
- retval = idetape_queue_pc_tail (drive, &pc);
+ idetape_create_rewind_cmd(drive, &pc);
+ retval = idetape_queue_pc_tail(drive, &pc);
if (retval)
return retval;
- idetape_create_read_position_cmd (&pc);
- retval = idetape_queue_pc_tail (drive, &pc);
+ idetape_create_read_position_cmd(&pc);
+ retval = idetape_queue_pc_tail(drive, &pc);
if (retval)
return retval;
tape->logical_blk_num = 0;
@@ -4218,7 +4466,7 @@
#if IDETAPE_DEBUG_LOG
if (tape->debug_level >= 4)
- printk (KERN_INFO "ide-tape: Reached idetape_blkdev_ioctl\n");
+ printk(KERN_INFO "ide-tape: Reached %s\n", __FUNCTION__);
#endif /* IDETAPE_DEBUG_LOG */
switch (cmd) {
case 0x0340:
@@ -4248,7 +4496,7 @@
{
MOD_INC_USE_COUNT;
#if ONSTREAM_DEBUG
- printk(KERN_INFO "ide-tape: MOD_INC_USE_COUNT in idetape_blkdev_open\n");
+ printk(KERN_INFO "ide-tape: MOD_INC_USE_COUNT in %s\n", __FUNCTION__);
#endif
return 0;
}
@@ -4257,7 +4505,7 @@
{
MOD_DEC_USE_COUNT;
#if ONSTREAM_DEBUG
- printk(KERN_INFO "ide-tape: MOD_DEC_USE_COUNT in idetape_blkdev_release\n");
+ printk(KERN_INFO "ide-tape: MOD_DEC_USE_COUNT in %s\n", __FUNCTION__);
#endif
}
@@ -4268,7 +4516,7 @@
{
idetape_tape_t *tape = drive->driver_data;
if (tape != NULL)
- set_bit (IDETAPE_IGNORE_DSC, &tape->flags);
+ set_bit(IDETAPE_IGNORE_DSC, &tape->flags);
}
/*
@@ -4291,7 +4539,8 @@
unsigned long flags;
if (!idetape_get_logical_blk(drive, -1, 10, 0)) {
- printk(KERN_INFO "ide-tape: %s: couldn't get logical blk num in space_filemarks_bwd\n", tape->name);
+ printk(KERN_INFO "ide-tape: %s: couldn't get logical blk "
+ "num in space_filemarks_bwd\n", tape->name);
return -EIO;
}
while (cnt != mt_count) {
@@ -4300,16 +4549,20 @@
return -EIO;
#if ONSTREAM_DEBUG
if (tape->debug_level >= 2)
- printk(KERN_INFO "ide-tape: positioning to last mark at %d\n", last_mark_addr);
+ printk(KERN_INFO "ide-tape: positioning to last "
+ "mark at %d\n", last_mark_addr);
#endif
idetape_position_tape(drive, last_mark_addr, 0, 0);
cnt++;
if (!idetape_get_logical_blk(drive, -1, 10, 0)) {
- printk(KERN_INFO "ide-tape: %s: couldn't get logical blk num in space_filemarks\n", tape->name);
+ printk(KERN_INFO "ide-tape: %s: couldn't get logical "
+ "blk num in space_filemarks\n", tape->name);
return -EIO;
}
if (tape->first_stage->aux->frame_type != OS_FRAME_TYPE_MARKER) {
- printk(KERN_INFO "ide-tape: %s: expected to find marker at block %d, not found\n", tape->name, last_mark_addr);
+ printk(KERN_INFO "ide-tape: %s: expected to find "
+ "marker at block %d, not found\n",
+ tape->name, last_mark_addr);
return -EIO;
}
}
@@ -4334,12 +4587,14 @@
unsigned long flags;
if (!idetape_get_logical_blk(drive, -1, 10, 0)) {
- printk(KERN_INFO "ide-tape: %s: couldn't get logical blk num in space_filemarks_fwd\n", tape->name);
+ printk(KERN_INFO "ide-tape: %s: couldn't get logical blk "
+ "num in space_filemarks_fwd\n", tape->name);
return -EIO;
}
while (1) {
if (!idetape_get_logical_blk(drive, -1, 10, 0)) {
- printk(KERN_INFO "ide-tape: %s: couldn't get logical blk num in space_filemarks\n", tape->name);
+ printk(KERN_INFO "ide-tape: %s: couldn't get logical "
+ "blk num in space_filemarks\n", tape->name);
return -EIO;
}
if (tape->first_stage->aux->frame_type == OS_FRAME_TYPE_MARKER)
@@ -4347,19 +4602,20 @@
if (tape->first_stage->aux->frame_type == OS_FRAME_TYPE_EOD) {
#if ONSTREAM_DEBUG
if (tape->debug_level >= 2)
- printk(KERN_INFO "ide-tape: %s: space_fwd: EOD reached\n", tape->name);
+ printk(KERN_INFO "ide-tape: %s: space_fwd: "
+ "EOD reached\n", tape->name);
#endif
return -EIO;
}
if (cnt == mt_count)
break;
spin_lock_irqsave(&tape->spinlock, flags);
- idetape_remove_stage_head (drive);
+ idetape_remove_stage_head(drive);
spin_unlock_irqrestore(&tape->spinlock, flags);
}
if (mt_op == MTFSF) {
spin_lock_irqsave(&tape->spinlock, flags);
- idetape_remove_stage_head (drive);
+ idetape_remove_stage_head(drive);
tape->logical_blk_num++;
spin_unlock_irqrestore(&tape->spinlock, flags);
}
@@ -4377,7 +4633,8 @@
unsigned long flags;
if (!idetape_get_logical_blk(drive, -1, 10, 0)) {
- printk(KERN_INFO "ide-tape: %s: couldn't get logical blk num in space_filemarks_fwd\n", tape->name);
+ printk(KERN_INFO "ide-tape: %s: couldn't get logical blk "
+ "num in space_filemarks_fwd\n", tape->name);
return -EIO;
}
@@ -4390,22 +4647,27 @@
if (tape->first_stage->aux->frame_type == OS_FRAME_TYPE_EOD) {
#if ONSTREAM_DEBUG
if (tape->debug_level >= 2)
- printk(KERN_INFO "ide-tape: %s: space_fwd: EOD reached\n", tape->name);
+ printk(KERN_INFO "ide-tape: %s: space_fwd: "
+ "EOD reached\n", tape->name);
#endif
return -EIO;
}
if (ntohl(tape->first_stage->aux->filemark_cnt) == 0) {
if (tape->first_mark_addr == -1) {
- printk(KERN_INFO "ide-tape: %s: reverting to slow filemark space\n", tape->name);
+ printk(KERN_INFO "ide-tape: %s: reverting to "
+ "slow filemark space\n", tape->name);
return idetape_onstream_space_over_filemarks_forward_slow(drive, mt_op, mt_count);
}
idetape_position_tape(drive, tape->first_mark_addr, 0, 0);
if (!idetape_get_logical_blk(drive, -1, 10, 0)) {
- printk(KERN_INFO "ide-tape: %s: couldn't get logical blk num in space_filemarks_fwd_fast\n", tape->name);
+ printk(KERN_INFO "ide-tape: %s: couldn't get "
+ "logical blk num in %s\n", __FUNCTION__, tape->name);
return -EIO;
}
if (tape->first_stage->aux->frame_type != OS_FRAME_TYPE_MARKER) {
- printk(KERN_INFO "ide-tape: %s: expected to find filemark at %d\n", tape->name, tape->first_mark_addr);
+ printk(KERN_INFO "ide-tape: %s: expected to "
+ "find filemark at %d\n",
+ tape->name, tape->first_mark_addr);
return -EIO;
}
} else {
@@ -4418,7 +4680,8 @@
while (cnt != mt_count) {
next_mark_addr = ntohl(tape->first_stage->aux->next_mark_addr);
if (!next_mark_addr || next_mark_addr > tape->eod_frame_addr) {
- printk(KERN_INFO "ide-tape: %s: reverting to slow filemark space\n", tape->name);
+ printk(KERN_INFO "ide-tape: %s: reverting to slow "
+ "filemark space\n", tape->name);
return idetape_onstream_space_over_filemarks_forward_slow(drive, mt_op, mt_count - cnt);
#if ONSTREAM_DEBUG
} else if (tape->debug_level >= 2) {
@@ -4428,17 +4691,20 @@
idetape_position_tape(drive, next_mark_addr, 0, 0);
cnt++;
if (!idetape_get_logical_blk(drive, -1, 10, 0)) {
- printk(KERN_INFO "ide-tape: %s: couldn't get logical blk num in space_filemarks\n", tape->name);
+ printk(KERN_INFO "ide-tape: %s: couldn't get logical "
+ "blk num in space_filemarks\n", tape->name);
return -EIO;
}
if (tape->first_stage->aux->frame_type != OS_FRAME_TYPE_MARKER) {
- printk(KERN_INFO "ide-tape: %s: expected to find marker at block %d, not found\n", tape->name, next_mark_addr);
+ printk(KERN_INFO "ide-tape: %s: expected to find "
+ "marker at block %d, not found\n",
+ tape->name, next_mark_addr);
return -EIO;
}
}
if (mt_op == MTFSF) {
spin_lock_irqsave(&tape->spinlock, flags);
- idetape_remove_stage_head (drive);
+ idetape_remove_stage_head(drive);
tape->logical_blk_num++;
spin_unlock_irqrestore(&tape->spinlock, flags);
}
@@ -4478,6 +4744,14 @@
tape->restart_speed_control_req = 1;
return retval;
}
+
+ if (mt_count == 0)
+ return 0;
+ if (MTBSF == mt_op || MTBSFM == mt_op) {
+ if (!tape->capabilities.sprev)
+ return -EIO;
+ mt_count = - mt_count;
+ }
if (tape->chrdev_direction == idetape_direction_read) {
/*
@@ -4485,28 +4759,36 @@
* filemarks.
*/
tape->merge_stage_size = 0;
- clear_bit (IDETAPE_FILEMARK, &tape->flags);
+ if (test_and_clear_bit(IDETAPE_FILEMARK, &tape->flags))
+ ++count;
while (tape->first_stage != NULL) {
- idetape_wait_first_stage(drive);
- if (tape->first_stage->rq.errors == IDETAPE_ERROR_FILEMARK)
- count++;
if (count == mt_count) {
- switch (mt_op) {
- case MTFSF:
- spin_lock_irqsave(&tape->spinlock, flags);
- idetape_remove_stage_head (drive);
- spin_unlock_irqrestore(&tape->spinlock, flags);
- case MTFSFM:
- return (0);
- default:
- break;
- }
+ if (mt_op == MTFSFM)
+ set_bit(IDETAPE_FILEMARK, &tape->flags);
+ return 0;
}
spin_lock_irqsave(&tape->spinlock, flags);
- idetape_remove_stage_head (drive);
- spin_unlock_irqrestore(&tape->spinlock, flags);
+ if (tape->first_stage == tape->active_stage) {
+ /*
+ * We have reached the active stage in the read pipeline.
+ * There is no point in allowing the drive to continue
+ * reading any farther, so we stop the pipeline.
+ *
+ * This section should be moved to a separate subroutine,
+ * because a similar function is performed in
+ * __idetape_discard_read_pipeline(), for example.
+ */
+ tape->next_stage = NULL;
+ spin_unlock_irqrestore(&tape->spinlock, flags);
+ idetape_wait_first_stage(drive);
+ tape->next_stage = tape->first_stage->next;
+ } else
+ spin_unlock_irqrestore(&tape->spinlock, flags);
+ if (tape->first_stage->rq.errors == IDETAPE_ERROR_FILEMARK)
+ ++count;
+ idetape_remove_stage_head(drive);
}
- idetape_discard_read_pipeline (drive, 1);
+ idetape_discard_read_pipeline(drive, 0);
}
/*
@@ -4515,27 +4797,20 @@
*/
switch (mt_op) {
case MTFSF:
- idetape_create_space_cmd (&pc,mt_count-count,IDETAPE_SPACE_OVER_FILEMARK);
- return (idetape_queue_pc_tail (drive, &pc));
- case MTFSFM:
- if (!tape->capabilities.sprev)
- return (-EIO);
- retval = idetape_space_over_filemarks (drive, MTFSF, mt_count-count);
- if (retval) return (retval);
- return (idetape_space_over_filemarks (drive, MTBSF, 1));
case MTBSF:
- if (!tape->capabilities.sprev)
- return (-EIO);
- idetape_create_space_cmd (&pc,-(mt_count+count),IDETAPE_SPACE_OVER_FILEMARK);
- return (idetape_queue_pc_tail (drive, &pc));
+ idetape_create_space_cmd(&pc,mt_count-count,IDETAPE_SPACE_OVER_FILEMARK);
+ return (idetape_queue_pc_tail(drive, &pc));
+ case MTFSFM:
case MTBSFM:
if (!tape->capabilities.sprev)
return (-EIO);
- retval = idetape_space_over_filemarks (drive, MTBSF, mt_count+count);
+ retval = idetape_space_over_filemarks(drive, MTFSF, mt_count-count);
if (retval) return (retval);
- return (idetape_space_over_filemarks (drive, MTFSF, 1));
+ count = (MTBSFM == mt_op ? 1 : -1);
+ return (idetape_space_over_filemarks(drive, MTFSF, count));
default:
- printk (KERN_ERR "ide-tape: MTIO operation %d not supported\n",mt_op);
+ printk(KERN_ERR "ide-tape: MTIO operation %d not "
+ "supported\n", mt_op);
return (-EIO);
}
}
@@ -4562,7 +4837,7 @@
size_t count, loff_t *ppos)
{
struct inode *inode = file->f_dentry->d_inode;
- ide_drive_t *drive = get_drive_ptr (inode->i_rdev);
+ ide_drive_t *drive = get_drive_ptr(inode->i_rdev);
idetape_tape_t *tape = drive->driver_data;
ssize_t bytes_read,temp, actually_read = 0, rc;
@@ -4571,17 +4846,21 @@
return -ENXIO;
}
if (tape->onstream && (count != tape->tape_block_size)) {
- printk(KERN_ERR "ide-tape: %s: use %d bytes as block size (%Zd used)\n", tape->name, tape->tape_block_size, count);
+ printk(KERN_ERR "ide-tape: %s: use %d bytes as block size "
+ "(%Zd used)\n", tape->name,
+ tape->tape_block_size, count);
return -EINVAL;
}
#if IDETAPE_DEBUG_LOG
if (tape->debug_level >= 3)
- printk (KERN_INFO "ide-tape: Reached idetape_chrdev_read, count %Zd\n", count);
+ printk (KERN_INFO "ide-tape: Reached %s, count %Zd\n",
+ __FUNCTION__, count);
#endif /* IDETAPE_DEBUG_LOG */
if (tape->chrdev_direction != idetape_direction_read) {
- if (test_bit (IDETAPE_DETECT_BS, &tape->flags))
- if (count > tape->tape_block_size && (count % tape->tape_block_size) == 0)
+ if (test_bit(IDETAPE_DETECT_BS, &tape->flags))
+ if (count > tape->tape_block_size &&
+ (count % tape->tape_block_size) == 0)
tape->user_bs_factor = count / tape->tape_block_size;
}
if ((rc = idetape_initiate_read(drive, tape->max_stages)) < 0)
@@ -4589,42 +4868,45 @@
if (count == 0)
return (0);
if (tape->merge_stage_size) {
- actually_read = IDE_MIN (tape->merge_stage_size, count);
- idetape_copy_stage_to_user (tape, buf, tape->merge_stage, actually_read);
+ actually_read = IDE_MIN(tape->merge_stage_size, count);
+ idetape_copy_stage_to_user(tape, buf, tape->merge_stage, actually_read);
buf += actually_read;
tape->merge_stage_size -= actually_read;
count -= actually_read;
}
while (count >= tape->stage_size) {
- bytes_read = idetape_add_chrdev_read_request (drive, tape->capabilities.ctl);
+ bytes_read = idetape_add_chrdev_read_request(drive, tape->capabilities.ctl);
if (bytes_read <= 0)
goto finish;
- idetape_copy_stage_to_user (tape, buf, tape->merge_stage, bytes_read);
+ idetape_copy_stage_to_user(tape, buf, tape->merge_stage, bytes_read);
buf += bytes_read;
count -= bytes_read;
actually_read += bytes_read;
}
if (count) {
- bytes_read=idetape_add_chrdev_read_request (drive, tape->capabilities.ctl);
+ bytes_read=idetape_add_chrdev_read_request(drive, tape->capabilities.ctl);
if (bytes_read <= 0)
goto finish;
- temp = IDE_MIN (count, bytes_read);
- idetape_copy_stage_to_user (tape, buf, tape->merge_stage, temp);
+ temp = IDE_MIN(count, bytes_read);
+ idetape_copy_stage_to_user(tape, buf, tape->merge_stage, temp);
actually_read += temp;
tape->merge_stage_size = bytes_read-temp;
}
finish:
- if (!actually_read && test_bit (IDETAPE_FILEMARK, &tape->flags)) {
+ if (!actually_read && test_bit(IDETAPE_FILEMARK, &tape->flags)) {
#if IDETAPE_DEBUG_LOG
if (tape->debug_level >= 2)
- printk(KERN_INFO "ide-tape: %s: spacing over filemark\n", tape->name);
+ printk(KERN_INFO "ide-tape: %s: spacing over "
+ "filemark\n", tape->name);
#endif
idetape_space_over_filemarks (drive, MTFSF, 1);
return 0;
}
- if (tape->onstream && !actually_read && test_and_clear_bit(IDETAPE_READ_ERROR, &tape->flags)) {
- printk(KERN_ERR "ide-tape: %s: unrecovered read error on logical block number %d, skipping\n",
- tape->name, tape->logical_blk_num);
+ if (tape->onstream && !actually_read &&
+ test_and_clear_bit(IDETAPE_READ_ERROR, &tape->flags)) {
+ printk(KERN_ERR "ide-tape: %s: unrecovered read error on "
+ "logical block number %d, skipping\n",
+ tape->name, tape->logical_blk_num);
tape->logical_blk_num++;
return -EIO;
}
@@ -4649,21 +4931,25 @@
position = idetape_read_position(drive);
#if ONSTREAM_DEBUG
if (tape->debug_level >= 2)
- printk(KERN_INFO "ide-tape: current position (2) %d, lblk %d\n", position, tape->logical_blk_num);
+ printk(KERN_INFO "ide-tape: current position (2) %d, "
+ "lblk %d\n", position, tape->logical_blk_num);
if (tape->debug_level >= 2)
- printk(KERN_INFO "ide-tape: current position (2) tape block %d\n", tape->last_frame_position);
+ printk(KERN_INFO "ide-tape: current position (2) tape "
+ "block %d\n", tape->last_frame_position);
#endif
idetape_position_tape(drive, last_mark_addr, 0, 0);
- if (!idetape_queue_rw_tail (drive, IDETAPE_READ_RQ, 1, stage->bh)) {
- printk(KERN_INFO "ide-tape: %s: couldn't read last marker\n", tape->name);
- __idetape_kfree_stage (stage);
+ if (!idetape_queue_rw_tail(drive, IDETAPE_READ_RQ, 1, stage->bh)) {
+ printk(KERN_INFO "ide-tape: %s: couldn't read last marker\n",
+ tape->name);
+ __idetape_kfree_stage(stage);
idetape_position_tape(drive, position, 0, 0);
return;
}
aux = stage->aux;
if (aux->frame_type != OS_FRAME_TYPE_MARKER) {
- printk(KERN_INFO "ide-tape: %s: expected to find marker at addr %d\n", tape->name, last_mark_addr);
- __idetape_kfree_stage (stage);
+ printk(KERN_INFO "ide-tape: %s: expected to find marker "
+ "at addr %d\n", tape->name, last_mark_addr);
+ __idetape_kfree_stage(stage);
idetape_position_tape(drive, position, 0, 0);
return;
}
@@ -4673,13 +4959,14 @@
#endif
aux->next_mark_addr = htonl(next_mark_addr);
idetape_position_tape(drive, last_mark_addr, 0, 0);
- if (!idetape_queue_rw_tail (drive, IDETAPE_WRITE_RQ, 1, stage->bh)) {
- printk(KERN_INFO "ide-tape: %s: couldn't write back marker frame at %d\n", tape->name, last_mark_addr);
- __idetape_kfree_stage (stage);
+ if (!idetape_queue_rw_tail(drive, IDETAPE_WRITE_RQ, 1, stage->bh)) {
+ printk(KERN_INFO "ide-tape: %s: couldn't write back marker "
+ "frame at %d\n", tape->name, last_mark_addr);
+ __idetape_kfree_stage(stage);
idetape_position_tape(drive, position, 0, 0);
return;
}
- __idetape_kfree_stage (stage);
+ __idetape_kfree_stage(stage);
idetape_flush_tape_buffers (drive);
idetape_position_tape(drive, position, 0, 0);
return;
@@ -4702,18 +4989,20 @@
#if ONSTREAM_DEBUG
printk(KERN_INFO "write_filler: positioning failed it returned %d\n", rc);
#endif
- if (rc != 0)
- return; /* don't write fillers if we cannot position the tape. */
+ if (rc != 0)
+ /* don't write fillers if we cannot position the tape. */
+ return;
strcpy(stage->bh->b_data, "Filler");
while (cnt--) {
- if (!idetape_queue_rw_tail (drive, IDETAPE_WRITE_RQ, 1, stage->bh)) {
- printk(KERN_INFO "ide-tape: %s: write_filler: couldn't write header frame\n", tape->name);
- __idetape_kfree_stage (stage);
+ if (!idetape_queue_rw_tail(drive, IDETAPE_WRITE_RQ, 1, stage->bh)) {
+ printk(KERN_INFO "ide-tape: %s: write_filler: "
+ "couldn't write header frame\n", tape->name);
+ __idetape_kfree_stage(stage);
return;
}
}
- __idetape_kfree_stage (stage);
+ __idetape_kfree_stage(stage);
}
static void __idetape_write_header (ide_drive_t *drive, int block, int cnt)
@@ -4741,14 +5030,14 @@
header.partition.eod_frame_addr = htonl(tape->eod_frame_addr);
memcpy(stage->bh->b_data, &header, sizeof(header));
while (cnt--) {
- if (!idetape_queue_rw_tail (drive, IDETAPE_WRITE_RQ, 1, stage->bh)) {
+ if (!idetape_queue_rw_tail(drive, IDETAPE_WRITE_RQ, 1, stage->bh)) {
printk(KERN_INFO "ide-tape: %s: couldn't write header frame\n", tape->name);
- __idetape_kfree_stage (stage);
+ __idetape_kfree_stage(stage);
return;
}
}
- __idetape_kfree_stage (stage);
- idetape_flush_tape_buffers (drive);
+ __idetape_kfree_stage(stage);
+ idetape_flush_tape_buffers(drive);
}
static void idetape_write_header (ide_drive_t *drive, int locate_eod)
@@ -4767,7 +5056,9 @@
if (locate_eod) {
#if ONSTREAM_DEBUG
if (tape->debug_level >= 2)
- printk(KERN_INFO "ide-tape: %s: locating back to eod frame addr %d\n", tape->name, tape->eod_frame_addr);
+ printk(KERN_INFO "ide-tape: %s: locating back to "
+ "eod frame addr %d\n", tape->name,
+ tape->eod_frame_addr);
#endif
idetape_position_tape(drive, tape->eod_frame_addr, 0, 0);
}
@@ -4777,7 +5068,7 @@
size_t count, loff_t *ppos)
{
struct inode *inode = file->f_dentry->d_inode;
- ide_drive_t *drive = get_drive_ptr (inode->i_rdev);
+ ide_drive_t *drive = get_drive_ptr(inode->i_rdev);
idetape_tape_t *tape = drive->driver_data;
ssize_t retval, actually_written = 0;
int position;
@@ -4794,13 +5085,14 @@
if (tape->onstream) {
if (count != tape->tape_block_size) {
- printk(KERN_ERR "ide-tape: %s: chrdev_write: use %d bytes as block size (%Zd used)\n",
- tape->name, tape->tape_block_size, count);
+ printk(KERN_ERR "ide-tape: %s: chrdev_write: "
+ "use %d bytes as block size (%Zd used)\n",
+ tape->name, tape->tape_block_size, count);
return -EINVAL;
}
/*
- * Check if we reach the end of the tape. Just assume the whole pipeline
- * is filled with write requests!
+ * Check if we reach the end of the tape. Just assume the whole
+ * pipeline is filled with write requests!
*/
if (tape->first_frame_position + tape->nr_stages >= tape->capacity - OS_EW) {
#if ONSTREAM_DEBUG
@@ -4812,19 +5104,20 @@
}
}
- if (tape->chrdev_direction != idetape_direction_write) { /* Initialize write operation */
+ /* Initialize write operation */
+ if (tape->chrdev_direction != idetape_direction_write) {
if (tape->chrdev_direction == idetape_direction_read)
- idetape_discard_read_pipeline (drive, 1);
+ idetape_discard_read_pipeline(drive, 1);
#if IDETAPE_DEBUG_BUGS
if (tape->merge_stage || tape->merge_stage_size) {
- printk (KERN_ERR "ide-tape: merge_stage_size should be 0 now\n");
+ printk(KERN_ERR "ide-tape: merge_stage_size should be 0 now\n");
tape->merge_stage_size = 0;
}
#endif /* IDETAPE_DEBUG_BUGS */
- if ((tape->merge_stage = __idetape_kmalloc_stage (tape, 0, 0)) == NULL)
+ if ((tape->merge_stage = __idetape_kmalloc_stage(tape, 0, 0)) == NULL)
return -ENOMEM;
tape->chrdev_direction = idetape_direction_write;
- idetape_init_merge_stage (tape);
+ idetape_init_merge_stage(tape);
if (tape->onstream) {
position = idetape_read_position(drive);
@@ -4860,9 +5153,9 @@
* is switched from completion mode to buffer available
* mode.
*/
- retval = idetape_queue_rw_tail (drive, IDETAPE_WRITE_RQ, 0, tape->merge_stage->bh);
+ retval = idetape_queue_rw_tail(drive, IDETAPE_WRITE_RQ, 0, tape->merge_stage->bh);
if (retval < 0) {
- kfree (tape->merge_stage);
+ __idetape_kfree_stage(tape->merge_stage);
tape->merge_stage = NULL;
tape->chrdev_direction = idetape_direction_none;
return retval;
@@ -4879,35 +5172,35 @@
if (tape->merge_stage_size) {
#if IDETAPE_DEBUG_BUGS
if (tape->merge_stage_size >= tape->stage_size) {
- printk (KERN_ERR "ide-tape: bug: merge buffer too big\n");
+ printk(KERN_ERR "ide-tape: bug: merge buffer too big\n");
tape->merge_stage_size = 0;
}
#endif /* IDETAPE_DEBUG_BUGS */
- actually_written = IDE_MIN (tape->stage_size - tape->merge_stage_size, count);
- idetape_copy_stage_from_user (tape, tape->merge_stage, buf, actually_written);
+ actually_written = IDE_MIN(tape->stage_size - tape->merge_stage_size, count);
+ idetape_copy_stage_from_user(tape, tape->merge_stage, buf, actually_written);
buf += actually_written;
tape->merge_stage_size += actually_written;
count -= actually_written;
if (tape->merge_stage_size == tape->stage_size) {
tape->merge_stage_size = 0;
- retval = idetape_add_chrdev_write_request (drive, tape->capabilities.ctl);
+ retval = idetape_add_chrdev_write_request(drive, tape->capabilities.ctl);
if (retval <= 0)
return (retval);
}
}
while (count >= tape->stage_size) {
- idetape_copy_stage_from_user (tape, tape->merge_stage, buf, tape->stage_size);
+ idetape_copy_stage_from_user(tape, tape->merge_stage, buf, tape->stage_size);
buf += tape->stage_size;
count -= tape->stage_size;
- retval = idetape_add_chrdev_write_request (drive, tape->capabilities.ctl);
+ retval = idetape_add_chrdev_write_request(drive, tape->capabilities.ctl);
actually_written += tape->stage_size;
if (retval <= 0)
return (retval);
}
if (count) {
- actually_written+=count;
- idetape_copy_stage_from_user (tape, tape->merge_stage, buf, count);
+ actually_written += count;
+ idetape_copy_stage_from_user(tape, tape->merge_stage, buf, count);
tape->merge_stage_size += count;
}
return (actually_written);
@@ -4920,19 +5213,20 @@
idetape_pc_t pc;
if (!tape->onstream) {
- idetape_create_write_filemark_cmd(drive, &pc, 1); /* Write a filemark */
- if (idetape_queue_pc_tail (drive, &pc)) {
- printk (KERN_ERR "ide-tape: Couldn't write a filemark\n");
+ /* Write a filemark */
+ idetape_create_write_filemark_cmd(drive, &pc, 1);
+ if (idetape_queue_pc_tail(drive, &pc)) {
+ printk(KERN_ERR "ide-tape: Couldn't write a filemark\n");
return -EIO;
}
} else if (!tape->raw) {
last_mark_addr = idetape_read_position(drive);
- tape->merge_stage = __idetape_kmalloc_stage (tape, 1, 0);
+ tape->merge_stage = __idetape_kmalloc_stage(tape, 1, 0);
if (tape->merge_stage != NULL) {
idetape_init_stage(drive, tape->merge_stage, OS_FRAME_TYPE_MARKER, tape->logical_blk_num);
- idetape_pad_zeros (drive, tape->stage_size);
+ idetape_pad_zeros(drive, tape->stage_size);
tape->logical_blk_num++;
- __idetape_kfree_stage (tape->merge_stage);
+ __idetape_kfree_stage(tape->merge_stage);
tape->merge_stage = NULL;
}
if (tape->filemark_cnt)
@@ -4950,11 +5244,11 @@
if (!tape->onstream || tape->raw)
return;
- tape->merge_stage = __idetape_kmalloc_stage (tape, 1, 0);
+ tape->merge_stage = __idetape_kmalloc_stage(tape, 1, 0);
if (tape->merge_stage != NULL) {
tape->eod_frame_addr = idetape_read_position(drive);
idetape_init_stage(drive, tape->merge_stage, OS_FRAME_TYPE_EOD, tape->logical_blk_num);
- idetape_pad_zeros (drive, tape->stage_size);
+ idetape_pad_zeros(drive, tape->stage_size);
__idetape_kfree_stage (tape->merge_stage);
tape->merge_stage = NULL;
}
@@ -4989,7 +5283,9 @@
error:
tape->speed_control = speed_control;
tape->restart_speed_control_req = 1;
- printk(KERN_INFO "ide-tape: %s: couldn't seek to logical block %d (at %d), %d retries\n", tape->name, logical_blk_num, tape->logical_blk_num, retries);
+ printk(KERN_INFO "ide-tape: %s: couldn't seek to logical block %d "
+ "(at %d), %d retries\n", tape->name, logical_blk_num,
+ tape->logical_blk_num, retries);
return -EIO;
ok:
tape->speed_control = speed_control;
@@ -5068,7 +5364,8 @@
#if IDETAPE_DEBUG_LOG
if (tape->debug_level >= 1)
- printk (KERN_INFO "ide-tape: Handling MTIOCTOP ioctl: mt_op=%d, mt_count=%d\n",mt_op,mt_count);
+ printk(KERN_INFO "ide-tape: Handling MTIOCTOP "
+ "ioctl: mt_op=%d, mt_count=%d\n", mt_op, mt_count);
#endif /* IDETAPE_DEBUG_LOG */
/*
* Commands which need our pipelined read-ahead stages.
@@ -5080,41 +5377,41 @@
case MTBSFM:
if (!mt_count)
return (0);
- return (idetape_space_over_filemarks (drive,mt_op,mt_count));
+ return (idetape_space_over_filemarks(drive,mt_op,mt_count));
default:
break;
}
switch (mt_op) {
case MTWEOF:
- idetape_discard_read_pipeline (drive, 1);
+ idetape_discard_read_pipeline(drive, 1);
for (i = 0; i < mt_count; i++) {
retval = idetape_write_filemark(drive);
if (retval) return retval;
}
return (0);
case MTREW:
- idetape_discard_read_pipeline (drive, 0);
+ idetape_discard_read_pipeline(drive, 0);
if (idetape_rewind_tape(drive))
return -EIO;
if (tape->onstream && !tape->raw)
return idetape_position_tape(drive, OS_DATA_STARTFRAME1, 0, 0);
return 0;
case MTLOAD:
- idetape_discard_read_pipeline (drive, 0);
- idetape_create_load_unload_cmd (drive, &pc, IDETAPE_LU_LOAD_MASK);
- return (idetape_queue_pc_tail (drive, &pc));
+ idetape_discard_read_pipeline(drive, 0);
+ idetape_create_load_unload_cmd(drive, &pc, IDETAPE_LU_LOAD_MASK);
+ return (idetape_queue_pc_tail(drive, &pc));
case MTUNLOAD:
case MTOFFL:
- idetape_discard_read_pipeline (drive, 0);
- idetape_create_load_unload_cmd (drive, &pc,!IDETAPE_LU_LOAD_MASK);
- return (idetape_queue_pc_tail (drive, &pc));
+ idetape_discard_read_pipeline(drive, 0);
+ idetape_create_load_unload_cmd(drive, &pc,!IDETAPE_LU_LOAD_MASK);
+ return (idetape_queue_pc_tail(drive, &pc));
case MTNOP:
- idetape_discard_read_pipeline (drive, 0);
- return (idetape_flush_tape_buffers (drive));
+ idetape_discard_read_pipeline(drive, 0);
+ return (idetape_flush_tape_buffers(drive));
case MTRETEN:
- idetape_discard_read_pipeline (drive, 0);
- idetape_create_load_unload_cmd (drive, &pc,IDETAPE_LU_RETENSION_MASK | IDETAPE_LU_LOAD_MASK);
- return (idetape_queue_pc_tail (drive, &pc));
+ idetape_discard_read_pipeline(drive, 0);
+ idetape_create_load_unload_cmd(drive, &pc,IDETAPE_LU_RETENSION_MASK | IDETAPE_LU_LOAD_MASK);
+ return (idetape_queue_pc_tail(drive, &pc));
case MTEOM:
if (tape->onstream) {
#if ONSTREAM_DEBUG
@@ -5128,8 +5425,8 @@
return -EIO;
return 0;
}
- idetape_create_space_cmd (&pc, 0, IDETAPE_SPACE_TO_EOD);
- return (idetape_queue_pc_tail (drive, &pc));
+ idetape_create_space_cmd(&pc, 0, IDETAPE_SPACE_TO_EOD);
+ return (idetape_queue_pc_tail(drive, &pc));
case MTERASE:
if (tape->onstream) {
tape->eod_frame_addr = OS_DATA_STARTFRAME1;
@@ -5137,7 +5434,7 @@
tape->first_mark_addr = tape->last_mark_addr = -1;
idetape_position_tape(drive, tape->eod_frame_addr, 0, 0);
idetape_write_eod(drive);
- idetape_flush_tape_buffers (drive);
+ idetape_flush_tape_buffers(drive);
idetape_write_header(drive, 0);
/*
* write filler frames to the unused frames...
@@ -5145,13 +5442,13 @@
*/
idetape_write_filler(drive, OS_DATA_STARTFRAME1 - 10, 10);
idetape_write_filler(drive, OS_DATA_ENDFRAME1, 10);
- idetape_flush_tape_buffers (drive);
- (void) idetape_rewind_tape (drive);
+ idetape_flush_tape_buffers(drive);
+ (void) idetape_rewind_tape(drive);
return 0;
}
- (void) idetape_rewind_tape (drive);
- idetape_create_erase_cmd (&pc);
- return (idetape_queue_pc_tail (drive, &pc));
+ (void) idetape_rewind_tape(drive);
+ idetape_create_erase_cmd(&pc);
+ return (idetape_queue_pc_tail(drive, &pc));
case MTSETBLK:
if (tape->onstream) {
if (mt_count != tape->tape_block_size) {
@@ -5164,21 +5461,21 @@
if (mt_count < tape->tape_block_size || mt_count % tape->tape_block_size)
return -EIO;
tape->user_bs_factor = mt_count / tape->tape_block_size;
- clear_bit (IDETAPE_DETECT_BS, &tape->flags);
+ clear_bit(IDETAPE_DETECT_BS, &tape->flags);
} else
- set_bit (IDETAPE_DETECT_BS, &tape->flags);
+ set_bit(IDETAPE_DETECT_BS, &tape->flags);
return 0;
case MTSEEK:
if (!tape->onstream || tape->raw) {
- idetape_discard_read_pipeline (drive, 0);
- return idetape_position_tape (drive, mt_count * tape->user_bs_factor, tape->partition, 0);
+ idetape_discard_read_pipeline(drive, 0);
+ return idetape_position_tape(drive, mt_count * tape->user_bs_factor, tape->partition, 0);
}
return idetape_seek_logical_blk(drive, mt_count);
case MTSETPART:
- idetape_discard_read_pipeline (drive, 0);
+ idetape_discard_read_pipeline(drive, 0);
if (tape->onstream)
return -EIO;
- return (idetape_position_tape (drive, 0, mt_count, 0));
+ return (idetape_position_tape(drive, 0, mt_count, 0));
case MTFSR:
case MTBSR:
if (tape->onstream) {
@@ -5187,26 +5484,26 @@
if (mt_op == MTFSR)
return idetape_seek_logical_blk(drive, tape->logical_blk_num + mt_count);
else {
- idetape_discard_read_pipeline (drive, 0);
+ idetape_discard_read_pipeline(drive, 0);
return idetape_seek_logical_blk(drive, tape->logical_blk_num - mt_count);
}
}
case MTLOCK:
if (!idetape_create_prevent_cmd(drive, &pc, 1))
return 0;
- retval = idetape_queue_pc_tail (drive, &pc);
+ retval = idetape_queue_pc_tail(drive, &pc);
if (retval) return retval;
tape->door_locked = DOOR_EXPLICITLY_LOCKED;
return 0;
case MTUNLOCK:
if (!idetape_create_prevent_cmd(drive, &pc, 0))
return 0;
- retval = idetape_queue_pc_tail (drive, &pc);
+ retval = idetape_queue_pc_tail(drive, &pc);
if (retval) return retval;
tape->door_locked = DOOR_UNLOCKED;
return 0;
default:
- printk (KERN_ERR "ide-tape: MTIO operation %d not supported\n",mt_op);
+ printk(KERN_ERR "ide-tape: MTIO operation %d not supported\n",mt_op);
return (-EIO);
}
}
@@ -5236,7 +5533,7 @@
*/
static int idetape_chrdev_ioctl (struct inode *inode, struct file *file, unsigned int cmd, unsigned long arg)
{
- ide_drive_t *drive = get_drive_ptr (inode->i_rdev);
+ ide_drive_t *drive = get_drive_ptr(inode->i_rdev);
idetape_tape_t *tape = drive->driver_data;
struct mtop mtop;
struct mtget mtget;
@@ -5245,30 +5542,30 @@
#if IDETAPE_DEBUG_LOG
if (tape->debug_level >= 3)
- printk (KERN_INFO "ide-tape: Reached idetape_chrdev_ioctl, cmd=%u\n",cmd);
+ printk(KERN_INFO "ide-tape: Reached idetape_chrdev_ioctl, cmd=%u\n",cmd);
#endif /* IDETAPE_DEBUG_LOG */
tape->restart_speed_control_req = 1;
if (tape->chrdev_direction == idetape_direction_write) {
- idetape_empty_write_pipeline (drive);
- idetape_flush_tape_buffers (drive);
+ idetape_empty_write_pipeline(drive);
+ idetape_flush_tape_buffers(drive);
}
if (cmd == MTIOCGET || cmd == MTIOCPOS) {
- block_offset = idetape_pipeline_size (drive) / (tape->tape_block_size * tape->user_bs_factor);
+ block_offset = idetape_pipeline_size(drive) / (tape->tape_block_size * tape->user_bs_factor);
if ((position = idetape_read_position(drive)) < 0)
return -EIO;
}
switch (cmd) {
case MTIOCTOP:
- if (copy_from_user ((char *) &mtop, (char *) arg, sizeof (struct mtop)))
+ if (copy_from_user((char *) &mtop, (char *) arg, sizeof (struct mtop)))
return -EFAULT;
- return (idetape_mtioctop (drive,mtop.mt_op,mtop.mt_count));
+ return (idetape_mtioctop(drive,mtop.mt_op,mtop.mt_count));
case MTIOCGET:
- memset (&mtget, 0, sizeof (struct mtget));
+ memset(&mtget, 0, sizeof (struct mtget));
mtget.mt_type = MT_ISSCSI2;
- if (!tape->onstream || tape->raw)
+ if (!tape->onstream || tape->raw) {
mtget.mt_blkno = position / tape->user_bs_factor - block_offset;
- else {
+ } else {
if (!idetape_get_logical_blk(drive, -1, 10, 0))
mtget.mt_blkno = -1;
else
@@ -5297,8 +5594,8 @@
return 0;
default:
if (tape->chrdev_direction == idetape_direction_read)
- idetape_discard_read_pipeline (drive, 1);
- return (idetape_blkdev_ioctl (drive,inode,file,cmd,arg));
+ idetape_discard_read_pipeline(drive, 1);
+ return (idetape_blkdev_ioctl(drive,inode,file,cmd,arg));
}
}
@@ -5318,7 +5615,7 @@
tape->wrt_pass_cntr = 0;
tape->eod_frame_addr = OS_DATA_STARTFRAME1;
tape->first_mark_addr = tape->last_mark_addr = -1;
- stage = __idetape_kmalloc_stage (tape, 0, 0);
+ stage = __idetape_kmalloc_stage(tape, 0, 0);
if (stage == NULL)
return 0;
#if ONSTREAM_DEBUG
@@ -5326,16 +5623,17 @@
printk(KERN_INFO "ide-tape: %s: reading header\n", tape->name);
#endif
idetape_position_tape(drive, block, 0, 0);
- if (!idetape_queue_rw_tail (drive, IDETAPE_READ_RQ, 1, stage->bh)) {
- printk(KERN_INFO "ide-tape: %s: couldn't read header frame\n", tape->name);
- __idetape_kfree_stage (stage);
+ if (!idetape_queue_rw_tail(drive, IDETAPE_READ_RQ, 1, stage->bh)) {
+ printk(KERN_INFO "ide-tape: %s: couldn't read header frame\n",
+ tape->name);
+ __idetape_kfree_stage(stage);
return 0;
}
header = (os_header_t *) stage->bh->b_data;
aux = stage->aux;
if (strncmp(header->ident_str, "ADR_SEQ", 7) != 0) {
printk(KERN_INFO "ide-tape: %s: invalid header identification string\n", tape->name);
- __idetape_kfree_stage (stage);
+ __idetape_kfree_stage(stage);
return 0;
}
if (header->major_rev != 1 || (header->minor_rev > OS_ADR_MINREV))
@@ -5354,17 +5652,21 @@
tape->linux_media = 1;
tape->linux_media_version = tape->application_sig[3] - '0';
if (tape->linux_media_version != 3)
- printk(KERN_INFO "ide-tape: %s: Linux media version %d detected (current 3)\n",
- tape->name, tape->linux_media_version);
+ printk(KERN_INFO "ide-tape: %s: Linux media version "
+ "%d detected (current 3)\n",
+ tape->name, tape->linux_media_version);
} else {
- printk(KERN_INFO "ide-tape: %s: non Linux media detected (%s)\n", tape->name, tape->application_sig);
+ printk(KERN_INFO "ide-tape: %s: non Linux media detected "
+ "(%s)\n", tape->name, tape->application_sig);
tape->linux_media = 0;
}
#if ONSTREAM_DEBUG
if (tape->debug_level >= 2)
- printk(KERN_INFO "ide-tape: %s: detected write pass counter %d, eod frame addr %d\n", tape->name, tape->wrt_pass_cntr, tape->eod_frame_addr);
+ printk(KERN_INFO "ide-tape: %s: detected write pass "
+ "counter %d, eod frame addr %d\n", tape->name,
+ tape->wrt_pass_cntr, tape->eod_frame_addr);
#endif
- __idetape_kfree_stage (stage);
+ __idetape_kfree_stage(stage);
return 1;
}
@@ -5385,7 +5687,8 @@
for (block = 0xbae; block < 0xbb3; block++) /* 2990 - 2994 */
if (__idetape_analyze_headers(drive, block))
goto ok;
- printk(KERN_ERR "ide-tape: %s: failed to find valid ADRL header\n", tape->name);
+ printk(KERN_ERR "ide-tape: %s: failed to find valid ADRL header\n",
+ tape->name);
return 0;
ok:
if (position < OS_DATA_STARTFRAME1)
@@ -5403,23 +5706,23 @@
ide_drive_t *drive;
idetape_tape_t *tape;
idetape_pc_t pc;
- unsigned int minor=MINOR (inode->i_rdev);
+ unsigned int minor = MINOR(inode->i_rdev);
#if IDETAPE_DEBUG_LOG
printk (KERN_INFO "ide-tape: Reached idetape_chrdev_open\n");
#endif /* IDETAPE_DEBUG_LOG */
- if ((drive = get_drive_ptr (inode->i_rdev)) == NULL)
+ if ((drive = get_drive_ptr(inode->i_rdev)) == NULL)
return -ENXIO;
tape = drive->driver_data;
- if (test_and_set_bit (IDETAPE_BUSY, &tape->flags))
+ if (test_and_set_bit(IDETAPE_BUSY, &tape->flags))
return -EBUSY;
MOD_INC_USE_COUNT;
if (!tape->onstream) {
idetape_read_position(drive);
- if (!test_bit (IDETAPE_ADDRESS_VALID, &tape->flags))
- (void) idetape_rewind_tape (drive);
+ if (!test_bit(IDETAPE_ADDRESS_VALID, &tape->flags))
+ (void) idetape_rewind_tape(drive);
} else {
if (minor & 64) {
tape->tape_block_size = tape->stage_size = 32768 + 512;
@@ -5436,14 +5739,16 @@
MOD_DEC_USE_COUNT;
return -EBUSY;
}
- idetape_read_position(drive);
+ if (tape->onstream)
+ idetape_read_position(drive);
MOD_DEC_USE_COUNT;
- clear_bit (IDETAPE_PIPELINE_ERROR, &tape->flags);
+ if (tape->chrdev_direction != idetape_direction_read)
+ clear_bit(IDETAPE_PIPELINE_ERROR, &tape->flags);
if (tape->chrdev_direction == idetape_direction_none) {
MOD_INC_USE_COUNT;
if (idetape_create_prevent_cmd(drive, &pc, 1)) {
- if (!idetape_queue_pc_tail (drive, &pc)) {
+ if (!idetape_queue_pc_tail(drive, &pc)) {
if (tape->door_locked != DOOR_EXPLICITLY_LOCKED)
tape->door_locked = DOOR_LOCKED;
}
@@ -5458,22 +5763,22 @@
static void idetape_write_release (struct inode *inode)
{
- ide_drive_t *drive = get_drive_ptr (inode->i_rdev);
+ ide_drive_t *drive = get_drive_ptr(inode->i_rdev);
idetape_tape_t *tape = drive->driver_data;
- unsigned int minor=MINOR (inode->i_rdev);
+ unsigned int minor = MINOR(inode->i_rdev);
- idetape_empty_write_pipeline (drive);
- tape->merge_stage = __idetape_kmalloc_stage (tape, 1, 0);
+ idetape_empty_write_pipeline(drive);
+ tape->merge_stage = __idetape_kmalloc_stage(tape, 1, 0);
if (tape->merge_stage != NULL) {
- idetape_pad_zeros (drive, tape->tape_block_size * (tape->user_bs_factor - 1));
- __idetape_kfree_stage (tape->merge_stage);
+ idetape_pad_zeros(drive, tape->tape_block_size * (tape->user_bs_factor - 1));
+ __idetape_kfree_stage(tape->merge_stage);
tape->merge_stage = NULL;
}
idetape_write_filemark(drive);
idetape_write_eod(drive);
- idetape_flush_tape_buffers (drive);
+ idetape_flush_tape_buffers(drive);
idetape_write_header(drive, minor >= 128);
- idetape_flush_tape_buffers (drive);
+ idetape_flush_tape_buffers(drive);
return;
}
@@ -5483,16 +5788,16 @@
*/
static int idetape_chrdev_release (struct inode *inode, struct file *filp)
{
- ide_drive_t *drive = get_drive_ptr (inode->i_rdev);
+ ide_drive_t *drive = get_drive_ptr(inode->i_rdev);
idetape_tape_t *tape;
idetape_pc_t pc;
- unsigned int minor=MINOR (inode->i_rdev);
+ unsigned int minor = MINOR(inode->i_rdev);
lock_kernel();
tape = drive->driver_data;
#if IDETAPE_DEBUG_LOG
if (tape->debug_level >= 3)
- printk (KERN_INFO "ide-tape: Reached idetape_chrdev_release\n");
+ printk(KERN_INFO "ide-tape: Reached idetape_chrdev_release\n");
#endif /* IDETAPE_DEBUG_LOG */
if (tape->chrdev_direction == idetape_direction_write) {
@@ -5500,25 +5805,26 @@
}
if (tape->chrdev_direction == idetape_direction_read) {
if (minor < 128)
- idetape_discard_read_pipeline (drive, 1);
+ idetape_discard_read_pipeline(drive, 1);
else
- idetape_wait_for_pipeline (drive);
+ idetape_wait_for_pipeline(drive);
}
if (tape->cache_stage != NULL) {
- __idetape_kfree_stage (tape->cache_stage);
+ __idetape_kfree_stage(tape->cache_stage);
tape->cache_stage = NULL;
}
if (minor < 128)
- (void) idetape_rewind_tape (drive);
+ (void) idetape_rewind_tape(drive);
if (tape->chrdev_direction == idetape_direction_none) {
- if (tape->door_locked != DOOR_EXPLICITLY_LOCKED) {
- if (idetape_create_prevent_cmd(drive, &pc, 0))
- if (!idetape_queue_pc_tail (drive, &pc))
+ if (tape->door_locked == DOOR_LOCKED) {
+ if (idetape_create_prevent_cmd(drive, &pc, 0)) {
+ if (!idetape_queue_pc_tail(drive, &pc))
tape->door_locked = DOOR_UNLOCKED;
+ }
}
MOD_DEC_USE_COUNT;
}
- clear_bit (IDETAPE_BUSY, &tape->flags);
+ clear_bit(IDETAPE_BUSY, &tape->flags);
unlock_kernel();
return 0;
}
@@ -5532,120 +5838,121 @@
*
* 0 If this tape driver is not currently supported by us.
*/
-static int idetape_identify_device (ide_drive_t *drive,struct hd_driveid *id)
+static int idetape_identify_device (ide_drive_t *drive)
{
struct idetape_id_gcw gcw;
+ struct hd_driveid *id = drive->id;
#if IDETAPE_DEBUG_INFO
unsigned short mask,i;
#endif /* IDETAPE_DEBUG_INFO */
- if (!id)
- return 0;
+ if(drive->id_read == 0)
+ return 1;
*((unsigned short *) &gcw) = id->config;
#if IDETAPE_DEBUG_INFO
- printk (KERN_INFO "ide-tape: Dumping ATAPI Identify Device tape parameters\n");
- printk (KERN_INFO "ide-tape: Protocol Type: ");
+ printk(KERN_INFO "ide-tape: Dumping ATAPI Identify Device tape parameters\n");
+ printk(KERN_INFO "ide-tape: Protocol Type: ");
switch (gcw.protocol) {
- case 0: case 1: printk (KERN_INFO "ATA\n");break;
- case 2: printk (KERN_INFO "ATAPI\n");break;
- case 3: printk (KERN_INFO "Reserved (Unknown to ide-tape)\n");break;
+ case 0: case 1: printk("ATA\n");break;
+ case 2: printk("ATAPI\n");break;
+ case 3: printk("Reserved (Unknown to ide-tape)\n");break;
}
- printk (KERN_INFO "ide-tape: Device Type: %x - ",gcw.device_type);
+ printk(KERN_INFO "ide-tape: Device Type: %x - ",gcw.device_type);
switch (gcw.device_type) {
- case 0: printk (KERN_INFO "Direct-access Device\n");break;
- case 1: printk (KERN_INFO "Streaming Tape Device\n");break;
- case 2: case 3: case 4: printk (KERN_INFO "Reserved\n");break;
- case 5: printk (KERN_INFO "CD-ROM Device\n");break;
- case 6: printk (KERN_INFO "Reserved\n");
- case 7: printk (KERN_INFO "Optical memory Device\n");break;
- case 0x1f: printk (KERN_INFO "Unknown or no Device type\n");break;
- default: printk (KERN_INFO "Reserved\n");
+ case 0: printk("Direct-access Device\n");break;
+ case 1: printk("Streaming Tape Device\n");break;
+ case 2: case 3: case 4: printk("Reserved\n");break;
+ case 5: printk("CD-ROM Device\n");break;
+ case 6: printk("Reserved\n");
+ case 7: printk("Optical memory Device\n");break;
+ case 0x1f: printk("Unknown or no Device type\n");break;
+ default: printk("Reserved\n");
}
- printk (KERN_INFO "ide-tape: Removable: %s",gcw.removable ? "Yes\n":"No\n");
- printk (KERN_INFO "ide-tape: Command Packet DRQ Type: ");
+ printk(KERN_INFO "ide-tape: Removable: %s",gcw.removable ? "Yes\n":"No\n");
+ printk(KERN_INFO "ide-tape: Command Packet DRQ Type: ");
switch (gcw.drq_type) {
- case 0: printk (KERN_INFO "Microprocessor DRQ\n");break;
- case 1: printk (KERN_INFO "Interrupt DRQ\n");break;
- case 2: printk (KERN_INFO "Accelerated DRQ\n");break;
- case 3: printk (KERN_INFO "Reserved\n");break;
+ case 0: printk("Microprocessor DRQ\n");break;
+ case 1: printk("Interrupt DRQ\n");break;
+ case 2: printk("Accelerated DRQ\n");break;
+ case 3: printk("Reserved\n");break;
}
- printk (KERN_INFO "ide-tape: Command Packet Size: ");
+ printk(KERN_INFO "ide-tape: Command Packet Size: ");
switch (gcw.packet_size) {
- case 0: printk (KERN_INFO "12 bytes\n");break;
- case 1: printk (KERN_INFO "16 bytes\n");break;
- default: printk (KERN_INFO "Reserved\n");break;
- }
- printk (KERN_INFO "ide-tape: Model: %.40s\n",id->model);
- printk (KERN_INFO "ide-tape: Firmware Revision: %.8s\n",id->fw_rev);
- printk (KERN_INFO "ide-tape: Serial Number: %.20s\n",id->serial_no);
- printk (KERN_INFO "ide-tape: Write buffer size: %d bytes\n",id->buf_size*512);
- printk (KERN_INFO "ide-tape: DMA: %s",id->capability & 0x01 ? "Yes\n":"No\n");
- printk (KERN_INFO "ide-tape: LBA: %s",id->capability & 0x02 ? "Yes\n":"No\n");
- printk (KERN_INFO "ide-tape: IORDY can be disabled: %s",id->capability & 0x04 ? "Yes\n":"No\n");
- printk (KERN_INFO "ide-tape: IORDY supported: %s",id->capability & 0x08 ? "Yes\n":"Unknown\n");
- printk (KERN_INFO "ide-tape: ATAPI overlap supported: %s",id->capability & 0x20 ? "Yes\n":"No\n");
- printk (KERN_INFO "ide-tape: PIO Cycle Timing Category: %d\n",id->tPIO);
- printk (KERN_INFO "ide-tape: DMA Cycle Timing Category: %d\n",id->tDMA);
- printk (KERN_INFO "ide-tape: Single Word DMA supported modes: ");
+ case 0: printk("12 bytes\n");break;
+ case 1: printk("16 bytes\n");break;
+ default: printk("Reserved\n");break;
+ }
+ printk(KERN_INFO "ide-tape: Model: %.40s\n",id->model);
+ printk(KERN_INFO "ide-tape: Firmware Revision: %.8s\n",id->fw_rev);
+ printk(KERN_INFO "ide-tape: Serial Number: %.20s\n",id->serial_no);
+ printk(KERN_INFO "ide-tape: Write buffer size: %d bytes\n",id->buf_size*512);
+ printk(KERN_INFO "ide-tape: DMA: %s",id->capability & 0x01 ? "Yes\n":"No\n");
+ printk(KERN_INFO "ide-tape: LBA: %s",id->capability & 0x02 ? "Yes\n":"No\n");
+ printk(KERN_INFO "ide-tape: IORDY can be disabled: %s",id->capability & 0x04 ? "Yes\n":"No\n");
+ printk(KERN_INFO "ide-tape: IORDY supported: %s",id->capability & 0x08 ? "Yes\n":"Unknown\n");
+ printk(KERN_INFO "ide-tape: ATAPI overlap supported: %s",id->capability & 0x20 ? "Yes\n":"No\n");
+ printk(KERN_INFO "ide-tape: PIO Cycle Timing Category: %d\n",id->tPIO);
+ printk(KERN_INFO "ide-tape: DMA Cycle Timing Category: %d\n",id->tDMA);
+ printk(KERN_INFO "ide-tape: Single Word DMA supported modes: ");
for (i=0,mask=1;i<8;i++,mask=mask << 1) {
if (id->dma_1word & mask)
- printk (KERN_INFO "%d ",i);
+ printk("%d ",i);
if (id->dma_1word & (mask << 8))
- printk (KERN_INFO "(active) ");
+ printk("(active) ");
}
- printk (KERN_INFO "\n");
- printk (KERN_INFO "ide-tape: Multi Word DMA supported modes: ");
+ printk("\n");
+ printk(KERN_INFO "ide-tape: Multi Word DMA supported modes: ");
for (i=0,mask=1;i<8;i++,mask=mask << 1) {
if (id->dma_mword & mask)
- printk (KERN_INFO "%d ",i);
+ printk("%d ",i);
if (id->dma_mword & (mask << 8))
- printk (KERN_INFO "(active) ");
+ printk("(active) ");
}
- printk (KERN_INFO "\n");
+ printk("\n");
if (id->field_valid & 0x0002) {
- printk (KERN_INFO "ide-tape: Enhanced PIO Modes: %s\n",id->eide_pio_modes & 1 ? "Mode 3":"None");
- printk (KERN_INFO "ide-tape: Minimum Multi-word DMA cycle per word: ");
+ printk(KERN_INFO "ide-tape: Enhanced PIO Modes: %s\n",id->eide_pio_modes & 1 ? "Mode 3":"None");
+ printk(KERN_INFO "ide-tape: Minimum Multi-word DMA cycle per word: ");
if (id->eide_dma_min == 0)
- printk (KERN_INFO "Not supported\n");
+ printk("Not supported\n");
else
- printk (KERN_INFO "%d ns\n",id->eide_dma_min);
+ printk("%d ns\n",id->eide_dma_min);
- printk (KERN_INFO "ide-tape: Manufacturer\'s Recommended Multi-word cycle: ");
+ printk(KERN_INFO "ide-tape: Manufacturer\'s Recommended Multi-word cycle: ");
if (id->eide_dma_time == 0)
- printk (KERN_INFO "Not supported\n");
+ printk("Not supported\n");
else
- printk (KERN_INFO "%d ns\n",id->eide_dma_time);
+ printk("%d ns\n",id->eide_dma_time);
- printk (KERN_INFO "ide-tape: Minimum PIO cycle without IORDY: ");
+ printk(KERN_INFO "ide-tape: Minimum PIO cycle without IORDY: ");
if (id->eide_pio == 0)
- printk (KERN_INFO "Not supported\n");
+ printk("Not supported\n");
else
- printk (KERN_INFO "%d ns\n",id->eide_pio);
+ printk("%d ns\n",id->eide_pio);
- printk (KERN_INFO "ide-tape: Minimum PIO cycle with IORDY: ");
+ printk(KERN_INFO "ide-tape: Minimum PIO cycle with IORDY: ");
if (id->eide_pio_iordy == 0)
- printk (KERN_INFO "Not supported\n");
+ printk("Not supported\n");
else
- printk (KERN_INFO "%d ns\n",id->eide_pio_iordy);
+ printk("%d ns\n",id->eide_pio_iordy);
} else
- printk (KERN_INFO "ide-tape: According to the device, fields 64-70 are not valid.\n");
+ printk(KERN_INFO "ide-tape: According to the device, fields 64-70 are not valid.\n");
#endif /* IDETAPE_DEBUG_INFO */
/* Check that we can support this device */
if (gcw.protocol !=2 )
- printk (KERN_ERR "ide-tape: Protocol is not ATAPI\n");
+ printk(KERN_ERR "ide-tape: Protocol is not ATAPI\n");
else if (gcw.device_type != 1)
- printk (KERN_ERR "ide-tape: Device type is not set to tape\n");
+ printk(KERN_ERR "ide-tape: Device type is not set to tape\n");
else if (!gcw.removable)
- printk (KERN_ERR "ide-tape: The removable flag is not set\n");
+ printk(KERN_ERR "ide-tape: The removable flag is not set\n");
else if (gcw.packet_size != 0) {
- printk (KERN_ERR "ide-tape: Packet size is not 12 bytes long\n");
+ printk(KERN_ERR "ide-tape: Packet size is not 12 bytes long\n");
if (gcw.packet_size == 1)
- printk (KERN_ERR "ide-tape: Sorry, padding to 16 bytes is still not supported\n");
+ printk(KERN_ERR "ide-tape: Sorry, padding to 16 bytes is still not supported\n");
} else
return 1;
return 0;
@@ -5672,8 +5979,8 @@
pc.buffer[4 + 5] = vendor[3];
pc.buffer[4 + 6] = 0;
pc.buffer[4 + 7] = 0;
- if (idetape_queue_pc_tail (drive, &pc))
- printk (KERN_ERR "ide-tape: Couldn't set vendor name to %s\n", vendor);
+ if (idetape_queue_pc_tail(drive, &pc))
+ printk(KERN_ERR "ide-tape: Couldn't set vendor name to %s\n", vendor);
}
@@ -5694,8 +6001,8 @@
pc.buffer[4 + 1] = 2;
pc.buffer[4 + 2] = 4;
pc.buffer[4 + 3] = retries;
- if (idetape_queue_pc_tail (drive, &pc))
- printk (KERN_ERR "ide-tape: Couldn't set retries to %d\n", retries);
+ if (idetape_queue_pc_tail(drive, &pc))
+ printk(KERN_ERR "ide-tape: Couldn't set retries to %d\n", retries);
}
#endif
@@ -5711,9 +6018,9 @@
/*
* Get the current block size from the block size mode page
*/
- idetape_create_mode_sense_cmd (&pc, IDETAPE_BLOCK_SIZE_PAGE);
- if (idetape_queue_pc_tail (drive, &pc))
- printk (KERN_ERR "ide-tape: can't get tape block size mode page\n");
+ idetape_create_mode_sense_cmd(&pc, IDETAPE_BLOCK_SIZE_PAGE);
+ if (idetape_queue_pc_tail(drive, &pc))
+ printk(KERN_ERR "ide-tape: can't get tape block size mode page\n");
header = (idetape_mode_parameter_header_t *) pc.buffer;
bs = (idetape_block_size_page_t *) (pc.buffer + sizeof(idetape_mode_parameter_header_t) + header->bdl);
@@ -5733,8 +6040,8 @@
bs->record32 = 0;
bs->record32_5 = 1;
idetape_create_mode_select_cmd(&pc, sizeof(*header) + sizeof(*bs));
- if (idetape_queue_pc_tail (drive, &pc))
- printk (KERN_ERR "ide-tape: Couldn't set tape block size mode page\n");
+ if (idetape_queue_pc_tail(drive, &pc))
+ printk(KERN_ERR "ide-tape: Couldn't set tape block size mode page\n");
#if ONSTREAM_DEBUG
/*
@@ -5756,8 +6063,8 @@
idetape_inquiry_result_t *inquiry;
idetape_create_inquiry_cmd(&pc);
- if (idetape_queue_pc_tail (drive, &pc)) {
- printk (KERN_ERR "ide-tape: %s: can't get INQUIRY results\n", tape->name);
+ if (idetape_queue_pc_tail(drive, &pc)) {
+ printk(KERN_ERR "ide-tape: %s: can't get INQUIRY results\n", tape->name);
return;
}
inquiry = (idetape_inquiry_result_t *) pc.buffer;
@@ -5809,9 +6116,9 @@
idetape_mode_parameter_header_t *header;
onstream_tape_paramtr_page_t *prm;
- idetape_create_mode_sense_cmd (&pc, IDETAPE_PARAMTR_PAGE);
- if (idetape_queue_pc_tail (drive, &pc)) {
- printk (KERN_ERR "ide-tape: Can't get tape parameters page - probably no tape inserted in onstream drive\n");
+ idetape_create_mode_sense_cmd(&pc, IDETAPE_PARAMTR_PAGE);
+ if (idetape_queue_pc_tail(drive, &pc)) {
+ printk(KERN_ERR "ide-tape: Can't get tape parameters page - probably no tape inserted in onstream drive\n");
return;
}
header = (idetape_mode_parameter_header_t *) pc.buffer;
@@ -5819,7 +6126,7 @@
tape->capacity = ntohs(prm->segtrk) * ntohs(prm->trks);
if (debug) {
- printk (KERN_INFO "ide-tape: %s <-> %s: Tape length %dMB (%d frames/track, %d tracks = %d blocks, density: %dKbpi)\n",
+ printk(KERN_INFO "ide-tape: %s <-> %s: Tape length %dMB (%d frames/track, %d tracks = %d blocks, density: %dKbpi)\n",
drive->name, tape->name, tape->capacity/32, ntohs(prm->segtrk), ntohs(prm->trks), tape->capacity, prm->density);
}
@@ -5838,20 +6145,22 @@
idetape_mode_parameter_header_t *header;
idetape_capabilities_page_t *capabilities;
- idetape_create_mode_sense_cmd (&pc, IDETAPE_CAPABILITIES_PAGE);
+ idetape_create_mode_sense_cmd(&pc, IDETAPE_CAPABILITIES_PAGE);
if (idetape_queue_pc_tail (drive, &pc)) {
- printk (KERN_ERR "ide-tape: Can't get tape parameters - assuming some default values\n");
- tape->tape_block_size = 512; tape->capabilities.ctl = 52;
- tape->capabilities.speed = 450; tape->capabilities.buffer_size = 6 * 52;
+ printk(KERN_ERR "ide-tape: Can't get tape parameters - assuming some default values\n");
+ tape->tape_block_size = 512;
+ tape->capabilities.ctl = 52;
+ tape->capabilities.speed = 450;
+ tape->capabilities.buffer_size = 6 * 52;
return;
}
header = (idetape_mode_parameter_header_t *) pc.buffer;
capabilities = (idetape_capabilities_page_t *) (pc.buffer + sizeof(idetape_mode_parameter_header_t) + header->bdl);
- capabilities->max_speed = ntohs (capabilities->max_speed);
- capabilities->ctl = ntohs (capabilities->ctl);
- capabilities->speed = ntohs (capabilities->speed);
- capabilities->buffer_size = ntohs (capabilities->buffer_size);
+ capabilities->max_speed = ntohs(capabilities->max_speed);
+ capabilities->ctl = ntohs(capabilities->ctl);
+ capabilities->speed = ntohs(capabilities->speed);
+ capabilities->buffer_size = ntohs(capabilities->buffer_size);
if (!capabilities->speed) {
printk(KERN_INFO "ide-tape: %s: overriding capabilities->speed (assuming 650KB/sec)\n", drive->name);
@@ -5861,6 +6170,10 @@
printk(KERN_INFO "ide-tape: %s: overriding capabilities->max_speed (assuming 650KB/sec)\n", drive->name);
capabilities->max_speed = 650;
}
+ if (!capabilities->ctl) {
+ printk(KERN_INFO "ide-tape: %s: overriding capabilities->ctl (assuming 26KB)\n", drive->name);
+ capabilities->ctl = 52;
+ }
tape->capabilities = *capabilities; /* Save us a copy */
if (capabilities->blk512)
@@ -5871,33 +6184,33 @@
tape->tape_block_size = 32768;
#if IDETAPE_DEBUG_INFO
- printk (KERN_INFO "ide-tape: Dumping the results of the MODE SENSE packet command\n");
- printk (KERN_INFO "ide-tape: Mode Parameter Header:\n");
- printk (KERN_INFO "ide-tape: Mode Data Length - %d\n",header->mode_data_length);
- printk (KERN_INFO "ide-tape: Medium Type - %d\n",header->medium_type);
- printk (KERN_INFO "ide-tape: Device Specific Parameter - %d\n",header->dsp);
- printk (KERN_INFO "ide-tape: Block Descriptor Length - %d\n",header->bdl);
+ printk(KERN_INFO "ide-tape: Dumping the results of the MODE SENSE packet command\n");
+ printk(KERN_INFO "ide-tape: Mode Parameter Header:\n");
+ printk(KERN_INFO "ide-tape: Mode Data Length - %d\n",header->mode_data_length);
+ printk(KERN_INFO "ide-tape: Medium Type - %d\n",header->medium_type);
+ printk(KERN_INFO "ide-tape: Device Specific Parameter - %d\n",header->dsp);
+ printk(KERN_INFO "ide-tape: Block Descriptor Length - %d\n",header->bdl);
- printk (KERN_INFO "ide-tape: Capabilities and Mechanical Status Page:\n");
- printk (KERN_INFO "ide-tape: Page code - %d\n",capabilities->page_code);
- printk (KERN_INFO "ide-tape: Page length - %d\n",capabilities->page_length);
- printk (KERN_INFO "ide-tape: Read only - %s\n",capabilities->ro ? "Yes":"No");
- printk (KERN_INFO "ide-tape: Supports reverse space - %s\n",capabilities->sprev ? "Yes":"No");
- printk (KERN_INFO "ide-tape: Supports erase initiated formatting - %s\n",capabilities->efmt ? "Yes":"No");
- printk (KERN_INFO "ide-tape: Supports QFA two Partition format - %s\n",capabilities->qfa ? "Yes":"No");
- printk (KERN_INFO "ide-tape: Supports locking the medium - %s\n",capabilities->lock ? "Yes":"No");
- printk (KERN_INFO "ide-tape: The volume is currently locked - %s\n",capabilities->locked ? "Yes":"No");
- printk (KERN_INFO "ide-tape: The device defaults in the prevent state - %s\n",capabilities->prevent ? "Yes":"No");
- printk (KERN_INFO "ide-tape: Supports ejecting the medium - %s\n",capabilities->eject ? "Yes":"No");
- printk (KERN_INFO "ide-tape: Supports error correction - %s\n",capabilities->ecc ? "Yes":"No");
- printk (KERN_INFO "ide-tape: Supports data compression - %s\n",capabilities->cmprs ? "Yes":"No");
- printk (KERN_INFO "ide-tape: Supports 512 bytes block size - %s\n",capabilities->blk512 ? "Yes":"No");
- printk (KERN_INFO "ide-tape: Supports 1024 bytes block size - %s\n",capabilities->blk1024 ? "Yes":"No");
- printk (KERN_INFO "ide-tape: Supports 32768 bytes block size / Restricted byte count for PIO transfers - %s\n",capabilities->blk32768 ? "Yes":"No");
- printk (KERN_INFO "ide-tape: Maximum supported speed in KBps - %d\n",capabilities->max_speed);
- printk (KERN_INFO "ide-tape: Continuous transfer limits in blocks - %d\n",capabilities->ctl);
- printk (KERN_INFO "ide-tape: Current speed in KBps - %d\n",capabilities->speed);
- printk (KERN_INFO "ide-tape: Buffer size - %d\n",capabilities->buffer_size*512);
+ printk(KERN_INFO "ide-tape: Capabilities and Mechanical Status Page:\n");
+ printk(KERN_INFO "ide-tape: Page code - %d\n",capabilities->page_code);
+ printk(KERN_INFO "ide-tape: Page length - %d\n",capabilities->page_length);
+ printk(KERN_INFO "ide-tape: Read only - %s\n",capabilities->ro ? "Yes":"No");
+ printk(KERN_INFO "ide-tape: Supports reverse space - %s\n",capabilities->sprev ? "Yes":"No");
+ printk(KERN_INFO "ide-tape: Supports erase initiated formatting - %s\n",capabilities->efmt ? "Yes":"No");
+ printk(KERN_INFO "ide-tape: Supports QFA two Partition format - %s\n",capabilities->qfa ? "Yes":"No");
+ printk(KERN_INFO "ide-tape: Supports locking the medium - %s\n",capabilities->lock ? "Yes":"No");
+ printk(KERN_INFO "ide-tape: The volume is currently locked - %s\n",capabilities->locked ? "Yes":"No");
+ printk(KERN_INFO "ide-tape: The device defaults in the prevent state - %s\n",capabilities->prevent ? "Yes":"No");
+ printk(KERN_INFO "ide-tape: Supports ejecting the medium - %s\n",capabilities->eject ? "Yes":"No");
+ printk(KERN_INFO "ide-tape: Supports error correction - %s\n",capabilities->ecc ? "Yes":"No");
+ printk(KERN_INFO "ide-tape: Supports data compression - %s\n",capabilities->cmprs ? "Yes":"No");
+ printk(KERN_INFO "ide-tape: Supports 512 bytes block size - %s\n",capabilities->blk512 ? "Yes":"No");
+ printk(KERN_INFO "ide-tape: Supports 1024 bytes block size - %s\n",capabilities->blk1024 ? "Yes":"No");
+ printk(KERN_INFO "ide-tape: Supports 32768 bytes block size / Restricted byte count for PIO transfers - %s\n",capabilities->blk32768 ? "Yes":"No");
+ printk(KERN_INFO "ide-tape: Maximum supported speed in KBps - %d\n",capabilities->max_speed);
+ printk(KERN_INFO "ide-tape: Continuous transfer limits in blocks - %d\n",capabilities->ctl);
+ printk(KERN_INFO "ide-tape: Current speed in KBps - %d\n",capabilities->speed);
+ printk(KERN_INFO "ide-tape: Buffer size - %d\n",capabilities->buffer_size*512);
#endif /* IDETAPE_DEBUG_INFO */
}
@@ -5913,22 +6226,19 @@
idetape_mode_parameter_header_t *header;
idetape_parameter_block_descriptor_t *block_descrp;
- idetape_create_mode_sense_cmd (&pc, IDETAPE_BLOCK_DESCRIPTOR);
- if (idetape_queue_pc_tail (drive, &pc)) {
- printk (KERN_ERR "ide-tape: Can't get block descriptor\n");
- if (tape->tape_block_size == 0) {
- printk(KERN_WARNING "ide-tape: Cannot deal with zero block size, assume 32k\n");
- tape->tape_block_size = 32768;
- }
+ idetape_create_mode_sense_cmd(&pc, IDETAPE_BLOCK_DESCRIPTOR);
+ if (idetape_queue_pc_tail(drive, &pc)) {
+ printk(KERN_ERR "ide-tape: Can't get block descriptor\n");
return;
}
header = (idetape_mode_parameter_header_t *) pc.buffer;
block_descrp = (idetape_parameter_block_descriptor_t *) (pc.buffer + sizeof(idetape_mode_parameter_header_t));
tape->tape_block_size =( block_descrp->length[0]<<16) + (block_descrp->length[1]<<8) + block_descrp->length[2];
#if IDETAPE_DEBUG_INFO
- printk (KERN_INFO "ide-tape: Adjusted block size - %d\n", tape->tape_block_size);
+ printk(KERN_INFO "ide-tape: Adjusted block size - %d\n", tape->tape_block_size);
#endif /* IDETAPE_DEBUG_INFO */
}
+
static void idetape_add_settings (ide_drive_t *drive)
{
idetape_tape_t *tape = drive->driver_data;
@@ -5937,9 +6247,9 @@
* drive setting name read/write ioctl ioctl data type min max mul_factor div_factor data pointer set function
*/
ide_add_setting(drive, "buffer", SETTING_READ, -1, -1, TYPE_SHORT, 0, 0xffff, 1, 2, &tape->capabilities.buffer_size, NULL);
- ide_add_setting(drive, "pipeline_min", SETTING_RW, -1, -1, TYPE_INT, 2, 0xffff, tape->stage_size / 1024, 1, &tape->min_pipeline, NULL);
- ide_add_setting(drive, "pipeline", SETTING_RW, -1, -1, TYPE_INT, 2, 0xffff, tape->stage_size / 1024, 1, &tape->max_stages, NULL);
- ide_add_setting(drive, "pipeline_max", SETTING_RW, -1, -1, TYPE_INT, 2, 0xffff, tape->stage_size / 1024, 1, &tape->max_pipeline, NULL);
+ ide_add_setting(drive, "pipeline_min", SETTING_RW, -1, -1, TYPE_INT, 1, 0xffff, tape->stage_size / 1024, 1, &tape->min_pipeline, NULL);
+ ide_add_setting(drive, "pipeline", SETTING_RW, -1, -1, TYPE_INT, 1, 0xffff, tape->stage_size / 1024, 1, &tape->max_stages, NULL);
+ ide_add_setting(drive, "pipeline_max", SETTING_RW, -1, -1, TYPE_INT, 1, 0xffff, tape->stage_size / 1024, 1, &tape->max_pipeline, NULL);
ide_add_setting(drive, "pipeline_used",SETTING_READ, -1, -1, TYPE_INT, 0, 0xffff, tape->stage_size / 1024, 1, &tape->nr_stages, NULL);
ide_add_setting(drive, "pipeline_pending",SETTING_READ,-1, -1, TYPE_INT, 0, 0xffff, tape->stage_size / 1024, 1, &tape->nr_pending_stages, NULL);
ide_add_setting(drive, "speed", SETTING_READ, -1, -1, TYPE_SHORT, 0, 0xffff, 1, 1, &tape->capabilities.speed, NULL);
@@ -5984,29 +6294,24 @@
int stage_size;
struct sysinfo si;
- memset (tape, 0, sizeof (idetape_tape_t));
+ memset(tape, 0, sizeof (idetape_tape_t));
spin_lock_init(&tape->spinlock);
drive->driver_data = tape;
- drive->ready_stat = 0; /* An ATAPI device ignores DRDY */
+ /* An ATAPI device ignores DRDY */
+ drive->ready_stat = 0;
if (strstr(drive->id->model, "OnStream DI-"))
tape->onstream = 1;
- drive->dsc_overlap = 1;
-#ifdef CONFIG_BLK_DEV_IDEPCI
- if (!tape->onstream && HWIF(drive)->pci_dev != NULL) {
- /*
- * These two ide-pci host adapters appear to need DSC overlap disabled.
- * This probably needs further analysis.
- */
- if ((HWIF(drive)->pci_dev->device == PCI_DEVICE_ID_ARTOP_ATP850UF) ||
- (HWIF(drive)->pci_dev->device == PCI_DEVICE_ID_TTI_HPT343)) {
- printk(KERN_INFO "ide-tape: %s: disabling DSC overlap\n", tape->name);
- drive->dsc_overlap = 0;
- }
+ drive->dsc_overlap = (HWIF(drive)->no_dsc) ? 0 : 1;
+ if (HWIF(drive)->no_dsc) {
+ printk(KERN_INFO "ide-tape: %s: disabling DSC overlap\n",
+ tape->name);
+ drive->dsc_overlap = 0;
}
-#endif /* CONFIG_BLK_DEV_IDEPCI */
tape->drive = drive;
tape->minor = minor;
- tape->name[0] = 'h'; tape->name[1] = 't'; tape->name[2] = '0' + minor;
+ tape->name[0] = 'h';
+ tape->name[1] = 't';
+ tape->name[2] = '0' + minor;
tape->chrdev_direction = idetape_direction_none;
tape->pc = tape->pc_stack;
tape->max_insert_speed = 10000;
@@ -6020,6 +6325,10 @@
idetape_get_inquiry_results(drive);
idetape_get_mode_sense_results(drive);
idetape_get_blocksize_from_block_descriptor(drive);
+ if (tape->tape_block_size == 0) {
+ printk(KERN_WARNING "ide-tape: Zero block size, using 512\n");
+ tape->tape_block_size = 512;
+ }
if (tape->onstream) {
idetape_onstream_mode_sense_tape_parameter_page(drive, 1);
idetape_configure_onstream(drive);
@@ -6044,7 +6353,7 @@
* Select the "best" DSC read/write polling frequency
* and pipeline size.
*/
- speed = IDE_MAX (tape->capabilities.speed, tape->capabilities.max_speed);
+ speed = IDE_MAX(tape->capabilities.speed, tape->capabilities.max_speed);
tape->max_stages = speed * 1000 * 10 / tape->stage_size;
@@ -6052,10 +6361,13 @@
* Limit memory use for pipeline to 10% of physical memory
*/
si_meminfo(&si);
- if ( tape->max_stages * tape->stage_size > si.totalram * si.mem_unit / 10)
+ if (tape->max_stages * tape->stage_size > si.totalram * si.mem_unit / 10)
tape->max_stages = si.totalram * si.mem_unit / (10 * tape->stage_size);
- tape->min_pipeline = tape->max_stages;
- tape->max_pipeline = tape->max_stages * 2;
+ tape->max_stages = IDE_MIN(tape->max_stages, IDETAPE_MAX_PIPELINE_STAGES);
+ tape->min_pipeline = IDE_MIN(tape->max_stages, IDETAPE_MIN_PIPELINE_STAGES);
+ tape->max_pipeline = IDE_MIN(tape->max_stages * 2, IDETAPE_MAX_PIPELINE_STAGES);
+ if (tape->max_stages == 0)
+ tape->max_stages = tape->min_pipeline = tape->max_pipeline = 1;
t1 = (tape->stage_size * HZ) / (speed * 1000);
tmid = (tape->capabilities.buffer_size * 32 * HZ) / (speed * 125);
@@ -6070,11 +6382,15 @@
* Ensure that the number we got makes sense; limit
* it within IDETAPE_DSC_RW_MIN and IDETAPE_DSC_RW_MAX.
*/
- tape->best_dsc_rw_frequency = IDE_MAX (IDE_MIN (t, IDETAPE_DSC_RW_MAX), IDETAPE_DSC_RW_MIN);
- printk (KERN_INFO "ide-tape: %s <-> %s: %dKBps, %d*%dkB buffer, %dkB pipeline, %lums tDSC%s\n",
- drive->name, tape->name, tape->capabilities.speed, (tape->capabilities.buffer_size * 512) / tape->stage_size,
- tape->stage_size / 1024, tape->max_stages * tape->stage_size / 1024,
- tape->best_dsc_rw_frequency * 1000 / HZ, drive->using_dma ? ", DMA":"");
+ tape->best_dsc_rw_frequency = IDE_MAX(IDE_MIN(t, IDETAPE_DSC_RW_MAX), IDETAPE_DSC_RW_MIN);
+ printk(KERN_INFO "ide-tape: %s <-> %s: %dKBps, %d*%dkB buffer, "
+ "%dkB pipeline, %lums tDSC%s\n",
+ drive->name, tape->name, tape->capabilities.speed,
+ (tape->capabilities.buffer_size * 512) / tape->stage_size,
+ tape->stage_size / 1024,
+ tape->max_stages * tape->stage_size / 1024,
+ tape->best_dsc_rw_frequency * 1000 / HZ,
+ drive->using_dma ? ", DMA":"");
idetape_add_settings(drive);
}
@@ -6085,24 +6401,24 @@
int minor = tape->minor;
unsigned long flags;
- save_flags (flags); /* all CPUs (overkill?) */
- cli(); /* all CPUs (overkill?) */
- if (test_bit (IDETAPE_BUSY, &tape->flags) || tape->first_stage != NULL || tape->merge_stage_size || drive->usage) {
- restore_flags(flags); /* all CPUs (overkill?) */
+ spin_lock_irqsave(&io_request_lock, flags);
+ if (test_bit(IDETAPE_BUSY, &tape->flags) || drive->usage ||
+ tape->first_stage != NULL || tape->merge_stage_size) {
+ spin_unlock_irqrestore(&io_request_lock, flags);
return 1;
}
idetape_chrdevs[minor].drive = NULL;
- restore_flags (flags); /* all CPUs (overkill?) */
+ spin_unlock_irqrestore(&io_request_lock, flags);
DRIVER(drive)->busy = 0;
- (void) ide_unregister_subdriver (drive);
+ (void) ide_unregister_subdriver(drive);
drive->driver_data = NULL;
- devfs_unregister (tape->de_r);
- devfs_unregister (tape->de_n);
- kfree (tape);
+ devfs_unregister(tape->de_r);
+ devfs_unregister(tape->de_n);
+ kfree(tape);
for (minor = 0; minor < MAX_HWIFS * MAX_DRIVES; minor++)
if (idetape_chrdevs[minor].drive != NULL)
return 0;
- devfs_unregister_chrdev (IDETAPE_MAJOR, "ht");
+ devfs_unregister_chrdev(IDETAPE_MAJOR, "ht");
idetape_chrdev_present = 0;
return 0;
}
@@ -6132,7 +6448,8 @@
#endif
-int idetape_reinit(ide_drive_t *drive);
+int idetape_init (void);
+int idetape_attach(ide_drive_t *drive);
/*
* IDE subdriver functions, registered with ide.c
@@ -6146,9 +6463,13 @@
supports_dsc_overlap: 1,
cleanup: idetape_cleanup,
standby: NULL,
+ suspend: NULL,
+ resume: NULL,
flushcache: NULL,
do_request: idetape_do_request,
end_request: idetape_end_request,
+ sense: NULL,
+ error: NULL,
ioctl: idetape_blkdev_ioctl,
open: idetape_blkdev_open,
release: idetape_blkdev_release,
@@ -6156,13 +6477,14 @@
revalidate: NULL,
pre_reset: idetape_pre_reset,
capacity: NULL,
+ special: NULL,
proc: idetape_proc,
- reinit: idetape_reinit,
+ init: idetape_init,
+ attach: idetape_attach,
ata_prebuilder: NULL,
atapi_prebuilder: NULL,
};
-int idetape_init (void);
static ide_module_t idetape_module = {
IDE_DRIVER_MODULE,
idetape_init,
@@ -6182,90 +6504,62 @@
release: idetape_chrdev_release,
};
-int idetape_reinit (ide_drive_t *drive)
+int idetape_attach (ide_drive_t *drive)
{
-#if 0
idetape_tape_t *tape;
- int minor, failed = 0, supported = 0;
-/* DRIVER(drive)->busy++; */
+ int minor = 0, ret = 0;
+
MOD_INC_USE_COUNT;
-#if ONSTREAM_DEBUG
- printk(KERN_INFO "ide-tape: MOD_INC_USE_COUNT in idetape_init\n");
-#endif
- if (!idetape_chrdev_present)
- for (minor = 0; minor < MAX_HWIFS * MAX_DRIVES; minor++ )
- idetape_chrdevs[minor].drive = NULL;
- if ((drive = ide_scan_devices (ide_tape, idetape_driver.name, NULL, failed++)) == NULL) {
- ide_register_module (&idetape_module);
- MOD_DEC_USE_COUNT;
-#if ONSTREAM_DEBUG
- printk(KERN_INFO "ide-tape: MOD_DEC_USE_COUNT in idetape_init\n");
-#endif
- return 0;
- }
- if (!idetape_chrdev_present &&
- devfs_register_chrdev (IDETAPE_MAJOR, "ht", &idetape_fops)) {
- printk (KERN_ERR "ide-tape: Failed to register character device interface\n");
- MOD_DEC_USE_COUNT;
-#if ONSTREAM_DEBUG
- printk(KERN_INFO "ide-tape: MOD_DEC_USE_COUNT in idetape_init\n");
-#endif
- return -EBUSY;
- }
- do {
- if (!idetape_identify_device (drive, drive->id)) {
- printk (KERN_ERR "ide-tape: %s: not supported by this version of ide-tape\n", drive->name);
- continue;
- }
- if (drive->scsi) {
- if (strstr(drive->id->model, "OnStream DI-30")) {
- printk("ide-tape: ide-scsi emulation is not supported for %s.\n", drive->id->model);
- } else {
- printk("ide-tape: passing drive %s to ide-scsi emulation.\n", drive->name);
- continue;
- }
- }
- tape = (idetape_tape_t *) kmalloc (sizeof (idetape_tape_t), GFP_KERNEL);
- if (tape == NULL) {
- printk (KERN_ERR "ide-tape: %s: Can't allocate a tape structure\n", drive->name);
- continue;
- }
- if (ide_register_subdriver (drive, &idetape_driver, IDE_SUBDRIVER_VERSION)) {
- printk (KERN_ERR "ide-tape: %s: Failed to register the driver with ide.c\n", drive->name);
- kfree (tape);
- continue;
- }
- for (minor = 0; idetape_chrdevs[minor].drive != NULL; minor++);
- idetape_setup (drive, tape, minor);
- idetape_chrdevs[minor].drive = drive;
- tape->de_r =
- devfs_register (drive->de, "mt", DEVFS_FL_DEFAULT,
+ if (idetape_identify_device(drive)) {
+ printk(KERN_ERR "ide-tape: %s: not supported by this "
+ "version of ide-tape\n", drive->name);
+ ret = 1;
+ goto bye_game_over;
+ }
+ if (drive->scsi) {
+ if (strstr(drive->id->model, "OnStream DI-30")) {
+ printk("ide-tape: ide-scsi emulation is not "
+ "supported for %s.\n", drive->id->model);
+ } else {
+ printk("ide-tape: passing drive %s to ide-scsi "
+ "emulation.\n", drive->name);
+ ret = 1;
+ goto bye_game_over;
+ }
+ }
+ tape = (idetape_tape_t *) kmalloc (sizeof (idetape_tape_t), GFP_KERNEL);
+ if (tape == NULL) {
+ printk(KERN_ERR "ide-tape: %s: Can't allocate a "
+ "tape structure\n", drive->name);
+ ret = 1;
+ goto bye_game_over;
+ }
+ if (ide_register_subdriver(drive,
+ &idetape_driver, IDE_SUBDRIVER_VERSION)) {
+ printk(KERN_ERR "ide-tape: %s: Failed to register the "
+ "driver with ide.c\n", drive->name);
+ kfree(tape);
+ ret = 1;
+ goto bye_game_over;
+ }
+ for (minor = 0; idetape_chrdevs[minor].drive != NULL; minor++);
+ idetape_setup (drive, tape, minor);
+ idetape_chrdevs[minor].drive = drive;
+ tape->de_r = devfs_register(drive->de, "mt", DEVFS_FL_DEFAULT,
HWIF(drive)->major, minor,
S_IFCHR | S_IRUGO | S_IWUGO,
&idetape_fops, NULL);
- tape->de_n =
- devfs_register (drive->de, "mtn", DEVFS_FL_DEFAULT,
+ tape->de_n = devfs_register(drive->de, "mtn", DEVFS_FL_DEFAULT,
HWIF(drive)->major, minor + 128,
S_IFCHR | S_IRUGO | S_IWUGO,
&idetape_fops, NULL);
- devfs_register_tape (tape->de_r);
- supported++; failed--;
- } while ((drive = ide_scan_devices (ide_tape, idetape_driver.name, NULL, failed++)) != NULL);
- if (!idetape_chrdev_present && !supported) {
- devfs_unregister_chrdev (IDETAPE_MAJOR, "ht");
- } else
- idetape_chrdev_present = 1;
- ide_register_module (&idetape_module);
+ devfs_register_tape(tape->de_r);
+
+bye_game_over:
MOD_DEC_USE_COUNT;
-#if ONSTREAM_DEBUG
- printk(KERN_INFO "ide-tape: MOD_DEC_USE_COUNT in idetape_init\n");
-#endif
- return 0;
-#else
- return 1;
-#endif
+ return ret;
}
MODULE_DESCRIPTION("ATAPI Streaming TAPE Driver");
@@ -6278,94 +6572,120 @@
for (minor = 0; minor < MAX_HWIFS * MAX_DRIVES; minor++) {
drive = idetape_chrdevs[minor].drive;
- if (drive != NULL && idetape_cleanup (drive))
- printk (KERN_ERR "ide-tape: %s: cleanup_module() called while still busy\n", drive->name);
+ if (drive) {
+ if (idetape_cleanup(drive))
+ printk(KERN_ERR "ide-tape: %s: cleanup_module() "
+ "called while still busy\n", drive->name);
+#ifdef CONFIG_PROC_FS
+ if (drive->proc)
+ ide_remove_proc_entries(drive->proc, idetape_proc);
+#endif
+ }
}
+
ide_unregister_module(&idetape_module);
}
-/*
- * idetape_init will register the driver for each tape.
- */
int idetape_init (void)
{
+#ifdef CLASSIC_BUILTINS_METHOD
ide_drive_t *drive;
idetape_tape_t *tape;
int minor, failed = 0, supported = 0;
/* DRIVER(drive)->busy++; */
MOD_INC_USE_COUNT;
#if ONSTREAM_DEBUG
- printk(KERN_INFO "ide-tape: MOD_INC_USE_COUNT in idetape_init\n");
+ printk(KERN_INFO "ide-tape: MOD_INC_USE_COUNT in idetape_init\n");
#endif
if (!idetape_chrdev_present)
for (minor = 0; minor < MAX_HWIFS * MAX_DRIVES; minor++ )
idetape_chrdevs[minor].drive = NULL;
-
- if ((drive = ide_scan_devices (ide_tape, idetape_driver.name, NULL, failed++)) == NULL) {
- ide_register_module (&idetape_module);
+ if ((drive = ide_scan_devices(ide_tape, idetape_driver.name,
+ NULL, failed++)) == NULL) {
+ ide_register_module(&idetape_module);
MOD_DEC_USE_COUNT;
#if ONSTREAM_DEBUG
- printk(KERN_INFO "ide-tape: MOD_DEC_USE_COUNT in idetape_init\n");
+ printk(KERN_INFO "ide-tape: MOD_DEC_USE_COUNT in "
+ "idetape_init\n");
#endif
return 0;
}
if (!idetape_chrdev_present &&
- devfs_register_chrdev (IDETAPE_MAJOR, "ht", &idetape_fops)) {
- printk (KERN_ERR "ide-tape: Failed to register character device interface\n");
+ devfs_register_chrdev(IDETAPE_MAJOR, "ht", &idetape_fops)) {
+ printk(KERN_ERR "ide-tape: Failed to register character "
+ "device interface\n");
MOD_DEC_USE_COUNT;
#if ONSTREAM_DEBUG
- printk(KERN_INFO "ide-tape: MOD_DEC_USE_COUNT in idetape_init\n");
+ printk(KERN_INFO "ide-tape: MOD_DEC_USE_COUNT in "
+ "idetape_init\n");
#endif
return -EBUSY;
}
do {
- if (!idetape_identify_device (drive, drive->id)) {
- printk (KERN_ERR "ide-tape: %s: not supported by this version of ide-tape\n", drive->name);
+ if (!idetape_identify_device(drive)) {
+ printk(KERN_ERR "ide-tape: %s: not supported by this "
+ "version of ide-tape\n", drive->name);
continue;
}
if (drive->scsi) {
if (strstr(drive->id->model, "OnStream DI-")) {
- printk("ide-tape: ide-scsi emulation is not supported for %s.\n", drive->id->model);
+ printk("ide-tape: ide-scsi emulation is not "
+ "supported for %s.\n",
+ drive->id->model);
} else {
- printk("ide-tape: passing drive %s to ide-scsi emulation.\n", drive->name);
+ printk("ide-tape: passing drive %s to "
+ "ide-scsi emulation.\n", drive->name);
continue;
}
}
tape = (idetape_tape_t *) kmalloc (sizeof (idetape_tape_t), GFP_KERNEL);
if (tape == NULL) {
- printk (KERN_ERR "ide-tape: %s: Can't allocate a tape structure\n", drive->name);
+ printk(KERN_ERR "ide-tape: %s: Can't allocate a tape "
+ "structure\n", drive->name);
continue;
}
- if (ide_register_subdriver (drive, &idetape_driver, IDE_SUBDRIVER_VERSION)) {
- printk (KERN_ERR "ide-tape: %s: Failed to register the driver with ide.c\n", drive->name);
- kfree (tape);
+ if (ide_register_subdriver(drive,
+ &idetape_driver, IDE_SUBDRIVER_VERSION)) {
+ printk(KERN_ERR "ide-tape: %s: Failed to register the "
+ "driver with ide.c\n", drive->name);
+ kfree(tape);
continue;
}
for (minor = 0; idetape_chrdevs[minor].drive != NULL; minor++);
- idetape_setup (drive, tape, minor);
+ idetape_setup(drive, tape, minor);
idetape_chrdevs[minor].drive = drive;
tape->de_r =
- devfs_register (drive->de, "mt", DEVFS_FL_DEFAULT,
+ devfs_register(drive->de, "mt", DEVFS_FL_DEFAULT,
HWIF(drive)->major, minor,
S_IFCHR | S_IRUGO | S_IWUGO,
&idetape_fops, NULL);
tape->de_n =
- devfs_register (drive->de, "mtn", DEVFS_FL_DEFAULT,
+ devfs_register(drive->de, "mtn", DEVFS_FL_DEFAULT,
HWIF(drive)->major, minor + 128,
S_IFCHR | S_IRUGO | S_IWUGO,
&idetape_fops, NULL);
- devfs_register_tape (tape->de_r);
- supported++; failed--;
- } while ((drive = ide_scan_devices (ide_tape, idetape_driver.name, NULL, failed++)) != NULL);
+ devfs_register_tape(tape->de_r);
+ supported++;
+ failed--;
+ } while ((drive = ide_scan_devices(ide_tape,
+ idetape_driver.name, NULL, failed++)) != NULL);
if (!idetape_chrdev_present && !supported) {
- devfs_unregister_chrdev (IDETAPE_MAJOR, "ht");
+ devfs_unregister_chrdev(IDETAPE_MAJOR, "ht");
} else
idetape_chrdev_present = 1;
- ide_register_module (&idetape_module);
+#else /* ! CLASSIC_BUILTINS_METHOD */
+ int minor = 0;
+
+ if (idetape_chrdev_present)
+ return 0;
+ idetape_chrdev_present = 1;
+ for (minor = 0; minor < MAX_HWIFS * MAX_DRIVES; minor++ )
+ idetape_chrdevs[minor].drive = NULL;
+ devfs_register_chrdev(IDETAPE_MAJOR, "ht", &idetape_fops);
+ MOD_INC_USE_COUNT;
+#endif /* CLASSIC_BUILTINS_METHOD */
+ ide_register_module(&idetape_module);
MOD_DEC_USE_COUNT;
-#if ONSTREAM_DEBUG
- printk(KERN_INFO "ide-tape: MOD_DEC_USE_COUNT in idetape_init\n");
-#endif
return 0;
}
FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen (who was at: slshen@lbl.gov)