/* Maps in a memory region such that it can be used for performing a DMA. */
int dma_map_start(DMA_MemMap_t *memMap, enum dma_data_direction dir)
/* Maps in a memory region such that it can be used for performing a DMA. */
int dma_map_start(DMA_MemMap_t *memMap, enum dma_data_direction dir)
{
	int rc;
	down(&memMap->lock);
	DMA_MAP_PRINT("memMap: %p\n", memMap);
	if (memMap->inUse) {
		printk(KERN_ERR "%s: memory map %p is already being used\n",
		       __func__, memMap);
		rc = -EBUSY;
		goto out;
	}
	memMap->inUse = 1;
	memMap->dir = dir;
	memMap->numRegionsUsed = 0;
	rc = 0;
out:
	DMA_MAP_PRINT("returning %d", rc);
	up(&memMap->lock);
	return rc;
}