aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/ide/ide-cd.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/ide/ide-cd.c')
-rw-r--r--drivers/ide/ide-cd.c81
1 files changed, 47 insertions, 34 deletions
diff --git a/drivers/ide/ide-cd.c b/drivers/ide/ide-cd.c
index 4c32e8db55c3..c859eafe759b 100644
--- a/drivers/ide/ide-cd.c
+++ b/drivers/ide/ide-cd.c
@@ -265,34 +265,6 @@ static void ide_cd_complete_failed_rq(ide_drive_t *drive, struct request *rq)
265 cdrom_analyze_sense_data(drive, NULL, sense); 265 cdrom_analyze_sense_data(drive, NULL, sense);
266} 266}
267 267
268static void cdrom_end_request(ide_drive_t *drive, int uptodate)
269{
270 struct request *rq = drive->hwif->rq;
271 int nsectors = rq->hard_cur_sectors;
272
273 ide_debug_log(IDE_DBG_FUNC, "cmd: 0x%x, uptodate: 0x%x, nsectors: %d",
274 rq->cmd[0], uptodate, nsectors);
275
276 if (blk_sense_request(rq) && uptodate)
277 ide_cd_complete_failed_rq(drive, rq);
278
279 if (!rq->current_nr_sectors && blk_fs_request(rq))
280 uptodate = 1;
281 /* make sure it's fully ended */
282 if (blk_pc_request(rq))
283 nsectors = (rq->data_len + 511) >> 9;
284 if (!nsectors)
285 nsectors = 1;
286
287 ide_debug_log(IDE_DBG_FUNC, "uptodate: 0x%x, nsectors: %d",
288 uptodate, nsectors);
289
290 if (blk_fs_request(rq) == 0 && uptodate <= 0 && rq->errors == 0)
291 rq->errors = -EIO;
292
293 ide_complete_rq(drive, uptodate ? 0 : -EIO, nsectors << 9);
294}
295
296/* 268/*
297 * Returns: 269 * Returns:
298 * 0: if the request should be continued. 270 * 0: if the request should be continued.
@@ -735,7 +707,7 @@ static ide_startstop_t cdrom_newpc_intr(ide_drive_t *drive)
735 xfer_func_t *xferfunc; 707 xfer_func_t *xferfunc;
736 ide_expiry_t *expiry = NULL; 708 ide_expiry_t *expiry = NULL;
737 int dma_error = 0, dma, stat, thislen, uptodate = 0; 709 int dma_error = 0, dma, stat, thislen, uptodate = 0;
738 int write = (rq_data_dir(rq) == WRITE) ? 1 : 0, rc; 710 int write = (rq_data_dir(rq) == WRITE) ? 1 : 0, rc, nsectors;
739 int sense = blk_sense_request(rq); 711 int sense = blk_sense_request(rq);
740 unsigned int timeout; 712 unsigned int timeout;
741 u16 len; 713 u16 len;
@@ -902,8 +874,14 @@ static ide_startstop_t cdrom_newpc_intr(ide_drive_t *drive)
902 rq->current_nr_sectors -= (blen >> 9); 874 rq->current_nr_sectors -= (blen >> 9);
903 rq->sector += (blen >> 9); 875 rq->sector += (blen >> 9);
904 876
905 if (rq->current_nr_sectors == 0 && rq->nr_sectors) 877 if (rq->current_nr_sectors == 0 && rq->nr_sectors) {
906 cdrom_end_request(drive, 1); 878 nsectors = rq->hard_cur_sectors;
879
880 if (nsectors == 0)
881 nsectors = 1;
882
883 ide_complete_rq(drive, 0, nsectors << 9);
884 }
907 } else { 885 } else {
908 rq->data_len -= blen; 886 rq->data_len -= blen;
909 887
@@ -951,7 +929,28 @@ out_end:
951 929
952 hwif->rq = NULL; 930 hwif->rq = NULL;
953 } else { 931 } else {
954 cdrom_end_request(drive, uptodate); 932 if (sense && uptodate)
933 ide_cd_complete_failed_rq(drive, rq);
934
935 if (blk_fs_request(rq)) {
936 if (rq->current_nr_sectors == 0)
937 uptodate = 1;
938 } else {
939 if (uptodate <= 0 && rq->errors == 0)
940 rq->errors = -EIO;
941 }
942
943 /* make sure it's fully ended */
944 if (blk_pc_request(rq))
945 nsectors = (rq->data_len + 511) >> 9;
946 else
947 nsectors = rq->hard_cur_sectors;
948
949 if (nsectors == 0)
950 nsectors = 1;
951
952 ide_complete_rq(drive, uptodate ? 0 : -EIO, nsectors << 9);
953
955 if (sense && rc == 2) 954 if (sense && rc == 2)
956 ide_error(drive, "request sense failure", stat); 955 ide_error(drive, "request sense failure", stat);
957 } 956 }
@@ -1040,7 +1039,7 @@ static ide_startstop_t ide_cd_do_request(ide_drive_t *drive, struct request *rq,
1040 sector_t block) 1039 sector_t block)
1041{ 1040{
1042 struct ide_cmd cmd; 1041 struct ide_cmd cmd;
1043 int uptodate = 0; 1042 int uptodate = 0, nsectors;
1044 1043
1045 ide_debug_log(IDE_DBG_RQ, "cmd: 0x%x, block: %llu", 1044 ide_debug_log(IDE_DBG_RQ, "cmd: 0x%x, block: %llu",
1046 rq->cmd[0], (unsigned long long)block); 1045 rq->cmd[0], (unsigned long long)block);
@@ -1076,7 +1075,21 @@ static ide_startstop_t ide_cd_do_request(ide_drive_t *drive, struct request *rq,
1076 1075
1077 return ide_issue_pc(drive, &cmd); 1076 return ide_issue_pc(drive, &cmd);
1078out_end: 1077out_end:
1079 cdrom_end_request(drive, uptodate); 1078 if (blk_fs_request(rq)) {
1079 if (rq->current_nr_sectors == 0)
1080 uptodate = 1;
1081 } else {
1082 if (uptodate <= 0 && rq->errors == 0)
1083 rq->errors = -EIO;
1084 }
1085
1086 nsectors = rq->hard_cur_sectors;
1087
1088 if (nsectors == 0)
1089 nsectors = 1;
1090
1091 ide_complete_rq(drive, uptodate ? 0 : -EIO, nsectors << 9);
1092
1080 return ide_stopped; 1093 return ide_stopped;
1081} 1094}
1082 1095