1 #ifndef LINUX_26_31_COMPAT_H
2 #define LINUX_26_31_COMPAT_H
4 #include <linux/autoconf.h>
5 #include <linux/version.h>
7 #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,31))
9 #include <linux/skbuff.h>
10 #include <linux/workqueue.h>
11 #include <linux/interrupt.h>
13 #include <net/genetlink.h>
14 #include <linux/ethtool.h>
17 * These macros allow us to backport rfkill without any
18 * changes on cfg80211 through compat.diff. Note that this
19 * file will be included by rfkill_backport.h so we must
20 * not conflict with things there.
22 #define rfkill_get_led_trigger_name backport_rfkill_get_led_trigger_name
23 #define rfkill_set_led_trigger_name backport_rfkill_set_led_trigger_name
24 #define rfkill_set_hw_state backport_rfkill_set_hw_state
25 #define rfkill_set_sw_state backport_rfkill_set_sw_state
26 #define rfkill_init_sw_state backport_rfkill_init_sw_state
27 #define rfkill_set_states backport_rfkill_set_states
28 #define rfkill_pause_polling backport_rfkill_pause_polling
29 #define rfkill_resume_polling backport_rfkill_resume_polling
30 #define rfkill_blocked backport_rfkill_blocked
31 #define rfkill_alloc backport_rfkill_alloc
32 #define rfkill_register backport_rfkill_register
33 #define rfkill_unregister backport_rfkill_unregister
34 #define rfkill_destroy backport_rfkill_destroy
37 #if !defined(CONFIG_ALPHA) && !defined(CONFIG_MIPS) && !defined(CONFIG_PARISC) && !defined(CONFIG_SPARC)
38 #define ERFKILL 132 /* Operation not possible due to RF-kill */
41 #define ERFKILL 138 /* Operation not possible due to RF-kill */
44 #define ERFKILL 167 /* Operation not possible due to RF-kill */
47 #define ERFKILL 256 /* Operation not possible due to RF-kill */
50 #define ERFKILL 134 /* Operation not possible due to RF-kill */
55 #define NETDEV_PRE_UP 0x000D
58 #ifndef SDIO_DEVICE_ID_MARVELL_8688WLAN
59 #define SDIO_DEVICE_ID_MARVELL_8688WLAN 0x9104
62 struct compat_threaded_irq {
64 irq_handler_t handler;
65 irq_handler_t thread_fn;
68 struct workqueue_struct *wq;
69 struct work_struct work;
73 * kmemleak was introduced on 2.6.31, since older kernels do not have
74 * we simply ignore its tuning.
76 static inline void kmemleak_ignore(const void *ptr)
81 static inline void kmemleak_not_leak(const void *ptr)
86 static inline void kmemleak_no_scan(const void *ptr)
92 * Added via adf30907d63893e4208dfe3f5c88ae12bc2f25d5
94 * There is no _sk_dst on older kernels, so just set the
95 * old dst to NULL and release it directly.
97 static inline void skb_dst_drop(struct sk_buff *skb)
99 dst_release(skb->dst);
103 static inline struct dst_entry *skb_dst(const struct sk_buff *skb)
105 return (struct dst_entry *)skb->dst;
108 static inline void skb_dst_set(struct sk_buff *skb, struct dst_entry *dst)
113 static inline struct rtable *skb_rtable(const struct sk_buff *skb)
115 return (struct rtable *)skb_dst(skb);
118 extern int genl_register_family_with_ops(struct genl_family *family,
119 struct genl_ops *ops, size_t n_ops);
122 /* Backport threaded IRQ support */
125 void compat_irq_work(struct work_struct *work)
127 struct compat_threaded_irq *comp = container_of(work, struct compat_threaded_irq, work);
128 comp->thread_fn(comp->irq, comp->dev_id);
132 irqreturn_t compat_irq_dispatcher(int irq, void *dev_id)
134 struct compat_threaded_irq *comp = dev_id;
137 res = comp->handler(irq, comp->dev_id);
138 if (res == IRQ_WAKE_THREAD) {
139 queue_work(comp->wq, &comp->work);
147 int compat_request_threaded_irq(struct compat_threaded_irq *comp,
149 irq_handler_t handler,
150 irq_handler_t thread_fn,
156 comp->handler = handler;
157 comp->thread_fn = thread_fn;
158 comp->dev_id = dev_id;
159 INIT_WORK(&comp->work, compat_irq_work);
162 snprintf(comp->wq_name, sizeof(comp->wq_name),
163 "compirq/%u-%s", irq, name);
164 comp->wq = create_singlethread_workqueue(comp->wq_name);
166 printk(KERN_ERR "Failed to create compat-threaded-IRQ workqueue %s\n",
171 return request_irq(irq, compat_irq_dispatcher, flags, name, comp);
175 void compat_free_threaded_irq(struct compat_threaded_irq *comp)
177 free_irq(comp->irq, comp);
181 void compat_destroy_threaded_irq(struct compat_threaded_irq *comp)
184 destroy_workqueue(comp->wq);
189 void compat_synchronize_threaded_irq(struct compat_threaded_irq *comp)
191 synchronize_irq(comp->irq);
192 cancel_work_sync(&comp->work);
196 #endif /* (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,31)) */
198 #endif /* LINUX_26_31_COMPAT_H */