firmware: convert ymfpci driver to use firmware loader exclusively
[safe/jmp/linux-2.6] / drivers / ide / ide-cd.c
index fcd33f1..68e7f19 100644 (file)
@@ -142,7 +142,6 @@ static void cdrom_analyze_sense_data(ide_drive_t *drive,
 {
        unsigned long sector;
        unsigned long bio_sectors;
-       unsigned long valid;
        struct cdrom_info *info = drive->driver_data;
 
        if (!cdrom_log_sense(drive, failed_command, sense))
@@ -173,17 +172,13 @@ static void cdrom_analyze_sense_data(ide_drive_t *drive,
                                 (sense->information[2] <<  8) |
                                 (sense->information[3]);
 
-                       bio_sectors = bio_sectors(failed_command->bio);
-                       if (bio_sectors < 4)
-                               bio_sectors = 4;
                        if (drive->queue->hardsect_size == 2048)
                                /* device sector size is 2K */
                                sector <<= 2;
+
+                       bio_sectors = max(bio_sectors(failed_command->bio), 4U);
                        sector &= ~(bio_sectors - 1);
-                       valid = (sector - failed_command->sector) << 9;
 
-                       if (valid < 0)
-                               valid = 0;
                        if (sector < get_capacity(info->disk) &&
                            drive->probed_capacity - sector < 4 * 75)
                                set_capacity(info->disk, sector);
@@ -539,7 +534,7 @@ static ide_startstop_t cdrom_start_packet_command(ide_drive_t *drive,
 
        /* FIXME: for Virtual DMA we must check harder */
        if (info->dma)
-               info->dma = !hwif->dma_setup(drive);
+               info->dma = !hwif->dma_ops->dma_setup(drive);
 
        /* set up the controller registers */
        ide_pktcmd_tf_load(drive, IDE_TFLAG_OUT_NSECT | IDE_TFLAG_OUT_LBAL |
@@ -555,14 +550,7 @@ static ide_startstop_t cdrom_start_packet_command(ide_drive_t *drive,
                                    ATAPI_WAIT_PC, cdrom_timer_expiry);
                return ide_started;
        } else {
-               unsigned long flags;
-
-               /* packet command */
-               spin_lock_irqsave(&ide_lock, flags);
-               hwif->OUTBSYNC(drive, WIN_PACKETCMD,
-                              hwif->io_ports[IDE_COMMAND_OFFSET]);
-               ndelay(400);
-               spin_unlock_irqrestore(&ide_lock, flags);
+               ide_execute_pkt_cmd(drive);
 
                return (*handler) (drive);
        }
@@ -613,11 +601,11 @@ static ide_startstop_t cdrom_transfer_packet_command(ide_drive_t *drive,
                cmd_len = ATAPI_MIN_CDB_BYTES;
 
        /* send the command to the device */
-       HWIF(drive)->atapi_output_bytes(drive, rq->cmd, cmd_len);
+       hwif->output_data(drive, NULL, rq->cmd, cmd_len);
 
        /* start the DMA if need be */
        if (info->dma)
-               hwif->dma_start(drive);
+               hwif->dma_ops->dma_start(drive);
 
        return ide_started;
 }
@@ -629,7 +617,7 @@ static void ide_cd_pad_transfer(ide_drive_t *drive, xfer_func_t *xf, int len)
 {
        while (len > 0) {
                int dum = 0;
-               xf(drive, &dum, sizeof(dum));
+               xf(drive, NULL, &dum, sizeof(dum));
                len -= sizeof(dum);
        }
 }
@@ -639,7 +627,7 @@ static void ide_cd_drain_data(ide_drive_t *drive, int nsects)
        while (nsects > 0) {
                static char dum[SECTOR_SIZE];
 
-               drive->hwif->atapi_input_bytes(drive, dum, sizeof(dum));
+               drive->hwif->input_data(drive, NULL, dum, sizeof(dum));
                nsects--;
        }
 }
@@ -666,7 +654,7 @@ static int ide_cd_check_ireason(ide_drive_t *drive, struct request *rq,
                printk(KERN_ERR "%s: %s: wrong transfer direction!\n",
                                drive->name, __func__);
 
-               xf = rw ? hwif->atapi_output_bytes : hwif->atapi_input_bytes;
+               xf = rw ? hwif->output_data : hwif->input_data;
                ide_cd_pad_transfer(drive, xf, len);
        } else  if (rw == 0 && ireason == 1) {
                /*
@@ -794,7 +782,7 @@ static ide_startstop_t cdrom_start_seek_continuation(ide_drive_t *drive)
 
        sector_div(frame, queue_hardsect_size(drive->queue) >> SECTOR_BITS);
 
-       memset(rq->cmd, 0, sizeof(rq->cmd));
+       memset(rq->cmd, 0, BLK_MAX_CDB);
        rq->cmd[0] = GPCMD_SEEK;
        put_unaligned(cpu_to_be32(frame), (unsigned int *) &rq->cmd[2]);
 
@@ -929,7 +917,7 @@ static ide_startstop_t cdrom_newpc_intr(ide_drive_t *drive)
        dma = info->dma;
        if (dma) {
                info->dma = 0;
-               dma_error = HWIF(drive)->ide_dma_end(drive);
+               dma_error = hwif->dma_ops->dma_end(drive);
                if (dma_error) {
                        printk(KERN_ERR "%s: DMA %s error\n", drive->name,
                                        write ? "write" : "read");
@@ -952,9 +940,9 @@ static ide_startstop_t cdrom_newpc_intr(ide_drive_t *drive)
        }
 
        /* ok we fall to pio :/ */
-       ireason = hwif->INB(hwif->io_ports[IDE_IREASON_OFFSET]) & 0x3;
-       lowcyl  = hwif->INB(hwif->io_ports[IDE_BCOUNTL_OFFSET]);
-       highcyl = hwif->INB(hwif->io_ports[IDE_BCOUNTH_OFFSET]);
+       ireason = hwif->INB(hwif->io_ports.nsect_addr) & 0x3;
+       lowcyl  = hwif->INB(hwif->io_ports.lbam_addr);
+       highcyl = hwif->INB(hwif->io_ports.lbah_addr);
 
        len = lowcyl + (256 * highcyl);
 
@@ -1019,10 +1007,10 @@ static ide_startstop_t cdrom_newpc_intr(ide_drive_t *drive)
 
        if (ireason == 0) {
                write = 1;
-               xferfunc = HWIF(drive)->atapi_output_bytes;
+               xferfunc = hwif->output_data;
        } else {
                write = 0;
-               xferfunc = HWIF(drive)->atapi_input_bytes;
+               xferfunc = hwif->input_data;
        }
 
        /* transfer data */
@@ -1061,7 +1049,7 @@ static ide_startstop_t cdrom_newpc_intr(ide_drive_t *drive)
                if (blen > thislen)
                        blen = thislen;
 
-               xferfunc(drive, ptr, blen);
+               xferfunc(drive, NULL, ptr, blen);
 
                thislen -= blen;
                len -= blen;
@@ -1706,7 +1694,7 @@ static int ide_cdrom_prep_fs(struct request_queue *q, struct request *rq)
        long block = (long)rq->hard_sector / (hard_sect >> 9);
        unsigned long blocks = rq->hard_nr_sectors / (hard_sect >> 9);
 
-       memset(rq->cmd, 0, sizeof(rq->cmd));
+       memset(rq->cmd, 0, BLK_MAX_CDB);
 
        if (rq_data_dir(rq) == READ)
                rq->cmd[0] = GPCMD_READ_10;
@@ -1909,9 +1897,7 @@ static int ide_cdrom_setup(ide_drive_t *drive)
        /* set correct block size */
        blk_queue_hardsect_size(drive->queue, CD_FRAMESIZE);
 
-       if (drive->autotune == IDE_TUNE_DEFAULT ||
-           drive->autotune == IDE_TUNE_AUTO)
-               drive->dsc_overlap = (drive->next != drive);
+       drive->dsc_overlap = (drive->next != drive);
 
        if (ide_cdrom_register(drive, nslots)) {
                printk(KERN_ERR "%s: %s failed to register device with the"