cs5530/sc1200: DMA support cleanup
authorBartlomiej Zolnierkiewicz <bzolnier@gmail.com>
Tue, 15 May 2007 22:51:44 +0000 (00:51 +0200)
committerBartlomiej Zolnierkiewicz <bzolnier@gmail.com>
Tue, 15 May 2007 22:51:44 +0000 (00:51 +0200)
sc1200.c:

* remove open-coded variant of ide_dma_host_off() (== ->dma_host_off),
  it is not needed because ->dma_off_quietly calls ->dma_host_off

* use ->dma_host_on (== ide_dma_host_on() for this driver) instead of
  open-coded variant, call it from the users of sc1200_config_dma2()

  [ there is no need to call ->dma_host_on in sc1200_config_dma() because
    core code takes care of calling ->ide_dma_on on successful execution
    of ->ide_dma_check ]

* add comment about ->tuneproc interface abuse

cs5530.c/sc1200.c:

* core code takes care of calling ->dma_off_quietly before calling
  ->ide_dma_check so there is no need to call it in ->ide_dma_check methods

* bump driver version

Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
drivers/ide/pci/cs5530.c
drivers/ide/pci/sc1200.c

index 845500115f3c93d55792126124743379f2da473c..ec52dbec675fa63ee748f8d8d67f39536a385304 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * linux/drivers/ide/pci/cs5530.c              Version 0.71    Mar 10 2007
+ * linux/drivers/ide/pci/cs5530.c              Version 0.72    Mar 10 2007
  *
  * Copyright (C) 2000                  Andre Hedrick <andre@linux-ide.org>
  * Copyright (C) 2000                  Mark Lord <mlord@pobox.com>
@@ -141,11 +141,6 @@ static int cs5530_config_dma(ide_drive_t *drive)
        unsigned long basereg;
        u8 unit = drive->dn & 1, mode = 0;
 
-       /*
-        * Default to DMA-off in case we run into trouble here.
-        */
-       hwif->dma_off_quietly(drive);
-
        if (ide_use_dma(drive))
                mode = ide_max_dma_mode(drive);
 
index c0254b5e7d921bded35223f27de040711f06cc0d..65dcabe48205b0835692a173f359a137f5b4388d 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * linux/drivers/ide/pci/sc1200.c              Version 0.92    Mar 10 2007
+ * linux/drivers/ide/pci/sc1200.c              Version 0.93    Mar 10 2007
  *
  * Copyright (C) 2000-2002             Mark Lord <mlord@pobox.com>
  * Copyright (C)      2007             Bartlomiej Zolnierkiewicz
@@ -136,12 +136,6 @@ static int sc1200_config_dma2 (ide_drive_t *drive, int mode)
        unsigned short          pci_clock;
        unsigned int            basereg = hwif->channel ? 0x50 : 0x40;
 
-       /*
-        * Default to DMA-off in case we run into trouble here.
-        */
-       hwif->dma_off_quietly(drive);   /* turn off DMA while we fiddle */
-       outb(inb(hwif->dma_base+2)&~(unit?0x40:0x20), hwif->dma_base+2); /* clear DMA_capable bit */
-
        /*
         * Tell the drive to switch to the new mode; abort on failure.
         */
@@ -217,8 +211,6 @@ static int sc1200_config_dma2 (ide_drive_t *drive, int mode)
                pci_write_config_dword(hwif->pci_dev, basereg+12, timings);
        }
 
-       outb(inb(hwif->dma_base+2)|(unit?0x40:0x20), hwif->dma_base+2); /* set DMA_capable bit */
-
        return 0;       /* success */
 }
 
@@ -277,6 +269,9 @@ static void sc1200_tuneproc (ide_drive_t *drive, byte pio)  /* mode=255 means "au
        static byte     modes[5] = {XFER_PIO_0, XFER_PIO_1, XFER_PIO_2, XFER_PIO_3, XFER_PIO_4};
        int             mode = -1;
 
+       /*
+        * bad abuse of ->tuneproc interface
+        */
        switch (pio) {
                case 200: mode = XFER_UDMA_0;   break;
                case 201: mode = XFER_UDMA_1;   break;
@@ -287,7 +282,9 @@ static void sc1200_tuneproc (ide_drive_t *drive, byte pio)  /* mode=255 means "au
        }
        if (mode != -1) {
                printk("SC1200: %s: changing (U)DMA mode\n", drive->name);
-               (void)sc1200_config_dma2(drive, mode);
+               hwif->dma_off_quietly(drive);
+               if (sc1200_config_dma2(drive, mode) == 0)
+                       hwif->dma_host_on(drive);
                return;
        }
 
@@ -421,12 +418,12 @@ static int sc1200_resume (struct pci_dev *dev)
                for (d = 0; d < MAX_DRIVES; ++d) {
                        ide_drive_t *drive = &(hwif->drives[d]);
                        if (drive->present && !__ide_dma_bad_drive(drive)) {
-                               int was_using_dma = drive->using_dma;
+                               int enable_dma = drive->using_dma;
                                hwif->dma_off_quietly(drive);
-                               sc1200_config_dma(drive);
-                               if (!was_using_dma && drive->using_dma) {
-                                       hwif->dma_off_quietly(drive);
-                               }
+                               if (sc1200_config_dma(drive))
+                                       enable_dma = 0;
+                               if (enable_dma)
+                                       hwif->dma_host_on(drive);
                        }
                }
        }