Commit 2bbc810a authored by Linus Torvalds's avatar Linus Torvalds

Clean up insane floppy driver CURRENT handling, make the

driver remove the ftont of the queue from the request list
and cache it in 'current_req'.

This simplifies the driver and should be a lot more robust.

Still, I'll probably go blind just for _looking_ at the dang
sources of this thing. Whee.
parent 88c70f33
...@@ -239,6 +239,7 @@ static int allowed_drive_mask = 0x33; ...@@ -239,6 +239,7 @@ static int allowed_drive_mask = 0x33;
static int irqdma_allocated; static int irqdma_allocated;
#define CURRENT current_req
#define LOCAL_END_REQUEST #define LOCAL_END_REQUEST
#define MAJOR_NR FLOPPY_MAJOR #define MAJOR_NR FLOPPY_MAJOR
#define DEVICE_NAME "floppy" #define DEVICE_NAME "floppy"
...@@ -249,6 +250,8 @@ static int irqdma_allocated; ...@@ -249,6 +250,8 @@ static int irqdma_allocated;
#include <linux/cdrom.h> /* for the compatibility eject ioctl */ #include <linux/cdrom.h> /* for the compatibility eject ioctl */
#include <linux/completion.h> #include <linux/completion.h>
static struct request *current_req;
#ifndef fd_get_dma_residue #ifndef fd_get_dma_residue
#define fd_get_dma_residue() get_dma_residue(FLOPPY_DMA) #define fd_get_dma_residue() get_dma_residue(FLOPPY_DMA)
#endif #endif
...@@ -2296,8 +2299,13 @@ static inline void end_request(struct request *req, int uptodate) ...@@ -2296,8 +2299,13 @@ static inline void end_request(struct request *req, int uptodate)
return; return;
add_blkdev_randomness(major(dev)); add_blkdev_randomness(major(dev));
floppy_off(DEVICE_NR(dev)); floppy_off(DEVICE_NR(dev));
blkdev_dequeue_request(req);
end_that_request_last(req); end_that_request_last(req);
/* Get the next request */
req = elv_next_request(QUEUE);
if (req)
blkdev_dequeue_request(req);
CURRENT = req;
} }
...@@ -2306,15 +2314,15 @@ static inline void end_request(struct request *req, int uptodate) ...@@ -2306,15 +2314,15 @@ static inline void end_request(struct request *req, int uptodate)
static void request_done(int uptodate) static void request_done(int uptodate)
{ {
struct request_queue *q = QUEUE; struct request_queue *q = QUEUE;
struct request *req = elv_next_request(q); struct request *req = CURRENT;
unsigned long flags; unsigned long flags;
int block; int block;
probing = 0; probing = 0;
reschedule_timeout(MAXTIMEOUT, "request done %d", uptodate); reschedule_timeout(MAXTIMEOUT, "request done %d", uptodate);
if (blk_queue_empty(q)) { if (!req) {
DPRINT("request list destroyed in floppy request done\n"); printk("floppy.c: no request in request_done\n");
return; return;
} }
...@@ -2328,7 +2336,7 @@ static void request_done(int uptodate) ...@@ -2328,7 +2336,7 @@ static void request_done(int uptodate)
/* unlock chained buffers */ /* unlock chained buffers */
spin_lock_irqsave(q->queue_lock, flags); spin_lock_irqsave(q->queue_lock, flags);
while (current_count_sectors && !blk_queue_empty(q) && while (current_count_sectors && CURRENT &&
current_count_sectors >= req->current_nr_sectors){ current_count_sectors >= req->current_nr_sectors){
current_count_sectors -= req->current_nr_sectors; current_count_sectors -= req->current_nr_sectors;
req->nr_sectors -= req->current_nr_sectors; req->nr_sectors -= req->current_nr_sectors;
...@@ -2337,7 +2345,7 @@ static void request_done(int uptodate) ...@@ -2337,7 +2345,7 @@ static void request_done(int uptodate)
} }
spin_unlock_irqrestore(q->queue_lock, flags); spin_unlock_irqrestore(q->queue_lock, flags);
if (current_count_sectors && !blk_queue_empty(q)) { if (current_count_sectors && CURRENT) {
/* "unlock" last subsector */ /* "unlock" last subsector */
req->buffer += current_count_sectors <<9; req->buffer += current_count_sectors <<9;
req->current_nr_sectors -= current_count_sectors; req->current_nr_sectors -= current_count_sectors;
...@@ -2346,7 +2354,7 @@ static void request_done(int uptodate) ...@@ -2346,7 +2354,7 @@ static void request_done(int uptodate)
return; return;
} }
if (current_count_sectors && blk_queue_empty(q)) if (current_count_sectors && !CURRENT)
DPRINT("request list destroyed in floppy request done\n"); DPRINT("request list destroyed in floppy request done\n");
} else { } else {
...@@ -2924,11 +2932,16 @@ static void redo_fd_request(void) ...@@ -2924,11 +2932,16 @@ static void redo_fd_request(void)
floppy_off(current_drive); floppy_off(current_drive);
for (;;) { for (;;) {
if (blk_queue_empty(QUEUE)) { if (!CURRENT) {
struct request *req = elv_next_request(QUEUE);
if (!req) {
do_floppy = NULL; do_floppy = NULL;
unlock_fdc(); unlock_fdc();
return; return;
} }
blkdev_dequeue_request(req);
CURRENT = req;
}
if (major(CURRENT->rq_dev) != MAJOR_NR) if (major(CURRENT->rq_dev) != MAJOR_NR)
panic(DEVICE_NAME ": request list destroyed"); panic(DEVICE_NAME ": request list destroyed");
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment