aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/block/ataflop.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/block/ataflop.c')
-rw-r--r--drivers/block/ataflop.c50
1 files changed, 39 insertions, 11 deletions
diff --git a/drivers/block/ataflop.c b/drivers/block/ataflop.c
index aceb96476524..0f4eec442e5d 100644
--- a/drivers/block/ataflop.c
+++ b/drivers/block/ataflop.c
@@ -79,8 +79,8 @@
79 79
80#undef DEBUG 80#undef DEBUG
81 81
82static struct request_queue *floppy_queue;
83static struct request *fd_request; 82static struct request *fd_request;
83static int fdc_queue;
84 84
85/* Disk types: DD, HD, ED */ 85/* Disk types: DD, HD, ED */
86static struct atari_disk_type { 86static struct atari_disk_type {
@@ -1391,6 +1391,29 @@ static void setup_req_params( int drive )
1391 ReqTrack, ReqSector, (unsigned long)ReqData )); 1391 ReqTrack, ReqSector, (unsigned long)ReqData ));
1392} 1392}
1393 1393
1394/*
1395 * Round-robin between our available drives, doing one request from each
1396 */
1397static struct request *set_next_request(void)
1398{
1399 struct request_queue *q;
1400 int old_pos = fdc_queue;
1401 struct request *rq;
1402
1403 do {
1404 q = unit[fdc_queue].disk->queue;
1405 if (++fdc_queue == FD_MAX_UNITS)
1406 fdc_queue = 0;
1407 if (q) {
1408 rq = blk_fetch_request(q);
1409 if (rq)
1410 break;
1411 }
1412 } while (fdc_queue != old_pos);
1413
1414 return rq;
1415}
1416
1394 1417
1395static void redo_fd_request(void) 1418static void redo_fd_request(void)
1396{ 1419{
@@ -1405,7 +1428,7 @@ static void redo_fd_request(void)
1405 1428
1406repeat: 1429repeat:
1407 if (!fd_request) { 1430 if (!fd_request) {
1408 fd_request = blk_fetch_request(floppy_queue); 1431 fd_request = set_next_request();
1409 if (!fd_request) 1432 if (!fd_request)
1410 goto the_end; 1433 goto the_end;
1411 } 1434 }
@@ -1932,10 +1955,6 @@ static int __init atari_floppy_init (void)
1932 PhysTrackBuffer = virt_to_phys(TrackBuffer); 1955 PhysTrackBuffer = virt_to_phys(TrackBuffer);
1933 BufferDrive = BufferSide = BufferTrack = -1; 1956 BufferDrive = BufferSide = BufferTrack = -1;
1934 1957
1935 floppy_queue = blk_init_queue(do_fd_request, &ataflop_lock);
1936 if (!floppy_queue)
1937 goto Enomem;
1938
1939 for (i = 0; i < FD_MAX_UNITS; i++) { 1958 for (i = 0; i < FD_MAX_UNITS; i++) {
1940 unit[i].track = -1; 1959 unit[i].track = -1;
1941 unit[i].flags = 0; 1960 unit[i].flags = 0;
@@ -1944,7 +1963,10 @@ static int __init atari_floppy_init (void)
1944 sprintf(unit[i].disk->disk_name, "fd%d", i); 1963 sprintf(unit[i].disk->disk_name, "fd%d", i);
1945 unit[i].disk->fops = &floppy_fops; 1964 unit[i].disk->fops = &floppy_fops;
1946 unit[i].disk->private_data = &unit[i]; 1965 unit[i].disk->private_data = &unit[i];
1947 unit[i].disk->queue = floppy_queue; 1966 unit[i].disk->queue = blk_init_queue(do_fd_request,
1967 &ataflop_lock);
1968 if (!unit[i].disk->queue)
1969 goto Enomem;
1948 set_capacity(unit[i].disk, MAX_DISK_SIZE * 2); 1970 set_capacity(unit[i].disk, MAX_DISK_SIZE * 2);
1949 add_disk(unit[i].disk); 1971 add_disk(unit[i].disk);
1950 } 1972 }
@@ -1959,10 +1981,14 @@ static int __init atari_floppy_init (void)
1959 1981
1960 return 0; 1982 return 0;
1961Enomem: 1983Enomem:
1962 while (i--) 1984 while (i--) {
1985 struct request_queue *q = unit[i].disk->queue;
1986
1963 put_disk(unit[i].disk); 1987 put_disk(unit[i].disk);
1964 if (floppy_queue) 1988 if (q)
1965 blk_cleanup_queue(floppy_queue); 1989 blk_cleanup_queue(q);
1990 }
1991
1966 unregister_blkdev(FLOPPY_MAJOR, "fd"); 1992 unregister_blkdev(FLOPPY_MAJOR, "fd");
1967 return -ENOMEM; 1993 return -ENOMEM;
1968} 1994}
@@ -2011,12 +2037,14 @@ static void __exit atari_floppy_exit(void)
2011 int i; 2037 int i;
2012 blk_unregister_region(MKDEV(FLOPPY_MAJOR, 0), 256); 2038 blk_unregister_region(MKDEV(FLOPPY_MAJOR, 0), 256);
2013 for (i = 0; i < FD_MAX_UNITS; i++) { 2039 for (i = 0; i < FD_MAX_UNITS; i++) {
2040 struct request_queue *q = unit[i].disk->queue;
2041
2014 del_gendisk(unit[i].disk); 2042 del_gendisk(unit[i].disk);
2015 put_disk(unit[i].disk); 2043 put_disk(unit[i].disk);
2044 blk_cleanup_queue(q);
2016 } 2045 }
2017 unregister_blkdev(FLOPPY_MAJOR, "fd"); 2046 unregister_blkdev(FLOPPY_MAJOR, "fd");
2018 2047
2019 blk_cleanup_queue(floppy_queue);
2020 del_timer_sync(&fd_timer); 2048 del_timer_sync(&fd_timer);
2021 atari_stram_free( DMABuffer ); 2049 atari_stram_free( DMABuffer );
2022} 2050}