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 /* avoid conflict with <dm/device.h> */
35 #define dev_dbg(dev, fmt, args...) \
37 #define dev_vdbg(dev, fmt, args...) \
39 #define dev_info(dev, fmt, args...) \
41 #define dev_err(dev, fmt, args...) \
43 #define dev_warn(dev, fmt, args...) \
46 #define GFP_ATOMIC ((gfp_t) 0)
47 #define GFP_KERNEL ((gfp_t) 0)
48 #define GFP_NOFS ((gfp_t) 0)
49 #define GFP_USER ((gfp_t) 0)
50 #define __GFP_NOWARN ((gfp_t) 0)
51 #define __GFP_ZERO ((__force gfp_t)0x8000u) /* Return zeroed page on success */
53 void *kmalloc(size_t size, int flags);
55 static inline void *kzalloc(size_t size, gfp_t flags)
57 return kmalloc(size, flags | __GFP_ZERO);
60 static inline void *kmalloc_array(size_t n, size_t size, gfp_t flags)
62 if (size != 0 && n > SIZE_MAX / size)
64 return kmalloc(n * size, flags | __GFP_ZERO);
67 static inline void *kcalloc(size_t n, size_t size, gfp_t flags)
69 return kmalloc_array(n, size, flags | __GFP_ZERO);
72 #define vmalloc(size) kmalloc(size, 0)
73 #define __vmalloc(size, flags, pgsz) kmalloc(size, flags)
74 static inline void *vzalloc(unsigned long size)
76 return kzalloc(size, 0);
78 static inline void kfree(const void *block)
82 static inline void vfree(const void *addr)
87 struct kmem_cache { int sz; };
89 struct kmem_cache *get_mem(int element_sz);
90 #define kmem_cache_create(a, sz, c, d, e) get_mem(sz)
91 void *kmem_cache_alloc(struct kmem_cache *obj, int flag);
92 static inline void kmem_cache_free(struct kmem_cache *cachep, void *obj)
96 static inline void kmem_cache_destroy(struct kmem_cache *cachep)
101 #define DECLARE_WAITQUEUE(...) do { } while (0)
102 #define add_wait_queue(...) do { } while (0)
103 #define remove_wait_queue(...) do { } while (0)
105 #define KERNEL_VERSION(a,b,c) (((a) << 16) + ((b) << 8) + (c))
107 #define PAGE_SIZE 4096
109 /* drivers/char/random.c */
110 #define get_random_bytes(...)
112 /* include/linux/leds.h */
113 struct led_trigger {};
115 #define DEFINE_LED_TRIGGER(x) static struct led_trigger *x;
116 enum led_brightness {
122 static inline void led_trigger_register_simple(const char *name,
123 struct led_trigger **trigger) {}
124 static inline void led_trigger_unregister_simple(struct led_trigger *trigger) {}
125 static inline void led_trigger_event(struct led_trigger *trigger,
126 enum led_brightness event) {}
128 /* uapi/linux/limits.h */
129 #define XATTR_LIST_MAX 65536 /* size of extended attribute namelist (64k) */
132 * The type used for indexing onto a disc or disc partition.
134 * Linux always considers sectors to be 512 bytes long independently
135 * of the devices real block size.
137 * blkcnt_t is the type of the inode's block count.
140 typedef u64 sector_t;
141 typedef u64 blkcnt_t;
143 typedef unsigned long sector_t;
144 typedef unsigned long blkcnt_t;
148 #define THIS_MODULE 0
149 #define try_module_get(...) 1
150 #define module_put(...) do { } while (0)
151 #define module_init(...)
152 #define module_exit(...)
153 #define EXPORT_SYMBOL(...)
154 #define EXPORT_SYMBOL_GPL(...)
155 #define module_param(...)
156 #define module_param_call(...)
157 #define MODULE_PARM_DESC(...)
158 #define MODULE_VERSION(...)
159 #define MODULE_DESCRIPTION(...)
160 #define MODULE_AUTHOR(...)
161 #define MODULE_LICENSE(...)
162 #define MODULE_ALIAS(...)
163 #define __module_get(...)
165 /* character device */
170 #define alloc_chrdev_region(...) 0
171 #define unregister_chrdev_region(...)
173 #define class_create(...) __builtin_return_address(0)
174 #define class_create_file(...) 0
175 #define class_register(...) 0
176 #define class_unregister(...)
177 #define class_remove_file(...)
178 #define class_destroy(...)
179 #define misc_register(...) 0
180 #define misc_deregister(...)
182 #define blocking_notifier_call_chain(...) 0
185 #define late_initcall(...)
187 #define dev_set_name(...) do { } while (0)
188 #define device_register(...) 0
189 #define device_unregister(...)
190 #define volume_sysfs_init(...) 0
191 #define volume_sysfs_close(...) do { } while (0)
193 #define init_waitqueue_head(...) do { } while (0)
194 #define wait_event_interruptible(...) 0
195 #define wake_up_interruptible(...) do { } while (0)
196 #define print_hex_dump(...) do { } while (0)
197 #define dump_stack(...) do { } while (0)
199 #define task_pid_nr(x) 0
200 #define set_freezable(...) do { } while (0)
201 #define try_to_freeze(...) 0
202 #define set_current_state(...) do { } while (0)
203 #define kthread_should_stop(...) 0
204 #define schedule() do { } while (0)
206 #define setup_timer(timer, func, data) do {} while (0)
207 #define del_timer_sync(timer) do {} while (0)
208 #define schedule_work(work) do {} while (0)
209 #define INIT_WORK(work, fun) do {} while (0)
211 struct work_struct {};
213 unsigned long copy_from_user(void *dest, const void *src,
214 unsigned long count);
216 typedef unused_t spinlock_t;
217 typedef int wait_queue_head_t;
219 #define spin_lock_init(lock) do {} while (0)
220 #define spin_lock(lock) do {} while (0)
221 #define spin_unlock(lock) do {} while (0)
222 #define spin_lock_irqsave(lock, flags) do { debug("%lu\n", flags); } while (0)
223 #define spin_unlock_irqrestore(lock, flags) do { flags = 0; } while (0)
225 #define DEFINE_MUTEX(...)
226 #define mutex_init(...)
227 #define mutex_lock(...)
228 #define mutex_unlock(...)
230 #define init_rwsem(...) do { } while (0)
231 #define down_read(...) do { } while (0)
232 #define down_write(...) do { } while (0)
233 #define down_write_trylock(...) 1
234 #define up_read(...) do { } while (0)
235 #define up_write(...) do { } while (0)
237 #define cond_resched() do { } while (0)
238 #define yield() do { } while (0)
243 #define __devinitdata
244 #define __devinitconst
246 #define kthread_create(...) __builtin_return_address(0)
247 #define kthread_stop(...) do { } while (0)
248 #define wake_up_process(...) do { } while (0)
250 struct rw_semaphore { int i; };
251 #define down_write(...) do { } while (0)
252 #define up_write(...) do { } while (0)
253 #define down_read(...) do { } while (0)
254 #define up_read(...) do { } while (0)
256 struct device *parent;
258 dev_t devt; /* dev_t, creates the sysfs "dev" */
259 void (*release)(struct device *dev);
260 /* This is used from drivers/usb/musb-new subsystem only */
261 void *driver_data; /* data private to the driver */
262 void *device_data; /* data private to the device */
264 struct mutex { int i; };
265 struct kernel_param { int i; };
271 #define cdev_init(...) do { } while (0)
272 #define cdev_add(...) 0
273 #define cdev_del(...) do { } while (0)
275 #define prandom_u32(...) 0
285 /* from include/linux/types.h */
288 * struct callback_head - callback structure for use with RCU and task_work
289 * @next: next update requests in a list
290 * @func: actual update function to call after the grace period.
292 struct callback_head {
293 struct callback_head *next;
294 void (*func)(struct callback_head *head);
296 #define rcu_head callback_head
297 enum writeback_sync_modes {
298 WB_SYNC_NONE, /* Don't wait on anything */
299 WB_SYNC_ALL, /* Wait on every mapping */
302 /* from include/linux/writeback.h */
304 * A control structure which tells the writeback code what to do. These are
305 * always on the stack, and hence need no locking. They are always initialised
306 * in a manner such that unspecified fields are set to zero.
308 struct writeback_control {
309 long nr_to_write; /* Write this many pages, and decrement
310 this for each page written */
311 long pages_skipped; /* Pages which were not written */
314 * For a_ops->writepages(): if start or end are non-zero then this is
315 * a hint that the filesystem need only write out the pages inside that
316 * byterange. The byte at `end' is included in the writeout request.
321 enum writeback_sync_modes sync_mode;
323 unsigned for_kupdate:1; /* A kupdate writeback */
324 unsigned for_background:1; /* A background writeback */
325 unsigned tagged_writepages:1; /* tag-and-write to avoid livelock */
326 unsigned for_reclaim:1; /* Invoked from the page allocator */
327 unsigned range_cyclic:1; /* range_start is cyclic */
328 unsigned for_sync:1; /* sync(2) WB_SYNC_ALL writeback */
331 void *kmemdup(const void *src, size_t len, gfp_t gfp);
333 typedef int irqreturn_t;
335 struct timer_list {};
336 struct notifier_block {};
338 typedef unsigned long dmaaddr_t;
340 #define pm_runtime_get_sync(dev) do {} while (0)
341 #define pm_runtime_put(dev) do {} while (0)
342 #define pm_runtime_put_sync(dev) do {} while (0)
343 #define pm_runtime_use_autosuspend(dev) do {} while (0)
344 #define pm_runtime_set_autosuspend_delay(dev, delay) do {} while (0)
345 #define pm_runtime_enable(dev) do {} while (0)
348 #define IRQ_HANDLED 1
349 #define IRQ_WAKE_THREAD 2
351 #define dev_set_drvdata(dev, data) do {} while (0)
353 #define enable_irq(...)
354 #define disable_irq(...)
355 #define disable_irq_wake(irq) do {} while (0)
356 #define enable_irq_wake(irq) -EINVAL
357 #define free_irq(irq, data) do {} while (0)
358 #define request_irq(nr, f, flags, nm, data) 0