usb: ehci-mx6: Handle fixed regulators correctly
[oweals/u-boot.git] / lib / linux_compat.c
index 81ea8fb126fa2fec7230479ae77d744cde337e4c..c83426f59dc208fd51f53d1c3f447c52e955602b 100644 (file)
@@ -1,6 +1,8 @@
 
 #include <common.h>
+#include <malloc.h>
 #include <memalign.h>
+#include <asm/cache.h>
 #include <linux/compat.h>
 
 struct p_current cur = {
@@ -40,3 +42,22 @@ void *kmem_cache_alloc(struct kmem_cache *obj, int flag)
 {
        return malloc_cache_aligned(obj->sz);
 }
+
+/**
+ * kmemdup - duplicate region of memory
+ *
+ * @src: memory region to duplicate
+ * @len: memory region length
+ * @gfp: GFP mask to use
+ *
+ * Return: newly allocated copy of @src or %NULL in case of error
+ */
+void *kmemdup(const void *src, size_t len, gfp_t gfp)
+{
+       void *p;
+
+       p = kmalloc(len, gfp);
+       if (p)
+               memcpy(p, src, len);
+       return p;
+}