diff options
Diffstat (limited to 'drivers/block/floppy.c')
-rw-r--r-- | drivers/block/floppy.c | 87 |
1 files changed, 39 insertions, 48 deletions
diff --git a/drivers/block/floppy.c b/drivers/block/floppy.c index 085b7794fb3e..80483aac4cc9 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) { |
@@ -3815,14 +3810,10 @@ static int check_floppy_change(struct gendisk *disk) | |||
3815 | * a disk in the drive, and whether that disk is writable. | 3810 | * a disk in the drive, and whether that disk is writable. |
3816 | */ | 3811 | */ |
3817 | 3812 | ||
3818 | static int floppy_rb0_complete(struct bio *bio, unsigned int bytes_done, | 3813 | static void floppy_rb0_complete(struct bio *bio, |
3819 | int err) | 3814 | int err) |
3820 | { | 3815 | { |
3821 | if (bio->bi_size) | ||
3822 | return 1; | ||
3823 | |||
3824 | complete((struct completion *)bio->bi_private); | 3816 | complete((struct completion *)bio->bi_private); |
3825 | return 0; | ||
3826 | } | 3817 | } |
3827 | 3818 | ||
3828 | static int __floppy_read_block_0(struct block_device *bdev) | 3819 | static int __floppy_read_block_0(struct block_device *bdev) |