aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/ide/ide-dma.c
diff options
context:
space:
mode:
authorBartlomiej Zolnierkiewicz <bzolnier@gmail.com>2007-02-16 20:40:26 -0500
committerBartlomiej Zolnierkiewicz <bzolnier@gmail.com>2007-02-16 20:40:26 -0500
commit3608b5d71a52c053787dbad6af20c25f7e0b75a9 (patch)
tree5bd6ac777d32d8426e65e3c31cc1587674771e8c /drivers/ide/ide-dma.c
parent9ef5791e1be91007951477b8ed1530ac1166a8e7 (diff)
ide: add ide_set_dma() helper (v2)
* add ide_set_dma() helper and make ide_hwif_t.ide_dma_check return -1 when DMA needs to be disabled (== need to call ->ide_dma_off_quietly) 0 when DMA needs to be enabled (== need to call ->ide_dma_on) 1 when DMA setting shouldn't be changed * fix IDE code to use ide_set_dma() instead if using ->ide_dma_check directly v2: * updated for scc_pata Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
Diffstat (limited to 'drivers/ide/ide-dma.c')
-rw-r--r--drivers/ide/ide-dma.c37
1 files changed, 30 insertions, 7 deletions
diff --git a/drivers/ide/ide-dma.c b/drivers/ide/ide-dma.c
index 1a288e5307d3..4fbcea4c1025 100644
--- a/drivers/ide/ide-dma.c
+++ b/drivers/ide/ide-dma.c
@@ -348,15 +348,14 @@ EXPORT_SYMBOL_GPL(ide_destroy_dmatable);
348static int config_drive_for_dma (ide_drive_t *drive) 348static int config_drive_for_dma (ide_drive_t *drive)
349{ 349{
350 struct hd_driveid *id = drive->id; 350 struct hd_driveid *id = drive->id;
351 ide_hwif_t *hwif = HWIF(drive);
352 351
353 if ((id->capability & 1) && hwif->autodma) { 352 if ((id->capability & 1) && drive->hwif->autodma) {
354 /* 353 /*
355 * Enable DMA on any drive that has 354 * Enable DMA on any drive that has
356 * UltraDMA (mode 0/1/2/3/4/5/6) enabled 355 * UltraDMA (mode 0/1/2/3/4/5/6) enabled
357 */ 356 */
358 if ((id->field_valid & 4) && ((id->dma_ultra >> 8) & 0x7f)) 357 if ((id->field_valid & 4) && ((id->dma_ultra >> 8) & 0x7f))
359 return hwif->ide_dma_on(drive); 358 return 0;
360 /* 359 /*
361 * Enable DMA on any drive that has mode2 DMA 360 * Enable DMA on any drive that has mode2 DMA
362 * (multi or single) enabled 361 * (multi or single) enabled
@@ -364,14 +363,14 @@ static int config_drive_for_dma (ide_drive_t *drive)
364 if (id->field_valid & 2) /* regular DMA */ 363 if (id->field_valid & 2) /* regular DMA */
365 if ((id->dma_mword & 0x404) == 0x404 || 364 if ((id->dma_mword & 0x404) == 0x404 ||
366 (id->dma_1word & 0x404) == 0x404) 365 (id->dma_1word & 0x404) == 0x404)
367 return hwif->ide_dma_on(drive); 366 return 0;
368 367
369 /* Consult the list of known "good" drives */ 368 /* Consult the list of known "good" drives */
370 if (__ide_dma_good_drive(drive)) 369 if (__ide_dma_good_drive(drive))
371 return hwif->ide_dma_on(drive); 370 return 0;
372 } 371 }
373// if (hwif->tuneproc != NULL) hwif->tuneproc(drive, 255); 372
374 return hwif->ide_dma_off_quietly(drive); 373 return -1;
375} 374}
376 375
377/** 376/**
@@ -765,6 +764,30 @@ bug_dma_off:
765 764
766EXPORT_SYMBOL(ide_dma_verbose); 765EXPORT_SYMBOL(ide_dma_verbose);
767 766
767int ide_set_dma(ide_drive_t *drive)
768{
769 ide_hwif_t *hwif = drive->hwif;
770 int rc;
771
772 rc = hwif->ide_dma_check(drive);
773
774 switch(rc) {
775 case -1: /* DMA needs to be disabled */
776 return hwif->ide_dma_off_quietly(drive);
777 case 0: /* DMA needs to be enabled */
778 return hwif->ide_dma_on(drive);
779 case 1: /* DMA setting cannot be changed */
780 break;
781 default:
782 BUG();
783 break;
784 }
785
786 return rc;
787}
788
789EXPORT_SYMBOL_GPL(ide_set_dma);
790
768#ifdef CONFIG_BLK_DEV_IDEDMA_PCI 791#ifdef CONFIG_BLK_DEV_IDEDMA_PCI
769int __ide_dma_lostirq (ide_drive_t *drive) 792int __ide_dma_lostirq (ide_drive_t *drive)
770{ 793{