X-Git-Url: https://git.librecmc.org/?a=blobdiff_plain;f=include%2Flinux%2Fcompat.h;h=8711fe2b48c46256fd1a7cd1b7535e77a7d0bd29;hb=9fb2c1faa18201ab1fb7efed4140eff97b453870;hp=7ff6064b187b7b914f27ac8f5e7004a014037130;hpb=f91df8ca177c446307ac03faa2f00c71dc79a9c2;p=oweals%2Fu-boot.git diff --git a/include/linux/compat.h b/include/linux/compat.h index 7ff6064b18..8711fe2b48 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; @@ -14,7 +15,22 @@ struct p_current{ extern struct p_current *current; -#define ndelay(x) udelay(1) +/* avoid conflict with */ +#ifdef dev_dbg +#undef dev_dbg +#endif +#ifdef dev_vdbg +#undef dev_vdbg +#endif +#ifdef dev_info +#undef dev_info +#endif +#ifdef dev_err +#undef dev_err +#endif +#ifdef dev_warn +#undef dev_warn +#endif #define dev_dbg(dev, fmt, args...) \ debug(fmt, ##args) @@ -24,32 +40,63 @@ extern struct p_current *current; printf(fmt, ##args) #define dev_err(dev, fmt, args...) \ printf(fmt, ##args) -#define printk printf -#define printk_once printf - -#define KERN_EMERG -#define KERN_ALERT -#define KERN_CRIT -#define KERN_ERR -#define KERN_WARNING -#define KERN_NOTICE -#define KERN_INFO -#define KERN_DEBUG +#define dev_warn(dev, fmt, args...) \ + printf(fmt, ##args) + +#define GFP_ATOMIC ((gfp_t) 0) +#define GFP_KERNEL ((gfp_t) 0) +#define GFP_NOFS ((gfp_t) 0) +#define GFP_USER ((gfp_t) 0) +#define __GFP_NOWARN ((gfp_t) 0) +#define __GFP_ZERO ((__force gfp_t)0x8000u) /* Return zeroed page on success */ void *kmalloc(size_t size, int flags); -void *kzalloc(size_t size, int flags); + +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) -#define kfree(ptr) free(ptr) -#define vfree(ptr) free(ptr) +static inline void *vzalloc(unsigned long size) +{ + return kzalloc(size, 0); +} +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) @@ -57,58 +104,11 @@ void *kmem_cache_alloc(struct kmem_cache *obj, int flag); #define KERNEL_VERSION(a,b,c) (((a) << 16) + ((b) << 8) + (c)) -/* - * ..and if you can't take the strict - * types, you can specify one yourself. - * - * Or not use min/max at all, of course. - */ -#define min_t(type,x,y) \ - ({ type __x = (x); type __y = (y); __x < __y ? __x: __y; }) -#define max_t(type,x,y) \ - ({ type __x = (x); type __y = (y); __x > __y ? __x: __y; }) - -#ifndef BUG -#define BUG() do { \ - printf("U-Boot BUG at %s:%d!\n", __FILE__, __LINE__); \ -} while (0) - -#define BUG_ON(condition) do { if (condition) BUG(); } while(0) -#endif /* BUG */ - -#define WARN_ON(x) if (x) {printf("WARNING in %s line %d\n" \ - , __FILE__, __LINE__); } - #define PAGE_SIZE 4096 -/** - * upper_32_bits - return MSB bits 32-63 of a number if little endian, or - * return MSB bits 0-31 of a number if big endian. - * @n: the number we're accessing - * - * A basic shift-right of a 64- or 32-bit quantity. Use this to suppress - * the "right shift count >= width of type" warning when that quantity is - * 32-bits. - */ -#define upper_32_bits(n) ((u32)(((n) >> 16) >> 16)) - -/** - * lower_32_bits - return LSB bits 0-31 of a number if little endian, or - * return LSB bits 32-63 of a number if big endian. - * @n: the number we're accessing - */ -#define lower_32_bits(n) ((u32)(n)) - /* drivers/char/random.c */ #define get_random_bytes(...) -/* idr.c */ -#define GFP_ATOMIC ((gfp_t) 0) -#define GFP_KERNEL ((gfp_t) 0) -#define GFP_NOFS ((gfp_t) 0) -#define GFP_USER ((gfp_t) 0) -#define __GFP_NOWARN ((gfp_t) 0) - /* include/linux/leds.h */ struct led_trigger {}; @@ -125,12 +125,6 @@ static inline void led_trigger_unregister_simple(struct led_trigger *trigger) {} static inline void led_trigger_event(struct led_trigger *trigger, enum led_brightness event) {} -/* include/linux/log2.h */ -static inline int is_power_of_2(unsigned long n) -{ - return (n != 0 && ((n & (n - 1)) == 0)); -} - /* uapi/linux/limits.h */ #define XATTR_LIST_MAX 65536 /* size of extended attribute namelist (64k) */ @@ -150,19 +144,6 @@ typedef unsigned long sector_t; typedef unsigned long blkcnt_t; #endif -#define ENOTSUPP 524 /* Operation is not supported */ - -/* from include/linux/kernel.h */ -/* - * This looks more complex than it should be. But we need to - * get the type for the ~ right in round_down (it needs to be - * as wide as the result!), and we want to evaluate the macro - * arguments just once each. - */ -#define __round_mask(x, y) ((__typeof__(x))((y)-1)) -#define round_up(x, y) ((((x)-1) | __round_mask(x, y))+1) -#define round_down(x, y) ((x) & ~__round_mask(x, y)) - /* module */ #define THIS_MODULE 0 #define try_module_get(...) 1 @@ -191,6 +172,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 @@ -198,23 +181,12 @@ typedef unsigned long blkcnt_t; #define blocking_notifier_call_chain(...) 0 -/* - * Multiplies an integer by a fraction, while avoiding unnecessary - * overflow or loss of precision. - */ -#define mult_frac(x, numer, denom)( \ -{ \ - typeof(x) quot = (x) / (denom); \ - typeof(x) rem = (x) % (denom); \ - (quot * (numer)) + ((rem * (numer)) / (denom)); \ -} \ -) - #define __initdata #define late_initcall(...) #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) @@ -241,8 +213,6 @@ struct work_struct {}; unsigned long copy_from_user(void *dest, const void *src, unsigned long count); -void *vzalloc(unsigned long size); - typedef unused_t spinlock_t; typedef int wait_queue_head_t; @@ -267,15 +237,11 @@ typedef int wait_queue_head_t; #define cond_resched() do { } while (0) #define yield() do { } while (0) -#define INT_MAX ((int)(~0U>>1)) - -#define __user #define __init #define __exit #define __devinit #define __devinitdata #define __devinitconst -#define __iomem #define kthread_create(...) __builtin_return_address(0) #define kthread_stop(...) do { } while (0) @@ -306,8 +272,6 @@ struct cdev { #define cdev_add(...) 0 #define cdev_del(...) do { } while (0) -#define MAX_ERRNO 4095 - #define prandom_u32(...) 0 typedef struct { @@ -320,7 +284,6 @@ typedef struct { /* from include/linux/types.h */ -typedef int atomic_t; /** * struct callback_head - callback structure for use with RCU and task_work * @next: next update requests in a list @@ -374,8 +337,6 @@ struct notifier_block {}; typedef unsigned long dmaaddr_t; -#define cpu_relax() do {} while (0) - #define pm_runtime_get_sync(dev) do {} while (0) #define pm_runtime_put(dev) do {} while (0) #define pm_runtime_put_sync(dev) do {} while (0) @@ -385,6 +346,7 @@ typedef unsigned long dmaaddr_t; #define IRQ_NONE 0 #define IRQ_HANDLED 1 +#define IRQ_WAKE_THREAD 2 #define dev_set_drvdata(dev, data) do {} while (0)