diff options
author | Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> | 2008-02-01 17:09:27 -0500 |
---|---|---|
committer | Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> | 2008-02-01 17:09:27 -0500 |
commit | 29f3aaca3c134d14309f6b0254edcfce54a0b00c (patch) | |
tree | c3d60ec17e7bc4d7885dbc21f4122bb7a074f2be /drivers/ide/ide-cd.c | |
parent | 94f5a86dc37c66b9ec0d7426a7518740fa41d871 (diff) |
ide-cd: merge cdrom_start_read_continuation() and cdrom_start_rw_cont()
* Add handling of write requests to cdrom_start_read_continuation(),
rename it to cdrom_start_rw_cont() and remove no longer needed
cdrom_start_write_cont().
* Remove redundant '(rq->sector & (sectors_per_frame - 1)' check.
There should be no functionality changes caused by this patch.
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
Diffstat (limited to 'drivers/ide/ide-cd.c')
-rw-r--r-- | drivers/ide/ide-cd.c | 74 |
1 files changed, 35 insertions, 39 deletions
diff --git a/drivers/ide/ide-cd.c b/drivers/ide/ide-cd.c index 58397617b281..edcdc7432ddf 100644 --- a/drivers/ide/ide-cd.c +++ b/drivers/ide/ide-cd.c | |||
@@ -800,39 +800,48 @@ static int cdrom_read_from_buffer (ide_drive_t *drive) | |||
800 | static ide_startstop_t cdrom_rw_intr(ide_drive_t *); | 800 | static ide_startstop_t cdrom_rw_intr(ide_drive_t *); |
801 | 801 | ||
802 | /* | 802 | /* |
803 | * Routine to send a read packet command to the drive. | 803 | * Routine to send a read/write packet command to the drive. |
804 | * This is usually called directly from cdrom_start_read. | 804 | * This is usually called directly from cdrom_start_{read,write}(). |
805 | * However, for drq_interrupt devices, it is called from an interrupt | 805 | * However, for drq_interrupt devices, it is called from an interrupt |
806 | * when the drive is ready to accept the command. | 806 | * when the drive is ready to accept the command. |
807 | */ | 807 | */ |
808 | static ide_startstop_t cdrom_start_read_continuation (ide_drive_t *drive) | 808 | static ide_startstop_t cdrom_start_rw_cont(ide_drive_t *drive) |
809 | { | 809 | { |
810 | struct request *rq = HWGROUP(drive)->rq; | 810 | struct request *rq = HWGROUP(drive)->rq; |
811 | unsigned short sectors_per_frame; | ||
812 | int nskip; | ||
813 | 811 | ||
814 | sectors_per_frame = queue_hardsect_size(drive->queue) >> SECTOR_BITS; | 812 | if (rq_data_dir(rq) == READ) { |
813 | unsigned short sectors_per_frame = | ||
814 | queue_hardsect_size(drive->queue) >> SECTOR_BITS; | ||
815 | int nskip = rq->sector & (sectors_per_frame - 1); | ||
815 | 816 | ||
816 | /* If the requested sector doesn't start on a cdrom block boundary, | 817 | /* |
817 | we must adjust the start of the transfer so that it does, | 818 | * If the requested sector doesn't start on a frame boundary, |
818 | and remember to skip the first few sectors. | 819 | * we must adjust the start of the transfer so that it does, |
819 | If the CURRENT_NR_SECTORS field is larger than the size | 820 | * and remember to skip the first few sectors. |
820 | of the buffer, it will mean that we're to skip a number | 821 | * |
821 | of sectors equal to the amount by which CURRENT_NR_SECTORS | 822 | * If the rq->current_nr_sectors field is larger than the size |
822 | is larger than the buffer size. */ | 823 | * of the buffer, it will mean that we're to skip a number of |
823 | nskip = rq->sector & (sectors_per_frame - 1); | 824 | * sectors equal to the amount by which rq->current_nr_sectors |
824 | if (nskip > 0) { | 825 | * is larger than the buffer size. |
825 | /* Sanity check... */ | 826 | */ |
826 | if (rq->current_nr_sectors != bio_cur_sectors(rq->bio) && | 827 | if (nskip > 0) { |
827 | (rq->sector & (sectors_per_frame - 1))) { | 828 | /* Sanity check... */ |
828 | printk(KERN_ERR "%s: cdrom_start_read_continuation: buffer botch (%u)\n", | 829 | if (rq->current_nr_sectors != |
829 | drive->name, rq->current_nr_sectors); | 830 | bio_cur_sectors(rq->bio)) { |
830 | cdrom_end_request(drive, 0); | 831 | printk(KERN_ERR "%s: %s: buffer botch (%u)\n", |
831 | return ide_stopped; | 832 | drive->name, __FUNCTION__, |
833 | rq->current_nr_sectors); | ||
834 | cdrom_end_request(drive, 0); | ||
835 | return ide_stopped; | ||
836 | } | ||
837 | rq->current_nr_sectors += nskip; | ||
832 | } | 838 | } |
833 | rq->current_nr_sectors += nskip; | ||
834 | } | 839 | } |
835 | 840 | #if 0 | |
841 | else | ||
842 | /* the immediate bit */ | ||
843 | rq->cmd[1] = 1 << 3; | ||
844 | #endif | ||
836 | /* Set up the command */ | 845 | /* Set up the command */ |
837 | rq->timeout = ATAPI_WAIT_PC; | 846 | rq->timeout = ATAPI_WAIT_PC; |
838 | 847 | ||
@@ -840,7 +849,6 @@ static ide_startstop_t cdrom_start_read_continuation (ide_drive_t *drive) | |||
840 | return cdrom_transfer_packet_command(drive, rq, cdrom_rw_intr); | 849 | return cdrom_transfer_packet_command(drive, rq, cdrom_rw_intr); |
841 | } | 850 | } |
842 | 851 | ||
843 | |||
844 | #define IDECD_SEEK_THRESHOLD (1000) /* 1000 blocks */ | 852 | #define IDECD_SEEK_THRESHOLD (1000) /* 1000 blocks */ |
845 | #define IDECD_SEEK_TIMER (5 * WAIT_MIN_SLEEP) /* 100 ms */ | 853 | #define IDECD_SEEK_TIMER (5 * WAIT_MIN_SLEEP) /* 100 ms */ |
846 | #define IDECD_SEEK_TIMEOUT (2 * WAIT_CMD) /* 20 sec */ | 854 | #define IDECD_SEEK_TIMEOUT (2 * WAIT_CMD) /* 20 sec */ |
@@ -939,7 +947,7 @@ static ide_startstop_t cdrom_start_read (ide_drive_t *drive, unsigned int block) | |||
939 | info->dma = 0; | 947 | info->dma = 0; |
940 | 948 | ||
941 | /* Start sending the read request to the drive. */ | 949 | /* Start sending the read request to the drive. */ |
942 | return cdrom_start_packet_command(drive, 32768, cdrom_start_read_continuation); | 950 | return cdrom_start_packet_command(drive, 32768, cdrom_start_rw_cont); |
943 | } | 951 | } |
944 | 952 | ||
945 | /**************************************************************************** | 953 | /**************************************************************************** |
@@ -1375,18 +1383,6 @@ static ide_startstop_t cdrom_rw_intr(ide_drive_t *drive) | |||
1375 | return ide_started; | 1383 | return ide_started; |
1376 | } | 1384 | } |
1377 | 1385 | ||
1378 | static ide_startstop_t cdrom_start_write_cont(ide_drive_t *drive) | ||
1379 | { | ||
1380 | struct request *rq = HWGROUP(drive)->rq; | ||
1381 | |||
1382 | #if 0 /* the immediate bit */ | ||
1383 | rq->cmd[1] = 1 << 3; | ||
1384 | #endif | ||
1385 | rq->timeout = ATAPI_WAIT_PC; | ||
1386 | |||
1387 | return cdrom_transfer_packet_command(drive, rq, cdrom_rw_intr); | ||
1388 | } | ||
1389 | |||
1390 | static ide_startstop_t cdrom_start_write(ide_drive_t *drive, struct request *rq) | 1386 | static ide_startstop_t cdrom_start_write(ide_drive_t *drive, struct request *rq) |
1391 | { | 1387 | { |
1392 | struct cdrom_info *info = drive->driver_data; | 1388 | struct cdrom_info *info = drive->driver_data; |
@@ -1419,7 +1415,7 @@ static ide_startstop_t cdrom_start_write(ide_drive_t *drive, struct request *rq) | |||
1419 | info->devinfo.media_written = 1; | 1415 | info->devinfo.media_written = 1; |
1420 | 1416 | ||
1421 | /* Start sending the write request to the drive. */ | 1417 | /* Start sending the write request to the drive. */ |
1422 | return cdrom_start_packet_command(drive, 32768, cdrom_start_write_cont); | 1418 | return cdrom_start_packet_command(drive, 32768, cdrom_start_rw_cont); |
1423 | } | 1419 | } |
1424 | 1420 | ||
1425 | static ide_startstop_t cdrom_do_newpc_cont(ide_drive_t *drive) | 1421 | static ide_startstop_t cdrom_do_newpc_cont(ide_drive_t *drive) |