diff options
Diffstat (limited to 'drivers/block/ataflop.c')
-rw-r--r-- | drivers/block/ataflop.c | 66 |
1 files changed, 34 insertions, 32 deletions
diff --git a/drivers/block/ataflop.c b/drivers/block/ataflop.c index 4234c11c1e4c..f5e7180d7f47 100644 --- a/drivers/block/ataflop.c +++ b/drivers/block/ataflop.c | |||
@@ -79,9 +79,7 @@ | |||
79 | #undef DEBUG | 79 | #undef DEBUG |
80 | 80 | ||
81 | static struct request_queue *floppy_queue; | 81 | static struct request_queue *floppy_queue; |
82 | 82 | static struct request *fd_request; | |
83 | #define QUEUE (floppy_queue) | ||
84 | #define CURRENT elv_next_request(floppy_queue) | ||
85 | 83 | ||
86 | /* Disk types: DD, HD, ED */ | 84 | /* Disk types: DD, HD, ED */ |
87 | static struct atari_disk_type { | 85 | static struct atari_disk_type { |
@@ -376,6 +374,12 @@ static DEFINE_TIMER(readtrack_timer, fd_readtrack_check, 0, 0); | |||
376 | static DEFINE_TIMER(timeout_timer, fd_times_out, 0, 0); | 374 | static DEFINE_TIMER(timeout_timer, fd_times_out, 0, 0); |
377 | static DEFINE_TIMER(fd_timer, check_change, 0, 0); | 375 | static DEFINE_TIMER(fd_timer, check_change, 0, 0); |
378 | 376 | ||
377 | static void fd_end_request_cur(int err) | ||
378 | { | ||
379 | if (!__blk_end_request_cur(fd_request, err)) | ||
380 | fd_request = NULL; | ||
381 | } | ||
382 | |||
379 | static inline void start_motor_off_timer(void) | 383 | static inline void start_motor_off_timer(void) |
380 | { | 384 | { |
381 | mod_timer(&motor_off_timer, jiffies + FD_MOTOR_OFF_DELAY); | 385 | mod_timer(&motor_off_timer, jiffies + FD_MOTOR_OFF_DELAY); |
@@ -606,15 +610,15 @@ static void fd_error( void ) | |||
606 | return; | 610 | return; |
607 | } | 611 | } |
608 | 612 | ||
609 | if (!CURRENT) | 613 | if (!fd_request) |
610 | return; | 614 | return; |
611 | 615 | ||
612 | CURRENT->errors++; | 616 | fd_request->errors++; |
613 | if (CURRENT->errors >= MAX_ERRORS) { | 617 | if (fd_request->errors >= MAX_ERRORS) { |
614 | printk(KERN_ERR "fd%d: too many errors.\n", SelectedDrive ); | 618 | printk(KERN_ERR "fd%d: too many errors.\n", SelectedDrive ); |
615 | end_request(CURRENT, 0); | 619 | fd_end_request_cur(-EIO); |
616 | } | 620 | } |
617 | else if (CURRENT->errors == RECALIBRATE_ERRORS) { | 621 | else if (fd_request->errors == RECALIBRATE_ERRORS) { |
618 | printk(KERN_WARNING "fd%d: recalibrating\n", SelectedDrive ); | 622 | printk(KERN_WARNING "fd%d: recalibrating\n", SelectedDrive ); |
619 | if (SelectedDrive != -1) | 623 | if (SelectedDrive != -1) |
620 | SUD.track = -1; | 624 | SUD.track = -1; |
@@ -725,16 +729,14 @@ static void do_fd_action( int drive ) | |||
725 | if (IS_BUFFERED( drive, ReqSide, ReqTrack )) { | 729 | if (IS_BUFFERED( drive, ReqSide, ReqTrack )) { |
726 | if (ReqCmd == READ) { | 730 | if (ReqCmd == READ) { |
727 | copy_buffer( SECTOR_BUFFER(ReqSector), ReqData ); | 731 | copy_buffer( SECTOR_BUFFER(ReqSector), ReqData ); |
728 | if (++ReqCnt < CURRENT->current_nr_sectors) { | 732 | if (++ReqCnt < blk_rq_cur_sectors(fd_request)) { |
729 | /* read next sector */ | 733 | /* read next sector */ |
730 | setup_req_params( drive ); | 734 | setup_req_params( drive ); |
731 | goto repeat; | 735 | goto repeat; |
732 | } | 736 | } |
733 | else { | 737 | else { |
734 | /* all sectors finished */ | 738 | /* all sectors finished */ |
735 | CURRENT->nr_sectors -= CURRENT->current_nr_sectors; | 739 | fd_end_request_cur(0); |
736 | CURRENT->sector += CURRENT->current_nr_sectors; | ||
737 | end_request(CURRENT, 1); | ||
738 | redo_fd_request(); | 740 | redo_fd_request(); |
739 | return; | 741 | return; |
740 | } | 742 | } |
@@ -1132,16 +1134,14 @@ static void fd_rwsec_done1(int status) | |||
1132 | } | 1134 | } |
1133 | } | 1135 | } |
1134 | 1136 | ||
1135 | if (++ReqCnt < CURRENT->current_nr_sectors) { | 1137 | if (++ReqCnt < blk_rq_cur_sectors(fd_request)) { |
1136 | /* read next sector */ | 1138 | /* read next sector */ |
1137 | setup_req_params( SelectedDrive ); | 1139 | setup_req_params( SelectedDrive ); |
1138 | do_fd_action( SelectedDrive ); | 1140 | do_fd_action( SelectedDrive ); |
1139 | } | 1141 | } |
1140 | else { | 1142 | else { |
1141 | /* all sectors finished */ | 1143 | /* all sectors finished */ |
1142 | CURRENT->nr_sectors -= CURRENT->current_nr_sectors; | 1144 | fd_end_request_cur(0); |
1143 | CURRENT->sector += CURRENT->current_nr_sectors; | ||
1144 | end_request(CURRENT, 1); | ||
1145 | redo_fd_request(); | 1145 | redo_fd_request(); |
1146 | } | 1146 | } |
1147 | return; | 1147 | return; |
@@ -1382,7 +1382,7 @@ static void setup_req_params( int drive ) | |||
1382 | ReqData = ReqBuffer + 512 * ReqCnt; | 1382 | ReqData = ReqBuffer + 512 * ReqCnt; |
1383 | 1383 | ||
1384 | if (UseTrackbuffer) | 1384 | if (UseTrackbuffer) |
1385 | read_track = (ReqCmd == READ && CURRENT->errors == 0); | 1385 | read_track = (ReqCmd == READ && fd_request->errors == 0); |
1386 | else | 1386 | else |
1387 | read_track = 0; | 1387 | read_track = 0; |
1388 | 1388 | ||
@@ -1396,25 +1396,27 @@ static void redo_fd_request(void) | |||
1396 | int drive, type; | 1396 | int drive, type; |
1397 | struct atari_floppy_struct *floppy; | 1397 | struct atari_floppy_struct *floppy; |
1398 | 1398 | ||
1399 | DPRINT(("redo_fd_request: CURRENT=%p dev=%s CURRENT->sector=%ld\n", | 1399 | DPRINT(("redo_fd_request: fd_request=%p dev=%s fd_request->sector=%ld\n", |
1400 | CURRENT, CURRENT ? CURRENT->rq_disk->disk_name : "", | 1400 | fd_request, fd_request ? fd_request->rq_disk->disk_name : "", |
1401 | CURRENT ? CURRENT->sector : 0 )); | 1401 | fd_request ? blk_rq_pos(fd_request) : 0 )); |
1402 | 1402 | ||
1403 | IsFormatting = 0; | 1403 | IsFormatting = 0; |
1404 | 1404 | ||
1405 | repeat: | 1405 | repeat: |
1406 | if (!fd_request) { | ||
1407 | fd_request = blk_fetch_request(floppy_queue); | ||
1408 | if (!fd_request) | ||
1409 | goto the_end; | ||
1410 | } | ||
1406 | 1411 | ||
1407 | if (!CURRENT) | 1412 | floppy = fd_request->rq_disk->private_data; |
1408 | goto the_end; | ||
1409 | |||
1410 | floppy = CURRENT->rq_disk->private_data; | ||
1411 | drive = floppy - unit; | 1413 | drive = floppy - unit; |
1412 | type = floppy->type; | 1414 | type = floppy->type; |
1413 | 1415 | ||
1414 | if (!UD.connected) { | 1416 | if (!UD.connected) { |
1415 | /* drive not connected */ | 1417 | /* drive not connected */ |
1416 | printk(KERN_ERR "Unknown Device: fd%d\n", drive ); | 1418 | printk(KERN_ERR "Unknown Device: fd%d\n", drive ); |
1417 | end_request(CURRENT, 0); | 1419 | fd_end_request_cur(-EIO); |
1418 | goto repeat; | 1420 | goto repeat; |
1419 | } | 1421 | } |
1420 | 1422 | ||
@@ -1430,12 +1432,12 @@ repeat: | |||
1430 | /* user supplied disk type */ | 1432 | /* user supplied disk type */ |
1431 | if (--type >= NUM_DISK_MINORS) { | 1433 | if (--type >= NUM_DISK_MINORS) { |
1432 | printk(KERN_WARNING "fd%d: invalid disk format", drive ); | 1434 | printk(KERN_WARNING "fd%d: invalid disk format", drive ); |
1433 | end_request(CURRENT, 0); | 1435 | fd_end_request_cur(-EIO); |
1434 | goto repeat; | 1436 | goto repeat; |
1435 | } | 1437 | } |
1436 | if (minor2disktype[type].drive_types > DriveType) { | 1438 | if (minor2disktype[type].drive_types > DriveType) { |
1437 | printk(KERN_WARNING "fd%d: unsupported disk format", drive ); | 1439 | printk(KERN_WARNING "fd%d: unsupported disk format", drive ); |
1438 | end_request(CURRENT, 0); | 1440 | fd_end_request_cur(-EIO); |
1439 | goto repeat; | 1441 | goto repeat; |
1440 | } | 1442 | } |
1441 | type = minor2disktype[type].index; | 1443 | type = minor2disktype[type].index; |
@@ -1444,8 +1446,8 @@ repeat: | |||
1444 | UD.autoprobe = 0; | 1446 | UD.autoprobe = 0; |
1445 | } | 1447 | } |
1446 | 1448 | ||
1447 | if (CURRENT->sector + 1 > UDT->blocks) { | 1449 | if (blk_rq_pos(fd_request) + 1 > UDT->blocks) { |
1448 | end_request(CURRENT, 0); | 1450 | fd_end_request_cur(-EIO); |
1449 | goto repeat; | 1451 | goto repeat; |
1450 | } | 1452 | } |
1451 | 1453 | ||
@@ -1453,9 +1455,9 @@ repeat: | |||
1453 | del_timer( &motor_off_timer ); | 1455 | del_timer( &motor_off_timer ); |
1454 | 1456 | ||
1455 | ReqCnt = 0; | 1457 | ReqCnt = 0; |
1456 | ReqCmd = rq_data_dir(CURRENT); | 1458 | ReqCmd = rq_data_dir(fd_request); |
1457 | ReqBlock = CURRENT->sector; | 1459 | ReqBlock = blk_rq_pos(fd_request); |
1458 | ReqBuffer = CURRENT->buffer; | 1460 | ReqBuffer = fd_request->buffer; |
1459 | setup_req_params( drive ); | 1461 | setup_req_params( drive ); |
1460 | do_fd_action( drive ); | 1462 | do_fd_action( drive ); |
1461 | 1463 | ||