ide-cd: factor out transfer size checking from cdrom_read_intr()

!MAILaRCHIVE_VOTE_RePLACE
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
To: <git-commits-head@...>
Date: Friday, February 1, 2008 - 7:59 pm

Gitweb:     http://git.kernel.org/git/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=64814f...
Commit:     64814f2399e7dd1e6e53dd7d08a4ad54d02665d3
Parent:     b4ab726c92f8a2c1635958212e8933309de0a37a
Author:     Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
AuthorDate: Fri Feb 1 23:09:26 2008 +0100
Committer:  Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
CommitDate: Fri Feb 1 23:09:26 2008 +0100

    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>
---
 drivers/ide/ide-cd.c |   38 ++++++++++++++++++++++++++------------
 1 files changed, 26 insertions(+), 12 deletions(-)

diff --git a/drivers/ide/ide-cd.c b/drivers/ide/ide-cd.c
index f0191f0..2e0c933 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)
 }
 
 /*
+ * Assume that the drive will always provide data in multiples of at least
+ * SECTOR_SIZE, as it gets hairy to keep track of the transfers otherwise.
+ */
+static int ide_cd_check_transfer_size(ide_drive_t *drive, int len)
+{
+	struct cdrom_info *cd = drive->driver_data;
+
+	if ((len % SECTOR_SIZE) == 0)
+		return 0;
+
+	printk(KERN_ERR "%s: %s: Bad transfer size %d\n",
+			drive->name, __FUNCTION__, len);
+
+	if (cd->cd_flags & IDE_CD_FLAG_LIMIT_NFRAMES)
+		printk(KERN_ERR "  This drive is not supported by "
+				"this version of the driver\n");
+	else {
+		printk(KERN_ERR "  Trying to limit transfer sizes\n");
+		cd->cd_flags |= IDE_CD_FLAG_LIMIT_NFRAMES;
+	}
+
+	return 1;
+}
+
+/*
  * Interrupt routine.  Called when a read request has completed.
  */
 static 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)
 	if (cdrom_read_check_ireason (drive, len, ireason))
 		return ide_stopped;
 
-	/* Assume that the drive will always provide data in multiples
-	   of at least SECTOR_SIZE, as it gets hairy to keep track
-	   of the transfers otherwise. */
-	if ((len % SECTOR_SIZE) != 0) {
-		printk (KERN_ERR "%s: cdrom_read_intr: Bad transfer size %d\n",
-			drive->name, len);
-		if (info->cd_flags & IDE_CD_FLAG_LIMIT_NFRAMES)
-			printk (KERN_ERR "  This drive is not supported by this version of the driver\n");
-		else {
-			printk (KERN_ERR "  Trying to limit transfer sizes\n");
-			info->cd_flags |= IDE_CD_FLAG_LIMIT_NFRAMES;
-		}
+	if (ide_cd_check_transfer_size(drive, len)) {
 		cdrom_end_request(drive, 0);
 		return ide_stopped;
 	}
-
To unsubscribe from this list: send the line "unsubscribe git-commits-head" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
ide-cd: factor out transfer size checking from cdrom_read_in..., Linux Kernel Mailing List..., (Fri Feb 1, 7:59 pm)