Commit 0ffbe56a authored by Alexander Viro's avatar Alexander Viro Committed by James Bottomley

[PATCH] swim3.c cleanup

	* killed uses of CURRENT and QUEUE
parent 0fe11f99
...@@ -34,12 +34,12 @@ ...@@ -34,12 +34,12 @@
#define MAJOR_NR FLOPPY_MAJOR #define MAJOR_NR FLOPPY_MAJOR
#define DEVICE_NAME "floppy" #define DEVICE_NAME "floppy"
#define QUEUE (&swim3_queue)
#include <linux/blk.h> #include <linux/blk.h>
#include <linux/devfs_fs_kernel.h> #include <linux/devfs_fs_kernel.h>
static struct request_queue swim3_queue; static struct request_queue swim3_queue;
static struct gendisk *disks[2]; static struct gendisk *disks[2];
static struct request *fd_req;
#define MAX_FLOPPIES 2 #define MAX_FLOPPIES 2
...@@ -315,45 +315,43 @@ static void start_request(struct floppy_state *fs) ...@@ -315,45 +315,43 @@ static void start_request(struct floppy_state *fs)
wake_up(&fs->wait); wake_up(&fs->wait);
return; return;
} }
while (!blk_queue_empty(QUEUE) && fs->state == idle) { while (!blk_queue_empty(&swim3_queue) && fs->state == idle) {
if (major(CURRENT->rq_dev) != MAJOR_NR) struct request *req = elv_next_request(&swim3_queue);
panic(DEVICE_NAME ": request list destroyed");
// if (CURRENT->bh && !buffer_locked(CURRENT->bh))
// panic(DEVICE_NAME ": block not locked");
#if 0 #if 0
printk("do_fd_req: dev=%x cmd=%d sec=%ld nr_sec=%ld buf=%p\n", printk("do_fd_req: dev=%s cmd=%d sec=%ld nr_sec=%ld buf=%p\n",
kdev_t_to_nr(CURRENT->rq_dev), CURRENT->cmd, req->rq_disk->disk_name, req->cmd,
CURRENT->sector, CURRENT->nr_sectors, CURRENT->buffer); req->sector, req->nr_sectors, req->buffer);
printk(" rq_status=%d errors=%d current_nr_sectors=%ld\n", printk(" rq_status=%d errors=%d current_nr_sectors=%ld\n",
CURRENT->rq_status, CURRENT->errors, CURRENT->current_nr_sectors); req->rq_status, req->errors, req->current_nr_sectors);
#endif #endif
if (CURRENT->sector < 0 || CURRENT->sector >= fs->total_secs) { if (req->sector < 0 || req->sector >= fs->total_secs) {
end_request(CURRENT, 0); end_request(req, 0);
continue; continue;
} }
if (CURRENT->current_nr_sectors == 0) { if (req->current_nr_sectors == 0) {
end_request(CURRENT, 1); end_request(req, 1);
continue; continue;
} }
if (fs->ejected) { if (fs->ejected) {
end_request(CURRENT, 0); end_request(req, 0);
continue; continue;
} }
if (rq_data_dir(CURRENT) == WRITE) { if (rq_data_dir(req) == WRITE) {
if (fs->write_prot < 0) if (fs->write_prot < 0)
fs->write_prot = swim3_readbit(fs, WRITE_PROT); fs->write_prot = swim3_readbit(fs, WRITE_PROT);
if (fs->write_prot) { if (fs->write_prot) {
end_request(CURRENT, 0); end_request(req, 0);
continue; continue;
} }
} }
fs->req_cyl = CURRENT->sector / fs->secpercyl; fs->req_cyl = req->sector / fs->secpercyl;
x = CURRENT->sector % fs->secpercyl; x = req->sector % fs->secpercyl;
fs->head = x / fs->secpertrack; fs->head = x / fs->secpertrack;
fs->req_sector = x % fs->secpertrack + 1; fs->req_sector = x % fs->secpertrack + 1;
fd_req = req;
fs->state = do_transfer; fs->state = do_transfer;
fs->retries = 0; fs->retries = 0;
...@@ -425,16 +423,16 @@ static inline void setup_transfer(struct floppy_state *fs) ...@@ -425,16 +423,16 @@ static inline void setup_transfer(struct floppy_state *fs)
struct dbdma_cmd *cp = fs->dma_cmd; struct dbdma_cmd *cp = fs->dma_cmd;
struct dbdma_regs *dr = fs->dma; struct dbdma_regs *dr = fs->dma;
if (CURRENT->current_nr_sectors <= 0) { if (fd_req->current_nr_sectors <= 0) {
printk(KERN_ERR "swim3: transfer 0 sectors?\n"); printk(KERN_ERR "swim3: transfer 0 sectors?\n");
return; return;
} }
if (rq_data_dir(CURRENT) == WRITE) if (rq_data_dir(fd_req) == WRITE)
n = 1; n = 1;
else { else {
n = fs->secpertrack - fs->req_sector + 1; n = fs->secpertrack - fs->req_sector + 1;
if (n > CURRENT->current_nr_sectors) if (n > fd_req->current_nr_sectors)
n = CURRENT->current_nr_sectors; n = fd_req->current_nr_sectors;
} }
fs->scount = n; fs->scount = n;
swim3_select(fs, fs->head? READ_DATA_1: READ_DATA_0); swim3_select(fs, fs->head? READ_DATA_1: READ_DATA_0);
...@@ -442,21 +440,21 @@ static inline void setup_transfer(struct floppy_state *fs) ...@@ -442,21 +440,21 @@ static inline void setup_transfer(struct floppy_state *fs)
out_8(&sw->nsect, n); out_8(&sw->nsect, n);
out_8(&sw->gap3, 0); out_8(&sw->gap3, 0);
st_le32(&dr->cmdptr, virt_to_bus(cp)); st_le32(&dr->cmdptr, virt_to_bus(cp));
if (rq_data_dir(CURRENT) == WRITE) { if (rq_data_dir(fd_req) == WRITE) {
/* Set up 3 dma commands: write preamble, data, postamble */ /* Set up 3 dma commands: write preamble, data, postamble */
init_dma(cp, OUTPUT_MORE, write_preamble, sizeof(write_preamble)); init_dma(cp, OUTPUT_MORE, write_preamble, sizeof(write_preamble));
++cp; ++cp;
init_dma(cp, OUTPUT_MORE, CURRENT->buffer, 512); init_dma(cp, OUTPUT_MORE, fd_req->buffer, 512);
++cp; ++cp;
init_dma(cp, OUTPUT_LAST, write_postamble, sizeof(write_postamble)); init_dma(cp, OUTPUT_LAST, write_postamble, sizeof(write_postamble));
} else { } else {
init_dma(cp, INPUT_LAST, CURRENT->buffer, n * 512); init_dma(cp, INPUT_LAST, fd_req->buffer, n * 512);
} }
++cp; ++cp;
out_le16(&cp->command, DBDMA_STOP); out_le16(&cp->command, DBDMA_STOP);
out_le32(&dr->control, (RUN << 16) | RUN); out_le32(&dr->control, (RUN << 16) | RUN);
out_8(&sw->control_bis, out_8(&sw->control_bis,
(rq_data_dir(CURRENT) == WRITE? WRITE_SECTORS: 0) | DO_ACTION); (rq_data_dir(fd_req) == WRITE? WRITE_SECTORS: 0) | DO_ACTION);
/* enable intr when transfer complete */ /* enable intr when transfer complete */
out_8(&sw->intr_enable, ERROR_INTR | TRANSFER_DONE); out_8(&sw->intr_enable, ERROR_INTR | TRANSFER_DONE);
set_timeout(fs, 2*HZ, xfer_timeout); /* enable timeout */ set_timeout(fs, 2*HZ, xfer_timeout); /* enable timeout */
...@@ -516,7 +514,7 @@ static void act(struct floppy_state *fs) ...@@ -516,7 +514,7 @@ static void act(struct floppy_state *fs)
case do_transfer: case do_transfer:
if (fs->cur_cyl != fs->req_cyl) { if (fs->cur_cyl != fs->req_cyl) {
if (fs->retries > 5) { if (fs->retries > 5) {
end_request(CURRENT, 0); end_request(fd_req, 0);
fs->state = idle; fs->state = idle;
return; return;
} }
...@@ -548,7 +546,7 @@ static void scan_timeout(unsigned long data) ...@@ -548,7 +546,7 @@ static void scan_timeout(unsigned long data)
out_8(&sw->intr_enable, 0); out_8(&sw->intr_enable, 0);
fs->cur_cyl = -1; fs->cur_cyl = -1;
if (fs->retries > 5) { if (fs->retries > 5) {
end_request(CURRENT, 0); end_request(fd_req, 0);
fs->state = idle; fs->state = idle;
start_request(fs); start_request(fs);
} else { } else {
...@@ -577,7 +575,7 @@ static void seek_timeout(unsigned long data) ...@@ -577,7 +575,7 @@ static void seek_timeout(unsigned long data)
return; return;
} }
printk(KERN_ERR "swim3: seek timeout\n"); printk(KERN_ERR "swim3: seek timeout\n");
end_request(CURRENT, 0); end_request(fd_req, 0);
fs->state = idle; fs->state = idle;
start_request(fs); start_request(fs);
} }
...@@ -595,17 +593,17 @@ static void xfer_timeout(unsigned long data) ...@@ -595,17 +593,17 @@ static void xfer_timeout(unsigned long data)
out_8(&sw->intr_enable, 0); out_8(&sw->intr_enable, 0);
out_8(&sw->control_bic, WRITE_SECTORS | DO_ACTION); out_8(&sw->control_bic, WRITE_SECTORS | DO_ACTION);
out_8(&sw->select, RELAX); out_8(&sw->select, RELAX);
if (rq_data_dir(CURRENT) == WRITE) if (rq_data_dir(fd_req) == WRITE)
++cp; ++cp;
if (ld_le16(&cp->xfer_status) != 0) if (ld_le16(&cp->xfer_status) != 0)
s = fs->scount - ((ld_le16(&cp->res_count) + 511) >> 9); s = fs->scount - ((ld_le16(&cp->res_count) + 511) >> 9);
else else
s = 0; s = 0;
CURRENT->sector += s; fd_req->sector += s;
CURRENT->current_nr_sectors -= s; fd_req->current_nr_sectors -= s;
printk(KERN_ERR "swim3: timeout %sing sector %ld\n", printk(KERN_ERR "swim3: timeout %sing sector %ld\n",
(rq_data_dir(CURRENT)==WRITE? "writ": "read"), CURRENT->sector); (rq_data_dir(fd_req)==WRITE? "writ": "read"), fd_req->sector);
end_request(CURRENT, 0); end_request(fd_req, 0);
fs->state = idle; fs->state = idle;
start_request(fs); start_request(fs);
} }
...@@ -626,7 +624,7 @@ static void swim3_interrupt(int irq, void *dev_id, struct pt_regs *regs) ...@@ -626,7 +624,7 @@ static void swim3_interrupt(int irq, void *dev_id, struct pt_regs *regs)
#endif #endif
if ((intr & ERROR_INTR) && fs->state != do_transfer) if ((intr & ERROR_INTR) && fs->state != do_transfer)
printk(KERN_ERR "swim3_interrupt, state=%d, dir=%lx, intr=%x, err=%x\n", printk(KERN_ERR "swim3_interrupt, state=%d, dir=%lx, intr=%x, err=%x\n",
fs->state, rq_data_dir(CURRENT), intr, err); fs->state, rq_data_dir(fd_req), intr, err);
switch (fs->state) { switch (fs->state) {
case locating: case locating:
if (intr & SEEN_SECTOR) { if (intr & SEEN_SECTOR) {
...@@ -639,7 +637,7 @@ static void swim3_interrupt(int irq, void *dev_id, struct pt_regs *regs) ...@@ -639,7 +637,7 @@ static void swim3_interrupt(int irq, void *dev_id, struct pt_regs *regs)
printk(KERN_ERR "swim3: seen sector but cyl=ff?\n"); printk(KERN_ERR "swim3: seen sector but cyl=ff?\n");
fs->cur_cyl = -1; fs->cur_cyl = -1;
if (fs->retries > 5) { if (fs->retries > 5) {
end_request(CURRENT, 0); end_request(fd_req, 0);
fs->state = idle; fs->state = idle;
start_request(fs); start_request(fs);
} else { } else {
...@@ -691,16 +689,16 @@ static void swim3_interrupt(int irq, void *dev_id, struct pt_regs *regs) ...@@ -691,16 +689,16 @@ static void swim3_interrupt(int irq, void *dev_id, struct pt_regs *regs)
out_8(&sw->select, RELAX); out_8(&sw->select, RELAX);
del_timer(&fs->timeout); del_timer(&fs->timeout);
fs->timeout_pending = 0; fs->timeout_pending = 0;
if (rq_data_dir(CURRENT) == WRITE) if (rq_data_dir(fd_req) == WRITE)
++cp; ++cp;
stat = ld_le16(&cp->xfer_status); stat = ld_le16(&cp->xfer_status);
resid = ld_le16(&cp->res_count); resid = ld_le16(&cp->res_count);
if (intr & ERROR_INTR) { if (intr & ERROR_INTR) {
n = fs->scount - 1 - resid / 512; n = fs->scount - 1 - resid / 512;
if (n > 0) { if (n > 0) {
CURRENT->sector += n; fd_req->sector += n;
CURRENT->current_nr_sectors -= n; fd_req->current_nr_sectors -= n;
CURRENT->buffer += n * 512; fd_req->buffer += n * 512;
fs->req_sector += n; fs->req_sector += n;
} }
if (fs->retries < 5) { if (fs->retries < 5) {
...@@ -708,9 +706,9 @@ static void swim3_interrupt(int irq, void *dev_id, struct pt_regs *regs) ...@@ -708,9 +706,9 @@ static void swim3_interrupt(int irq, void *dev_id, struct pt_regs *regs)
act(fs); act(fs);
} else { } else {
printk("swim3: error %sing block %ld (err=%x)\n", printk("swim3: error %sing block %ld (err=%x)\n",
rq_data_dir(CURRENT) == WRITE? "writ": "read", rq_data_dir(fd_req) == WRITE? "writ": "read",
CURRENT->sector, err); fd_req->sector, err);
end_request(CURRENT, 0); end_request(fd_req, 0);
fs->state = idle; fs->state = idle;
} }
} else { } else {
...@@ -718,17 +716,17 @@ static void swim3_interrupt(int irq, void *dev_id, struct pt_regs *regs) ...@@ -718,17 +716,17 @@ static void swim3_interrupt(int irq, void *dev_id, struct pt_regs *regs)
/* musta been an error */ /* musta been an error */
printk(KERN_ERR "swim3: fd dma: stat=%x resid=%d\n", stat, resid); printk(KERN_ERR "swim3: fd dma: stat=%x resid=%d\n", stat, resid);
printk(KERN_ERR " state=%d, dir=%lx, intr=%x, err=%x\n", printk(KERN_ERR " state=%d, dir=%lx, intr=%x, err=%x\n",
fs->state, rq_data_dir(CURRENT), intr, err); fs->state, rq_data_dir(fd_req), intr, err);
end_request(CURRENT, 0); end_request(fd_req, 0);
fs->state = idle; fs->state = idle;
start_request(fs); start_request(fs);
break; break;
} }
CURRENT->sector += fs->scount; fd_req->sector += fs->scount;
CURRENT->current_nr_sectors -= fs->scount; fd_req->current_nr_sectors -= fs->scount;
CURRENT->buffer += fs->scount * 512; fd_req->buffer += fs->scount * 512;
if (CURRENT->current_nr_sectors <= 0) { if (fd_req->current_nr_sectors <= 0) {
end_request(CURRENT, 1); end_request(fd_req, 1);
fs->state = idle; fs->state = idle;
} else { } else {
fs->req_sector += fs->scount; fs->req_sector += fs->scount;
......
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