Skip to content

Commit 467ca75

Browse files
htejunJens Axboe
authored andcommitted
swim3: clean up request completion paths
swim3 curiously tries to update request parameters before calling __blk_end_request() when __blk_end_request() will do it anyway, and it updates request for partial completion manually instead of using blk_update_request(). Also, it does some spurious checks on rq such as testing whether rq->sector is negative or current_nr_sectors is zero right after fetching. Drop unnecessary stuff and use standard block layer mechanisms. [ Impact: cleanup ] Signed-off-by: Tejun Heo <tj@kernel.org> Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org> Signed-off-by: Jens Axboe <jens.axboe@oracle.com>
1 parent e091eb6 commit 467ca75

1 file changed

Lines changed: 5 additions & 26 deletions

File tree

‎drivers/block/swim3.c‎

Lines changed: 5 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -319,14 +319,10 @@ static void start_request(struct floppy_state *fs)
319319
req->errors, req->current_nr_sectors);
320320
#endif
321321

322-
if (req->sector < 0 || req->sector >= fs->total_secs) {
322+
if (req->sector >= fs->total_secs) {
323323
__blk_end_request_cur(req, -EIO);
324324
continue;
325325
}
326-
if (req->current_nr_sectors == 0) {
327-
__blk_end_request_cur(req, 0);
328-
continue;
329-
}
330326
if (fs->ejected) {
331327
__blk_end_request_cur(req, -EIO);
332328
continue;
@@ -593,8 +589,6 @@ static void xfer_timeout(unsigned long data)
593589
struct floppy_state *fs = (struct floppy_state *) data;
594590
struct swim3 __iomem *sw = fs->swim3;
595591
struct dbdma_regs __iomem *dr = fs->dma;
596-
struct dbdma_cmd *cp = fs->dma_cmd;
597-
unsigned long s;
598592
int n;
599593

600594
fs->timeout_pending = 0;
@@ -605,14 +599,6 @@ static void xfer_timeout(unsigned long data)
605599
out_8(&sw->intr_enable, 0);
606600
out_8(&sw->control_bic, WRITE_SECTORS | DO_ACTION);
607601
out_8(&sw->select, RELAX);
608-
if (rq_data_dir(fd_req) == WRITE)
609-
++cp;
610-
if (ld_le16(&cp->xfer_status) != 0)
611-
s = fs->scount - ((ld_le16(&cp->res_count) + 511) >> 9);
612-
else
613-
s = 0;
614-
fd_req->sector += s;
615-
fd_req->current_nr_sectors -= s;
616602
printk(KERN_ERR "swim3: timeout %sing sector %ld\n",
617603
(rq_data_dir(fd_req)==WRITE? "writ": "read"), (long)fd_req->sector);
618604
__blk_end_request_cur(fd_req, -EIO);
@@ -719,9 +705,7 @@ static irqreturn_t swim3_interrupt(int irq, void *dev_id)
719705
if (intr & ERROR_INTR) {
720706
n = fs->scount - 1 - resid / 512;
721707
if (n > 0) {
722-
fd_req->sector += n;
723-
fd_req->current_nr_sectors -= n;
724-
fd_req->buffer += n * 512;
708+
blk_update_request(fd_req, 0, n << 9);
725709
fs->req_sector += n;
726710
}
727711
if (fs->retries < 5) {
@@ -745,13 +729,7 @@ static irqreturn_t swim3_interrupt(int irq, void *dev_id)
745729
start_request(fs);
746730
break;
747731
}
748-
fd_req->sector += fs->scount;
749-
fd_req->current_nr_sectors -= fs->scount;
750-
fd_req->buffer += fs->scount * 512;
751-
if (fd_req->current_nr_sectors <= 0) {
752-
__blk_end_request_cur(fd_req, 0);
753-
fs->state = idle;
754-
} else {
732+
if (__blk_end_request(fd_req, 0, fs->scount << 9)) {
755733
fs->req_sector += fs->scount;
756734
if (fs->req_sector > fs->secpertrack) {
757735
fs->req_sector -= fs->secpertrack;
@@ -761,7 +739,8 @@ static irqreturn_t swim3_interrupt(int irq, void *dev_id)
761739
}
762740
}
763741
act(fs);
764-
}
742+
} else
743+
fs->state = idle;
765744
}
766745
if (fs->state == idle)
767746
start_request(fs);

0 commit comments

Comments
 (0)