
From: Jens Axboe <axboe@suse.de>

The blacklist stuff is broken.  When set_using_dma() calls into
ide_dma_check(), it returns ide_dma_off() for a blacklisted drive.  This of
course succeeds, returning success to the caller of ide_dma_check().  Not
so good...  It then uncondtionally calls ide_dma_on(), which turns on dma
for the drive.

This moves the check to ide_dma_on() so we also catch the buggy
->ide_dma_check() defined by various chipset drivers.

Signed-off-by: Andrew Morton <akpm@osdl.org>
---

 25-akpm/drivers/ide/ide-dma.c |   13 +++++++++----
 1 files changed, 9 insertions(+), 4 deletions(-)

diff -puN drivers/ide/ide-dma.c~ide-dma-blacklist-behaviour-broken drivers/ide/ide-dma.c
--- 25/drivers/ide/ide-dma.c~ide-dma-blacklist-behaviour-broken	2004-10-05 11:05:51.906920096 -0700
+++ 25-akpm/drivers/ide/ide-dma.c	2004-10-05 11:05:51.909919640 -0700
@@ -406,11 +406,13 @@ static int config_drive_for_dma (ide_dri
 	struct hd_driveid *id = drive->id;
 	ide_hwif_t *hwif = HWIF(drive);
 
-	if ((id->capability & 1) && hwif->autodma) {
-		/* Consult the list of known "bad" drives */
-		if (__ide_dma_bad_drive(drive))
-			return __ide_dma_off(drive);
+	/* Consult the list of known "bad" drives */
+	if (__ide_dma_bad_drive(drive)) {
+		__ide_dma_off(drive);
+		return 1;
+	}
 
+	if ((id->capability & 1) && hwif->autodma) {
 		/*
 		 * Enable DMA on any drive that has
 		 * UltraDMA (mode 0/1/2/3/4/5/6) enabled
@@ -564,6 +566,9 @@ EXPORT_SYMBOL(__ide_dma_host_on);
  
 int __ide_dma_on (ide_drive_t *drive)
 {
+	if (__ide_dma_bad_drive(drive))
+		return 1;
+
 	drive->using_dma = 1;
 	ide_toggle_bounce(drive, 1);
 
_
