/* RETURNS: Pointer to allocated memory on success, NULL on failure.  */
void* dmam_alloc_coherent(struct device *dev, size_t size, dma_addr_t *dma_handle, gfp_t gfp)
/* RETURNS: Pointer to allocated memory on success, NULL on failure.  */
void* dmam_alloc_coherent(struct device *dev, size_t size, dma_addr_t *dma_handle, gfp_t gfp)
{
	struct dma_devres *dr;
	void *vaddr;
	dr = devres_alloc(dmam_coherent_release, sizeof(*dr), gfp);
	if (!dr)
		return NULL;
	vaddr = dma_alloc_coherent(dev, size, dma_handle, gfp);
	if (!vaddr) {
		devres_free(dr);
		return NULL;
	}
	dr->vaddr = vaddr;
	dr->dma_handle = *dma_handle;
	dr->size = size;
	devres_add(dev, dr);
	return vaddr;
}