#include_next <asm/dma-mapping.h>
#include <linux/version.h>
-#if LINUX_VERSION_CODE < KERNEL_VERSION(3,6,0)
-
+#if defined(CPTCFG_BACKPORT_BUILD_DMA_SHARED_HELPERS)
#define dma_common_get_sgtable LINUX_BACKPORT(dma_common_get_sgtable)
int
dma_common_get_sgtable(struct device *dev, struct sg_table *sgt,
void *cpu_addr, dma_addr_t dma_addr, size_t size);
+#endif /* defined(CPTCFG_BACKPORT_BUILD_DMA_SHARED_HELPERS) */
+
+#if LINUX_VERSION_CODE < KERNEL_VERSION(3,6,0)
#define dma_get_sgtable_attrs LINUX_BACKPORT(dma_get_sgtable_attrs)
struct dma_attrs;
}
#define dma_get_sgtable(d, t, v, h, s) dma_get_sgtable_attrs(d, t, v, h, s, NULL)
-#endif
+#endif /* LINUX_VERSION_CODE < KERNEL_VERSION(3,6,0) */
#endif /* __BACKPORT_ASM_DMA_MAPPING_H */
--- /dev/null
+#ifndef __BACKPORT_DMA_ATTR_H
+#define __BACKPORT_DMA_ATTR_H
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,26)
+#include_next <linux/dma-attrs.h>
+#endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,26) */
+#endif /* __BACKPORT_DMA_ATTR_H */
config BACKPORT_HDMI
bool
+config BACKPORT_BUILD_DMA_SHARED_HELPERS
+ bool
+ depends on HAS_DMA
+ # Build on other kernels kernels < 3.9 if HAVE_GENERIC_DMA_COHERENT is
+ # not set. Kernels >= 3.8 have this if HAS_DMA is set.
+ depends on (!HAVE_GENERIC_DMA_COHERENT || BACKPORT_KERNEL_3_9)
+ # Always build if on 3.3 - 3.5
+ default y if (BACKPORT_KERNEL_3_4 || BACKPORT_KERNEL_3_5 || BACKPORT_KERNEL_3_6)
+ # build for testing
+ default y if BACKPORT_USERSEL_BUILD_ALL
+
config BACKPORT_BUILD_LEDS
bool
depends on !NEW_LEDS || !LEDS_CLASS || !LEDS_TRIGGERS
compat-$(CPTCFG_BACKPORT_BUILD_KFIFO) += kfifo.o
compat-$(CPTCFG_BACKPORT_BUILD_GENERIC_ATOMIC64) += compat_atomic.o
+compat-$(CPTCFG_BACKPORT_BUILD_DMA_SHARED_HELPERS) += dma-shared-helpers.o
#include <linux/i2c.h>
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,2,0))
-#include <linux/dma-attrs.h>
-/*
- * 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);
-
/**
* __i2c_transfer - unlocked flavor of i2c_transfer
* @adap: Handle to I2C bus
--- /dev/null
+/*
+ * 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);