1 --- a/include/linux/compat-2.6.h
2 +++ b/include/linux/compat-2.6.h
3 @@ -69,6 +69,7 @@ void compat_dependency_symbol(void);
4 #include <linux/compat-3.6.h>
5 #include <linux/compat-3.7.h>
6 #include <linux/compat-3.8.h>
7 +#include <linux/compat-3.9.h>
9 #endif /* __ASSEMBLY__ */
12 +++ b/include/linux/compat-3.9.h
14 +#ifndef LINUX_3_9_COMPAT_H
15 +#define LINUX_3_9_COMPAT_H
17 +#include <linux/version.h>
19 +#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,9,0))
21 +#include <linux/idr.h>
22 +#include <linux/list.h>
23 +#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,25))
24 +#include <linux/rculist.h>
26 +#include <net/sock.h>
27 +#include <linux/tty.h>
28 +#include <linux/tty_flip.h>
30 +/* include this before changing hlist_for_each_* to use the old versions. */
31 +#include <net/sch_generic.h>
35 + * backport of idr idr_alloc() usage
37 + * This backports a patch series send by Tejun Heo:
38 + * https://lkml.org/lkml/2013/2/2/159
40 +static inline void compat_idr_destroy(struct idr *idp)
42 + idr_remove_all(idp);
45 +#define idr_destroy(idp) compat_idr_destroy(idp)
47 +static inline int idr_alloc(struct idr *idr, void *ptr, int start, int end,
53 + if (!idr_pre_get(idr, gfp_mask))
55 + ret = idr_get_new_above(idr, ptr, start, &id);
56 + if (!ret && id > end) {
57 + idr_remove(idr, id);
60 + } while (ret == -EAGAIN);
62 + return ret ? ret : id;
65 +static inline void idr_preload(gfp_t gfp_mask)
69 +static inline void idr_preload_end(void)
77 + * commit 0bbacca7c3911451cea923b0ad6389d58e3d9ce9
78 + * Author: Sasha Levin <sasha.levin@oracle.com>
79 + * Date: Thu Feb 7 12:32:18 2013 +1100
81 + * hlist: drop the node parameter from iterators
84 +#define hlist_entry_safe(ptr, type, member) \
85 + (ptr) ? hlist_entry(ptr, type, member) : NULL
87 +#undef hlist_for_each_entry
89 + * hlist_for_each_entry - iterate over list of given type
90 + * @pos: the type * to use as a loop cursor.
91 + * @head: the head for your list.
92 + * @member: the name of the hlist_node within the struct.
94 +#define hlist_for_each_entry(pos, head, member) \
95 + for (pos = hlist_entry_safe((head)->first, typeof(*(pos)), member); \
97 + pos = hlist_entry_safe((pos)->member.next, typeof(*(pos)), member))
99 +#undef hlist_for_each_entry_safe
101 + * hlist_for_each_entry_safe - iterate over list of given type safe against removal of list entry
102 + * @pos: the type * to use as a loop cursor.
103 + * @n: another &struct hlist_node to use as temporary storage
104 + * @head: the head for your list.
105 + * @member: the name of the hlist_node within the struct.
107 +#define hlist_for_each_entry_safe(pos, n, head, member) \
108 + for (pos = hlist_entry_safe((head)->first, typeof(*pos), member); \
109 + pos && ({ n = pos->member.next; 1; }); \
110 + pos = hlist_entry_safe(n, typeof(*pos), member))
112 +#undef hlist_for_each_entry_rcu
114 + * hlist_for_each_entry_rcu - iterate over rcu list of given type
115 + * @pos: the type * to use as a loop cursor.
116 + * @head: the head for your list.
117 + * @member: the name of the hlist_node within the struct.
119 + * This list-traversal primitive may safely run concurrently with
120 + * the _rcu list-mutation primitives such as hlist_add_head_rcu()
121 + * as long as the traversal is guarded by rcu_read_lock().
123 +#define hlist_for_each_entry_rcu(pos, head, member) \
124 + for (pos = hlist_entry_safe (rcu_dereference_raw(hlist_first_rcu(head)),\
125 + typeof(*(pos)), member); \
127 + pos = hlist_entry_safe(rcu_dereference_raw(hlist_next_rcu( \
128 + &(pos)->member)), typeof(*(pos)), member))
131 +#define sk_for_each(__sk, list) \
132 + hlist_for_each_entry(__sk, list, sk_node)
134 +#define tty_flip_buffer_push(port) tty_flip_buffer_push((port)->tty)
135 +#define tty_insert_flip_string(port, chars, size) tty_insert_flip_string((port)->tty, chars, size)
140 + * commit 496ad9aa8ef448058e36ca7a787c61f2e63f0f54
141 + * Author: Al Viro <viro@zeniv.linux.org.uk>
142 + * Date: Wed Jan 23 17:07:38 2013 -0500
144 + * new helper: file_inode(file)
146 +static inline struct inode *file_inode(struct file *f)
148 + return f->f_path.dentry->d_inode;
151 +#endif /* (LINUX_VERSION_CODE < KERNEL_VERSION(3,9,0)) */
153 +#endif /* LINUX_3_9_COMPAT_H */