aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBorislav Petkov <petkovbb@googlemail.com>2008-02-05 20:57:52 -0500
committerBartlomiej Zolnierkiewicz <bzolnier@gmail.com>2008-02-05 20:57:52 -0500
commit37016bab601c2fecfe833d2feda42e6c6f9b08c8 (patch)
tree9470604ca56ecd8c817b1d06498dc8045ebfb3eb
parenta2f5b7f42a73e99518a719189570da43c6b66657 (diff)
ide-tape: remove unreachable code chunk
tape->speed_control is set to 1 in idetape_setup(), but, in calculate_speeds() its value is tested for being 0, 1, or 2. Remove the if-branches where tape->speed_control != 1 since they are never executed. Also, rename calculate_speeds() by adding driver's prefix as is with the other function names. Signed-off-by: Borislav Petkov <petkovbb@gmail.com> Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
-rw-r--r--drivers/ide/ide-tape.c22
1 files changed, 10 insertions, 12 deletions
diff --git a/drivers/ide/ide-tape.c b/drivers/ide/ide-tape.c
index 3c516ff1adf0..1dc4a9ec36fc 100644
--- a/drivers/ide/ide-tape.c
+++ b/drivers/ide/ide-tape.c
@@ -87,7 +87,8 @@ enum {
87 * the optimum value or until we reach MAX. 87 * the optimum value or until we reach MAX.
88 * 88 *
89 * Setting the following parameter to 0 is illegal: the pipelined mode 89 * Setting the following parameter to 0 is illegal: the pipelined mode
90 * cannot be disabled (calculate_speeds() divides by tape->max_stages.) 90 * cannot be disabled (idetape_calculate_speeds() divides by
91 * tape->max_stages.)
91 */ 92 */
92#define IDETAPE_MIN_PIPELINE_STAGES 1 93#define IDETAPE_MIN_PIPELINE_STAGES 1
93#define IDETAPE_MAX_PIPELINE_STAGES 400 94#define IDETAPE_MAX_PIPELINE_STAGES 400
@@ -1475,10 +1476,9 @@ static void idetape_create_mode_sense_cmd (idetape_pc_t *pc, u8 page_code)
1475 pc->callback = &idetape_pc_callback; 1476 pc->callback = &idetape_pc_callback;
1476} 1477}
1477 1478
1478static void calculate_speeds(ide_drive_t *drive) 1479static void idetape_calculate_speeds(ide_drive_t *drive)
1479{ 1480{
1480 idetape_tape_t *tape = drive->driver_data; 1481 idetape_tape_t *tape = drive->driver_data;
1481 int full = 125, empty = 75;
1482 1482
1483 if (time_after(jiffies, tape->controlled_pipeline_head_time + 120 * HZ)) { 1483 if (time_after(jiffies, tape->controlled_pipeline_head_time + 120 * HZ)) {
1484 tape->controlled_previous_pipeline_head = tape->controlled_last_pipeline_head; 1484 tape->controlled_previous_pipeline_head = tape->controlled_last_pipeline_head;
@@ -1505,22 +1505,20 @@ static void calculate_speeds(ide_drive_t *drive)
1505 } 1505 }
1506 } 1506 }
1507 tape->pipeline_head_speed = max(tape->uncontrolled_pipeline_head_speed, tape->controlled_pipeline_head_speed); 1507 tape->pipeline_head_speed = max(tape->uncontrolled_pipeline_head_speed, tape->controlled_pipeline_head_speed);
1508 if (tape->speed_control == 0) { 1508
1509 tape->max_insert_speed = 5000; 1509 if (tape->speed_control == 1) {
1510 } else if (tape->speed_control == 1) {
1511 if (tape->nr_pending_stages >= tape->max_stages / 2) 1510 if (tape->nr_pending_stages >= tape->max_stages / 2)
1512 tape->max_insert_speed = tape->pipeline_head_speed + 1511 tape->max_insert_speed = tape->pipeline_head_speed +
1513 (1100 - tape->pipeline_head_speed) * 2 * (tape->nr_pending_stages - tape->max_stages / 2) / tape->max_stages; 1512 (1100 - tape->pipeline_head_speed) * 2 * (tape->nr_pending_stages - tape->max_stages / 2) / tape->max_stages;
1514 else 1513 else
1515 tape->max_insert_speed = 500 + 1514 tape->max_insert_speed = 500 +
1516 (tape->pipeline_head_speed - 500) * 2 * tape->nr_pending_stages / tape->max_stages; 1515 (tape->pipeline_head_speed - 500) * 2 * tape->nr_pending_stages / tape->max_stages;
1516
1517 if (tape->nr_pending_stages >= tape->max_stages * 99 / 100) 1517 if (tape->nr_pending_stages >= tape->max_stages * 99 / 100)
1518 tape->max_insert_speed = 5000; 1518 tape->max_insert_speed = 5000;
1519 } else if (tape->speed_control == 2) {
1520 tape->max_insert_speed = tape->pipeline_head_speed * empty / 100 +
1521 (tape->pipeline_head_speed * full / 100 - tape->pipeline_head_speed * empty / 100) * tape->nr_pending_stages / tape->max_stages;
1522 } else 1519 } else
1523 tape->max_insert_speed = tape->speed_control; 1520 tape->max_insert_speed = tape->speed_control;
1521
1524 tape->max_insert_speed = max(tape->max_insert_speed, 500); 1522 tape->max_insert_speed = max(tape->max_insert_speed, 500);
1525} 1523}
1526 1524
@@ -1698,7 +1696,7 @@ static ide_startstop_t idetape_do_request(ide_drive_t *drive,
1698 tape->measure_insert_time = 1; 1696 tape->measure_insert_time = 1;
1699 if (time_after(jiffies, tape->insert_time)) 1697 if (time_after(jiffies, tape->insert_time))
1700 tape->insert_speed = tape->insert_size / 1024 * HZ / (jiffies - tape->insert_time); 1698 tape->insert_speed = tape->insert_size / 1024 * HZ / (jiffies - tape->insert_time);
1701 calculate_speeds(drive); 1699 idetape_calculate_speeds(drive);
1702 if (!test_and_clear_bit(IDETAPE_IGNORE_DSC, &tape->flags) && 1700 if (!test_and_clear_bit(IDETAPE_IGNORE_DSC, &tape->flags) &&
1703 (stat & SEEK_STAT) == 0) { 1701 (stat & SEEK_STAT) == 0) {
1704 if (postponed_rq == NULL) { 1702 if (postponed_rq == NULL) {
@@ -2419,7 +2417,7 @@ static int idetape_add_chrdev_write_request (ide_drive_t *drive, int blocks)
2419 idetape_switch_buffers(tape, new_stage); 2417 idetape_switch_buffers(tape, new_stage);
2420 idetape_add_stage_tail(drive, new_stage); 2418 idetape_add_stage_tail(drive, new_stage);
2421 tape->pipeline_head++; 2419 tape->pipeline_head++;
2422 calculate_speeds(drive); 2420 idetape_calculate_speeds(drive);
2423 2421
2424 /* 2422 /*
2425 * Estimate whether the tape has stopped writing by checking 2423 * Estimate whether the tape has stopped writing by checking
@@ -2659,7 +2657,7 @@ static int idetape_add_chrdev_read_request (ide_drive_t *drive,int blocks)
2659 idetape_remove_stage_head(drive); 2657 idetape_remove_stage_head(drive);
2660 spin_unlock_irqrestore(&tape->spinlock, flags); 2658 spin_unlock_irqrestore(&tape->spinlock, flags);
2661 tape->pipeline_head++; 2659 tape->pipeline_head++;
2662 calculate_speeds(drive); 2660 idetape_calculate_speeds(drive);
2663 } 2661 }
2664 if (bytes_read > blocks * tape->tape_block_size) { 2662 if (bytes_read > blocks * tape->tape_block_size) {
2665 printk(KERN_ERR "ide-tape: bug: trying to return more bytes than requested\n"); 2663 printk(KERN_ERR "ide-tape: bug: trying to return more bytes than requested\n");