From: Heiko Schocher Date: Thu, 22 Oct 2015 04:19:20 +0000 (+0200) Subject: linux, compat: add missing definitions for ubi X-Git-Url: http://git.dujemihanovic.xyz/?a=commitdiff_plain;h=5219db8ae802210730b348a888474efc2f9bf0a4;p=u-boot.git 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 --- 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 #include #include +#include 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)