1 #ifndef _LINUX_COMPAT_H_
2 #define _LINUX_COMPAT_H_
5 #include <linux/types.h>
7 #include <linux/kernel.h>
10 typedef struct unused unused_t;
16 extern struct p_current *current;
18 #define ndelay(x) udelay(1)
20 #define dev_dbg(dev, fmt, args...) \
22 #define dev_vdbg(dev, fmt, args...) \
24 #define dev_info(dev, fmt, args...) \
26 #define dev_err(dev, fmt, args...) \
29 #define printk_once printf
40 #define GFP_ATOMIC ((gfp_t) 0)
41 #define GFP_KERNEL ((gfp_t) 0)
42 #define GFP_NOFS ((gfp_t) 0)
43 #define GFP_USER ((gfp_t) 0)
44 #define __GFP_NOWARN ((gfp_t) 0)
45 #define __GFP_ZERO ((__force gfp_t)0x8000u) /* Return zeroed page on success */
47 void *kmalloc(size_t size, int flags);
49 static inline void *kzalloc(size_t size, gfp_t flags)
51 return kmalloc(size, flags | __GFP_ZERO);
54 static inline void *kmalloc_array(size_t n, size_t size, gfp_t flags)
56 if (size != 0 && n > SIZE_MAX / size)
58 return kmalloc(n * size, flags | __GFP_ZERO);
61 static inline void *kcalloc(size_t n, size_t size, gfp_t flags)
63 return kmalloc_array(n, size, flags | __GFP_ZERO);
66 #define vmalloc(size) kmalloc(size, 0)
67 #define __vmalloc(size, flags, pgsz) kmalloc(size, flags)
68 static inline void *vzalloc(unsigned long size)
70 return kzalloc(size, 0);
72 static inline void kfree(const void *block)
76 static inline void vfree(const void *addr)
81 struct kmem_cache { int sz; };
83 struct kmem_cache *get_mem(int element_sz);
84 #define kmem_cache_create(a, sz, c, d, e) get_mem(sz)
85 void *kmem_cache_alloc(struct kmem_cache *obj, int flag);
86 static inline void kmem_cache_free(struct kmem_cache *cachep, void *obj)
90 static inline void kmem_cache_destroy(struct kmem_cache *cachep)
95 #define DECLARE_WAITQUEUE(...) do { } while (0)
96 #define add_wait_queue(...) do { } while (0)
97 #define remove_wait_queue(...) do { } while (0)
99 #define KERNEL_VERSION(a,b,c) (((a) << 16) + ((b) << 8) + (c))
103 printf("U-Boot BUG at %s:%d!\n", __FILE__, __LINE__); \
106 #define BUG_ON(condition) do { if (condition) BUG(); } while(0)
109 #define WARN_ON(x) if (x) {printf("WARNING in %s line %d\n" \
110 , __FILE__, __LINE__); }
112 #define PAGE_SIZE 4096
114 /* drivers/char/random.c */
115 #define get_random_bytes(...)
117 /* include/linux/leds.h */
118 struct led_trigger {};
120 #define DEFINE_LED_TRIGGER(x) static struct led_trigger *x;
121 enum led_brightness {
127 static inline void led_trigger_register_simple(const char *name,
128 struct led_trigger **trigger) {}
129 static inline void led_trigger_unregister_simple(struct led_trigger *trigger) {}
130 static inline void led_trigger_event(struct led_trigger *trigger,
131 enum led_brightness event) {}
133 /* include/linux/log2.h */
134 static inline int is_power_of_2(unsigned long n)
136 return (n != 0 && ((n & (n - 1)) == 0));
139 /* uapi/linux/limits.h */
140 #define XATTR_LIST_MAX 65536 /* size of extended attribute namelist (64k) */
143 * The type used for indexing onto a disc or disc partition.
145 * Linux always considers sectors to be 512 bytes long independently
146 * of the devices real block size.
148 * blkcnt_t is the type of the inode's block count.
151 typedef u64 sector_t;
152 typedef u64 blkcnt_t;
154 typedef unsigned long sector_t;
155 typedef unsigned long blkcnt_t;
158 #define ENOTSUPP 524 /* Operation is not supported */
161 #define THIS_MODULE 0
162 #define try_module_get(...) 1
163 #define module_put(...) do { } while (0)
164 #define module_init(...)
165 #define module_exit(...)
166 #define EXPORT_SYMBOL(...)
167 #define EXPORT_SYMBOL_GPL(...)
168 #define module_param(...)
169 #define module_param_call(...)
170 #define MODULE_PARM_DESC(...)
171 #define MODULE_VERSION(...)
172 #define MODULE_DESCRIPTION(...)
173 #define MODULE_AUTHOR(...)
174 #define MODULE_LICENSE(...)
175 #define MODULE_ALIAS(...)
176 #define __module_get(...)
178 /* character device */
183 #define alloc_chrdev_region(...) 0
184 #define unregister_chrdev_region(...)
186 #define class_create(...) __builtin_return_address(0)
187 #define class_create_file(...) 0
188 #define class_register(...) 0
189 #define class_unregister(...)
190 #define class_remove_file(...)
191 #define class_destroy(...)
192 #define misc_register(...) 0
193 #define misc_deregister(...)
195 #define blocking_notifier_call_chain(...) 0
198 #define late_initcall(...)
200 #define dev_set_name(...) do { } while (0)
201 #define device_register(...) 0
202 #define device_unregister(...)
203 #define volume_sysfs_init(...) 0
204 #define volume_sysfs_close(...) do { } while (0)
206 #define init_waitqueue_head(...) do { } while (0)
207 #define wait_event_interruptible(...) 0
208 #define wake_up_interruptible(...) do { } while (0)
209 #define print_hex_dump(...) do { } while (0)
210 #define dump_stack(...) do { } while (0)
212 #define task_pid_nr(x) 0
213 #define set_freezable(...) do { } while (0)
214 #define try_to_freeze(...) 0
215 #define set_current_state(...) do { } while (0)
216 #define kthread_should_stop(...) 0
217 #define schedule() do { } while (0)
219 #define setup_timer(timer, func, data) do {} while (0)
220 #define del_timer_sync(timer) do {} while (0)
221 #define schedule_work(work) do {} while (0)
222 #define INIT_WORK(work, fun) do {} while (0)
224 struct work_struct {};
226 unsigned long copy_from_user(void *dest, const void *src,
227 unsigned long count);
229 typedef unused_t spinlock_t;
230 typedef int wait_queue_head_t;
232 #define spin_lock_init(lock) do {} while (0)
233 #define spin_lock(lock) do {} while (0)
234 #define spin_unlock(lock) do {} while (0)
235 #define spin_lock_irqsave(lock, flags) do { debug("%lu\n", flags); } while (0)
236 #define spin_unlock_irqrestore(lock, flags) do { flags = 0; } while (0)
238 #define DEFINE_MUTEX(...)
239 #define mutex_init(...)
240 #define mutex_lock(...)
241 #define mutex_unlock(...)
243 #define init_rwsem(...) do { } while (0)
244 #define down_read(...) do { } while (0)
245 #define down_write(...) do { } while (0)
246 #define down_write_trylock(...) 1
247 #define up_read(...) do { } while (0)
248 #define up_write(...) do { } while (0)
250 #define cond_resched() do { } while (0)
251 #define yield() do { } while (0)
256 #define __devinitdata
257 #define __devinitconst
259 #define kthread_create(...) __builtin_return_address(0)
260 #define kthread_stop(...) do { } while (0)
261 #define wake_up_process(...) do { } while (0)
263 struct rw_semaphore { int i; };
264 #define down_write(...) do { } while (0)
265 #define up_write(...) do { } while (0)
266 #define down_read(...) do { } while (0)
267 #define up_read(...) do { } while (0)
269 struct device *parent;
271 dev_t devt; /* dev_t, creates the sysfs "dev" */
272 void (*release)(struct device *dev);
273 /* This is used from drivers/usb/musb-new subsystem only */
274 void *driver_data; /* data private to the driver */
275 void *device_data; /* data private to the device */
277 struct mutex { int i; };
278 struct kernel_param { int i; };
284 #define cdev_init(...) do { } while (0)
285 #define cdev_add(...) 0
286 #define cdev_del(...) do { } while (0)
288 #define prandom_u32(...) 0
298 /* from include/linux/types.h */
301 * struct callback_head - callback structure for use with RCU and task_work
302 * @next: next update requests in a list
303 * @func: actual update function to call after the grace period.
305 struct callback_head {
306 struct callback_head *next;
307 void (*func)(struct callback_head *head);
309 #define rcu_head callback_head
310 enum writeback_sync_modes {
311 WB_SYNC_NONE, /* Don't wait on anything */
312 WB_SYNC_ALL, /* Wait on every mapping */
315 /* from include/linux/writeback.h */
317 * A control structure which tells the writeback code what to do. These are
318 * always on the stack, and hence need no locking. They are always initialised
319 * in a manner such that unspecified fields are set to zero.
321 struct writeback_control {
322 long nr_to_write; /* Write this many pages, and decrement
323 this for each page written */
324 long pages_skipped; /* Pages which were not written */
327 * For a_ops->writepages(): if start or end are non-zero then this is
328 * a hint that the filesystem need only write out the pages inside that
329 * byterange. The byte at `end' is included in the writeout request.
334 enum writeback_sync_modes sync_mode;
336 unsigned for_kupdate:1; /* A kupdate writeback */
337 unsigned for_background:1; /* A background writeback */
338 unsigned tagged_writepages:1; /* tag-and-write to avoid livelock */
339 unsigned for_reclaim:1; /* Invoked from the page allocator */
340 unsigned range_cyclic:1; /* range_start is cyclic */
341 unsigned for_sync:1; /* sync(2) WB_SYNC_ALL writeback */
344 void *kmemdup(const void *src, size_t len, gfp_t gfp);
346 typedef int irqreturn_t;
348 struct timer_list {};
349 struct notifier_block {};
351 typedef unsigned long dmaaddr_t;
353 #define pm_runtime_get_sync(dev) do {} while (0)
354 #define pm_runtime_put(dev) do {} while (0)
355 #define pm_runtime_put_sync(dev) do {} while (0)
356 #define pm_runtime_use_autosuspend(dev) do {} while (0)
357 #define pm_runtime_set_autosuspend_delay(dev, delay) do {} while (0)
358 #define pm_runtime_enable(dev) do {} while (0)
361 #define IRQ_HANDLED 1
362 #define IRQ_WAKE_THREAD 2
364 #define dev_set_drvdata(dev, data) do {} while (0)
366 #define enable_irq(...)
367 #define disable_irq(...)
368 #define disable_irq_wake(irq) do {} while (0)
369 #define enable_irq_wake(irq) -EINVAL
370 #define free_irq(irq, data) do {} while (0)
371 #define request_irq(nr, f, flags, nm, data) 0