diff options
author | NeilBrown <neilb@suse.de> | 2007-09-25 06:35:59 -0400 |
---|---|---|
committer | Jens Axboe <axboe@carl.home.kernel.dk> | 2007-10-10 03:25:56 -0400 |
commit | 5705f7021748a69d84d6567e68e8851dab551464 (patch) | |
tree | 5a6dbc8fc6055c0334f4a97540e36a7844b9c482 /drivers/block/floppy.c | |
parent | 9dfa52831e96194b8649613e3131baa2c109f7dc (diff) |
Introduce rq_for_each_segment replacing rq_for_each_bio
Every usage of rq_for_each_bio wraps a usage of
bio_for_each_segment, so these can be combined into
rq_for_each_segment.
We define "struct req_iterator" to hold the 'bio' and 'index' that
are needed for the double iteration.
Signed-off-by: Neil Brown <neilb@suse.de>
Various compile fixes by me...
Signed-off-by: Jens Axboe <jens.axboe@oracle.com>
Diffstat (limited to 'drivers/block/floppy.c')
-rw-r--r-- | drivers/block/floppy.c | 81 |
1 files changed, 38 insertions, 43 deletions
diff --git a/drivers/block/floppy.c b/drivers/block/floppy.c index 085b7794fb3e..f0a86e201b44 100644 --- a/drivers/block/floppy.c +++ b/drivers/block/floppy.c | |||
@@ -2437,22 +2437,19 @@ static void rw_interrupt(void) | |||
2437 | /* Compute maximal contiguous buffer size. */ | 2437 | /* Compute maximal contiguous buffer size. */ |
2438 | static int buffer_chain_size(void) | 2438 | static int buffer_chain_size(void) |
2439 | { | 2439 | { |
2440 | struct bio *bio; | ||
2441 | struct bio_vec *bv; | 2440 | struct bio_vec *bv; |
2442 | int size, i; | 2441 | int size; |
2442 | struct req_iterator iter; | ||
2443 | char *base; | 2443 | char *base; |
2444 | 2444 | ||
2445 | base = bio_data(current_req->bio); | 2445 | base = bio_data(current_req->bio); |
2446 | size = 0; | 2446 | size = 0; |
2447 | 2447 | ||
2448 | rq_for_each_bio(bio, current_req) { | 2448 | rq_for_each_segment(bv, current_req, iter) { |
2449 | bio_for_each_segment(bv, bio, i) { | 2449 | if (page_address(bv->bv_page) + bv->bv_offset != base + size) |
2450 | if (page_address(bv->bv_page) + bv->bv_offset != | 2450 | break; |
2451 | base + size) | ||
2452 | break; | ||
2453 | 2451 | ||
2454 | size += bv->bv_len; | 2452 | size += bv->bv_len; |
2455 | } | ||
2456 | } | 2453 | } |
2457 | 2454 | ||
2458 | return size >> 9; | 2455 | return size >> 9; |
@@ -2479,9 +2476,9 @@ static void copy_buffer(int ssize, int max_sector, int max_sector_2) | |||
2479 | { | 2476 | { |
2480 | int remaining; /* number of transferred 512-byte sectors */ | 2477 | int remaining; /* number of transferred 512-byte sectors */ |
2481 | struct bio_vec *bv; | 2478 | struct bio_vec *bv; |
2482 | struct bio *bio; | ||
2483 | char *buffer, *dma_buffer; | 2479 | char *buffer, *dma_buffer; |
2484 | int size, i; | 2480 | int size; |
2481 | struct req_iterator iter; | ||
2485 | 2482 | ||
2486 | max_sector = transfer_size(ssize, | 2483 | max_sector = transfer_size(ssize, |
2487 | min(max_sector, max_sector_2), | 2484 | min(max_sector, max_sector_2), |
@@ -2514,43 +2511,41 @@ static void copy_buffer(int ssize, int max_sector, int max_sector_2) | |||
2514 | 2511 | ||
2515 | size = current_req->current_nr_sectors << 9; | 2512 | size = current_req->current_nr_sectors << 9; |
2516 | 2513 | ||
2517 | rq_for_each_bio(bio, current_req) { | 2514 | rq_for_each_segment(bv, current_req, iter) { |
2518 | bio_for_each_segment(bv, bio, i) { | 2515 | if (!remaining) |
2519 | if (!remaining) | 2516 | break; |
2520 | break; | ||
2521 | 2517 | ||
2522 | size = bv->bv_len; | 2518 | size = bv->bv_len; |
2523 | SUPBOUND(size, remaining); | 2519 | SUPBOUND(size, remaining); |
2524 | 2520 | ||
2525 | buffer = page_address(bv->bv_page) + bv->bv_offset; | 2521 | buffer = page_address(bv->bv_page) + bv->bv_offset; |
2526 | #ifdef FLOPPY_SANITY_CHECK | 2522 | #ifdef FLOPPY_SANITY_CHECK |
2527 | if (dma_buffer + size > | 2523 | if (dma_buffer + size > |
2528 | floppy_track_buffer + (max_buffer_sectors << 10) || | 2524 | floppy_track_buffer + (max_buffer_sectors << 10) || |
2529 | dma_buffer < floppy_track_buffer) { | 2525 | dma_buffer < floppy_track_buffer) { |
2530 | DPRINT("buffer overrun in copy buffer %d\n", | 2526 | DPRINT("buffer overrun in copy buffer %d\n", |
2531 | (int)((floppy_track_buffer - | 2527 | (int)((floppy_track_buffer - |
2532 | dma_buffer) >> 9)); | 2528 | dma_buffer) >> 9)); |
2533 | printk("fsector_t=%d buffer_min=%d\n", | 2529 | printk("fsector_t=%d buffer_min=%d\n", |
2534 | fsector_t, buffer_min); | 2530 | fsector_t, buffer_min); |
2535 | printk("current_count_sectors=%ld\n", | 2531 | printk("current_count_sectors=%ld\n", |
2536 | current_count_sectors); | 2532 | current_count_sectors); |
2537 | if (CT(COMMAND) == FD_READ) | ||
2538 | printk("read\n"); | ||
2539 | if (CT(COMMAND) == FD_WRITE) | ||
2540 | printk("write\n"); | ||
2541 | break; | ||
2542 | } | ||
2543 | if (((unsigned long)buffer) % 512) | ||
2544 | DPRINT("%p buffer not aligned\n", buffer); | ||
2545 | #endif | ||
2546 | if (CT(COMMAND) == FD_READ) | 2533 | if (CT(COMMAND) == FD_READ) |
2547 | memcpy(buffer, dma_buffer, size); | 2534 | printk("read\n"); |
2548 | else | 2535 | if (CT(COMMAND) == FD_WRITE) |
2549 | memcpy(dma_buffer, buffer, size); | 2536 | printk("write\n"); |
2550 | 2537 | break; | |
2551 | remaining -= size; | ||
2552 | dma_buffer += size; | ||
2553 | } | 2538 | } |
2539 | if (((unsigned long)buffer) % 512) | ||
2540 | DPRINT("%p buffer not aligned\n", buffer); | ||
2541 | #endif | ||
2542 | if (CT(COMMAND) == FD_READ) | ||
2543 | memcpy(buffer, dma_buffer, size); | ||
2544 | else | ||
2545 | memcpy(dma_buffer, buffer, size); | ||
2546 | |||
2547 | remaining -= size; | ||
2548 | dma_buffer += size; | ||
2554 | } | 2549 | } |
2555 | #ifdef FLOPPY_SANITY_CHECK | 2550 | #ifdef FLOPPY_SANITY_CHECK |
2556 | if (remaining) { | 2551 | if (remaining) { |