diff options
author | root <root@artemis.panaceas.org> | 2015-12-25 15:00:15 +0000 |
---|---|---|
committer | root <root@artemis.panaceas.org> | 2015-12-25 15:00:15 +0000 |
commit | ddd86436f4e3643c04b797f858dab95d5f2e4de9 (patch) | |
tree | bfe7a780cf9a2f4fc33aec32c82e625e79dece1f /compat/dma-shared-helpers.c | |
download | backports-3.10.19-1-master.tar.gz backports-3.10.19-1-master.tar.bz2 backports-3.10.19-1-master.zip |
Diffstat (limited to 'compat/dma-shared-helpers.c')
-rw-r--r-- | compat/dma-shared-helpers.c | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/compat/dma-shared-helpers.c b/compat/dma-shared-helpers.c new file mode 100644 index 0000000..e09dd6b --- /dev/null +++ b/compat/dma-shared-helpers.c @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2013 Luis R. Rodriguez <mcgrof@do-not-panic.com> + * + * Backport compatibility file for Linux for some DMA helpers + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + */ + +#include <linux/module.h> +#include <linux/scatterlist.h> +#include <linux/dma-attrs.h> +#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,3,0) +#if LINUX_VERSION_CODE <= KERNEL_VERSION(3,6,0) +#include <linux/dma-direction.h> +#include <linux/dma-mapping.h> +#include <asm/dma-mapping.h> +#endif /* LINUX_VERSION_CODE <= KERNEL_VERSION(3,6,0) */ +#endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(3,3,0) */ + +/* + * Create scatter-list for the already allocated DMA buffer. + */ +int dma_common_get_sgtable(struct device *dev, struct sg_table *sgt, + void *cpu_addr, dma_addr_t handle, size_t size) +{ + struct page *page = virt_to_page(cpu_addr); + int ret; + + ret = sg_alloc_table(sgt, 1, GFP_KERNEL); + if (unlikely(ret)) + return ret; + + sg_set_page(sgt->sgl, page, PAGE_ALIGN(size), 0); + return 0; +} +EXPORT_SYMBOL_GPL(dma_common_get_sgtable); |