temporary fix for inet_twdr_hangman() related bug
[linux-2.6.git] / drivers / ide / ide-dma.c
index 7e28fc0..7c3a13e 100644 (file)
@@ -74,7 +74,6 @@
  *
  */
 
-#include <linux/config.h>
 #include <linux/module.h>
 #include <linux/types.h>
 #include <linux/kernel.h>
 #include <asm/io.h>
 #include <asm/irq.h>
 
-struct drive_list_entry {
-       const char *id_model;
-       const char *id_firmware;
-};
-
 static const struct drive_list_entry drive_whitelist [] = {
 
        { "Micropolis 2112A"    ,       "ALL"           },
@@ -116,7 +110,6 @@ static const struct drive_list_entry drive_blacklist [] = {
        { "Compaq CRD-8241B"    ,       "ALL"           },
        { "CRD-8400B"           ,       "ALL"           },
        { "CRD-8480B",                  "ALL"           },
-       { "CRD-8480C",                  "ALL"           },
        { "CRD-8482B",                  "ALL"           },
        { "CRD-84"              ,       "ALL"           },
        { "SanDisk SDP3B"       ,       "ALL"           },
@@ -140,7 +133,7 @@ static const struct drive_list_entry drive_blacklist [] = {
 };
 
 /**
- *     in_drive_list   -       look for drive in black/white list
+ *     ide_in_drive_list       -       look for drive in black/white list
  *     @id: drive identifier
  *     @drive_table: list to inspect
  *
@@ -148,7 +141,7 @@ static const struct drive_list_entry drive_blacklist [] = {
  *     Returns 1 if the drive is found in the table.
  */
 
-static int in_drive_list(struct hd_driveid *id, const struct drive_list_entry *drive_table)
+int ide_in_drive_list(struct hd_driveid *id, const struct drive_list_entry *drive_table)
 {
        for ( ; drive_table->id_model ; drive_table++)
                if ((!strcmp(drive_table->id_model, id->model)) &&
@@ -158,7 +151,8 @@ static int in_drive_list(struct hd_driveid *id, const struct drive_list_entry *d
        return 0;
 }
 
-#ifdef CONFIG_BLK_DEV_IDEDMA_PCI
+EXPORT_SYMBOL_GPL(ide_in_drive_list);
+
 /**
  *     ide_dma_intr    -       IDE DMA interrupt handler
  *     @drive: the drive the interrupt is for
@@ -177,17 +171,24 @@ ide_startstop_t ide_dma_intr (ide_drive_t *drive)
                if (!dma_stat) {
                        struct request *rq = HWGROUP(drive)->rq;
 
-                       DRIVER(drive)->end_request(drive, 1, rq->nr_sectors);
+                       if (rq->rq_disk) {
+                               ide_driver_t *drv;
+
+                               drv = *(ide_driver_t **)rq->rq_disk->private_data;
+                               drv->end_request(drive, 1, rq->nr_sectors);
+                       } else
+                               ide_end_request(drive, 1, rq->nr_sectors);
                        return ide_stopped;
                }
                printk(KERN_ERR "%s: dma_intr: bad DMA status (dma_stat=%x)\n", 
                       drive->name, dma_stat);
        }
-       return DRIVER(drive)->error(drive, "dma_intr", stat);
+       return ide_error(drive, "dma_intr", stat);
 }
 
 EXPORT_SYMBOL_GPL(ide_dma_intr);
 
+#ifdef CONFIG_BLK_DEV_IDEDMA_PCI
 /**
  *     ide_build_sglist        -       map IDE scatter gather for DMA I/O
  *     @drive: the drive to build the DMA table for
@@ -204,8 +205,7 @@ int ide_build_sglist(ide_drive_t *drive, struct request *rq)
        ide_hwif_t *hwif = HWIF(drive);
        struct scatterlist *sg = hwif->sg_table;
 
-       if ((rq->flags & REQ_DRIVE_TASKFILE) && rq->nr_sectors > 256)
-               BUG();
+       BUG_ON((rq->flags & REQ_DRIVE_TASKFILE) && rq->nr_sectors > 256);
 
        ide_map_sg(drive, rq);
 
@@ -227,7 +227,9 @@ EXPORT_SYMBOL_GPL(ide_build_sglist);
  *     the PRD table that the IDE layer wants to be fed. The code
  *     knows about the 64K wrap bug in the CS5530.
  *
- *     Returns 0 if all went okay, returns 1 otherwise.
+ *     Returns the number of built PRD entries if all went okay,
+ *     returns 0 otherwise.
+ *
  *     May also be invoked from trm290.c
  */
  
@@ -631,7 +633,7 @@ int __ide_dma_end (ide_drive_t *drive)
 EXPORT_SYMBOL(__ide_dma_end);
 
 /* returns 1 if dma irq issued, 0 otherwise */
-int __ide_dma_test_irq (ide_drive_t *drive)
+static int __ide_dma_test_irq(ide_drive_t *drive)
 {
        ide_hwif_t *hwif        = HWIF(drive);
        u8 dma_stat             = hwif->INB(hwif->dma_status);
@@ -650,15 +652,13 @@ int __ide_dma_test_irq (ide_drive_t *drive)
                        drive->name, __FUNCTION__);
        return 0;
 }
-
-EXPORT_SYMBOL(__ide_dma_test_irq);
 #endif /* CONFIG_BLK_DEV_IDEDMA_PCI */
 
 int __ide_dma_bad_drive (ide_drive_t *drive)
 {
        struct hd_driveid *id = drive->id;
 
-       int blacklist = in_drive_list(id, drive_blacklist);
+       int blacklist = ide_in_drive_list(id, drive_blacklist);
        if (blacklist) {
                printk(KERN_WARNING "%s: Disabling (U)DMA for %s (blacklisted)\n",
                                    drive->name, id->model);
@@ -672,7 +672,7 @@ EXPORT_SYMBOL(__ide_dma_bad_drive);
 int __ide_dma_good_drive (ide_drive_t *drive)
 {
        struct hd_driveid *id = drive->id;
-       return in_drive_list(id, drive_whitelist);
+       return ide_in_drive_list(id, drive_whitelist);
 }
 
 EXPORT_SYMBOL(__ide_dma_good_drive);
@@ -750,7 +750,7 @@ void ide_dma_verbose(ide_drive_t *drive)
                        goto bug_dma_off;
                printk(", DMA");
        } else if (id->field_valid & 1) {
-               printk(", BUG");
+               goto bug_dma_off;
        }
        return;
 bug_dma_off:
@@ -784,7 +784,7 @@ EXPORT_SYMBOL(__ide_dma_timeout);
 /*
  * Needed for allowing full modular support of ide-driver
  */
-int ide_release_dma_engine (ide_hwif_t *hwif)
+static int ide_release_dma_engine(ide_hwif_t *hwif)
 {
        if (hwif->dmatable_cpu) {
                pci_free_consistent(hwif->pci_dev,
@@ -796,7 +796,7 @@ int ide_release_dma_engine (ide_hwif_t *hwif)
        return 1;
 }
 
-int ide_release_iomio_dma (ide_hwif_t *hwif)
+static int ide_release_iomio_dma(ide_hwif_t *hwif)
 {
        if ((hwif->dma_extra) && (hwif->channel == 0))
                release_region((hwif->dma_base + 16), hwif->dma_extra);
@@ -820,7 +820,7 @@ int ide_release_dma (ide_hwif_t *hwif)
        return ide_release_iomio_dma(hwif);
 }
 
-int ide_allocate_dma_engine (ide_hwif_t *hwif)
+static int ide_allocate_dma_engine(ide_hwif_t *hwif)
 {
        hwif->dmatable_cpu = pci_alloc_consistent(hwif->pci_dev,
                                                  PRD_ENTRIES * PRD_BYTES,
@@ -830,14 +830,13 @@ int ide_allocate_dma_engine (ide_hwif_t *hwif)
                return 0;
 
        printk(KERN_ERR "%s: -- Error, unable to allocate%s DMA table(s).\n",
-               (hwif->dmatable_cpu == NULL) ? " CPU" : "",
-               hwif->cds->name);
+                       hwif->cds->name, !hwif->dmatable_cpu ? " CPU" : "");
 
        ide_release_dma_engine(hwif);
        return 1;
 }
 
-int ide_mapped_mmio_dma (ide_hwif_t *hwif, unsigned long base, unsigned int ports)
+static int ide_mapped_mmio_dma(ide_hwif_t *hwif, unsigned long base, unsigned int ports)
 {
        printk(KERN_INFO "    %s: MMIO-DMA ", hwif->name);
 
@@ -852,7 +851,7 @@ int ide_mapped_mmio_dma (ide_hwif_t *hwif, unsigned long base, unsigned int port
        return 0;
 }
 
-int ide_iomio_dma (ide_hwif_t *hwif, unsigned long base, unsigned int ports)
+static int ide_iomio_dma(ide_hwif_t *hwif, unsigned long base, unsigned int ports)
 {
        printk(KERN_INFO "    %s: BM-DMA at 0x%04lx-0x%04lx",
                hwif->name, base, base + ports - 1);
@@ -881,10 +880,7 @@ int ide_iomio_dma (ide_hwif_t *hwif, unsigned long base, unsigned int ports)
        return 0;
 }
 
-/*
- * 
- */
-int ide_dma_iobase (ide_hwif_t *hwif, unsigned long base, unsigned int ports)
+static int ide_dma_iobase(ide_hwif_t *hwif, unsigned long base, unsigned int ports)
 {
        if (hwif->mmio == 2)
                return ide_mapped_mmio_dma(hwif, base,ports);
@@ -926,12 +922,12 @@ void ide_setup_dma (ide_hwif_t *hwif, unsigned long dma_base, unsigned int num_p
                hwif->ide_dma_host_on = &__ide_dma_host_on;
        if (!hwif->ide_dma_check)
                hwif->ide_dma_check = &__ide_dma_check;
-       if (!hwif->ide_dma_setup)
-               hwif->ide_dma_setup = &ide_dma_setup;
-       if (!hwif->ide_dma_exec_cmd)
-               hwif->ide_dma_exec_cmd = &ide_dma_exec_cmd;
-       if (!hwif->ide_dma_start)
-               hwif->ide_dma_start = &ide_dma_start;
+       if (!hwif->dma_setup)
+               hwif->dma_setup = &ide_dma_setup;
+       if (!hwif->dma_exec_cmd)
+               hwif->dma_exec_cmd = &ide_dma_exec_cmd;
+       if (!hwif->dma_start)
+               hwif->dma_start = &ide_dma_start;
        if (!hwif->ide_dma_end)
                hwif->ide_dma_end = &__ide_dma_end;
        if (!hwif->ide_dma_test_irq)
@@ -949,8 +945,7 @@ void ide_setup_dma (ide_hwif_t *hwif, unsigned long dma_base, unsigned int num_p
        }
        printk("\n");
 
-       if (!(hwif->dma_master))
-               BUG();
+       BUG_ON(!hwif->dma_master);
 }
 
 EXPORT_SYMBOL_GPL(ide_setup_dma);