Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 3608b5d7 authored by Bartlomiej Zolnierkiewicz's avatar Bartlomiej Zolnierkiewicz
Browse files

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: default avatarBartlomiej Zolnierkiewicz <bzolnier@gmail.com>
parent 9ef5791e
Loading
Loading
Loading
Loading
+1 −4
Original line number Diff line number Diff line
@@ -365,10 +365,7 @@ static int icside_dma_check(ide_drive_t *drive)
out:
	on = icside_set_speed(drive, xfer_mode);

	if (on)
		return icside_dma_on(drive);
	else
		return icside_dma_off_quietly(drive);
	return on ? 0 : -1;
}

static int icside_dma_end(ide_drive_t *drive)
+2 −4
Original line number Diff line number Diff line
@@ -1048,12 +1048,10 @@ static ide_startstop_t cris_dma_intr (ide_drive_t *drive)

static int cris_dma_check(ide_drive_t *drive)
{
	ide_hwif_t *hwif = drive->hwif;

	if (ide_use_dma(drive) && cris_config_drive_for_dma(drive))
		return hwif->ide_dma_on(drive);
		return 0;

	return hwif->ide_dma_off_quietly(drive);
	return -1;
}

static int cris_dma_end(ide_drive_t *drive)
+30 −7
Original line number Diff line number Diff line
@@ -348,15 +348,14 @@ EXPORT_SYMBOL_GPL(ide_destroy_dmatable);
static int config_drive_for_dma (ide_drive_t *drive)
{
	struct hd_driveid *id = drive->id;
	ide_hwif_t *hwif = HWIF(drive);

	if ((id->capability & 1) && hwif->autodma) {
	if ((id->capability & 1) && drive->hwif->autodma) {
		/*
		 * Enable DMA on any drive that has
		 * UltraDMA (mode 0/1/2/3/4/5/6) enabled
		 */
		if ((id->field_valid & 4) && ((id->dma_ultra >> 8) & 0x7f))
			return hwif->ide_dma_on(drive);
			return 0;
		/*
		 * Enable DMA on any drive that has mode2 DMA
		 * (multi or single) enabled
@@ -364,14 +363,14 @@ static int config_drive_for_dma (ide_drive_t *drive)
		if (id->field_valid & 2)	/* regular DMA */
			if ((id->dma_mword & 0x404) == 0x404 ||
			    (id->dma_1word & 0x404) == 0x404)
				return hwif->ide_dma_on(drive);
				return 0;

		/* Consult the list of known "good" drives */
		if (__ide_dma_good_drive(drive))
			return hwif->ide_dma_on(drive);
			return 0;
	}
//	if (hwif->tuneproc != NULL) hwif->tuneproc(drive, 255);
	return hwif->ide_dma_off_quietly(drive);

	return -1;
}

/**
@@ -765,6 +764,30 @@ bug_dma_off:

EXPORT_SYMBOL(ide_dma_verbose);

int ide_set_dma(ide_drive_t *drive)
{
	ide_hwif_t *hwif = drive->hwif;
	int rc;

	rc = hwif->ide_dma_check(drive);

	switch(rc) {
	case -1: /* DMA needs to be disabled */
		return hwif->ide_dma_off_quietly(drive);
	case  0: /* DMA needs to be enabled */
		return hwif->ide_dma_on(drive);
	case  1: /* DMA setting cannot be changed */
		break;
	default:
		BUG();
		break;
	}

	return rc;
}

EXPORT_SYMBOL_GPL(ide_set_dma);

#ifdef CONFIG_BLK_DEV_IDEDMA_PCI
int __ide_dma_lostirq (ide_drive_t *drive)
{
+1 −1
Original line number Diff line number Diff line
@@ -226,7 +226,7 @@ static ide_startstop_t ide_start_power_step(ide_drive_t *drive, struct request *
			break;
		if (drive->hwif->ide_dma_check == NULL)
			break;
		drive->hwif->ide_dma_check(drive);
		ide_set_dma(drive);
		break;
	}
	pm->pm_step = ide_pm_state_completed;
+1 −1
Original line number Diff line number Diff line
@@ -857,7 +857,7 @@ static void probe_hwif(ide_hwif_t *hwif)
#ifdef CONFIG_IDEDMA_ONLYDISK
				if (drive->media == ide_disk)
#endif
					hwif->ide_dma_check(drive);
					ide_set_dma(drive);
			}
		}
	}
Loading