diff options
Diffstat (limited to 'drivers/block/floppy.c')
-rw-r--r-- | drivers/block/floppy.c | 85 |
1 files changed, 55 insertions, 30 deletions
diff --git a/drivers/block/floppy.c b/drivers/block/floppy.c index 1300df6f1642..862b40c90181 100644 --- a/drivers/block/floppy.c +++ b/drivers/block/floppy.c | |||
@@ -931,7 +931,7 @@ static inline void unlock_fdc(void) | |||
931 | del_timer(&fd_timeout); | 931 | del_timer(&fd_timeout); |
932 | cont = NULL; | 932 | cont = NULL; |
933 | clear_bit(0, &fdc_busy); | 933 | clear_bit(0, &fdc_busy); |
934 | if (elv_next_request(floppy_queue)) | 934 | if (current_req || blk_peek_request(floppy_queue)) |
935 | do_fd_request(floppy_queue); | 935 | do_fd_request(floppy_queue); |
936 | spin_unlock_irqrestore(&floppy_lock, flags); | 936 | spin_unlock_irqrestore(&floppy_lock, flags); |
937 | wake_up(&fdc_wait); | 937 | wake_up(&fdc_wait); |
@@ -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,23 @@ 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 > blk_rq_bytes(current_req) && CT(COMMAND) == FD_WRITE) { |
2516 | CT(COMMAND) == FD_WRITE) { | ||
2517 | DPRINT("in copy buffer\n"); | 2516 | DPRINT("in copy buffer\n"); |
2518 | printk("current_count_sectors=%ld\n", current_count_sectors); | 2517 | printk("current_count_sectors=%ld\n", current_count_sectors); |
2519 | printk("remaining=%d\n", remaining >> 9); | 2518 | printk("remaining=%d\n", remaining >> 9); |
2520 | printk("current_req->nr_sectors=%ld\n", | 2519 | printk("current_req->nr_sectors=%u\n", |
2521 | current_req->nr_sectors); | 2520 | blk_rq_sectors(current_req)); |
2522 | printk("current_req->current_nr_sectors=%u\n", | 2521 | printk("current_req->current_nr_sectors=%u\n", |
2523 | current_req->current_nr_sectors); | 2522 | blk_rq_cur_sectors(current_req)); |
2524 | printk("max_sector=%d\n", max_sector); | 2523 | printk("max_sector=%d\n", max_sector); |
2525 | printk("ssize=%d\n", ssize); | 2524 | printk("ssize=%d\n", ssize); |
2526 | } | 2525 | } |
@@ -2530,7 +2529,7 @@ static void copy_buffer(int ssize, int max_sector, int max_sector_2) | |||
2530 | 2529 | ||
2531 | dma_buffer = floppy_track_buffer + ((fsector_t - buffer_min) << 9); | 2530 | dma_buffer = floppy_track_buffer + ((fsector_t - buffer_min) << 9); |
2532 | 2531 | ||
2533 | size = current_req->current_nr_sectors << 9; | 2532 | size = blk_rq_cur_bytes(current_req); |
2534 | 2533 | ||
2535 | rq_for_each_segment(bv, current_req, iter) { | 2534 | rq_for_each_segment(bv, current_req, iter) { |
2536 | if (!remaining) | 2535 | if (!remaining) |
@@ -2648,10 +2647,10 @@ static int make_raw_rw_request(void) | |||
2648 | 2647 | ||
2649 | max_sector = _floppy->sect * _floppy->head; | 2648 | max_sector = _floppy->sect * _floppy->head; |
2650 | 2649 | ||
2651 | TRACK = (int)current_req->sector / max_sector; | 2650 | TRACK = (int)blk_rq_pos(current_req) / max_sector; |
2652 | fsector_t = (int)current_req->sector % max_sector; | 2651 | fsector_t = (int)blk_rq_pos(current_req) % max_sector; |
2653 | if (_floppy->track && TRACK >= _floppy->track) { | 2652 | if (_floppy->track && TRACK >= _floppy->track) { |
2654 | if (current_req->current_nr_sectors & 1) { | 2653 | if (blk_rq_cur_sectors(current_req) & 1) { |
2655 | current_count_sectors = 1; | 2654 | current_count_sectors = 1; |
2656 | return 1; | 2655 | return 1; |
2657 | } else | 2656 | } else |
@@ -2669,7 +2668,7 @@ static int make_raw_rw_request(void) | |||
2669 | if (fsector_t >= max_sector) { | 2668 | if (fsector_t >= max_sector) { |
2670 | current_count_sectors = | 2669 | current_count_sectors = |
2671 | min_t(int, _floppy->sect - fsector_t, | 2670 | min_t(int, _floppy->sect - fsector_t, |
2672 | current_req->nr_sectors); | 2671 | blk_rq_sectors(current_req)); |
2673 | return 1; | 2672 | return 1; |
2674 | } | 2673 | } |
2675 | SIZECODE = 2; | 2674 | SIZECODE = 2; |
@@ -2720,7 +2719,7 @@ static int make_raw_rw_request(void) | |||
2720 | 2719 | ||
2721 | in_sector_offset = (fsector_t % _floppy->sect) % ssize; | 2720 | in_sector_offset = (fsector_t % _floppy->sect) % ssize; |
2722 | aligned_sector_t = fsector_t - in_sector_offset; | 2721 | aligned_sector_t = fsector_t - in_sector_offset; |
2723 | max_size = current_req->nr_sectors; | 2722 | max_size = blk_rq_sectors(current_req); |
2724 | if ((raw_cmd->track == buffer_track) && | 2723 | if ((raw_cmd->track == buffer_track) && |
2725 | (current_drive == buffer_drive) && | 2724 | (current_drive == buffer_drive) && |
2726 | (fsector_t >= buffer_min) && (fsector_t < buffer_max)) { | 2725 | (fsector_t >= buffer_min) && (fsector_t < buffer_max)) { |
@@ -2729,10 +2728,10 @@ static int make_raw_rw_request(void) | |||
2729 | copy_buffer(1, max_sector, buffer_max); | 2728 | copy_buffer(1, max_sector, buffer_max); |
2730 | return 1; | 2729 | return 1; |
2731 | } | 2730 | } |
2732 | } else if (in_sector_offset || current_req->nr_sectors < ssize) { | 2731 | } else if (in_sector_offset || blk_rq_sectors(current_req) < ssize) { |
2733 | if (CT(COMMAND) == FD_WRITE) { | 2732 | if (CT(COMMAND) == FD_WRITE) { |
2734 | if (fsector_t + current_req->nr_sectors > ssize && | 2733 | if (fsector_t + blk_rq_sectors(current_req) > ssize && |
2735 | fsector_t + current_req->nr_sectors < ssize + ssize) | 2734 | fsector_t + blk_rq_sectors(current_req) < ssize + ssize) |
2736 | max_size = ssize + ssize; | 2735 | max_size = ssize + ssize; |
2737 | else | 2736 | else |
2738 | max_size = ssize; | 2737 | max_size = ssize; |
@@ -2776,7 +2775,7 @@ static int make_raw_rw_request(void) | |||
2776 | (indirect * 2 > direct * 3 && | 2775 | (indirect * 2 > direct * 3 && |
2777 | *errors < DP->max_errors.read_track && ((!probing | 2776 | *errors < DP->max_errors.read_track && ((!probing |
2778 | || (DP->read_track & (1 << DRS->probed_format)))))) { | 2777 | || (DP->read_track & (1 << DRS->probed_format)))))) { |
2779 | max_size = current_req->nr_sectors; | 2778 | max_size = blk_rq_sectors(current_req); |
2780 | } else { | 2779 | } else { |
2781 | raw_cmd->kernel_data = current_req->buffer; | 2780 | raw_cmd->kernel_data = current_req->buffer; |
2782 | raw_cmd->length = current_count_sectors << 9; | 2781 | raw_cmd->length = current_count_sectors << 9; |
@@ -2801,7 +2800,7 @@ static int make_raw_rw_request(void) | |||
2801 | fsector_t > buffer_max || | 2800 | fsector_t > buffer_max || |
2802 | fsector_t < buffer_min || | 2801 | fsector_t < buffer_min || |
2803 | ((CT(COMMAND) == FD_READ || | 2802 | ((CT(COMMAND) == FD_READ || |
2804 | (!in_sector_offset && current_req->nr_sectors >= ssize)) && | 2803 | (!in_sector_offset && blk_rq_sectors(current_req) >= ssize)) && |
2805 | max_sector > 2 * max_buffer_sectors + buffer_min && | 2804 | max_sector > 2 * max_buffer_sectors + buffer_min && |
2806 | max_size + fsector_t > 2 * max_buffer_sectors + buffer_min) | 2805 | max_size + fsector_t > 2 * max_buffer_sectors + buffer_min) |
2807 | /* not enough space */ | 2806 | /* not enough space */ |
@@ -2879,8 +2878,8 @@ static int make_raw_rw_request(void) | |||
2879 | printk("write\n"); | 2878 | printk("write\n"); |
2880 | return 0; | 2879 | return 0; |
2881 | } | 2880 | } |
2882 | } else if (raw_cmd->length > current_req->nr_sectors << 9 || | 2881 | } else if (raw_cmd->length > blk_rq_bytes(current_req) || |
2883 | current_count_sectors > current_req->nr_sectors) { | 2882 | current_count_sectors > blk_rq_sectors(current_req)) { |
2884 | DPRINT("buffer overrun in direct transfer\n"); | 2883 | DPRINT("buffer overrun in direct transfer\n"); |
2885 | return 0; | 2884 | return 0; |
2886 | } else if (raw_cmd->length < current_count_sectors << 9) { | 2885 | } else if (raw_cmd->length < current_count_sectors << 9) { |
@@ -2913,7 +2912,7 @@ static void redo_fd_request(void) | |||
2913 | struct request *req; | 2912 | struct request *req; |
2914 | 2913 | ||
2915 | spin_lock_irq(floppy_queue->queue_lock); | 2914 | spin_lock_irq(floppy_queue->queue_lock); |
2916 | req = elv_next_request(floppy_queue); | 2915 | req = blk_fetch_request(floppy_queue); |
2917 | spin_unlock_irq(floppy_queue->queue_lock); | 2916 | spin_unlock_irq(floppy_queue->queue_lock); |
2918 | if (!req) { | 2917 | if (!req) { |
2919 | do_floppy = NULL; | 2918 | do_floppy = NULL; |
@@ -2990,8 +2989,9 @@ static void do_fd_request(struct request_queue * q) | |||
2990 | if (usage_count == 0) { | 2989 | if (usage_count == 0) { |
2991 | printk("warning: usage count=0, current_req=%p exiting\n", | 2990 | printk("warning: usage count=0, current_req=%p exiting\n", |
2992 | current_req); | 2991 | current_req); |
2993 | printk("sect=%ld type=%x flags=%x\n", (long)current_req->sector, | 2992 | printk("sect=%ld type=%x flags=%x\n", |
2994 | current_req->cmd_type, current_req->cmd_flags); | 2993 | (long)blk_rq_pos(current_req), current_req->cmd_type, |
2994 | current_req->cmd_flags); | ||
2995 | return; | 2995 | return; |
2996 | } | 2996 | } |
2997 | if (test_bit(0, &fdc_busy)) { | 2997 | if (test_bit(0, &fdc_busy)) { |
@@ -4148,6 +4148,24 @@ static void floppy_device_release(struct device *dev) | |||
4148 | { | 4148 | { |
4149 | } | 4149 | } |
4150 | 4150 | ||
4151 | static int floppy_resume(struct platform_device *dev) | ||
4152 | { | ||
4153 | int fdc; | ||
4154 | |||
4155 | for (fdc = 0; fdc < N_FDC; fdc++) | ||
4156 | if (FDCS->address != -1) | ||
4157 | user_reset_fdc(-1, FD_RESET_ALWAYS, 0); | ||
4158 | |||
4159 | return 0; | ||
4160 | } | ||
4161 | |||
4162 | static struct platform_driver floppy_driver = { | ||
4163 | .resume = floppy_resume, | ||
4164 | .driver = { | ||
4165 | .name = "floppy", | ||
4166 | }, | ||
4167 | }; | ||
4168 | |||
4151 | static struct platform_device floppy_device[N_DRIVE]; | 4169 | static struct platform_device floppy_device[N_DRIVE]; |
4152 | 4170 | ||
4153 | static struct kobject *floppy_find(dev_t dev, int *part, void *data) | 4171 | static struct kobject *floppy_find(dev_t dev, int *part, void *data) |
@@ -4196,10 +4214,14 @@ static int __init floppy_init(void) | |||
4196 | if (err) | 4214 | if (err) |
4197 | goto out_put_disk; | 4215 | goto out_put_disk; |
4198 | 4216 | ||
4217 | err = platform_driver_register(&floppy_driver); | ||
4218 | if (err) | ||
4219 | goto out_unreg_blkdev; | ||
4220 | |||
4199 | floppy_queue = blk_init_queue(do_fd_request, &floppy_lock); | 4221 | floppy_queue = blk_init_queue(do_fd_request, &floppy_lock); |
4200 | if (!floppy_queue) { | 4222 | if (!floppy_queue) { |
4201 | err = -ENOMEM; | 4223 | err = -ENOMEM; |
4202 | goto out_unreg_blkdev; | 4224 | goto out_unreg_driver; |
4203 | } | 4225 | } |
4204 | blk_queue_max_sectors(floppy_queue, 64); | 4226 | blk_queue_max_sectors(floppy_queue, 64); |
4205 | 4227 | ||
@@ -4346,6 +4368,8 @@ out_flush_work: | |||
4346 | out_unreg_region: | 4368 | out_unreg_region: |
4347 | blk_unregister_region(MKDEV(FLOPPY_MAJOR, 0), 256); | 4369 | blk_unregister_region(MKDEV(FLOPPY_MAJOR, 0), 256); |
4348 | blk_cleanup_queue(floppy_queue); | 4370 | blk_cleanup_queue(floppy_queue); |
4371 | out_unreg_driver: | ||
4372 | platform_driver_unregister(&floppy_driver); | ||
4349 | out_unreg_blkdev: | 4373 | out_unreg_blkdev: |
4350 | unregister_blkdev(FLOPPY_MAJOR, "fd"); | 4374 | unregister_blkdev(FLOPPY_MAJOR, "fd"); |
4351 | out_put_disk: | 4375 | out_put_disk: |
@@ -4566,6 +4590,7 @@ static void __exit floppy_module_exit(void) | |||
4566 | 4590 | ||
4567 | blk_unregister_region(MKDEV(FLOPPY_MAJOR, 0), 256); | 4591 | blk_unregister_region(MKDEV(FLOPPY_MAJOR, 0), 256); |
4568 | unregister_blkdev(FLOPPY_MAJOR, "fd"); | 4592 | unregister_blkdev(FLOPPY_MAJOR, "fd"); |
4593 | platform_driver_unregister(&floppy_driver); | ||
4569 | 4594 | ||
4570 | for (drive = 0; drive < N_DRIVE; drive++) { | 4595 | for (drive = 0; drive < N_DRIVE; drive++) { |
4571 | del_timer_sync(&motor_off_timer[drive]); | 4596 | del_timer_sync(&motor_off_timer[drive]); |