Commit 0c06db59836746c5caf397e642cd0f2bf1cc20a6

Authored by Heiko Schocher
Committed by Tom Rini
1 parent cc96c9a79c

lib, linux: move linux specific defines to linux/compat.h

- move linux specific defines from usb and video code
  into linux/compat.h
- move common linux specific defines from include/ubi_uboot.h
  to linux/compat.h
- add for new mtd/ubi/ubifs sync new needed linux specific
  defines to linux/compat.h

Signed-off-by: Heiko Schocher <hs@denx.de>
Cc: Marek Vasut <marex@denx.de>
Cc: Anatolij Gustschin <agust@denx.de>
[trini: Add spin_lock_irqsave/spin_unlock_irqrestore dummies from
usb/lin_gadet_compat.h]
Signed-off-by: Tom Rini <trini@ti.com>

Showing 11 changed files with 385 additions and 235 deletions Side-by-side Diff

drivers/usb/gadget/ether.c
... ... @@ -25,14 +25,9 @@
25 25  
26 26 #define atomic_read
27 27 extern struct platform_data brd;
28   -#define spin_lock(x)
29   -#define spin_unlock(x)
30 28  
31 29  
32 30 unsigned packet_received, packet_sent;
33   -
34   -#define GFP_ATOMIC ((gfp_t) 0)
35   -#define GFP_KERNEL ((gfp_t) 0)
36 31  
37 32 /*
38 33 * Ethernet gadget driver -- with CDC and non-CDC options
drivers/usb/gadget/storage_common.c
... ... @@ -267,11 +267,6 @@
267 267 #define ASCQ(x) ((u8) (x))
268 268  
269 269 struct device_attribute { int i; };
270   -struct rw_semaphore { int i; };
271   -#define down_write(...) do { } while (0)
272   -#define up_write(...) do { } while (0)
273   -#define down_read(...) do { } while (0)
274   -#define up_read(...) do { } while (0)
275 270 #define ETOOSMALL 525
276 271  
277 272 #include <usb_mass_storage.h>
drivers/usb/musb-new/linux-compat.h
... ... @@ -5,39 +5,6 @@
5 5 #include <linux/list.h>
6 6 #include <linux/compat.h>
7 7  
8   -#define __init
9   -#define __devinit
10   -#define __devinitdata
11   -#define __devinitconst
12   -#define __iomem
13   -#define __deprecated
14   -
15   -struct unused {};
16   -typedef struct unused unused_t;
17   -
18   -typedef int irqreturn_t;
19   -typedef unused_t spinlock_t;
20   -
21   -struct work_struct {};
22   -
23   -struct timer_list {};
24   -struct notifier_block {};
25   -
26   -typedef unsigned long dmaaddr_t;
27   -
28   -#define spin_lock_init(lock) do {} while (0)
29   -#define spin_lock(lock) do {} while (0)
30   -#define spin_unlock(lock) do {} while (0)
31   -#define spin_lock_irqsave(lock, flags) do {} while (0)
32   -#define spin_unlock_irqrestore(lock, flags) do {} while (0)
33   -
34   -#define setup_timer(timer, func, data) do {} while (0)
35   -#define del_timer_sync(timer) do {} while (0)
36   -#define schedule_work(work) do {} while (0)
37   -#define INIT_WORK(work, fun) do {} while (0)
38   -
39   -#define cpu_relax() do {} while (0)
40   -
41 8 #define pr_debug(fmt, args...) debug(fmt, ##args)
42 9  
43 10 #define WARN(condition, fmt, args...) ({ \
44 11  
... ... @@ -46,37 +13,12 @@
46 13 printf(fmt, ##args); \
47 14 ret_warn; })
48 15  
49   -#define pm_runtime_get_sync(dev) do {} while (0)
50   -#define pm_runtime_put(dev) do {} while (0)
51   -#define pm_runtime_put_sync(dev) do {} while (0)
52   -#define pm_runtime_use_autosuspend(dev) do {} while (0)
53   -#define pm_runtime_set_autosuspend_delay(dev, delay) do {} while (0)
54   -#define pm_runtime_enable(dev) do {} while (0)
55   -
56   -#define MODULE_DESCRIPTION(desc)
57   -#define MODULE_AUTHOR(author)
58   -#define MODULE_LICENSE(license)
59   -#define MODULE_ALIAS(alias)
60   -#define module_param(name, type, perm)
61   -#define MODULE_PARM_DESC(name, desc)
62   -#define EXPORT_SYMBOL_GPL(name)
63   -
64 16 #define writesl(a, d, s) __raw_writesl((unsigned long)a, d, s)
65 17 #define readsl(a, d, s) __raw_readsl((unsigned long)a, d, s)
66 18 #define writesw(a, d, s) __raw_writesw((unsigned long)a, d, s)
67 19 #define readsw(a, d, s) __raw_readsw((unsigned long)a, d, s)
68 20 #define writesb(a, d, s) __raw_writesb((unsigned long)a, d, s)
69 21 #define readsb(a, d, s) __raw_readsb((unsigned long)a, d, s)
70   -
71   -#define IRQ_NONE 0
72   -#define IRQ_HANDLED 0
73   -
74   -#define dev_set_drvdata(dev, data) do {} while (0)
75   -
76   -#define disable_irq_wake(irq) do {} while (0)
77   -#define enable_irq_wake(irq) -EINVAL
78   -#define free_irq(irq, data) do {} while (0)
79   -#define request_irq(nr, f, flags, nm, data) 0
80 22  
81 23 #define device_init_wakeup(dev, a) do {} while (0)
82 24  
drivers/video/exynos_dp.c
... ... @@ -9,6 +9,7 @@
9 9 #include <config.h>
10 10 #include <common.h>
11 11 #include <malloc.h>
  12 +#include <linux/compat.h>
12 13 #include <linux/err.h>
13 14 #include <asm/arch/clk.h>
14 15 #include <asm/arch/cpu.h>
drivers/video/exynos_mipi_dsi.c
... ... @@ -11,6 +11,7 @@
11 11 #include <malloc.h>
12 12 #include <fdtdec.h>
13 13 #include <libfdt.h>
  14 +#include <linux/compat.h>
14 15 #include <linux/err.h>
15 16 #include <asm/arch/dsim.h>
16 17 #include <asm/arch/mipi_dsim.h>
fs/yaffs2/ydirectenv.h
... ... @@ -58,8 +58,6 @@
58 58 #define inline
59 59 #endif
60 60  
61   -#define cond_resched() do {} while (0)
62   -
63 61 #define yaffs_trace(msk, fmt, ...) do { \
64 62 if (yaffs_trace_mask & (msk)) \
65 63 printf("yaffs: " fmt "\n", ##__VA_ARGS__); \
include/linux/compat.h
1 1 #ifndef _LINUX_COMPAT_H_
2 2 #define _LINUX_COMPAT_H_
3 3  
  4 +#include <malloc.h>
  5 +#include <linux/types.h>
  6 +#include <linux/err.h>
  7 +
  8 +struct unused {};
  9 +typedef struct unused unused_t;
  10 +
  11 +struct p_current{
  12 + int pid;
  13 +};
  14 +
  15 +extern struct p_current *current;
  16 +
4 17 #define ndelay(x) udelay(1)
5 18  
6 19 #define dev_dbg(dev, fmt, args...) \
... ... @@ -12,6 +25,7 @@
12 25 #define dev_err(dev, fmt, args...) \
13 26 printf(fmt, ##args)
14 27 #define printk printf
  28 +#define printk_once printf
15 29  
16 30 #define KERN_EMERG
17 31 #define KERN_ALERT
18 32  
... ... @@ -22,12 +36,21 @@
22 36 #define KERN_INFO
23 37 #define KERN_DEBUG
24 38  
25   -#define kmalloc(size, flags) malloc(size)
26   -#define kzalloc(size, flags) calloc(size, 1)
27   -#define vmalloc(size) malloc(size)
28   -#define kfree(ptr) free(ptr)
29   -#define vfree(ptr) free(ptr)
  39 +void *kmalloc(size_t size, int flags);
  40 +void *kzalloc(size_t size, int flags);
  41 +#define vmalloc(size) kmalloc(size, 0)
  42 +#define __vmalloc(size, flags, pgsz) kmalloc(size, flags)
  43 +#define kfree(ptr) free(ptr)
  44 +#define vfree(ptr) free(ptr)
30 45  
  46 +struct kmem_cache { int sz; };
  47 +
  48 +struct kmem_cache *get_mem(int element_sz);
  49 +#define kmem_cache_create(a, sz, c, d, e) get_mem(sz)
  50 +void *kmem_cache_alloc(struct kmem_cache *obj, int flag);
  51 +#define kmem_cache_free(obj, size) free(size)
  52 +#define kmem_cache_destroy(obj) free(obj)
  53 +
31 54 #define DECLARE_WAITQUEUE(...) do { } while (0)
32 55 #define add_wait_queue(...) do { } while (0)
33 56 #define remove_wait_queue(...) do { } while (0)
... ... @@ -75,6 +98,302 @@
75 98 * @n: the number we're accessing
76 99 */
77 100 #define lower_32_bits(n) ((u32)(n))
  101 +
  102 +/* drivers/char/random.c */
  103 +#define get_random_bytes(...)
  104 +
  105 +/* idr.c */
  106 +#define GFP_ATOMIC ((gfp_t) 0)
  107 +#define GFP_KERNEL ((gfp_t) 0)
  108 +#define GFP_NOFS ((gfp_t) 0)
  109 +#define GFP_USER ((gfp_t) 0)
  110 +#define __GFP_NOWARN ((gfp_t) 0)
  111 +
  112 +/* include/linux/leds.h */
  113 +struct led_trigger {};
  114 +
  115 +#define DEFINE_LED_TRIGGER(x) static struct led_trigger *x;
  116 +enum led_brightness {
  117 + LED_OFF = 0,
  118 + LED_HALF = 127,
  119 + LED_FULL = 255,
  120 +};
  121 +
  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) {}
  127 +
  128 +/* include/linux/log2.h */
  129 +static inline int is_power_of_2(unsigned long n)
  130 +{
  131 + return (n != 0 && ((n & (n - 1)) == 0));
  132 +}
  133 +
  134 +/* uapi/linux/limits.h */
  135 +#define XATTR_LIST_MAX 65536 /* size of extended attribute namelist (64k) */
  136 +
  137 +/**
  138 + * The type used for indexing onto a disc or disc partition.
  139 + *
  140 + * Linux always considers sectors to be 512 bytes long independently
  141 + * of the devices real block size.
  142 + *
  143 + * blkcnt_t is the type of the inode's block count.
  144 + */
  145 +#ifdef CONFIG_LBDAF
  146 +typedef u64 sector_t;
  147 +typedef u64 blkcnt_t;
  148 +#else
  149 +typedef unsigned long sector_t;
  150 +typedef unsigned long blkcnt_t;
  151 +#endif
  152 +
  153 +#define ENOTSUPP 524 /* Operation is not supported */
  154 +
  155 +/* from include/linux/kernel.h */
  156 +/*
  157 + * This looks more complex than it should be. But we need to
  158 + * get the type for the ~ right in round_down (it needs to be
  159 + * as wide as the result!), and we want to evaluate the macro
  160 + * arguments just once each.
  161 + */
  162 +#define __round_mask(x, y) ((__typeof__(x))((y)-1))
  163 +#define round_up(x, y) ((((x)-1) | __round_mask(x, y))+1)
  164 +#define round_down(x, y) ((x) & ~__round_mask(x, y))
  165 +
  166 +/* module */
  167 +#define THIS_MODULE 0
  168 +#define try_module_get(...) 1
  169 +#define module_put(...) do { } while (0)
  170 +#define module_init(...)
  171 +#define module_exit(...)
  172 +#define EXPORT_SYMBOL(...)
  173 +#define EXPORT_SYMBOL_GPL(...)
  174 +#define module_param(...)
  175 +#define module_param_call(...)
  176 +#define MODULE_PARM_DESC(...)
  177 +#define MODULE_VERSION(...)
  178 +#define MODULE_DESCRIPTION(...)
  179 +#define MODULE_AUTHOR(...)
  180 +#define MODULE_LICENSE(...)
  181 +#define MODULE_ALIAS(...)
  182 +#define __module_get(...)
  183 +
  184 +/* character device */
  185 +#define MKDEV(...) 0
  186 +#define MAJOR(dev) 0
  187 +#define MINOR(dev) 0
  188 +
  189 +#define alloc_chrdev_region(...) 0
  190 +#define unregister_chrdev_region(...)
  191 +
  192 +#define class_create(...) __builtin_return_address(0)
  193 +#define class_create_file(...) 0
  194 +#define class_remove_file(...)
  195 +#define class_destroy(...)
  196 +#define misc_register(...) 0
  197 +#define misc_deregister(...)
  198 +
  199 +#define blocking_notifier_call_chain(...) 0
  200 +
  201 +/*
  202 + * Multiplies an integer by a fraction, while avoiding unnecessary
  203 + * overflow or loss of precision.
  204 + */
  205 +#define mult_frac(x, numer, denom)( \
  206 +{ \
  207 + typeof(x) quot = (x) / (denom); \
  208 + typeof(x) rem = (x) % (denom); \
  209 + (quot * (numer)) + ((rem * (numer)) / (denom)); \
  210 +} \
  211 +)
  212 +
  213 +#define __initdata
  214 +#define late_initcall(...)
  215 +
  216 +#define dev_set_name(...) do { } while (0)
  217 +#define device_register(...) 0
  218 +#define volume_sysfs_init(...) 0
  219 +#define volume_sysfs_close(...) do { } while (0)
  220 +
  221 +#define init_waitqueue_head(...) do { } while (0)
  222 +#define wait_event_interruptible(...) 0
  223 +#define wake_up_interruptible(...) do { } while (0)
  224 +#define print_hex_dump(...) do { } while (0)
  225 +#define dump_stack(...) do { } while (0)
  226 +
  227 +#define task_pid_nr(x) 0
  228 +#define set_freezable(...) do { } while (0)
  229 +#define try_to_freeze(...) 0
  230 +#define set_current_state(...) do { } while (0)
  231 +#define kthread_should_stop(...) 0
  232 +#define schedule() do { } while (0)
  233 +
  234 +#define setup_timer(timer, func, data) do {} while (0)
  235 +#define del_timer_sync(timer) do {} while (0)
  236 +#define schedule_work(work) do {} while (0)
  237 +#define INIT_WORK(work, fun) do {} while (0)
  238 +
  239 +struct work_struct {};
  240 +
  241 +unsigned long copy_from_user(void *dest, const void *src,
  242 + unsigned long count);
  243 +
  244 +void *vzalloc(unsigned long size);
  245 +
  246 +typedef unused_t spinlock_t;
  247 +typedef int wait_queue_head_t;
  248 +
  249 +#define spin_lock_init(lock) do {} while (0)
  250 +#define spin_lock(lock) do {} while (0)
  251 +#define spin_unlock(lock) do {} while (0)
  252 +#define spin_lock_irqsave(lock, flags) do { debug("%lu\n", flags); } while (0)
  253 +#define spin_unlock_irqrestore(lock, flags) do { flags = 0; } while (0)
  254 +
  255 +#define DEFINE_MUTEX(...)
  256 +#define mutex_init(...)
  257 +#define mutex_lock(...)
  258 +#define mutex_unlock(...)
  259 +
  260 +#define init_rwsem(...) do { } while (0)
  261 +#define down_read(...) do { } while (0)
  262 +#define down_write(...) do { } while (0)
  263 +#define down_write_trylock(...) 1
  264 +#define up_read(...) do { } while (0)
  265 +#define up_write(...) do { } while (0)
  266 +
  267 +#define cond_resched() do { } while (0)
  268 +#define yield() do { } while (0)
  269 +
  270 +#define INT_MAX ((int)(~0U>>1))
  271 +
  272 +#define __user
  273 +#define __init
  274 +#define __exit
  275 +#define __devinit
  276 +#define __devinitdata
  277 +#define __devinitconst
  278 +#define __iomem
  279 +
  280 +#define kthread_create(...) __builtin_return_address(0)
  281 +#define kthread_stop(...) do { } while (0)
  282 +#define wake_up_process(...) do { } while (0)
  283 +
  284 +struct rw_semaphore { int i; };
  285 +#define down_write(...) do { } while (0)
  286 +#define up_write(...) do { } while (0)
  287 +#define down_read(...) do { } while (0)
  288 +#define up_read(...) do { } while (0)
  289 +struct device {
  290 + struct device *parent;
  291 + struct class *class;
  292 + dev_t devt; /* dev_t, creates the sysfs "dev" */
  293 + void (*release)(struct device *dev);
  294 + /* This is used from drivers/usb/musb-new subsystem only */
  295 + void *driver_data; /* data private to the driver */
  296 + void *device_data; /* data private to the device */
  297 +};
  298 +struct mutex { int i; };
  299 +struct kernel_param { int i; };
  300 +
  301 +struct cdev {
  302 + int owner;
  303 + dev_t dev;
  304 +};
  305 +#define cdev_init(...) do { } while (0)
  306 +#define cdev_add(...) 0
  307 +#define cdev_del(...) do { } while (0)
  308 +
  309 +#define MAX_ERRNO 4095
  310 +
  311 +#define prandom_u32(...) 0
  312 +
  313 +typedef struct {
  314 + uid_t val;
  315 +} kuid_t;
  316 +
  317 +typedef struct {
  318 + gid_t val;
  319 +} kgid_t;
  320 +
  321 +/* from include/linux/types.h */
  322 +
  323 +typedef int atomic_t;
  324 +/**
  325 + * struct callback_head - callback structure for use with RCU and task_work
  326 + * @next: next update requests in a list
  327 + * @func: actual update function to call after the grace period.
  328 + */
  329 +struct callback_head {
  330 + struct callback_head *next;
  331 + void (*func)(struct callback_head *head);
  332 +};
  333 +#define rcu_head callback_head
  334 +enum writeback_sync_modes {
  335 + WB_SYNC_NONE, /* Don't wait on anything */
  336 + WB_SYNC_ALL, /* Wait on every mapping */
  337 +};
  338 +
  339 +/* from include/linux/writeback.h */
  340 +/*
  341 + * A control structure which tells the writeback code what to do. These are
  342 + * always on the stack, and hence need no locking. They are always initialised
  343 + * in a manner such that unspecified fields are set to zero.
  344 + */
  345 +struct writeback_control {
  346 + long nr_to_write; /* Write this many pages, and decrement
  347 + this for each page written */
  348 + long pages_skipped; /* Pages which were not written */
  349 +
  350 + /*
  351 + * For a_ops->writepages(): if start or end are non-zero then this is
  352 + * a hint that the filesystem need only write out the pages inside that
  353 + * byterange. The byte at `end' is included in the writeout request.
  354 + */
  355 + loff_t range_start;
  356 + loff_t range_end;
  357 +
  358 + enum writeback_sync_modes sync_mode;
  359 +
  360 + unsigned for_kupdate:1; /* A kupdate writeback */
  361 + unsigned for_background:1; /* A background writeback */
  362 + unsigned tagged_writepages:1; /* tag-and-write to avoid livelock */
  363 + unsigned for_reclaim:1; /* Invoked from the page allocator */
  364 + unsigned range_cyclic:1; /* range_start is cyclic */
  365 + unsigned for_sync:1; /* sync(2) WB_SYNC_ALL writeback */
  366 +};
  367 +
  368 +void *kmemdup(const void *src, size_t len, gfp_t gfp);
  369 +
  370 +typedef int irqreturn_t;
  371 +
  372 +struct timer_list {};
  373 +struct notifier_block {};
  374 +
  375 +typedef unsigned long dmaaddr_t;
  376 +
  377 +#define cpu_relax() do {} while (0)
  378 +
  379 +#define pm_runtime_get_sync(dev) do {} while (0)
  380 +#define pm_runtime_put(dev) do {} while (0)
  381 +#define pm_runtime_put_sync(dev) do {} while (0)
  382 +#define pm_runtime_use_autosuspend(dev) do {} while (0)
  383 +#define pm_runtime_set_autosuspend_delay(dev, delay) do {} while (0)
  384 +#define pm_runtime_enable(dev) do {} while (0)
  385 +
  386 +#define IRQ_NONE 0
  387 +#define IRQ_HANDLED 1
  388 +
  389 +#define dev_set_drvdata(dev, data) do {} while (0)
  390 +
  391 +#define enable_irq(...)
  392 +#define disable_irq(...)
  393 +#define disable_irq_wake(irq) do {} while (0)
  394 +#define enable_irq_wake(irq) -EINVAL
  395 +#define free_irq(irq, data) do {} while (0)
  396 +#define request_irq(nr, f, flags, nm, data) 0
78 397  
79 398 #endif
include/linux/usb/gadget.h
... ... @@ -19,6 +19,7 @@
19 19 #define __LINUX_USB_GADGET_H
20 20  
21 21 #include <errno.h>
  22 +#include <linux/compat.h>
22 23 #include <linux/list.h>
23 24  
24 25 struct usb_ep;
... ... @@ -408,11 +409,6 @@
408 409 int (*pullup) (struct usb_gadget *, int is_on);
409 410 int (*ioctl)(struct usb_gadget *,
410 411 unsigned code, unsigned long param);
411   -};
412   -
413   -struct device {
414   - void *driver_data; /* data private to the driver */
415   - void *device_data; /* data private to the device */
416 412 };
417 413  
418 414 /**
... ... @@ -16,8 +16,10 @@
16 16  
17 17 #include <common.h>
18 18 #include <compiler.h>
  19 +#include <linux/compat.h>
19 20 #include <malloc.h>
20 21 #include <div64.h>
  22 +#include <linux/math64.h>
21 23 #include <linux/crc32.h>
22 24 #include <linux/types.h>
23 25 #include <linux/list.h>
24 26  
25 27  
26 28  
... ... @@ -32,15 +34,11 @@
32 34  
33 35 #include <asm/errno.h>
34 36  
35   -#define DPRINTK(format, args...) \
36   -do { \
37   - printf("%s[%d]: " format "\n", __func__, __LINE__, ##args); \
38   -} while (0)
39   -
40 37 /* configurable */
  38 +#if !defined(CONFIG_MTD_UBI_WL_THRESHOLD)
41 39 #define CONFIG_MTD_UBI_WL_THRESHOLD 4096
  40 +#endif
42 41 #define CONFIG_MTD_UBI_BEB_RESERVE 1
43   -#define UBI_IO_DEBUG 0
44 42  
45 43 /* debug options (Linux: drivers/mtd/ubi/Kconfig.debug) */
46 44 #undef CONFIG_MTD_UBI_DEBUG
47 45  
48 46  
... ... @@ -50,161 +48,18 @@
50 48 #undef CONFIG_MTD_UBI_DEBUG_MSG_WL
51 49 #undef CONFIG_MTD_UBI_DEBUG_MSG_IO
52 50 #undef CONFIG_MTD_UBI_DEBUG_MSG_BLD
53   -#define CONFIG_MTD_UBI_DEBUG_DISABLE_BGT
54 51  
  52 +#undef CONFIG_MTD_UBI_BLOCK
  53 +
  54 +#if !defined(CONFIG_MTD_UBI_BEB_LIMIT)
  55 +#define CONFIG_MTD_UBI_BEB_LIMIT 20
  56 +#endif
  57 +
55 58 /* build.c */
56 59 #define get_device(...)
57 60 #define put_device(...)
58 61 #define ubi_sysfs_init(...) 0
59 62 #define ubi_sysfs_close(...) do { } while (0)
60   -static inline int is_power_of_2(unsigned long n)
61   -{
62   - return (n != 0 && ((n & (n - 1)) == 0));
63   -}
64   -
65   -/* FIXME */
66   -#define MKDEV(...) 0
67   -#define MAJOR(dev) 0
68   -#define MINOR(dev) 0
69   -
70   -#define alloc_chrdev_region(...) 0
71   -#define unregister_chrdev_region(...)
72   -
73   -#define class_create(...) __builtin_return_address(0)
74   -#define class_create_file(...) 0
75   -#define class_remove_file(...)
76   -#define class_destroy(...)
77   -#define misc_register(...) 0
78   -#define misc_deregister(...)
79   -
80   -/* vmt.c */
81   -#define device_register(...) 0
82   -#define volume_sysfs_init(...) 0
83   -#define volume_sysfs_close(...) do { } while (0)
84   -
85   -/* kapi.c */
86   -
87   -/* eba.c */
88   -
89   -/* io.c */
90   -#define init_waitqueue_head(...) do { } while (0)
91   -#define wait_event_interruptible(...) 0
92   -#define wake_up_interruptible(...) do { } while (0)
93   -#define print_hex_dump(...) do { } while (0)
94   -#define dump_stack(...) do { } while (0)
95   -
96   -/* wl.c */
97   -#define task_pid_nr(x) 0
98   -#define set_freezable(...) do { } while (0)
99   -#define try_to_freeze(...) 0
100   -#define set_current_state(...) do { } while (0)
101   -#define kthread_should_stop(...) 0
102   -#define schedule() do { } while (0)
103   -
104   -/* upd.c */
105   -static inline unsigned long copy_from_user(void *dest, const void *src,
106   - unsigned long count)
107   -{
108   - memcpy((void *)dest, (void *)src, count);
109   - return 0;
110   -}
111   -
112   -/* common */
113   -typedef int spinlock_t;
114   -typedef int wait_queue_head_t;
115   -#define spin_lock_init(...)
116   -#define spin_lock(...)
117   -#define spin_unlock(...)
118   -
119   -#define mutex_init(...)
120   -#define mutex_lock(...)
121   -#define mutex_unlock(...)
122   -
123   -#define init_rwsem(...) do { } while (0)
124   -#define down_read(...) do { } while (0)
125   -#define down_write(...) do { } while (0)
126   -#define down_write_trylock(...) 1
127   -#define up_read(...) do { } while (0)
128   -#define up_write(...) do { } while (0)
129   -
130   -struct kmem_cache { int i; };
131   -#define kmem_cache_create(...) 1
132   -#define kmem_cache_alloc(obj, gfp) malloc(sizeof(struct ubi_wl_entry))
133   -#define kmem_cache_free(obj, size) free(size)
134   -#define kmem_cache_destroy(...)
135   -
136   -#define cond_resched() do { } while (0)
137   -#define yield() do { } while (0)
138   -
139   -#define KERN_WARNING
140   -#define KERN_ERR
141   -#define KERN_NOTICE
142   -#define KERN_DEBUG
143   -
144   -#define GFP_KERNEL 0
145   -#define GFP_NOFS 1
146   -
147   -#define __user
148   -#define __init
149   -#define __exit
150   -
151   -#define kthread_create(...) __builtin_return_address(0)
152   -#define kthread_stop(...) do { } while (0)
153   -#define wake_up_process(...) do { } while (0)
154   -
155   -#define BUS_ID_SIZE 20
156   -
157   -struct rw_semaphore { int i; };
158   -struct device {
159   - struct device *parent;
160   - struct class *class;
161   - char bus_id[BUS_ID_SIZE]; /* position on parent bus */
162   - dev_t devt; /* dev_t, creates the sysfs "dev" */
163   - void (*release)(struct device *dev);
164   -};
165   -struct mutex { int i; };
166   -struct kernel_param { int i; };
167   -
168   -struct cdev {
169   - int owner;
170   - dev_t dev;
171   -};
172   -#define cdev_init(...) do { } while (0)
173   -#define cdev_add(...) 0
174   -#define cdev_del(...) do { } while (0)
175   -
176   -#define MAX_ERRNO 4095
177   -#define IS_ERR_VALUE(x) ((x) >= (unsigned long)-MAX_ERRNO)
178   -
179   -static inline void *ERR_PTR(long error)
180   -{
181   - return (void *) error;
182   -}
183   -
184   -static inline long PTR_ERR(const void *ptr)
185   -{
186   - return (long) ptr;
187   -}
188   -
189   -static inline long IS_ERR(const void *ptr)
190   -{
191   - return IS_ERR_VALUE((unsigned long)ptr);
192   -}
193   -
194   -/* module */
195   -#define THIS_MODULE 0
196   -#define try_module_get(...) 1
197   -#define module_put(...) do { } while (0)
198   -#define module_init(...)
199   -#define module_exit(...)
200   -#define EXPORT_SYMBOL(...)
201   -#define EXPORT_SYMBOL_GPL(...)
202   -#define module_param_call(...)
203   -#define MODULE_PARM_DESC(...)
204   -#define MODULE_VERSION(...)
205   -#define MODULE_DESCRIPTION(...)
206   -#define MODULE_AUTHOR(...)
207   -#define MODULE_LICENSE(...)
208 63  
209 64 #ifndef __UBIFS_H__
210 65 #include "../drivers/mtd/ubi/ubi.h"
... ... @@ -59,6 +59,7 @@
59 59 obj-y += ctype.o
60 60 obj-y += div64.o
61 61 obj-y += hang.o
  62 +obj-y += linux_compat.o
62 63 obj-y += linux_string.o
63 64 obj-$(CONFIG_REGEX) += slre.o
64 65 obj-y += string.o
  1 +
  2 +#include <common.h>
  3 +#include <linux/compat.h>
  4 +
  5 +struct p_current cur = {
  6 + .pid = 1,
  7 +};
  8 +__maybe_unused struct p_current *current = &cur;
  9 +
  10 +unsigned long copy_from_user(void *dest, const void *src,
  11 + unsigned long count)
  12 +{
  13 + memcpy((void *)dest, (void *)src, count);
  14 + return 0;
  15 +}
  16 +
  17 +void *kmalloc(size_t size, int flags)
  18 +{
  19 + return memalign(ARCH_DMA_MINALIGN, size);
  20 +}
  21 +
  22 +void *kzalloc(size_t size, int flags)
  23 +{
  24 + void *ptr = kmalloc(size, flags);
  25 + memset(ptr, 0, size);
  26 + return ptr;
  27 +}
  28 +
  29 +void *vzalloc(unsigned long size)
  30 +{
  31 + return kzalloc(size, 0);
  32 +}
  33 +
  34 +struct kmem_cache *get_mem(int element_sz)
  35 +{
  36 + struct kmem_cache *ret;
  37 +
  38 + ret = memalign(ARCH_DMA_MINALIGN, sizeof(struct kmem_cache));
  39 + ret->sz = element_sz;
  40 +
  41 + return ret;
  42 +}
  43 +
  44 +void *kmem_cache_alloc(struct kmem_cache *obj, int flag)
  45 +{
  46 + return memalign(ARCH_DMA_MINALIGN, obj->sz);
  47 +}