Commit aaa04c28 authored by Kiyoshi Ueda's avatar Kiyoshi Ueda Committed by Jens Axboe

blk_end_request: changing ide-cd (take 4)

This patch converts ide-cd (cdrom_newpc_intr()) to use blk_end_request
interfaces.  Related 'uptodate' arguments are converted to 'error'.

In PIO mode, ide-cd (cdrom_newpc_intr()) needs to defer
end_that_request_last() until the device clears DRQ_STAT and raises
an interrupt after end_that_request_first().
So blk_end_request() has to return without completing request
even if no leftover in the request.

ide-cd uses blk_end_request_callback() and a dummy callback function,
which just returns value '1', to tell blk_end_request_callback()
about that.

Cc: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
Signed-off-by: default avatarKiyoshi Ueda <k-ueda@ct.jp.nec.com>
Signed-off-by: default avatarJun'ichi Nomura <j-nomura@ce.jp.nec.com>
Signed-off-by: default avatarJens Axboe <jens.axboe@oracle.com>
parent e19a3ab0
...@@ -1647,6 +1647,17 @@ static int cdrom_write_check_ireason(ide_drive_t *drive, int len, int ireason) ...@@ -1647,6 +1647,17 @@ static int cdrom_write_check_ireason(ide_drive_t *drive, int len, int ireason)
return 1; return 1;
} }
/*
* Called from blk_end_request_callback() after the data of the request
* is completed and before the request is completed.
* By returning value '1', blk_end_request_callback() returns immediately
* without completing the request.
*/
static int cdrom_newpc_intr_dummy_cb(struct request *rq)
{
return 1;
}
typedef void (xfer_func_t)(ide_drive_t *, void *, u32); typedef void (xfer_func_t)(ide_drive_t *, void *, u32);
/* /*
...@@ -1685,9 +1696,13 @@ static ide_startstop_t cdrom_newpc_intr(ide_drive_t *drive) ...@@ -1685,9 +1696,13 @@ static ide_startstop_t cdrom_newpc_intr(ide_drive_t *drive)
return ide_error(drive, "dma error", stat); return ide_error(drive, "dma error", stat);
} }
end_that_request_chunk(rq, 1, rq->data_len); spin_lock_irqsave(&ide_lock, flags);
rq->data_len = 0; if (__blk_end_request(rq, 0, rq->data_len))
goto end_request; BUG();
HWGROUP(drive)->rq = NULL;
spin_unlock_irqrestore(&ide_lock, flags);
return ide_stopped;
} }
/* /*
...@@ -1705,8 +1720,15 @@ static ide_startstop_t cdrom_newpc_intr(ide_drive_t *drive) ...@@ -1705,8 +1720,15 @@ static ide_startstop_t cdrom_newpc_intr(ide_drive_t *drive)
/* /*
* If DRQ is clear, the command has completed. * If DRQ is clear, the command has completed.
*/ */
if ((stat & DRQ_STAT) == 0) if ((stat & DRQ_STAT) == 0) {
goto end_request; spin_lock_irqsave(&ide_lock, flags);
if (__blk_end_request(rq, 0, 0))
BUG();
HWGROUP(drive)->rq = NULL;
spin_unlock_irqrestore(&ide_lock, flags);
return ide_stopped;
}
/* /*
* check which way to transfer data * check which way to transfer data
...@@ -1759,7 +1781,14 @@ static ide_startstop_t cdrom_newpc_intr(ide_drive_t *drive) ...@@ -1759,7 +1781,14 @@ static ide_startstop_t cdrom_newpc_intr(ide_drive_t *drive)
rq->data_len -= blen; rq->data_len -= blen;
if (rq->bio) if (rq->bio)
end_that_request_chunk(rq, 1, blen); /*
* The request can't be completed until DRQ is cleared.
* So complete the data, but don't complete the request
* using the dummy function for the callback feature
* of blk_end_request_callback().
*/
blk_end_request_callback(rq, 0, blen,
cdrom_newpc_intr_dummy_cb);
else else
rq->data += blen; rq->data += blen;
} }
...@@ -1780,14 +1809,6 @@ static ide_startstop_t cdrom_newpc_intr(ide_drive_t *drive) ...@@ -1780,14 +1809,6 @@ static ide_startstop_t cdrom_newpc_intr(ide_drive_t *drive)
ide_set_handler(drive, cdrom_newpc_intr, rq->timeout, NULL); ide_set_handler(drive, cdrom_newpc_intr, rq->timeout, NULL);
return ide_started; return ide_started;
end_request:
spin_lock_irqsave(&ide_lock, flags);
blkdev_dequeue_request(rq);
end_that_request_last(rq, 1);
HWGROUP(drive)->rq = NULL;
spin_unlock_irqrestore(&ide_lock, flags);
return ide_stopped;
} }
static ide_startstop_t cdrom_write_intr(ide_drive_t *drive) static ide_startstop_t cdrom_write_intr(ide_drive_t *drive)
......
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