/* This function also needs to know which DMA device this transfer will be destined for, so that the appropriate DMA configuration can be retrieved. DMA parameters such as transfer width, and whether this is a memory-to-memory or memory-to-peripheral, etc can all affect the actual number of descriptors required. */
int dma_calculate_descriptor_count(DMA_Device_t device, dma_addr_t srcData, dma_addr_t dstData, size_t numBytes)
/* This function also needs to know which DMA device this transfer will be destined for, so that the appropriate DMA configuration can be retrieved. DMA parameters such as transfer width, and whether this is a memory-to-memory or memory-to-peripheral, etc can all affect the actual number of descriptors required. */
int dma_calculate_descriptor_count(DMA_Device_t device, dma_addr_t srcData, dma_addr_t dstData, size_t numBytes)
{
	int numDescriptors;
	DMA_DeviceAttribute_t *devAttr;
	if (!IsDeviceValid(device)) {
		return -ENODEV;
	}
	devAttr = &DMA_gDeviceAttribute[device];
	numDescriptors = dmacHw_calculateDescriptorCount(&devAttr->config,
							      (void *)srcData,
							      (void *)dstData,
							      numBytes);
	if (numDescriptors < 0) {
		printk(KERN_ERR
		       "dma_calculate_descriptor_count: dmacHw_calculateDescriptorCount failed\n");
		return -EINVAL;
	}
	return numDescriptors;
}