aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/ide/ide-cd.c
diff options
context:
space:
mode:
authorBartlomiej Zolnierkiewicz <bzolnier@gmail.com>2008-02-01 17:09:26 -0500
committerBartlomiej Zolnierkiewicz <bzolnier@gmail.com>2008-02-01 17:09:26 -0500
commit64814f2399e7dd1e6e53dd7d08a4ad54d02665d3 (patch)
treec48c206147349727f94354c6cc962cd5932c3426 /drivers/ide/ide-cd.c
parentb4ab726c92f8a2c1635958212e8933309de0a37a (diff)
ide-cd: factor out transfer size checking from cdrom_read_intr()
This is a preparation for cdrom_read_intr() and cdrom_write_intr() merge. Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
Diffstat (limited to 'drivers/ide/ide-cd.c')
-rw-r--r--drivers/ide/ide-cd.c38
1 files changed, 26 insertions, 12 deletions
diff --git a/drivers/ide/ide-cd.c b/drivers/ide/ide-cd.c
index f0191f061775..2e0c93377582 100644
--- a/drivers/ide/ide-cd.c
+++ b/drivers/ide/ide-cd.c
@@ -714,6 +714,31 @@ int cdrom_read_check_ireason (ide_drive_t *drive, int len, int ireason)
714} 714}
715 715
716/* 716/*
717 * Assume that the drive will always provide data in multiples of at least
718 * SECTOR_SIZE, as it gets hairy to keep track of the transfers otherwise.
719 */
720static int ide_cd_check_transfer_size(ide_drive_t *drive, int len)
721{
722 struct cdrom_info *cd = drive->driver_data;
723
724 if ((len % SECTOR_SIZE) == 0)
725 return 0;
726
727 printk(KERN_ERR "%s: %s: Bad transfer size %d\n",
728 drive->name, __FUNCTION__, len);
729
730 if (cd->cd_flags & IDE_CD_FLAG_LIMIT_NFRAMES)
731 printk(KERN_ERR " This drive is not supported by "
732 "this version of the driver\n");
733 else {
734 printk(KERN_ERR " Trying to limit transfer sizes\n");
735 cd->cd_flags |= IDE_CD_FLAG_LIMIT_NFRAMES;
736 }
737
738 return 1;
739}
740
741/*
717 * Interrupt routine. Called when a read request has completed. 742 * Interrupt routine. Called when a read request has completed.
718 */ 743 */
719static ide_startstop_t cdrom_read_intr (ide_drive_t *drive) 744static ide_startstop_t cdrom_read_intr (ide_drive_t *drive)
@@ -774,18 +799,7 @@ static ide_startstop_t cdrom_read_intr (ide_drive_t *drive)
774 if (cdrom_read_check_ireason (drive, len, ireason)) 799 if (cdrom_read_check_ireason (drive, len, ireason))
775 return ide_stopped; 800 return ide_stopped;
776 801
777 /* Assume that the drive will always provide data in multiples 802 if (ide_cd_check_transfer_size(drive, len)) {
778 of at least SECTOR_SIZE, as it gets hairy to keep track
779 of the transfers otherwise. */
780 if ((len % SECTOR_SIZE) != 0) {
781 printk (KERN_ERR "%s: cdrom_read_intr: Bad transfer size %d\n",
782 drive->name, len);
783 if (info->cd_flags & IDE_CD_FLAG_LIMIT_NFRAMES)
784 printk (KERN_ERR " This drive is not supported by this version of the driver\n");
785 else {
786 printk (KERN_ERR " Trying to limit transfer sizes\n");
787 info->cd_flags |= IDE_CD_FLAG_LIMIT_NFRAMES;
788 }
789 cdrom_end_request(drive, 0); 803 cdrom_end_request(drive, 0);
790 return ide_stopped; 804 return ide_stopped;
791 } 805 }