]> pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - drivers/ide/ide-cd.c
netxen: Needs to include linux/vmalloc.h
[linux-2.6-omap-h63xx.git] / drivers / ide / ide-cd.c
index 6ade498cd2fe691ae66c42b531cdb24791388e76..6e29dd5320901c65cfe9f9b985cf28c8997832ac 100644 (file)
@@ -666,16 +666,9 @@ static int ide_cd_check_transfer_size(ide_drive_t *drive, int len)
 
 static ide_startstop_t cdrom_newpc_intr(ide_drive_t *);
 
-/*
- * Routine to send a read/write packet command to the drive. This is usually
- * called directly from cdrom_start_{read,write}(). However, for drq_interrupt
- * devices, it is called from an interrupt when the drive is ready to accept
- * the command.
- */
-static ide_startstop_t cdrom_start_rw_cont(ide_drive_t *drive)
+static ide_startstop_t ide_cd_prepare_rw_request(ide_drive_t *drive,
+                                                struct request *rq)
 {
-       struct request *rq = HWGROUP(drive)->rq;
-
        if (rq_data_dir(rq) == READ) {
                unsigned short sectors_per_frame =
                        queue_hardsect_size(drive->queue) >> SECTOR_BITS;
@@ -712,6 +705,19 @@ static ide_startstop_t cdrom_start_rw_cont(ide_drive_t *drive)
        /* set up the command */
        rq->timeout = ATAPI_WAIT_PC;
 
+       return ide_started;
+}
+
+/*
+ * Routine to send a read/write packet command to the drive. This is usually
+ * called directly from cdrom_start_{read,write}(). However, for drq_interrupt
+ * devices, it is called from an interrupt when the drive is ready to accept
+ * the command.
+ */
+static ide_startstop_t cdrom_start_rw_cont(ide_drive_t *drive)
+{
+       struct request *rq = drive->hwif->hwgroup->rq;
+
        /* send the command to the drive and return */
        return cdrom_transfer_packet_command(drive, rq, cdrom_newpc_intr);
 }
@@ -738,9 +744,8 @@ static ide_startstop_t cdrom_seek_intr(ide_drive_t *drive)
        return ide_stopped;
 }
 
-static ide_startstop_t cdrom_start_seek_continuation(ide_drive_t *drive)
+static void ide_cd_prepare_seek_request(ide_drive_t *drive, struct request *rq)
 {
-       struct request *rq = HWGROUP(drive)->rq;
        sector_t frame = rq->sector;
 
        sector_div(frame, queue_hardsect_size(drive->queue) >> SECTOR_BITS);
@@ -750,17 +755,13 @@ static ide_startstop_t cdrom_start_seek_continuation(ide_drive_t *drive)
        put_unaligned(cpu_to_be32(frame), (unsigned int *) &rq->cmd[2]);
 
        rq->timeout = ATAPI_WAIT_PC;
-       return cdrom_transfer_packet_command(drive, rq, &cdrom_seek_intr);
 }
 
-static ide_startstop_t cdrom_start_seek(ide_drive_t *drive, unsigned int block)
+static ide_startstop_t cdrom_start_seek_continuation(ide_drive_t *drive)
 {
-       struct cdrom_info *info = drive->driver_data;
+       struct request *rq = drive->hwif->hwgroup->rq;
 
-       info->dma = 0;
-       info->start_seek = jiffies;
-       return cdrom_start_packet_command(drive, 0,
-                                         cdrom_start_seek_continuation);
+       return cdrom_transfer_packet_command(drive, rq, &cdrom_seek_intr);
 }
 
 /*
@@ -1135,21 +1136,17 @@ static ide_startstop_t cdrom_start_rw(ide_drive_t *drive, struct request *rq)
        if (write)
                cd->devinfo.media_written = 1;
 
-       /* start sending the read/write request to the drive */
-       return cdrom_start_packet_command(drive, 32768, cdrom_start_rw_cont);
+       return ide_started;
 }
 
 static ide_startstop_t cdrom_do_newpc_cont(ide_drive_t *drive)
 {
        struct request *rq = HWGROUP(drive)->rq;
 
-       if (!rq->timeout)
-               rq->timeout = ATAPI_WAIT_PC;
-
        return cdrom_transfer_packet_command(drive, rq, cdrom_newpc_intr);
 }
 
-static ide_startstop_t cdrom_do_block_pc(ide_drive_t *drive, struct request *rq)
+static void cdrom_do_block_pc(ide_drive_t *drive, struct request *rq)
 {
        struct cdrom_info *info = drive->driver_data;
 
@@ -1188,20 +1185,17 @@ static ide_startstop_t cdrom_do_block_pc(ide_drive_t *drive, struct request *rq)
                      ((unsigned long)current->stack & stack_mask)))
                        info->dma = 0;
        }
-
-       /* start sending the command to the drive */
-       return cdrom_start_packet_command(drive, rq->data_len,
-                                         cdrom_do_newpc_cont);
 }
 
 /*
  * cdrom driver request routine.
  */
-static ide_startstop_t ide_do_rw_cdrom(ide_drive_t *drive, struct request *rq,
+static ide_startstop_t ide_cd_do_request(ide_drive_t *drive, struct request *rq,
                                        sector_t block)
 {
-       ide_startstop_t action;
        struct cdrom_info *info = drive->driver_data;
+       ide_handler_t *fn;
+       int xferlen;
 
        if (blk_fs_request(rq)) {
                if (info->cd_flags & IDE_CD_FLAG_SEEKING) {
@@ -1221,16 +1215,35 @@ static ide_startstop_t ide_do_rw_cdrom(ide_drive_t *drive, struct request *rq,
                }
                if (rq_data_dir(rq) == READ &&
                    IDE_LARGE_SEEK(info->last_block, block,
-                                  IDECD_SEEK_THRESHOLD) &&
-                   drive->dsc_overlap)
-                       action = cdrom_start_seek(drive, block);
-               else
-                       action = cdrom_start_rw(drive, rq);
+                           IDECD_SEEK_THRESHOLD) &&
+                   drive->dsc_overlap) {
+                       xferlen = 0;
+                       fn = cdrom_start_seek_continuation;
+
+                       info->dma = 0;
+                       info->start_seek = jiffies;
+
+                       ide_cd_prepare_seek_request(drive, rq);
+               } else {
+                       xferlen = 32768;
+                       fn = cdrom_start_rw_cont;
+
+                       if (cdrom_start_rw(drive, rq) == ide_stopped)
+                               return ide_stopped;
+
+                       if (ide_cd_prepare_rw_request(drive, rq) == ide_stopped)
+                               return ide_stopped;
+               }
                info->last_block = block;
-               return action;
        } else if (blk_sense_request(rq) || blk_pc_request(rq) ||
                   rq->cmd_type == REQ_TYPE_ATA_PC) {
-               return cdrom_do_block_pc(drive, rq);
+               xferlen = rq->data_len;
+               fn = cdrom_do_newpc_cont;
+
+               if (!rq->timeout)
+                       rq->timeout = ATAPI_WAIT_PC;
+
+               cdrom_do_block_pc(drive, rq);
        } else if (blk_special_request(rq)) {
                /* right now this can only be a reset... */
                cdrom_end_request(drive, 1);
@@ -1240,9 +1253,9 @@ static ide_startstop_t ide_do_rw_cdrom(ide_drive_t *drive, struct request *rq,
                cdrom_end_request(drive, 0);
                return ide_stopped;
        }
-}
-
 
+       return cdrom_start_packet_command(drive, xferlen, fn);
+}
 
 /*
  * Ioctl handling.
@@ -1936,10 +1949,9 @@ static ide_driver_t ide_cdrom_driver = {
        .version                = IDECD_VERSION,
        .media                  = ide_cdrom,
        .supports_dsc_overlap   = 1,
-       .do_request             = ide_do_rw_cdrom,
+       .do_request             = ide_cd_do_request,
        .end_request            = ide_end_request,
        .error                  = __ide_error,
-       .abort                  = __ide_abort,
 #ifdef CONFIG_IDE_PROC_FS
        .proc                   = idecd_proc,
 #endif