[U-Boot] [PATCH v1 1/3] linux, compat: add missing definitions for ubi
Heiko Schocher
hs at denx.de
Thu Oct 22 06:19:20 CEST 2015
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 at denx.de>
---
drivers/usb/dwc3/linux-compat.h | 5 -----
include/linux/compat.h | 37 +++++++++++++++++++++++++++++++++----
2 files changed, 33 insertions(+), 9 deletions(-)
diff --git a/drivers/usb/dwc3/linux-compat.h b/drivers/usb/dwc3/linux-compat.h
index b36f68f..6c9c279 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 fbebf91..59937de 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)
--
2.1.0
More information about the U-Boot
mailing list