aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/ide
diff options
context:
space:
mode:
authorBartlomiej Zolnierkiewicz <bzolnier@gmail.com>2008-02-01 17:09:28 -0500
committerBartlomiej Zolnierkiewicz <bzolnier@gmail.com>2008-02-01 17:09:28 -0500
commit0d6f7e3a1845165b81adab3fc5fd13916f22aa61 (patch)
tree6c746e8d55b002bb8e2867de97cfece137a26018 /drivers/ide
parent0041e7c6ca9719309bef6a4754e4eb9566b37ae1 (diff)
ide-cd: merge cdrom_write_check_ireason() and cdrom_read_check_ireason()
Add 'rw' parameter to cdrom_read_check_ireason(), make it handle both read and write checking, rename it to ide_cd_check_ireason(), finally remove no longer needed cdrom_write_check_ireason(). There should be no functionality changes caused by this patch. Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
Diffstat (limited to 'drivers/ide')
-rw-r--r--drivers/ide/ide-cd.c64
1 files changed, 15 insertions, 49 deletions
diff --git a/drivers/ide/ide-cd.c b/drivers/ide/ide-cd.c
index 50f78eb7dce9..9d2e458250ba 100644
--- a/drivers/ide/ide-cd.c
+++ b/drivers/ide/ide-cd.c
@@ -683,21 +683,25 @@ static void cdrom_buffer_sectors (ide_drive_t *drive, unsigned long sector,
683 * ok; nonzero if the request has been terminated. 683 * ok; nonzero if the request has been terminated.
684 */ 684 */
685static 685static
686int cdrom_read_check_ireason (ide_drive_t *drive, int len, int ireason) 686int ide_cd_check_ireason(ide_drive_t *drive, int len, int ireason, int rw)
687{ 687{
688 if (ireason == 2) 688 /*
689 * ireason == 0: the drive wants to receive data from us
690 * ireason == 2: the drive is expecting to transfer data to us
691 */
692 if (ireason == (!rw << 1))
689 return 0; 693 return 0;
690 else if (ireason == 0) { 694 else if (ireason == (rw << 1)) {
691 ide_hwif_t *hwif = drive->hwif; 695 ide_hwif_t *hwif = drive->hwif;
696 xfer_func_t *xf;
692 697
693 /* Whoops... The drive is expecting to receive data from us! */ 698 /* Whoops... */
694 printk(KERN_ERR "%s: %s: wrong transfer direction!\n", 699 printk(KERN_ERR "%s: %s: wrong transfer direction!\n",
695 drive->name, __FUNCTION__); 700 drive->name, __FUNCTION__);
696 701
697 /* Throw some data at the drive so it doesn't hang 702 xf = rw ? hwif->atapi_output_bytes : hwif->atapi_input_bytes;
698 and quit this request. */ 703 ide_cd_pad_transfer(drive, xf, len);
699 ide_cd_pad_transfer(drive, hwif->atapi_output_bytes, len); 704 } else if (rw == 0 && ireason == 1) {
700 } else if (ireason == 1) {
701 /* Some drives (ASUS) seem to tell us that status 705 /* Some drives (ASUS) seem to tell us that status
702 * info is available. just get it and ignore. 706 * info is available. just get it and ignore.
703 */ 707 */
@@ -985,35 +989,6 @@ int ide_cd_queue_pc(ide_drive_t *drive, struct request *rq)
985} 989}
986 990
987/* 991/*
988 * Write handling
989 */
990static int cdrom_write_check_ireason(ide_drive_t *drive, int len, int ireason)
991{
992 /* Two notes about IDE interrupt reason here - 0 means that
993 * the drive wants to receive data from us, 2 means that
994 * the drive is expecting to transfer data to us.
995 */
996 if (ireason == 0)
997 return 0;
998 else if (ireason == 2) {
999 ide_hwif_t *hwif = drive->hwif;
1000
1001 /* Whoops... The drive wants to send data. */
1002 printk(KERN_ERR "%s: %s: wrong transfer direction!\n",
1003 drive->name, __FUNCTION__);
1004
1005 ide_cd_pad_transfer(drive, hwif->atapi_input_bytes, len);
1006 } else {
1007 /* Drive wants a command packet, or invalid ireason... */
1008 printk(KERN_ERR "%s: %s: bad interrupt reason 0x%02x\n",
1009 drive->name, __FUNCTION__, ireason);
1010 }
1011
1012 cdrom_end_request(drive, 0);
1013 return 1;
1014}
1015
1016/*
1017 * Called from blk_end_request_callback() after the data of the request 992 * Called from blk_end_request_callback() after the data of the request
1018 * is completed and before the request is completed. 993 * is completed and before the request is completed.
1019 * By returning value '1', blk_end_request_callback() returns immediately 994 * By returning value '1', blk_end_request_callback() returns immediately
@@ -1108,20 +1083,11 @@ static ide_startstop_t cdrom_newpc_intr(ide_drive_t *drive)
1108 /* 1083 /*
1109 * check which way to transfer data 1084 * check which way to transfer data
1110 */ 1085 */
1111 if ((blk_fs_request(rq) || blk_pc_request(rq)) && write) { 1086 if (blk_fs_request(rq) || blk_pc_request(rq)) {
1112 /* 1087 if (ide_cd_check_ireason(drive, len, ireason, write))
1113 * write to drive
1114 */
1115 if (cdrom_write_check_ireason(drive, len, ireason))
1116 return ide_stopped;
1117 } else if (blk_fs_request(rq) || blk_pc_request(rq)) {
1118 /*
1119 * read from drive
1120 */
1121 if (cdrom_read_check_ireason(drive, len, ireason))
1122 return ide_stopped; 1088 return ide_stopped;
1123 1089
1124 if (blk_fs_request(rq)) { 1090 if (blk_fs_request(rq) && write == 0) {
1125 int nskip; 1091 int nskip;
1126 1092
1127 if (ide_cd_check_transfer_size(drive, len)) { 1093 if (ide_cd_check_transfer_size(drive, len)) {