Commit 0371b9a3 authored by Bartlomiej Zolnierkiewicz's avatar Bartlomiej Zolnierkiewicz Committed by Linus Torvalds

[PATCH] ide: some CodingStyle fixes from 2.4.x for ide-tape.c

makes 2.4->2.6 diff noticeable smaller
parent 8f7ea5e8
......@@ -764,12 +764,18 @@ typedef struct idetape_packet_command_s {
/*
* 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
......@@ -888,12 +894,17 @@ typedef struct {
* 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.
......@@ -907,17 +918,23 @@ typedef struct {
* 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
*/
u8 partition;
unsigned int first_frame_position; /* Current block */
/* Current block */
unsigned int first_frame_position;
unsigned int last_frame_position;
unsigned int blocks_in_buffer;
......@@ -930,15 +947,19 @@ typedef struct {
* 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.
......@@ -953,8 +974,10 @@ typedef struct {
* 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 which is 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 idetape_bh *bh;
......@@ -967,19 +990,30 @@ typedef struct {
* 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
......@@ -988,31 +1022,44 @@ typedef struct {
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-specific media */
/* write error recovery active */
int onstream_write_error;
/* header frame verified ok */
int header_ok;
/* reading linux-specific 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;
......@@ -1025,8 +1072,10 @@ typedef struct {
* 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;
......@@ -1035,7 +1084,8 @@ typedef struct {
* 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:
......@@ -1068,11 +1118,17 @@ typedef struct {
* 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;
/*
......@@ -1379,23 +1435,40 @@ char *idetape_sense_key_verbose(u8 idetape_sense_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);
......@@ -1545,7 +1618,7 @@ static struct request *idetape_next_rq_storage (ide_drive_t *drive)
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++]);
}
......@@ -1879,7 +1952,7 @@ static int idetape_end_request(ide_drive_t *drive, int uptodate, int nr_sects)
(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);
......@@ -2090,21 +2163,25 @@ static ide_startstop_t idetape_pc_intr (ide_drive_t *drive)
if (tape->debug_level >= 1)
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) {
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);
}
if (test_and_clear_bit(PC_DMA_IN_PROGRESS, &pc->flags)) {
printk(KERN_ERR "ide-tape: The tape wants to issue more "
......@@ -2123,14 +2200,16 @@ static ide_startstop_t idetape_pc_intr (ide_drive_t *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 */
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->buffer_size) {
......@@ -2149,20 +2228,24 @@ static ide_startstop_t idetape_pc_intr (ide_drive_t *drive)
if (pc->bh != NULL)
idetape_output_buffers(drive, pc, bcount.all);
else
HWIF(drive)->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);
else
HWIF(drive)->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 */
/* 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);
#endif
ide_set_handler(drive, &idetape_pc_intr, IDETAPE_WAIT_CMD, NULL); /* And set the interrupt handler again */
/* And set the interrupt handler again */
ide_set_handler(drive, &idetape_pc_intr, IDETAPE_WAIT_CMD, NULL);
return ide_started;
}
......@@ -2199,9 +2282,9 @@ static ide_startstop_t idetape_pc_intr (ide_drive_t *drive)
*
* 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
* up to 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
......@@ -2243,7 +2326,8 @@ static ide_startstop_t idetape_transfer_pc(ide_drive_t *drive)
/* Set the interrupt routine */
ide_set_handler(drive, &idetape_pc_intr, IDETAPE_WAIT_CMD, NULL);
#ifdef CONFIG_BLK_DEV_IDEDMA
if (test_bit(PC_DMA_IN_PROGRESS, &pc->flags)) /* Begin DMA, if necessary */
/* 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 */
......@@ -2268,7 +2352,8 @@ static ide_startstop_t idetape_issue_packet_command (ide_drive_t *drive, idetape
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)) {
......@@ -2290,10 +2375,12 @@ static ide_startstop_t idetape_issue_packet_command (ide_drive_t *drive, idetape
if (tape->onstream &&
pc->c[0] == IDETAPE_READ_CMD &&
tape->sense_key == 3 &&
tape->asc == 0x11) /* AJN-1: 11 should be 0x11 */
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);
......@@ -2304,9 +2391,11 @@ static ide_startstop_t idetape_issue_packet_command (ide_drive_t *drive, idetape
#endif /* IDETAPE_DEBUG_LOG */
pc->retries++;
pc->actually_transferred = 0; /* We haven't transferred any data yet */
/* We haven't transferred any data yet */
pc->actually_transferred = 0;
pc->current_position = pc->buffer;
bcount.all = pc->request_transfer; /* Request to transfer the entire buffer at once */
/* Request to transfer the entire buffer at once */
bcount.all = pc->request_transfer;
if (test_and_clear_bit(PC_DMA_ERROR, &pc->flags)) {
printk(KERN_WARNING "ide-tape: DMA disabled, "
......@@ -2433,7 +2522,8 @@ static void calculate_speeds(ide_drive_t *drive)
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);
......@@ -2475,9 +2565,12 @@ static ide_startstop_t idetape_media_access_finished (ide_drive_t *drive)
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 */
if (status.b.check) {
/* Error detected */
printk(KERN_ERR "ide-tape: %s: I/O error, ",tape->name);
return idetape_retry_pc(drive); /* Retry operation */
/* Retry operation */
return idetape_retry_pc(drive);
}
pc->error = 0;
if (tape->failed_pc == pc)
......@@ -2729,7 +2822,8 @@ static ide_startstop_t idetape_do_request(ide_drive_t *drive,
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;
......@@ -2992,7 +3086,8 @@ static void idetape_switch_buffers (idetape_tape_t *tape, idetape_stage_t *stage
struct idetape_bh *tmp;
os_aux_t *tmp_aux;
tmp = stage->bh; tmp_aux = stage->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;
......@@ -3013,7 +3108,7 @@ static void idetape_add_stage_tail (ide_drive_t *drive,idetape_stage_t *stage)
printk (KERN_INFO "ide-tape: Reached idetape_add_stage_tail\n");
#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
......@@ -3080,9 +3175,12 @@ static void idetape_init_stage (ide_drive_t *drive, idetape_stage_t *stage, int
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);
}
/*
......@@ -3186,8 +3284,8 @@ static void idetape_create_test_unit_ready_cmd(idetape_pc_t *pc)
* 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
......@@ -3808,7 +3906,8 @@ static int idetape_add_chrdev_write_request (ide_drive_t *drive, int blocks)
rq = &new_stage->rq;
ide_init_drive_cmd(rq);
rq->flags = 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);
......@@ -3851,7 +3950,8 @@ static int idetape_add_chrdev_write_request (ide_drive_t *drive, int blocks)
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;
}
......@@ -3971,10 +4071,11 @@ static int idetape_initiate_read (ide_drive_t *drive, int max_stages)
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) {
......@@ -4058,19 +4159,27 @@ static int idetape_get_logical_blk (ide_drive_t *drive, int logical_blk_num, int
position = idetape_read_position(drive);
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;
......@@ -4172,9 +4281,9 @@ static int idetape_add_chrdev_read_request (ide_drive_t *drive,int blocks)
calculate_speeds(drive);
}
#if IDETAPE_DEBUG_BUGS
if (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;
bytes_read = blocks * tape->tape_block_size;
}
#endif /* IDETAPE_DEBUG_BUGS */
return (bytes_read);
......@@ -4601,7 +4710,8 @@ static ssize_t idetape_chrdev_read (struct file *file, char *buf,
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 (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)
......@@ -4835,8 +4945,8 @@ static ssize_t idetape_chrdev_write (struct file *file, const char *buf,
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
......@@ -4849,8 +4959,8 @@ static ssize_t idetape_chrdev_write (struct file *file, const char *buf,
}
}
if (tape->chrdev_direction != idetape_direction_write) {
/* Initialize write operation */
if (tape->chrdev_direction != idetape_direction_write) {
if (tape->chrdev_direction == idetape_direction_read)
idetape_discard_read_pipeline(drive, 1);
#if IDETAPE_DEBUG_BUGS
......@@ -4937,7 +5047,7 @@ static ssize_t idetape_chrdev_write (struct file *file, const char *buf,
tape->merge_stage_size = 0;
retval = idetape_add_chrdev_write_request(drive, tape->capabilities.ctl);
if (retval <= 0)
return(retval);
return (retval);
}
}
while (count >= tape->stage_size) {
......@@ -4947,7 +5057,7 @@ static ssize_t idetape_chrdev_write (struct file *file, const char *buf,
retval = idetape_add_chrdev_write_request(drive, tape->capabilities.ctl);
actually_written += tape->stage_size;
if (retval <= 0)
return(retval);
return (retval);
}
if (count) {
actually_written += count;
......@@ -4964,7 +5074,8 @@ static int idetape_write_filemark (ide_drive_t *drive)
idetape_pc_t pc;
if (!tape->onstream) {
idetape_create_write_filemark_cmd(drive, &pc, 1); /* Write a filemark */
/* 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;
......@@ -5894,17 +6005,19 @@ static void idetape_get_mode_sense_results (ide_drive_t *drive)
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;
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);
......@@ -6040,7 +6153,8 @@ static void idetape_setup (ide_drive_t *drive, idetape_tape_t *tape, int minor)
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;
......@@ -6059,7 +6173,9 @@ static void idetape_setup (ide_drive_t *drive, idetape_tape_t *tape, int minor)
#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;
......@@ -6146,7 +6262,7 @@ static int idetape_cleanup (ide_drive_t *drive)
unsigned long flags;
spin_lock_irqsave(&ide_lock, flags);
if (test_bit (IDETAPE_BUSY, &tape->flags) || drive->usage ||
if (test_bit(IDETAPE_BUSY, &tape->flags) || drive->usage ||
tape->first_stage != NULL || tape->merge_stage_size) {
spin_unlock_irqrestore(&ide_lock, flags);
return 1;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment