Wolfgang Denk | 2f9b7e4 | 2005-08-17 12:55:25 +0200 | [diff] [blame] | 1 | #ifndef _LINUX_COMPAT_H_ |
| 2 | #define _LINUX_COMPAT_H_ |
| 3 | |
Heiko Schocher | 4f7a9a3 | 2014-06-24 10:10:03 +0200 | [diff] [blame] | 4 | #include <malloc.h> |
| 5 | #include <linux/types.h> |
| 6 | #include <linux/err.h> |
Heiko Schocher | 9851f52 | 2015-10-22 06:19:20 +0200 | [diff] [blame] | 7 | #include <linux/kernel.h> |
Heiko Schocher | 4f7a9a3 | 2014-06-24 10:10:03 +0200 | [diff] [blame] | 8 | |
| 9 | struct unused {}; |
| 10 | typedef struct unused unused_t; |
| 11 | |
| 12 | struct p_current{ |
| 13 | int pid; |
| 14 | }; |
| 15 | |
| 16 | extern struct p_current *current; |
| 17 | |
Wolfgang Denk | 2f9b7e4 | 2005-08-17 12:55:25 +0200 | [diff] [blame] | 18 | #define ndelay(x) udelay(1) |
| 19 | |
Wu, Josh | ba6babf | 2013-07-03 11:11:47 +0800 | [diff] [blame] | 20 | #define dev_dbg(dev, fmt, args...) \ |
| 21 | debug(fmt, ##args) |
| 22 | #define dev_vdbg(dev, fmt, args...) \ |
| 23 | debug(fmt, ##args) |
| 24 | #define dev_info(dev, fmt, args...) \ |
| 25 | printf(fmt, ##args) |
| 26 | #define dev_err(dev, fmt, args...) \ |
| 27 | printf(fmt, ##args) |
Andreas Bießmann | 317a382 | 2016-06-04 22:27:22 +0200 | [diff] [blame] | 28 | #define dev_warn(dev, fmt, args...) \ |
| 29 | printf(fmt, ##args) |
Wolfgang Denk | 2f9b7e4 | 2005-08-17 12:55:25 +0200 | [diff] [blame] | 30 | #define printk printf |
Heiko Schocher | 4f7a9a3 | 2014-06-24 10:10:03 +0200 | [diff] [blame] | 31 | #define printk_once printf |
Wolfgang Denk | 2f9b7e4 | 2005-08-17 12:55:25 +0200 | [diff] [blame] | 32 | |
| 33 | #define KERN_EMERG |
| 34 | #define KERN_ALERT |
| 35 | #define KERN_CRIT |
| 36 | #define KERN_ERR |
| 37 | #define KERN_WARNING |
| 38 | #define KERN_NOTICE |
| 39 | #define KERN_INFO |
| 40 | #define KERN_DEBUG |
| 41 | |
Masahiro Yamada | 7b5ec7e | 2015-07-13 13:17:07 +0900 | [diff] [blame] | 42 | #define GFP_ATOMIC ((gfp_t) 0) |
| 43 | #define GFP_KERNEL ((gfp_t) 0) |
| 44 | #define GFP_NOFS ((gfp_t) 0) |
| 45 | #define GFP_USER ((gfp_t) 0) |
| 46 | #define __GFP_NOWARN ((gfp_t) 0) |
| 47 | #define __GFP_ZERO ((__force gfp_t)0x8000u) /* Return zeroed page on success */ |
| 48 | |
Heiko Schocher | 4f7a9a3 | 2014-06-24 10:10:03 +0200 | [diff] [blame] | 49 | void *kmalloc(size_t size, int flags); |
Masahiro Yamada | 7b5ec7e | 2015-07-13 13:17:07 +0900 | [diff] [blame] | 50 | |
| 51 | static inline void *kzalloc(size_t size, gfp_t flags) |
| 52 | { |
| 53 | return kmalloc(size, flags | __GFP_ZERO); |
| 54 | } |
Heiko Schocher | 9851f52 | 2015-10-22 06:19:20 +0200 | [diff] [blame] | 55 | |
| 56 | static inline void *kmalloc_array(size_t n, size_t size, gfp_t flags) |
| 57 | { |
| 58 | if (size != 0 && n > SIZE_MAX / size) |
| 59 | return NULL; |
| 60 | return kmalloc(n * size, flags | __GFP_ZERO); |
| 61 | } |
| 62 | |
| 63 | static inline void *kcalloc(size_t n, size_t size, gfp_t flags) |
| 64 | { |
| 65 | return kmalloc_array(n, size, flags | __GFP_ZERO); |
| 66 | } |
| 67 | |
Heiko Schocher | 4f7a9a3 | 2014-06-24 10:10:03 +0200 | [diff] [blame] | 68 | #define vmalloc(size) kmalloc(size, 0) |
| 69 | #define __vmalloc(size, flags, pgsz) kmalloc(size, flags) |
Masahiro Yamada | c537347 | 2015-07-13 13:17:06 +0900 | [diff] [blame] | 70 | static inline void *vzalloc(unsigned long size) |
| 71 | { |
| 72 | return kzalloc(size, 0); |
| 73 | } |
Heiko Schocher | 9851f52 | 2015-10-22 06:19:20 +0200 | [diff] [blame] | 74 | static inline void kfree(const void *block) |
| 75 | { |
| 76 | free((void *)block); |
| 77 | } |
| 78 | static inline void vfree(const void *addr) |
| 79 | { |
| 80 | free((void *)addr); |
| 81 | } |
Heiko Schocher | 4f7a9a3 | 2014-06-24 10:10:03 +0200 | [diff] [blame] | 82 | |
| 83 | struct kmem_cache { int sz; }; |
| 84 | |
| 85 | struct kmem_cache *get_mem(int element_sz); |
| 86 | #define kmem_cache_create(a, sz, c, d, e) get_mem(sz) |
| 87 | void *kmem_cache_alloc(struct kmem_cache *obj, int flag); |
Heiko Schocher | 9851f52 | 2015-10-22 06:19:20 +0200 | [diff] [blame] | 88 | static inline void kmem_cache_free(struct kmem_cache *cachep, void *obj) |
| 89 | { |
| 90 | free(obj); |
| 91 | } |
| 92 | static inline void kmem_cache_destroy(struct kmem_cache *cachep) |
| 93 | { |
| 94 | free(cachep); |
| 95 | } |
Stefan Roese | e0860d4 | 2009-05-12 14:29:39 +0200 | [diff] [blame] | 96 | |
| 97 | #define DECLARE_WAITQUEUE(...) do { } while (0) |
| 98 | #define add_wait_queue(...) do { } while (0) |
| 99 | #define remove_wait_queue(...) do { } while (0) |
William Juul | 52c0796 | 2007-10-31 13:53:06 +0100 | [diff] [blame] | 100 | |
Stefan Roese | e0860d4 | 2009-05-12 14:29:39 +0200 | [diff] [blame] | 101 | #define KERNEL_VERSION(a,b,c) (((a) << 16) + ((b) << 8) + (c)) |
Wolfgang Denk | 2f9b7e4 | 2005-08-17 12:55:25 +0200 | [diff] [blame] | 102 | |
Stefan Roese | 42fbddd | 2006-09-07 11:51:23 +0200 | [diff] [blame] | 103 | #ifndef BUG |
Wolfgang Denk | 2f9b7e4 | 2005-08-17 12:55:25 +0200 | [diff] [blame] | 104 | #define BUG() do { \ |
| 105 | printf("U-Boot BUG at %s:%d!\n", __FILE__, __LINE__); \ |
| 106 | } while (0) |
| 107 | |
| 108 | #define BUG_ON(condition) do { if (condition) BUG(); } while(0) |
Stefan Roese | 42fbddd | 2006-09-07 11:51:23 +0200 | [diff] [blame] | 109 | #endif /* BUG */ |
Wolfgang Denk | 2f9b7e4 | 2005-08-17 12:55:25 +0200 | [diff] [blame] | 110 | |
Mike Frysinger | 1f19e3f | 2012-04-26 02:34:44 +0000 | [diff] [blame] | 111 | #define WARN_ON(x) if (x) {printf("WARNING in %s line %d\n" \ |
| 112 | , __FILE__, __LINE__); } |
| 113 | |
Wolfgang Denk | 2f9b7e4 | 2005-08-17 12:55:25 +0200 | [diff] [blame] | 114 | #define PAGE_SIZE 4096 |
Lijun Pan | 036f66d | 2014-06-20 12:17:29 -0500 | [diff] [blame] | 115 | |
Heiko Schocher | 4f7a9a3 | 2014-06-24 10:10:03 +0200 | [diff] [blame] | 116 | /* drivers/char/random.c */ |
| 117 | #define get_random_bytes(...) |
| 118 | |
Heiko Schocher | 4f7a9a3 | 2014-06-24 10:10:03 +0200 | [diff] [blame] | 119 | /* include/linux/leds.h */ |
| 120 | struct led_trigger {}; |
| 121 | |
| 122 | #define DEFINE_LED_TRIGGER(x) static struct led_trigger *x; |
| 123 | enum led_brightness { |
| 124 | LED_OFF = 0, |
| 125 | LED_HALF = 127, |
| 126 | LED_FULL = 255, |
| 127 | }; |
| 128 | |
| 129 | static inline void led_trigger_register_simple(const char *name, |
| 130 | struct led_trigger **trigger) {} |
| 131 | static inline void led_trigger_unregister_simple(struct led_trigger *trigger) {} |
| 132 | static inline void led_trigger_event(struct led_trigger *trigger, |
| 133 | enum led_brightness event) {} |
| 134 | |
Heiko Schocher | 4f7a9a3 | 2014-06-24 10:10:03 +0200 | [diff] [blame] | 135 | /* uapi/linux/limits.h */ |
| 136 | #define XATTR_LIST_MAX 65536 /* size of extended attribute namelist (64k) */ |
| 137 | |
| 138 | /** |
| 139 | * The type used for indexing onto a disc or disc partition. |
| 140 | * |
| 141 | * Linux always considers sectors to be 512 bytes long independently |
| 142 | * of the devices real block size. |
| 143 | * |
| 144 | * blkcnt_t is the type of the inode's block count. |
| 145 | */ |
| 146 | #ifdef CONFIG_LBDAF |
| 147 | typedef u64 sector_t; |
| 148 | typedef u64 blkcnt_t; |
| 149 | #else |
| 150 | typedef unsigned long sector_t; |
| 151 | typedef unsigned long blkcnt_t; |
| 152 | #endif |
| 153 | |
| 154 | #define ENOTSUPP 524 /* Operation is not supported */ |
| 155 | |
Heiko Schocher | 4f7a9a3 | 2014-06-24 10:10:03 +0200 | [diff] [blame] | 156 | /* module */ |
| 157 | #define THIS_MODULE 0 |
| 158 | #define try_module_get(...) 1 |
| 159 | #define module_put(...) do { } while (0) |
| 160 | #define module_init(...) |
| 161 | #define module_exit(...) |
| 162 | #define EXPORT_SYMBOL(...) |
| 163 | #define EXPORT_SYMBOL_GPL(...) |
| 164 | #define module_param(...) |
| 165 | #define module_param_call(...) |
| 166 | #define MODULE_PARM_DESC(...) |
| 167 | #define MODULE_VERSION(...) |
| 168 | #define MODULE_DESCRIPTION(...) |
| 169 | #define MODULE_AUTHOR(...) |
| 170 | #define MODULE_LICENSE(...) |
| 171 | #define MODULE_ALIAS(...) |
| 172 | #define __module_get(...) |
| 173 | |
| 174 | /* character device */ |
| 175 | #define MKDEV(...) 0 |
| 176 | #define MAJOR(dev) 0 |
| 177 | #define MINOR(dev) 0 |
| 178 | |
| 179 | #define alloc_chrdev_region(...) 0 |
| 180 | #define unregister_chrdev_region(...) |
| 181 | |
| 182 | #define class_create(...) __builtin_return_address(0) |
| 183 | #define class_create_file(...) 0 |
Heiko Schocher | 9851f52 | 2015-10-22 06:19:20 +0200 | [diff] [blame] | 184 | #define class_register(...) 0 |
| 185 | #define class_unregister(...) |
Heiko Schocher | 4f7a9a3 | 2014-06-24 10:10:03 +0200 | [diff] [blame] | 186 | #define class_remove_file(...) |
| 187 | #define class_destroy(...) |
| 188 | #define misc_register(...) 0 |
| 189 | #define misc_deregister(...) |
| 190 | |
| 191 | #define blocking_notifier_call_chain(...) 0 |
| 192 | |
Heiko Schocher | 4f7a9a3 | 2014-06-24 10:10:03 +0200 | [diff] [blame] | 193 | #define __initdata |
| 194 | #define late_initcall(...) |
| 195 | |
| 196 | #define dev_set_name(...) do { } while (0) |
| 197 | #define device_register(...) 0 |
Heiko Schocher | 9851f52 | 2015-10-22 06:19:20 +0200 | [diff] [blame] | 198 | #define device_unregister(...) |
Heiko Schocher | 4f7a9a3 | 2014-06-24 10:10:03 +0200 | [diff] [blame] | 199 | #define volume_sysfs_init(...) 0 |
| 200 | #define volume_sysfs_close(...) do { } while (0) |
| 201 | |
| 202 | #define init_waitqueue_head(...) do { } while (0) |
| 203 | #define wait_event_interruptible(...) 0 |
| 204 | #define wake_up_interruptible(...) do { } while (0) |
| 205 | #define print_hex_dump(...) do { } while (0) |
| 206 | #define dump_stack(...) do { } while (0) |
| 207 | |
| 208 | #define task_pid_nr(x) 0 |
| 209 | #define set_freezable(...) do { } while (0) |
| 210 | #define try_to_freeze(...) 0 |
| 211 | #define set_current_state(...) do { } while (0) |
| 212 | #define kthread_should_stop(...) 0 |
| 213 | #define schedule() do { } while (0) |
| 214 | |
| 215 | #define setup_timer(timer, func, data) do {} while (0) |
| 216 | #define del_timer_sync(timer) do {} while (0) |
| 217 | #define schedule_work(work) do {} while (0) |
| 218 | #define INIT_WORK(work, fun) do {} while (0) |
| 219 | |
| 220 | struct work_struct {}; |
| 221 | |
| 222 | unsigned long copy_from_user(void *dest, const void *src, |
| 223 | unsigned long count); |
| 224 | |
Heiko Schocher | 4f7a9a3 | 2014-06-24 10:10:03 +0200 | [diff] [blame] | 225 | typedef unused_t spinlock_t; |
| 226 | typedef int wait_queue_head_t; |
| 227 | |
| 228 | #define spin_lock_init(lock) do {} while (0) |
| 229 | #define spin_lock(lock) do {} while (0) |
| 230 | #define spin_unlock(lock) do {} while (0) |
| 231 | #define spin_lock_irqsave(lock, flags) do { debug("%lu\n", flags); } while (0) |
| 232 | #define spin_unlock_irqrestore(lock, flags) do { flags = 0; } while (0) |
| 233 | |
| 234 | #define DEFINE_MUTEX(...) |
| 235 | #define mutex_init(...) |
| 236 | #define mutex_lock(...) |
| 237 | #define mutex_unlock(...) |
| 238 | |
| 239 | #define init_rwsem(...) do { } while (0) |
| 240 | #define down_read(...) do { } while (0) |
| 241 | #define down_write(...) do { } while (0) |
| 242 | #define down_write_trylock(...) 1 |
| 243 | #define up_read(...) do { } while (0) |
| 244 | #define up_write(...) do { } while (0) |
| 245 | |
| 246 | #define cond_resched() do { } while (0) |
| 247 | #define yield() do { } while (0) |
| 248 | |
Heiko Schocher | 4f7a9a3 | 2014-06-24 10:10:03 +0200 | [diff] [blame] | 249 | #define __init |
| 250 | #define __exit |
| 251 | #define __devinit |
| 252 | #define __devinitdata |
| 253 | #define __devinitconst |
Heiko Schocher | 4f7a9a3 | 2014-06-24 10:10:03 +0200 | [diff] [blame] | 254 | |
| 255 | #define kthread_create(...) __builtin_return_address(0) |
| 256 | #define kthread_stop(...) do { } while (0) |
| 257 | #define wake_up_process(...) do { } while (0) |
| 258 | |
| 259 | struct rw_semaphore { int i; }; |
| 260 | #define down_write(...) do { } while (0) |
| 261 | #define up_write(...) do { } while (0) |
| 262 | #define down_read(...) do { } while (0) |
| 263 | #define up_read(...) do { } while (0) |
| 264 | struct device { |
| 265 | struct device *parent; |
| 266 | struct class *class; |
| 267 | dev_t devt; /* dev_t, creates the sysfs "dev" */ |
| 268 | void (*release)(struct device *dev); |
| 269 | /* This is used from drivers/usb/musb-new subsystem only */ |
| 270 | void *driver_data; /* data private to the driver */ |
| 271 | void *device_data; /* data private to the device */ |
| 272 | }; |
| 273 | struct mutex { int i; }; |
| 274 | struct kernel_param { int i; }; |
| 275 | |
| 276 | struct cdev { |
| 277 | int owner; |
| 278 | dev_t dev; |
| 279 | }; |
| 280 | #define cdev_init(...) do { } while (0) |
| 281 | #define cdev_add(...) 0 |
| 282 | #define cdev_del(...) do { } while (0) |
| 283 | |
Heiko Schocher | 4f7a9a3 | 2014-06-24 10:10:03 +0200 | [diff] [blame] | 284 | #define prandom_u32(...) 0 |
| 285 | |
| 286 | typedef struct { |
| 287 | uid_t val; |
| 288 | } kuid_t; |
| 289 | |
| 290 | typedef struct { |
| 291 | gid_t val; |
| 292 | } kgid_t; |
| 293 | |
| 294 | /* from include/linux/types.h */ |
| 295 | |
Heiko Schocher | 4f7a9a3 | 2014-06-24 10:10:03 +0200 | [diff] [blame] | 296 | /** |
| 297 | * struct callback_head - callback structure for use with RCU and task_work |
| 298 | * @next: next update requests in a list |
| 299 | * @func: actual update function to call after the grace period. |
| 300 | */ |
| 301 | struct callback_head { |
| 302 | struct callback_head *next; |
| 303 | void (*func)(struct callback_head *head); |
| 304 | }; |
| 305 | #define rcu_head callback_head |
| 306 | enum writeback_sync_modes { |
| 307 | WB_SYNC_NONE, /* Don't wait on anything */ |
| 308 | WB_SYNC_ALL, /* Wait on every mapping */ |
| 309 | }; |
| 310 | |
| 311 | /* from include/linux/writeback.h */ |
| 312 | /* |
| 313 | * A control structure which tells the writeback code what to do. These are |
| 314 | * always on the stack, and hence need no locking. They are always initialised |
| 315 | * in a manner such that unspecified fields are set to zero. |
| 316 | */ |
| 317 | struct writeback_control { |
| 318 | long nr_to_write; /* Write this many pages, and decrement |
| 319 | this for each page written */ |
| 320 | long pages_skipped; /* Pages which were not written */ |
| 321 | |
| 322 | /* |
| 323 | * For a_ops->writepages(): if start or end are non-zero then this is |
| 324 | * a hint that the filesystem need only write out the pages inside that |
| 325 | * byterange. The byte at `end' is included in the writeout request. |
| 326 | */ |
| 327 | loff_t range_start; |
| 328 | loff_t range_end; |
| 329 | |
| 330 | enum writeback_sync_modes sync_mode; |
| 331 | |
| 332 | unsigned for_kupdate:1; /* A kupdate writeback */ |
| 333 | unsigned for_background:1; /* A background writeback */ |
| 334 | unsigned tagged_writepages:1; /* tag-and-write to avoid livelock */ |
| 335 | unsigned for_reclaim:1; /* Invoked from the page allocator */ |
| 336 | unsigned range_cyclic:1; /* range_start is cyclic */ |
| 337 | unsigned for_sync:1; /* sync(2) WB_SYNC_ALL writeback */ |
| 338 | }; |
| 339 | |
| 340 | void *kmemdup(const void *src, size_t len, gfp_t gfp); |
| 341 | |
| 342 | typedef int irqreturn_t; |
| 343 | |
| 344 | struct timer_list {}; |
| 345 | struct notifier_block {}; |
| 346 | |
| 347 | typedef unsigned long dmaaddr_t; |
| 348 | |
Heiko Schocher | 4f7a9a3 | 2014-06-24 10:10:03 +0200 | [diff] [blame] | 349 | #define pm_runtime_get_sync(dev) do {} while (0) |
| 350 | #define pm_runtime_put(dev) do {} while (0) |
| 351 | #define pm_runtime_put_sync(dev) do {} while (0) |
| 352 | #define pm_runtime_use_autosuspend(dev) do {} while (0) |
| 353 | #define pm_runtime_set_autosuspend_delay(dev, delay) do {} while (0) |
| 354 | #define pm_runtime_enable(dev) do {} while (0) |
| 355 | |
| 356 | #define IRQ_NONE 0 |
| 357 | #define IRQ_HANDLED 1 |
Kishon Vijay Abraham I | 35ffd28 | 2015-02-23 18:39:58 +0530 | [diff] [blame] | 358 | #define IRQ_WAKE_THREAD 2 |
Heiko Schocher | 4f7a9a3 | 2014-06-24 10:10:03 +0200 | [diff] [blame] | 359 | |
| 360 | #define dev_set_drvdata(dev, data) do {} while (0) |
| 361 | |
| 362 | #define enable_irq(...) |
| 363 | #define disable_irq(...) |
| 364 | #define disable_irq_wake(irq) do {} while (0) |
| 365 | #define enable_irq_wake(irq) -EINVAL |
| 366 | #define free_irq(irq, data) do {} while (0) |
| 367 | #define request_irq(nr, f, flags, nm, data) 0 |
| 368 | |
Wolfgang Denk | 2f9b7e4 | 2005-08-17 12:55:25 +0200 | [diff] [blame] | 369 | #endif |