]> pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - drivers/ide/ide-iops.c
ide: remove redundant BUG_ON() from [atapi_]reset_pollfunc()
[linux-2.6-omap-h63xx.git] / drivers / ide / ide-iops.c
index c97c0719ddf10365ba12f80208191e75e470df00..7647ac4cdef863a2ccf7e6af6350e7da49d42ec8 100644 (file)
@@ -1,6 +1,4 @@
 /*
- * linux/drivers/ide/ide-iops.c        Version 0.37    Mar 05, 2003
- *
  *  Copyright (C) 2000-2002    Andre Hedrick <andre@linux-ide.org>
  *  Copyright (C) 2003         Red Hat <alan@redhat.com>
  *
@@ -165,8 +163,6 @@ void SELECT_DRIVE (ide_drive_t *drive)
        HWIF(drive)->OUTB(drive->select.all, IDE_SELECT_REG);
 }
 
-EXPORT_SYMBOL(SELECT_DRIVE);
-
 void SELECT_MASK (ide_drive_t *drive, int mask)
 {
        if (HWIF(drive)->maskproc)
@@ -616,66 +612,6 @@ no_80w:
        return 0;
 }
 
-int ide_ata66_check (ide_drive_t *drive, ide_task_t *args)
-{
-       if (args->tf.command == WIN_SETFEATURES &&
-           args->tf.lbal > XFER_UDMA_2 &&
-           args->tf.feature == SETFEATURES_XFER) {
-               if (eighty_ninty_three(drive) == 0) {
-                       printk(KERN_WARNING "%s: UDMA speeds >UDMA33 cannot "
-                                           "be set\n", drive->name);
-                       return 1;
-               }
-       }
-
-       return 0;
-}
-
-/*
- * Backside of HDIO_DRIVE_CMD call of SETFEATURES_XFER.
- * 1 : Safe to update drive->id DMA registers.
- * 0 : OOPs not allowed.
- */
-int set_transfer (ide_drive_t *drive, ide_task_t *args)
-{
-       if (args->tf.command == WIN_SETFEATURES &&
-           args->tf.lbal >= XFER_SW_DMA_0 &&
-           args->tf.feature == SETFEATURES_XFER &&
-           (drive->id->dma_ultra ||
-            drive->id->dma_mword ||
-            drive->id->dma_1word))
-               return 1;
-
-       return 0;
-}
-
-#ifdef CONFIG_BLK_DEV_IDEDMA
-static u8 ide_auto_reduce_xfer (ide_drive_t *drive)
-{
-       if (!drive->crc_count)
-               return drive->current_speed;
-       drive->crc_count = 0;
-
-       switch(drive->current_speed) {
-               case XFER_UDMA_7:       return XFER_UDMA_6;
-               case XFER_UDMA_6:       return XFER_UDMA_5;
-               case XFER_UDMA_5:       return XFER_UDMA_4;
-               case XFER_UDMA_4:       return XFER_UDMA_3;
-               case XFER_UDMA_3:       return XFER_UDMA_2;
-               case XFER_UDMA_2:       return XFER_UDMA_1;
-               case XFER_UDMA_1:       return XFER_UDMA_0;
-                       /*
-                        * OOPS we do not goto non Ultra DMA modes
-                        * without iCRC's available we force
-                        * the system to PIO and make the user
-                        * invoke the ATA-1 ATA-2 DMA modes.
-                        */
-               case XFER_UDMA_0:
-               default:                return XFER_PIO_4;
-       }
-}
-#endif /* CONFIG_BLK_DEV_IDEDMA */
-
 int ide_driveid_update(ide_drive_t *drive)
 {
        ide_hwif_t *hwif = drive->hwif;
@@ -688,8 +624,7 @@ int ide_driveid_update(ide_drive_t *drive)
         */
 
        SELECT_MASK(drive, 1);
-       if (IDE_CONTROL_REG)
-               hwif->OUTB(drive->ctl,IDE_CONTROL_REG);
+       ide_set_irq(drive, 1);
        msleep(50);
        hwif->OUTB(WIN_IDENTIFY, IDE_COMMAND_REG);
        timeout = jiffies + WAIT_WORSTCASE;
@@ -742,8 +677,8 @@ int ide_config_drive_speed(ide_drive_t *drive, u8 speed)
 //             msleep(50);
 
 #ifdef CONFIG_BLK_DEV_IDEDMA
-       if (hwif->ide_dma_on)   /* check if host supports DMA */
-               hwif->dma_host_off(drive);
+       if (hwif->dma_host_set) /* check if host supports DMA */
+               hwif->dma_host_set(drive, 0);
 #endif
 
        /* Skip setting PIO flow-control modes on pre-EIDE drives */
@@ -772,13 +707,12 @@ int ide_config_drive_speed(ide_drive_t *drive, u8 speed)
        SELECT_DRIVE(drive);
        SELECT_MASK(drive, 0);
        udelay(1);
-       if (IDE_CONTROL_REG)
-               hwif->OUTB(drive->ctl | 2, IDE_CONTROL_REG);
+       ide_set_irq(drive, 0);
        hwif->OUTB(speed, IDE_NSECTOR_REG);
        hwif->OUTB(SETFEATURES_XFER, IDE_FEATURE_REG);
        hwif->OUTBSYNC(drive, WIN_SETFEATURES, IDE_COMMAND_REG);
-       if ((IDE_CONTROL_REG) && (drive->quirk_list == 2))
-               hwif->OUTB(drive->ctl, IDE_CONTROL_REG);
+       if (drive->quirk_list == 2)
+               ide_set_irq(drive, 1);
 
        error = __ide_wait_stat(drive, drive->ready_stat,
                                BUSY_STAT|DRQ_STAT|ERR_STAT,
@@ -799,10 +733,11 @@ int ide_config_drive_speed(ide_drive_t *drive, u8 speed)
 
  skip:
 #ifdef CONFIG_BLK_DEV_IDEDMA
-       if (speed >= XFER_SW_DMA_0)
-               hwif->dma_host_on(drive);
-       else if (hwif->ide_dma_on)      /* check if host supports DMA */
-               hwif->dma_off_quietly(drive);
+       if ((speed >= XFER_SW_DMA_0 || (hwif->host_flags & IDE_HFLAG_VDMA)) &&
+           drive->using_dma)
+               hwif->dma_host_set(drive, 1);
+       else if (hwif->dma_host_set)    /* check if host supports DMA */
+               ide_dma_off_quietly(drive);
 #endif
 
        switch(speed) {
@@ -885,22 +820,17 @@ void ide_execute_command(ide_drive_t *drive, u8 cmd, ide_handler_t *handler,
        unsigned long flags;
        ide_hwgroup_t *hwgroup = HWGROUP(drive);
        ide_hwif_t *hwif = HWIF(drive);
-       
+
        spin_lock_irqsave(&ide_lock, flags);
-       
        BUG_ON(hwgroup->handler);
-       hwgroup->handler        = handler;
-       hwgroup->expiry         = expiry;
-       hwgroup->timer.expires  = jiffies + timeout;
-       hwgroup->req_gen_timer = hwgroup->req_gen;
-       add_timer(&hwgroup->timer);
+       __ide_set_handler(drive, handler, timeout, expiry);
        hwif->OUTBSYNC(drive, cmd, IDE_COMMAND_REG);
-       /* Drive takes 400nS to respond, we must avoid the IRQ being
-          serviced before that. 
-          
-          FIXME: we could skip this delay with care on non shared
-          devices 
-       */
+       /*
+        * Drive takes 400nS to respond, we must avoid the IRQ being
+        * serviced before that.
+        *
+        * FIXME: we could skip this delay with care on non shared devices
+        */
        ndelay(400);
        spin_unlock_irqrestore(&ide_lock, flags);
 }
@@ -930,7 +860,6 @@ static ide_startstop_t atapi_reset_pollfunc (ide_drive_t *drive)
                printk("%s: ATAPI reset complete\n", drive->name);
        } else {
                if (time_before(jiffies, hwgroup->poll_timeout)) {
-                       BUG_ON(HWGROUP(drive)->handler != NULL);
                        ide_set_handler(drive, &atapi_reset_pollfunc, HZ/20, NULL);
                        /* continue polling */
                        return ide_started;
@@ -970,7 +899,6 @@ static ide_startstop_t reset_pollfunc (ide_drive_t *drive)
 
        if (!OK_STAT(tmp = hwif->INB(IDE_STATUS_REG), 0, BUSY_STAT)) {
                if (time_before(jiffies, hwgroup->poll_timeout)) {
-                       BUG_ON(HWGROUP(drive)->handler != NULL);
                        ide_set_handler(drive, &reset_pollfunc, HZ/20, NULL);
                        /* continue polling */
                        return ide_started;
@@ -1008,19 +936,6 @@ static ide_startstop_t reset_pollfunc (ide_drive_t *drive)
        return ide_stopped;
 }
 
-static void check_dma_crc(ide_drive_t *drive)
-{
-#ifdef CONFIG_BLK_DEV_IDEDMA
-       if (drive->crc_count) {
-               drive->hwif->dma_off_quietly(drive);
-               ide_set_xfer_rate(drive, ide_auto_reduce_xfer(drive));
-               if (drive->current_speed >= XFER_SW_DMA_0)
-                       (void) HWIF(drive)->ide_dma_on(drive);
-       } else
-               ide_dma_off(drive);
-#endif
-}
-
 static void ide_disk_pre_reset(ide_drive_t *drive)
 {
        int legacy = (drive->id->cfs_enable_2 & 0x0400) ? 0 : 1;
@@ -1042,17 +957,20 @@ static void pre_reset(ide_drive_t *drive)
        else
                drive->post_reset = 1;
 
+       if (drive->using_dma) {
+               if (drive->crc_count)
+                       ide_check_dma_crc(drive);
+               else
+                       ide_dma_off(drive);
+       }
+
        if (!drive->keep_settings) {
-               if (drive->using_dma) {
-                       check_dma_crc(drive);
-               } else {
+               if (!drive->using_dma) {
                        drive->unmask = 0;
                        drive->io_32bit = 0;
                }
                return;
        }
-       if (drive->using_dma)
-               check_dma_crc(drive);
 
        if (HWIF(drive)->pre_reset != NULL)
                HWIF(drive)->pre_reset(drive);
@@ -1169,7 +1087,7 @@ EXPORT_SYMBOL(ide_do_reset);
 
 /*
  * ide_wait_not_busy() waits for the currently selected device on the hwif
- * to report a non-busy status, see comments in probe_hwif().
+ * to report a non-busy status, see comments in ide_probe_port().
  */
 int ide_wait_not_busy(ide_hwif_t *hwif, unsigned long timeout)
 {