summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHeiko Schocher <hs@denx.de>2015-10-22 06:19:20 +0200
committerHeiko Schocher <hs@denx.de>2015-10-26 09:22:02 +0100
commit5219db8ae802210730b348a888474efc2f9bf0a4 (patch)
tree9ac4e8397615397621441df872b43b0c7b32be51
parent677f970bc62a661690b3431543d5a5d5e682ba70 (diff)
downloadblackbird-obmc-uboot-5219db8ae802210730b348a888474efc2f9bf0a4.tar.gz
blackbird-obmc-uboot-5219db8ae802210730b348a888474efc2f9bf0a4.zip
linux, compat: add missing definitions for ubi
add missing definitions for the ubi/ubifs sync with linux 4.2, also change "#define kfree ..." into a static inline, so prevent ubi compile error: CC drivers/mtd/ubi/fastmap.o drivers/mtd/ubi/fastmap.c: In function 'scan_pool': drivers/mtd/ubi/fastmap.c:475:3: error: called object 'free' is not a function Signed-off-by: Heiko Schocher <hs@denx.de>
-rw-r--r--drivers/usb/dwc3/linux-compat.h5
-rw-r--r--include/linux/compat.h37
2 files changed, 33 insertions, 9 deletions
diff --git a/drivers/usb/dwc3/linux-compat.h b/drivers/usb/dwc3/linux-compat.h
index b36f68fec8..6c9c2791a8 100644
--- a/drivers/usb/dwc3/linux-compat.h
+++ b/drivers/usb/dwc3/linux-compat.h
@@ -30,9 +30,4 @@ static inline void *devm_kzalloc(struct device *dev, unsigned int size,
{
return kzalloc(size, flags);
}
-
-static inline void *kmalloc_array(size_t n, size_t size, gfp_t flags)
-{
- return kzalloc(n * size, flags);
-}
#endif
diff --git a/include/linux/compat.h b/include/linux/compat.h
index fbebf910ad..59937de960 100644
--- a/include/linux/compat.h
+++ b/include/linux/compat.h
@@ -4,6 +4,7 @@
#include <malloc.h>
#include <linux/types.h>
#include <linux/err.h>
+#include <linux/kernel.h>
struct unused {};
typedef struct unused unused_t;
@@ -49,22 +50,47 @@ static inline void *kzalloc(size_t size, gfp_t flags)
{
return kmalloc(size, flags | __GFP_ZERO);
}
+
+static inline void *kmalloc_array(size_t n, size_t size, gfp_t flags)
+{
+ if (size != 0 && n > SIZE_MAX / size)
+ return NULL;
+ return kmalloc(n * size, flags | __GFP_ZERO);
+}
+
+static inline void *kcalloc(size_t n, size_t size, gfp_t flags)
+{
+ return kmalloc_array(n, size, flags | __GFP_ZERO);
+}
+
#define vmalloc(size) kmalloc(size, 0)
#define __vmalloc(size, flags, pgsz) kmalloc(size, flags)
static inline void *vzalloc(unsigned long size)
{
return kzalloc(size, 0);
}
-#define kfree(ptr) free(ptr)
-#define vfree(ptr) free(ptr)
+static inline void kfree(const void *block)
+{
+ free((void *)block);
+}
+static inline void vfree(const void *addr)
+{
+ free((void *)addr);
+}
struct kmem_cache { int sz; };
struct kmem_cache *get_mem(int element_sz);
#define kmem_cache_create(a, sz, c, d, e) get_mem(sz)
void *kmem_cache_alloc(struct kmem_cache *obj, int flag);
-#define kmem_cache_free(obj, size) free(size)
-#define kmem_cache_destroy(obj) free(obj)
+static inline void kmem_cache_free(struct kmem_cache *cachep, void *obj)
+{
+ free(obj);
+}
+static inline void kmem_cache_destroy(struct kmem_cache *cachep)
+{
+ free(cachep);
+}
#define DECLARE_WAITQUEUE(...) do { } while (0)
#define add_wait_queue(...) do { } while (0)
@@ -159,6 +185,8 @@ typedef unsigned long blkcnt_t;
#define class_create(...) __builtin_return_address(0)
#define class_create_file(...) 0
+#define class_register(...) 0
+#define class_unregister(...)
#define class_remove_file(...)
#define class_destroy(...)
#define misc_register(...) 0
@@ -171,6 +199,7 @@ typedef unsigned long blkcnt_t;
#define dev_set_name(...) do { } while (0)
#define device_register(...) 0
+#define device_unregister(...)
#define volume_sysfs_init(...) 0
#define volume_sysfs_close(...) do { } while (0)
OpenPOWER on IntegriCloud