aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorBartlomiej Zolnierkiewicz <bzolnier@gmail.com>2009-03-31 14:15:03 -0400
committerBartlomiej Zolnierkiewicz <bzolnier@gmail.com>2009-03-31 14:15:03 -0400
commit8a116974852a727bdfe6b1b897102903a17228a5 (patch)
treeca5bc143612e3c1988b37283515ea26956d664b0 /drivers
parent984c5e5974227d2d4dba58cdf19af641f89be83f (diff)
ide-cd: unify cdrom_newpc_intr() exit paths
* Move cdrom_end_request() calls from cdrom_decode_status() and ide_cd_check_ireason() to cdrom_newpc_intr(). * Unify cdrom_newpc_intr() exit paths. There should be no functional changes caused by this patch. Cc: Borislav Petkov <petkovbb@gmail.com> Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/ide/ide-cd.c48
1 files changed, 23 insertions, 25 deletions
diff --git a/drivers/ide/ide-cd.c b/drivers/ide/ide-cd.c
index b66da3f1678e..4c32e8db55c3 100644
--- a/drivers/ide/ide-cd.c
+++ b/drivers/ide/ide-cd.c
@@ -296,7 +296,8 @@ static void cdrom_end_request(ide_drive_t *drive, int uptodate)
296/* 296/*
297 * Returns: 297 * Returns:
298 * 0: if the request should be continued. 298 * 0: if the request should be continued.
299 * 1: if the request was ended. 299 * 1: if the request will be going through error recovery.
300 * 2: if the request should be ended.
300 */ 301 */
301static int cdrom_decode_status(ide_drive_t *drive, int good_stat, int *stat_ret) 302static int cdrom_decode_status(ide_drive_t *drive, int good_stat, int *stat_ret)
302{ 303{
@@ -329,10 +330,7 @@ static int cdrom_decode_status(ide_drive_t *drive, int good_stat, int *stat_ret)
329 * Just give up. 330 * Just give up.
330 */ 331 */
331 rq->cmd_flags |= REQ_FAILED; 332 rq->cmd_flags |= REQ_FAILED;
332 cdrom_end_request(drive, 0); 333 return 2;
333 ide_error(drive, "request sense failure", stat);
334 return 1;
335
336 } else if (blk_pc_request(rq) || rq->cmd_type == REQ_TYPE_ATA_PC) { 334 } else if (blk_pc_request(rq) || rq->cmd_type == REQ_TYPE_ATA_PC) {
337 /* All other functions, except for READ. */ 335 /* All other functions, except for READ. */
338 336
@@ -472,14 +470,12 @@ static int cdrom_decode_status(ide_drive_t *drive, int good_stat, int *stat_ret)
472 */ 470 */
473 if (stat & ATA_ERR) 471 if (stat & ATA_ERR)
474 cdrom_queue_request_sense(drive, NULL, NULL); 472 cdrom_queue_request_sense(drive, NULL, NULL);
473 return 1;
475 } else { 474 } else {
476 blk_dump_rq_flags(rq, PFX "bad rq"); 475 blk_dump_rq_flags(rq, PFX "bad rq");
477 cdrom_end_request(drive, 0); 476 return 2;
478 } 477 }
479 478
480 /* retry, or handle the next request */
481 return 1;
482
483end_request: 479end_request:
484 if (stat & ATA_ERR) { 480 if (stat & ATA_ERR) {
485 struct request_queue *q = drive->queue; 481 struct request_queue *q = drive->queue;
@@ -492,10 +488,9 @@ end_request:
492 hwif->rq = NULL; 488 hwif->rq = NULL;
493 489
494 cdrom_queue_request_sense(drive, rq->sense, rq); 490 cdrom_queue_request_sense(drive, rq->sense, rq);
491 return 1;
495 } else 492 } else
496 cdrom_end_request(drive, 0); 493 return 2;
497
498 return 1;
499} 494}
500 495
501/* 496/*
@@ -539,7 +534,6 @@ static int ide_cd_check_ireason(ide_drive_t *drive, struct request *rq,
539 if (rq->cmd_type == REQ_TYPE_ATA_PC) 534 if (rq->cmd_type == REQ_TYPE_ATA_PC)
540 rq->cmd_flags |= REQ_FAILED; 535 rq->cmd_flags |= REQ_FAILED;
541 536
542 cdrom_end_request(drive, 0);
543 return -1; 537 return -1;
544} 538}
545 539
@@ -741,7 +735,8 @@ static ide_startstop_t cdrom_newpc_intr(ide_drive_t *drive)
741 xfer_func_t *xferfunc; 735 xfer_func_t *xferfunc;
742 ide_expiry_t *expiry = NULL; 736 ide_expiry_t *expiry = NULL;
743 int dma_error = 0, dma, stat, thislen, uptodate = 0; 737 int dma_error = 0, dma, stat, thislen, uptodate = 0;
744 int write = (rq_data_dir(rq) == WRITE) ? 1 : 0; 738 int write = (rq_data_dir(rq) == WRITE) ? 1 : 0, rc;
739 int sense = blk_sense_request(rq);
745 unsigned int timeout; 740 unsigned int timeout;
746 u16 len; 741 u16 len;
747 u8 ireason; 742 u8 ireason;
@@ -761,8 +756,12 @@ static ide_startstop_t cdrom_newpc_intr(ide_drive_t *drive)
761 } 756 }
762 } 757 }
763 758
764 if (cdrom_decode_status(drive, 0, &stat)) 759 rc = cdrom_decode_status(drive, 0, &stat);
760 if (rc) {
761 if (rc == 2)
762 goto out_end;
765 return ide_stopped; 763 return ide_stopped;
764 }
766 765
767 /* using dma, transfer is complete now */ 766 /* using dma, transfer is complete now */
768 if (dma) { 767 if (dma) {
@@ -807,8 +806,6 @@ static ide_startstop_t cdrom_newpc_intr(ide_drive_t *drive)
807 rq->cmd_flags |= REQ_FAILED; 806 rq->cmd_flags |= REQ_FAILED;
808 uptodate = 0; 807 uptodate = 0;
809 } 808 }
810 cdrom_end_request(drive, uptodate);
811 return ide_stopped;
812 } else if (!blk_pc_request(rq)) { 809 } else if (!blk_pc_request(rq)) {
813 ide_cd_request_sense_fixup(drive, rq); 810 ide_cd_request_sense_fixup(drive, rq);
814 /* complain if we still have data left to transfer */ 811 /* complain if we still have data left to transfer */
@@ -820,17 +817,16 @@ static ide_startstop_t cdrom_newpc_intr(ide_drive_t *drive)
820 } 817 }
821 818
822 /* check which way to transfer data */ 819 /* check which way to transfer data */
823 if (ide_cd_check_ireason(drive, rq, len, ireason, write)) 820 rc = ide_cd_check_ireason(drive, rq, len, ireason, write);
824 return ide_stopped; 821 if (rc)
822 goto out_end;
825 823
826 if (blk_fs_request(rq)) { 824 if (blk_fs_request(rq)) {
827 if (write == 0) { 825 if (write == 0) {
828 int nskip; 826 int nskip;
829 827
830 if (ide_cd_check_transfer_size(drive, len)) { 828 if (ide_cd_check_transfer_size(drive, len))
831 cdrom_end_request(drive, 0); 829 goto out_end;
832 return ide_stopped;
833 }
834 830
835 /* 831 /*
836 * First, figure out if we need to bit-bucket 832 * First, figure out if we need to bit-bucket
@@ -923,7 +919,7 @@ static ide_startstop_t cdrom_newpc_intr(ide_drive_t *drive)
923 else 919 else
924 rq->data += blen; 920 rq->data += blen;
925 } 921 }
926 if (!write && blk_sense_request(rq)) 922 if (sense && write == 0)
927 rq->sense_len += blen; 923 rq->sense_len += blen;
928 } 924 }
929 925
@@ -944,7 +940,7 @@ static ide_startstop_t cdrom_newpc_intr(ide_drive_t *drive)
944 return ide_started; 940 return ide_started;
945 941
946out_end: 942out_end:
947 if (blk_pc_request(rq)) { 943 if (blk_pc_request(rq) && rc == 0) {
948 unsigned int dlen = rq->data_len; 944 unsigned int dlen = rq->data_len;
949 945
950 if (dma) 946 if (dma)
@@ -956,6 +952,8 @@ out_end:
956 hwif->rq = NULL; 952 hwif->rq = NULL;
957 } else { 953 } else {
958 cdrom_end_request(drive, uptodate); 954 cdrom_end_request(drive, uptodate);
955 if (sense && rc == 2)
956 ide_error(drive, "request sense failure", stat);
959 } 957 }
960 return ide_stopped; 958 return ide_stopped;
961} 959}