aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/block/floppy.c
diff options
context:
space:
mode:
authorTejun Heo <tj@kernel.org>2009-05-07 09:24:39 -0400
committerJens Axboe <jens.axboe@oracle.com>2009-05-11 03:50:54 -0400
commit83096ebf1263b2c1ee5e653ba37d993d02e3eb7b (patch)
tree2226b71a616ec1cb2d37511c6a09ba9507a1cd69 /drivers/block/floppy.c
parent5b93629b4509c03ffa87a9316412fedf6f58cb37 (diff)
block: convert to pos and nr_sectors accessors
With recent cleanups, there is no place where low level driver directly manipulates request fields. This means that the 'hard' request fields always equal the !hard fields. Convert all rq->sectors, nr_sectors and current_nr_sectors references to accessors. While at it, drop superflous blk_rq_pos() < 0 test in swim.c. [ Impact: use pos and nr_sectors accessors ] Signed-off-by: Tejun Heo <tj@kernel.org> Acked-by: Geert Uytterhoeven <Geert.Uytterhoeven@sonycom.com> Tested-by: Grant Likely <grant.likely@secretlab.ca> Acked-by: Grant Likely <grant.likely@secretlab.ca> Tested-by: Adrian McMenamin <adrian@mcmen.demon.co.uk> Acked-by: Adrian McMenamin <adrian@mcmen.demon.co.uk> Acked-by: Mike Miller <mike.miller@hp.com> Cc: James Bottomley <James.Bottomley@HansenPartnership.com> Cc: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> Cc: Borislav Petkov <petkovbb@googlemail.com> Cc: Sergei Shtylyov <sshtylyov@ru.mvista.com> Cc: Eric Moore <Eric.Moore@lsi.com> Cc: Alan Stern <stern@rowland.harvard.edu> Cc: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp> Cc: Pete Zaitcev <zaitcev@redhat.com> Cc: Stephen Rothwell <sfr@canb.auug.org.au> Cc: Paul Clements <paul.clements@steeleye.com> Cc: Tim Waugh <tim@cyberelk.net> Cc: Jeff Garzik <jgarzik@pobox.com> Cc: Jeremy Fitzhardinge <jeremy@xensource.com> Cc: Alex Dubov <oakad@yahoo.com> Cc: David Woodhouse <dwmw2@infradead.org> Cc: Martin Schwidefsky <schwidefsky@de.ibm.com> Cc: Dario Ballabio <ballabio_dario@emc.com> Cc: David S. Miller <davem@davemloft.net> Cc: Rusty Russell <rusty@rustcorp.com.au> Cc: unsik Kim <donari75@gmail.com> Cc: Laurent Vivier <Laurent@lvivier.info> Signed-off-by: Jens Axboe <jens.axboe@oracle.com>
Diffstat (limited to 'drivers/block/floppy.c')
-rw-r--r--drivers/block/floppy.c53
1 files changed, 27 insertions, 26 deletions
diff --git a/drivers/block/floppy.c b/drivers/block/floppy.c
index 1300df6f1642..452486283386 100644
--- a/drivers/block/floppy.c
+++ b/drivers/block/floppy.c
@@ -2303,7 +2303,7 @@ static void floppy_end_request(struct request *req, int error)
2303 2303
2304 /* current_count_sectors can be zero if transfer failed */ 2304 /* current_count_sectors can be zero if transfer failed */
2305 if (error) 2305 if (error)
2306 nr_sectors = req->current_nr_sectors; 2306 nr_sectors = blk_rq_cur_sectors(req);
2307 if (__blk_end_request(req, error, nr_sectors << 9)) 2307 if (__blk_end_request(req, error, nr_sectors << 9))
2308 return; 2308 return;
2309 2309
@@ -2332,7 +2332,7 @@ static void request_done(int uptodate)
2332 if (uptodate) { 2332 if (uptodate) {
2333 /* maintain values for invalidation on geometry 2333 /* maintain values for invalidation on geometry
2334 * change */ 2334 * change */
2335 block = current_count_sectors + req->sector; 2335 block = current_count_sectors + blk_rq_pos(req);
2336 INFBOUND(DRS->maxblock, block); 2336 INFBOUND(DRS->maxblock, block);
2337 if (block > _floppy->sect) 2337 if (block > _floppy->sect)
2338 DRS->maxtrack = 1; 2338 DRS->maxtrack = 1;
@@ -2346,10 +2346,10 @@ static void request_done(int uptodate)
2346 /* record write error information */ 2346 /* record write error information */
2347 DRWE->write_errors++; 2347 DRWE->write_errors++;
2348 if (DRWE->write_errors == 1) { 2348 if (DRWE->write_errors == 1) {
2349 DRWE->first_error_sector = req->sector; 2349 DRWE->first_error_sector = blk_rq_pos(req);
2350 DRWE->first_error_generation = DRS->generation; 2350 DRWE->first_error_generation = DRS->generation;
2351 } 2351 }
2352 DRWE->last_error_sector = req->sector; 2352 DRWE->last_error_sector = blk_rq_pos(req);
2353 DRWE->last_error_generation = DRS->generation; 2353 DRWE->last_error_generation = DRS->generation;
2354 } 2354 }
2355 spin_lock_irqsave(q->queue_lock, flags); 2355 spin_lock_irqsave(q->queue_lock, flags);
@@ -2503,24 +2503,24 @@ static void copy_buffer(int ssize, int max_sector, int max_sector_2)
2503 2503
2504 max_sector = transfer_size(ssize, 2504 max_sector = transfer_size(ssize,
2505 min(max_sector, max_sector_2), 2505 min(max_sector, max_sector_2),
2506 current_req->nr_sectors); 2506 blk_rq_sectors(current_req));
2507 2507
2508 if (current_count_sectors <= 0 && CT(COMMAND) == FD_WRITE && 2508 if (current_count_sectors <= 0 && CT(COMMAND) == FD_WRITE &&
2509 buffer_max > fsector_t + current_req->nr_sectors) 2509 buffer_max > fsector_t + blk_rq_sectors(current_req))
2510 current_count_sectors = min_t(int, buffer_max - fsector_t, 2510 current_count_sectors = min_t(int, buffer_max - fsector_t,
2511 current_req->nr_sectors); 2511 blk_rq_sectors(current_req));
2512 2512
2513 remaining = current_count_sectors << 9; 2513 remaining = current_count_sectors << 9;
2514#ifdef FLOPPY_SANITY_CHECK 2514#ifdef FLOPPY_SANITY_CHECK
2515 if ((remaining >> 9) > current_req->nr_sectors && 2515 if ((remaining >> 9) > blk_rq_sectors(current_req) &&
2516 CT(COMMAND) == FD_WRITE) { 2516 CT(COMMAND) == FD_WRITE) {
2517 DPRINT("in copy buffer\n"); 2517 DPRINT("in copy buffer\n");
2518 printk("current_count_sectors=%ld\n", current_count_sectors); 2518 printk("current_count_sectors=%ld\n", current_count_sectors);
2519 printk("remaining=%d\n", remaining >> 9); 2519 printk("remaining=%d\n", remaining >> 9);
2520 printk("current_req->nr_sectors=%ld\n", 2520 printk("current_req->nr_sectors=%u\n",
2521 current_req->nr_sectors); 2521 blk_rq_sectors(current_req));
2522 printk("current_req->current_nr_sectors=%u\n", 2522 printk("current_req->current_nr_sectors=%u\n",
2523 current_req->current_nr_sectors); 2523 blk_rq_cur_sectors(current_req));
2524 printk("max_sector=%d\n", max_sector); 2524 printk("max_sector=%d\n", max_sector);
2525 printk("ssize=%d\n", ssize); 2525 printk("ssize=%d\n", ssize);
2526 } 2526 }
@@ -2530,7 +2530,7 @@ static void copy_buffer(int ssize, int max_sector, int max_sector_2)
2530 2530
2531 dma_buffer = floppy_track_buffer + ((fsector_t - buffer_min) << 9); 2531 dma_buffer = floppy_track_buffer + ((fsector_t - buffer_min) << 9);
2532 2532
2533 size = current_req->current_nr_sectors << 9; 2533 size = blk_rq_cur_sectors(current_req) << 9;
2534 2534
2535 rq_for_each_segment(bv, current_req, iter) { 2535 rq_for_each_segment(bv, current_req, iter) {
2536 if (!remaining) 2536 if (!remaining)
@@ -2648,10 +2648,10 @@ static int make_raw_rw_request(void)
2648 2648
2649 max_sector = _floppy->sect * _floppy->head; 2649 max_sector = _floppy->sect * _floppy->head;
2650 2650
2651 TRACK = (int)current_req->sector / max_sector; 2651 TRACK = (int)blk_rq_pos(current_req) / max_sector;
2652 fsector_t = (int)current_req->sector % max_sector; 2652 fsector_t = (int)blk_rq_pos(current_req) % max_sector;
2653 if (_floppy->track && TRACK >= _floppy->track) { 2653 if (_floppy->track && TRACK >= _floppy->track) {
2654 if (current_req->current_nr_sectors & 1) { 2654 if (blk_rq_cur_sectors(current_req) & 1) {
2655 current_count_sectors = 1; 2655 current_count_sectors = 1;
2656 return 1; 2656 return 1;
2657 } else 2657 } else
@@ -2669,7 +2669,7 @@ static int make_raw_rw_request(void)
2669 if (fsector_t >= max_sector) { 2669 if (fsector_t >= max_sector) {
2670 current_count_sectors = 2670 current_count_sectors =
2671 min_t(int, _floppy->sect - fsector_t, 2671 min_t(int, _floppy->sect - fsector_t,
2672 current_req->nr_sectors); 2672 blk_rq_sectors(current_req));
2673 return 1; 2673 return 1;
2674 } 2674 }
2675 SIZECODE = 2; 2675 SIZECODE = 2;
@@ -2720,7 +2720,7 @@ static int make_raw_rw_request(void)
2720 2720
2721 in_sector_offset = (fsector_t % _floppy->sect) % ssize; 2721 in_sector_offset = (fsector_t % _floppy->sect) % ssize;
2722 aligned_sector_t = fsector_t - in_sector_offset; 2722 aligned_sector_t = fsector_t - in_sector_offset;
2723 max_size = current_req->nr_sectors; 2723 max_size = blk_rq_sectors(current_req);
2724 if ((raw_cmd->track == buffer_track) && 2724 if ((raw_cmd->track == buffer_track) &&
2725 (current_drive == buffer_drive) && 2725 (current_drive == buffer_drive) &&
2726 (fsector_t >= buffer_min) && (fsector_t < buffer_max)) { 2726 (fsector_t >= buffer_min) && (fsector_t < buffer_max)) {
@@ -2729,10 +2729,10 @@ static int make_raw_rw_request(void)
2729 copy_buffer(1, max_sector, buffer_max); 2729 copy_buffer(1, max_sector, buffer_max);
2730 return 1; 2730 return 1;
2731 } 2731 }
2732 } else if (in_sector_offset || current_req->nr_sectors < ssize) { 2732 } else if (in_sector_offset || blk_rq_sectors(current_req) < ssize) {
2733 if (CT(COMMAND) == FD_WRITE) { 2733 if (CT(COMMAND) == FD_WRITE) {
2734 if (fsector_t + current_req->nr_sectors > ssize && 2734 if (fsector_t + blk_rq_sectors(current_req) > ssize &&
2735 fsector_t + current_req->nr_sectors < ssize + ssize) 2735 fsector_t + blk_rq_sectors(current_req) < ssize + ssize)
2736 max_size = ssize + ssize; 2736 max_size = ssize + ssize;
2737 else 2737 else
2738 max_size = ssize; 2738 max_size = ssize;
@@ -2776,7 +2776,7 @@ static int make_raw_rw_request(void)
2776 (indirect * 2 > direct * 3 && 2776 (indirect * 2 > direct * 3 &&
2777 *errors < DP->max_errors.read_track && ((!probing 2777 *errors < DP->max_errors.read_track && ((!probing
2778 || (DP->read_track & (1 << DRS->probed_format)))))) { 2778 || (DP->read_track & (1 << DRS->probed_format)))))) {
2779 max_size = current_req->nr_sectors; 2779 max_size = blk_rq_sectors(current_req);
2780 } else { 2780 } else {
2781 raw_cmd->kernel_data = current_req->buffer; 2781 raw_cmd->kernel_data = current_req->buffer;
2782 raw_cmd->length = current_count_sectors << 9; 2782 raw_cmd->length = current_count_sectors << 9;
@@ -2801,7 +2801,7 @@ static int make_raw_rw_request(void)
2801 fsector_t > buffer_max || 2801 fsector_t > buffer_max ||
2802 fsector_t < buffer_min || 2802 fsector_t < buffer_min ||
2803 ((CT(COMMAND) == FD_READ || 2803 ((CT(COMMAND) == FD_READ ||
2804 (!in_sector_offset && current_req->nr_sectors >= ssize)) && 2804 (!in_sector_offset && blk_rq_sectors(current_req) >= ssize)) &&
2805 max_sector > 2 * max_buffer_sectors + buffer_min && 2805 max_sector > 2 * max_buffer_sectors + buffer_min &&
2806 max_size + fsector_t > 2 * max_buffer_sectors + buffer_min) 2806 max_size + fsector_t > 2 * max_buffer_sectors + buffer_min)
2807 /* not enough space */ 2807 /* not enough space */
@@ -2879,8 +2879,8 @@ static int make_raw_rw_request(void)
2879 printk("write\n"); 2879 printk("write\n");
2880 return 0; 2880 return 0;
2881 } 2881 }
2882 } else if (raw_cmd->length > current_req->nr_sectors << 9 || 2882 } else if (raw_cmd->length > blk_rq_sectors(current_req) << 9 ||
2883 current_count_sectors > current_req->nr_sectors) { 2883 current_count_sectors > blk_rq_sectors(current_req)) {
2884 DPRINT("buffer overrun in direct transfer\n"); 2884 DPRINT("buffer overrun in direct transfer\n");
2885 return 0; 2885 return 0;
2886 } else if (raw_cmd->length < current_count_sectors << 9) { 2886 } else if (raw_cmd->length < current_count_sectors << 9) {
@@ -2990,8 +2990,9 @@ static void do_fd_request(struct request_queue * q)
2990 if (usage_count == 0) { 2990 if (usage_count == 0) {
2991 printk("warning: usage count=0, current_req=%p exiting\n", 2991 printk("warning: usage count=0, current_req=%p exiting\n",
2992 current_req); 2992 current_req);
2993 printk("sect=%ld type=%x flags=%x\n", (long)current_req->sector, 2993 printk("sect=%ld type=%x flags=%x\n",
2994 current_req->cmd_type, current_req->cmd_flags); 2994 (long)blk_rq_pos(current_req), current_req->cmd_type,
2995 current_req->cmd_flags);
2995 return; 2996 return;
2996 } 2997 }
2997 if (test_bit(0, &fdc_busy)) { 2998 if (test_bit(0, &fdc_busy)) {