ide-atapi: accomodate transfer length calculation for ide-cd
authorBorislav Petkov <petkovbb@googlemail.com>
Fri, 2 Jan 2009 15:12:52 +0000 (16:12 +0100)
committerBartlomiej Zolnierkiewicz <bzolnier@gmail.com>
Fri, 2 Jan 2009 15:12:52 +0000 (16:12 +0100)
... by factoring it out of ide_cd_do_request() into a helper, as suggested by
Bart.

There should be no functionality change resulting from this patch.

Signed-off-by: Borislav Petkov <petkovbb@gmail.com>
[bart: BLK_DEV_IDECD needs to select IDE_ATAPI now]
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
drivers/ide/Kconfig
drivers/ide/ide-atapi.c
drivers/ide/ide-cd.c
include/linux/ide.h

index 937945e471df7bf023e3beb1686150ca92dfe53f..4ee85fcf9aaf024acff74aa94d48d1f8e5e94fcb 100644 (file)
@@ -137,6 +137,7 @@ config BLK_DEV_DELKIN
 
 config BLK_DEV_IDECD
        tristate "Include IDE/ATAPI CDROM support"
+       select IDE_ATAPI
        ---help---
          If you have a CD-ROM drive using the ATAPI protocol, say Y. ATAPI is
          a newer protocol used by IDE CD-ROM and TAPE drives, similar to the
index 74273fdc882740a1b138b1e45c47d22533aa8a0c..8884877bd2b511ec1124a70fed7b62c1e38f6b98 100644 (file)
@@ -252,6 +252,18 @@ int ide_scsi_expiry(ide_drive_t *drive)
 }
 EXPORT_SYMBOL_GPL(ide_scsi_expiry);
 
+int ide_cd_get_xferlen(struct request *rq)
+{
+       if (blk_fs_request(rq))
+               return 32768;
+       else if (blk_sense_request(rq) || blk_pc_request(rq) ||
+                        rq->cmd_type == REQ_TYPE_ATA_PC)
+               return rq->data_len;
+       else
+               return 0;
+}
+EXPORT_SYMBOL_GPL(ide_cd_get_xferlen);
+
 /*
  * This is the usual interrupt handler which will be called during a packet
  * command.  We will transfer some of the data (as requested by the drive)
@@ -551,7 +563,7 @@ ide_startstop_t ide_issue_pc(ide_drive_t *drive, unsigned int timeout,
        struct ide_atapi_pc *pc = drive->pc;
        ide_hwif_t *hwif = drive->hwif;
        u32 tf_flags;
-       u16 bcount = 0;
+       u16 bcount;
        u8 scsi = !!(drive->dev_flags & IDE_DFLAG_SCSI);
 
        /* We haven't transferred any data yet */
@@ -560,6 +572,7 @@ ide_startstop_t ide_issue_pc(ide_drive_t *drive, unsigned int timeout,
 
        if (dev_is_idecd(drive)) {
                tf_flags = IDE_TFLAG_OUT_NSECT | IDE_TFLAG_OUT_LBAL;
+               bcount = ide_cd_get_xferlen(hwif->hwgroup->rq);
        } else if (scsi) {
                tf_flags = 0;
                bcount = min(pc->req_xfer, 63 * 1024);
index 65e5513758b06882a9484af8070b95a66800e8ec..8d3c7714682ed2e6316d58b487138c34415b4158 100644 (file)
@@ -1214,8 +1214,9 @@ static ide_startstop_t ide_cd_do_request(ide_drive_t *drive, struct request *rq,
                      __func__, rq->cmd[0], rq->cmd_type,
                      (unsigned long long)block);
 
+       xferlen = ide_cd_get_xferlen(rq);
+
        if (blk_fs_request(rq)) {
-               xferlen = 32768;
                fn = cdrom_start_rw_cont;
 
                if (cdrom_start_rw(drive, rq) == ide_stopped)
@@ -1225,7 +1226,6 @@ static ide_startstop_t ide_cd_do_request(ide_drive_t *drive, struct request *rq,
                        return ide_stopped;
        } else if (blk_sense_request(rq) || blk_pc_request(rq) ||
                   rq->cmd_type == REQ_TYPE_ATA_PC) {
-               xferlen = rq->data_len;
                fn = cdrom_do_newpc_cont;
 
                if (!rq->timeout)
index eb4c01f7f253565bf480e7f5fd532a1c2593df8a..e35ff682789747bc4eddec921fd7c93c94c1c332 100644 (file)
@@ -1254,6 +1254,8 @@ static inline unsigned long ide_scsi_get_timeout(struct ide_atapi_pc *pc)
 
 int ide_scsi_expiry(ide_drive_t *);
 
+int ide_cd_get_xferlen(struct request *);
+
 ide_startstop_t ide_issue_pc(ide_drive_t *, unsigned int, ide_expiry_t *);
 
 ide_startstop_t do_rw_taskfile(ide_drive_t *, ide_task_t *);