ide: cleanup ide_set_dma()
authorBartlomiej Zolnierkiewicz <bzolnier@gmail.com>
Fri, 25 Jan 2008 21:17:19 +0000 (22:17 +0100)
committerBartlomiej Zolnierkiewicz <bzolnier@gmail.com>
Fri, 25 Jan 2008 21:17:19 +0000 (22:17 +0100)
* ->dma_off_quietly is always called before ide_set_dma()
  so the call can be moved inside ide_set_dma().

* ide_dma_check() doesn't touch hardware so ->dma_off_quietly
  call for 'rc == -1' case is redundant, remove it.

* '0' and '-1' are the only values returned by ide_dma_check()
  so remove dead code for other cases.

There should be no functionality changes caused by this patch.

Acked-by: Sergei Shtylyov <sshtylyov@ru.mvista.com>
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
drivers/ide/ide-dma.c
drivers/ide/ide-io.c
drivers/ide/ide-probe.c
drivers/ide/ide.c

index 7568c3e81f2f3fcef0ba7d76a3ce5f057f206573..01036305d6fcb55a1c82e97246f7401c2cf48bb2 100644 (file)
@@ -827,22 +827,19 @@ int ide_set_dma(ide_drive_t *drive)
        ide_hwif_t *hwif = drive->hwif;
        int rc;
 
-       rc = ide_dma_check(drive);
+       /*
+        * Force DMAing for the beginning of the check.
+        * Some chipsets appear to do interesting
+        * things, if not checked and cleared.
+        *   PARANOIA!!!
+        */
+       hwif->dma_off_quietly(drive);
 
-       switch(rc) {
-       case -1: /* DMA needs to be disabled */
-               hwif->dma_off_quietly(drive);
-               return -1;
-       case  0: /* DMA needs to be enabled */
-               return hwif->ide_dma_on(drive);
-       case  1: /* DMA setting cannot be changed */
-               break;
-       default:
-               BUG();
-               break;
-       }
+       rc = ide_dma_check(drive);
+       if (rc)
+               return rc;
 
-       return rc;
+       return hwif->ide_dma_on(drive);
 }
 
 #ifdef CONFIG_BLK_DEV_IDEDMA_PCI
index e053e00a705882a47c552433e327f3bbbe9ffdf6..2711b5a6962df05ca9579cc7bcb4b9cd54df274a 100644 (file)
@@ -221,7 +221,6 @@ static ide_startstop_t ide_start_power_step(ide_drive_t *drive, struct request *
                 */
                if (drive->hwif->ide_dma_on == NULL)
                        break;
-               drive->hwif->dma_off_quietly(drive);
                /*
                 * TODO: respect ->using_dma setting
                 */
index 33e62d28465d639e8b6066010c13adfc8493c119..0379d1f697cfb5146186d1d193e40c049a0ebda6 100644 (file)
@@ -833,16 +833,8 @@ static void probe_hwif(ide_hwif_t *hwif)
 
                        drive->nice1 = 1;
 
-                       if (hwif->ide_dma_on) {
-                               /*
-                                * Force DMAing for the beginning of the check.
-                                * Some chipsets appear to do interesting
-                                * things, if not checked and cleared.
-                                *   PARANOIA!!!
-                                */
-                               hwif->dma_off_quietly(drive);
+                       if (hwif->ide_dma_on)
                                ide_set_dma(drive);
-                       }
                }
        }
 
index 00ef6ec2c273931175b3cfd37b156b3a44218d78..c6d4f630e18a4fd44b6b98438aa3770f28085774 100644 (file)
@@ -851,7 +851,6 @@ int set_using_dma(ide_drive_t *drive, int arg)
        err = 0;
 
        if (arg) {
-               hwif->dma_off_quietly(drive);
                if (ide_set_dma(drive))
                        err = -EIO;
        } else