diff options
Diffstat (limited to 'drivers/block/swim.c')
-rw-r--r-- | drivers/block/swim.c | 48 |
1 files changed, 17 insertions, 31 deletions
diff --git a/drivers/block/swim.c b/drivers/block/swim.c index d22cc3856937..cf7877fb8a7d 100644 --- a/drivers/block/swim.c +++ b/drivers/block/swim.c | |||
@@ -514,7 +514,7 @@ static int floppy_read_sectors(struct floppy_state *fs, | |||
514 | ret = swim_read_sector(fs, side, track, sector, | 514 | ret = swim_read_sector(fs, side, track, sector, |
515 | buffer); | 515 | buffer); |
516 | if (try-- == 0) | 516 | if (try-- == 0) |
517 | return -1; | 517 | return -EIO; |
518 | } while (ret != 512); | 518 | } while (ret != 512); |
519 | 519 | ||
520 | buffer += ret; | 520 | buffer += ret; |
@@ -528,45 +528,31 @@ static void redo_fd_request(struct request_queue *q) | |||
528 | struct request *req; | 528 | struct request *req; |
529 | struct floppy_state *fs; | 529 | struct floppy_state *fs; |
530 | 530 | ||
531 | while ((req = elv_next_request(q))) { | 531 | req = blk_fetch_request(q); |
532 | while (req) { | ||
533 | int err = -EIO; | ||
532 | 534 | ||
533 | fs = req->rq_disk->private_data; | 535 | fs = req->rq_disk->private_data; |
534 | if (req->sector < 0 || req->sector >= fs->total_secs) { | 536 | if (blk_rq_pos(req) >= fs->total_secs) |
535 | end_request(req, 0); | 537 | goto done; |
536 | continue; | 538 | if (!fs->disk_in) |
537 | } | 539 | goto done; |
538 | if (req->current_nr_sectors == 0) { | 540 | if (rq_data_dir(req) == WRITE && fs->write_protected) |
539 | end_request(req, 1); | 541 | goto done; |
540 | continue; | 542 | |
541 | } | ||
542 | if (!fs->disk_in) { | ||
543 | end_request(req, 0); | ||
544 | continue; | ||
545 | } | ||
546 | if (rq_data_dir(req) == WRITE) { | ||
547 | if (fs->write_protected) { | ||
548 | end_request(req, 0); | ||
549 | continue; | ||
550 | } | ||
551 | } | ||
552 | switch (rq_data_dir(req)) { | 543 | switch (rq_data_dir(req)) { |
553 | case WRITE: | 544 | case WRITE: |
554 | /* NOT IMPLEMENTED */ | 545 | /* NOT IMPLEMENTED */ |
555 | end_request(req, 0); | ||
556 | break; | 546 | break; |
557 | case READ: | 547 | case READ: |
558 | if (floppy_read_sectors(fs, req->sector, | 548 | err = floppy_read_sectors(fs, blk_rq_pos(req), |
559 | req->current_nr_sectors, | 549 | blk_rq_cur_sectors(req), |
560 | req->buffer)) { | 550 | req->buffer); |
561 | end_request(req, 0); | ||
562 | continue; | ||
563 | } | ||
564 | req->nr_sectors -= req->current_nr_sectors; | ||
565 | req->sector += req->current_nr_sectors; | ||
566 | req->buffer += req->current_nr_sectors * 512; | ||
567 | end_request(req, 1); | ||
568 | break; | 551 | break; |
569 | } | 552 | } |
553 | done: | ||
554 | if (!__blk_end_request_cur(req, err)) | ||
555 | req = blk_fetch_request(q); | ||
570 | } | 556 | } |
571 | } | 557 | } |
572 | 558 | ||