GUI: Fix Tomato RAF theme for all builds. Compilation typo.
[tomato.git] / release / src-rt-6.x.4708 / include / linuxver.h
blobcaebd67fb3ca978268a787b1b7bdd25279776bab
1 /*
2 * Linux-specific abstractions to gain some independence from linux kernel versions.
3 * Pave over some 2.2 versus 2.4 versus 2.6 kernel differences.
5 * Copyright (C) 2012, Broadcom Corporation. All Rights Reserved.
6 *
7 * Permission to use, copy, modify, and/or distribute this software for any
8 * purpose with or without fee is hereby granted, provided that the above
9 * copyright notice and this permission notice appear in all copies.
11 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
12 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
13 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
14 * SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
15 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
16 * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
17 * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
19 * $Id: linuxver.h 338951 2012-06-14 23:30:48Z $
22 #ifndef _linuxver_h_
23 #define _linuxver_h_
25 #include <linux/version.h>
26 #if (LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 0))
27 #include <linux/config.h>
28 #else
29 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 33))
30 #include <generated/autoconf.h>
31 #else
32 #include <linux/autoconf.h>
33 #endif
34 #endif /* (LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 0)) */
36 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 1, 0))
37 #include <linux/kconfig.h>
38 #endif
40 #include <linux/module.h>
42 #if (LINUX_VERSION_CODE < KERNEL_VERSION(2, 3, 0))
43 /* __NO_VERSION__ must be defined for all linkables except one in 2.2 */
44 #ifdef __UNDEF_NO_VERSION__
45 #undef __NO_VERSION__
46 #else
47 #define __NO_VERSION__
48 #endif
49 #endif /* LINUX_VERSION_CODE < KERNEL_VERSION(2, 3, 0) */
51 #if LINUX_VERSION_CODE < KERNEL_VERSION(2, 5, 0)
52 #define module_param(_name_, _type_, _perm_) MODULE_PARM(_name_, "i")
53 #define module_param_string(_name_, _string_, _size_, _perm_) \
54 MODULE_PARM(_string_, "c" __MODULE_STRING(_size_))
55 #endif
57 /* linux/malloc.h is deprecated, use linux/slab.h instead. */
58 #if (LINUX_VERSION_CODE < KERNEL_VERSION(2, 4, 9))
59 #include <linux/malloc.h>
60 #else
61 #include <linux/slab.h>
62 #endif
64 #include <linux/types.h>
65 #include <linux/init.h>
66 #include <linux/mm.h>
67 #include <linux/string.h>
68 #include <linux/pci.h>
69 #include <linux/interrupt.h>
70 #include <linux/netdevice.h>
71 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 27))
72 #include <linux/semaphore.h>
73 #else
74 #include <asm/semaphore.h>
75 #endif /* (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 27)) */
76 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 28))
77 #undef IP_TOS
78 #endif /* (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 28)) */
79 #include <asm/io.h>
81 #if (LINUX_VERSION_CODE > KERNEL_VERSION(2, 5, 41))
82 #include <linux/workqueue.h>
83 #else
84 #include <linux/tqueue.h>
85 #ifndef work_struct
86 #define work_struct tq_struct
87 #endif
88 #ifndef INIT_WORK
89 #define INIT_WORK(_work, _func, _data) INIT_TQUEUE((_work), (_func), (_data))
90 #endif
91 #ifndef schedule_work
92 #define schedule_work(_work) schedule_task((_work))
93 #endif
94 #ifndef flush_scheduled_work
95 #define flush_scheduled_work() flush_scheduled_tasks()
96 #endif
97 #endif /* LINUX_VERSION_CODE > KERNEL_VERSION(2, 5, 41) */
99 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 19)
100 #define MY_INIT_WORK(_work, _func) INIT_WORK(_work, _func)
101 #else
102 #define MY_INIT_WORK(_work, _func) INIT_WORK(_work, _func, _work)
103 typedef void (*work_func_t)(void *work);
104 #endif /* >= 2.6.20 */
106 #if (LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 0))
107 /* Some distributions have their own 2.6.x compatibility layers */
108 #ifndef IRQ_NONE
109 typedef void irqreturn_t;
110 #define IRQ_NONE
111 #define IRQ_HANDLED
112 #define IRQ_RETVAL(x)
113 #endif
114 #else
115 typedef irqreturn_t(*FN_ISR) (int irq, void *dev_id, struct pt_regs *ptregs);
116 #endif /* LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 0) */
118 #if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 18)
119 #define IRQF_SHARED SA_SHIRQ
120 #endif /* < 2.6.18 */
122 #if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 17)
123 #ifdef CONFIG_NET_RADIO
124 #define CONFIG_WIRELESS_EXT
125 #endif
126 #endif /* < 2.6.17 */
128 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 5, 67)
129 #define MOD_INC_USE_COUNT
130 #define MOD_DEC_USE_COUNT
131 #endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(2, 5, 67) */
133 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 32)
134 #include <linux/sched.h>
135 #endif
137 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 29)
138 #include <net/lib80211.h>
139 #endif
140 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 29)
141 #include <linux/ieee80211.h>
142 #else
143 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 14)
144 #include <net/ieee80211.h>
145 #endif
146 #endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 30) */
148 #if defined(CONFIG_PCMCIA) || defined(CONFIG_PCMCIA_MODULE)
150 #if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 27)
151 #include <pcmcia/version.h>
152 #endif /* LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 27) */
154 #if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 36)
155 #include <pcmcia/cs_types.h>
156 #include <pcmcia/cs.h>
157 #endif
158 #include <pcmcia/cistpl.h>
159 #include <pcmcia/cisreg.h>
160 #include <pcmcia/ds.h>
162 #if (LINUX_VERSION_CODE < KERNEL_VERSION(2, 5, 69))
163 /* In 2.5 (as of 2.5.69 at least) there is a cs_error exported which
164 * does this, but it's not in 2.4 so we do our own for now.
166 static inline void
167 cs_error(client_handle_t handle, int func, int ret)
169 error_info_t err = { func, ret };
170 CardServices(ReportError, handle, &err);
172 #endif
174 #if (LINUX_VERSION_CODE > KERNEL_VERSION(2, 6, 16))
176 typedef struct pcmcia_device dev_link_t;
178 #endif
180 #endif /* CONFIG_PCMCIA */
182 #ifndef __exit
183 #define __exit
184 #endif
185 #ifndef __devexit
186 #define __devexit
187 #endif
188 #ifndef __devinit
189 #define __devinit __init
190 #endif
191 #ifndef __devinitdata
192 #define __devinitdata
193 #endif
194 #ifndef __devexit_p
195 #define __devexit_p(x) x
196 #endif
198 #if (LINUX_VERSION_CODE < KERNEL_VERSION(2, 4, 0))
200 #define pci_get_drvdata(dev) (dev)->sysdata
201 #define pci_set_drvdata(dev, value) (dev)->sysdata = (value)
204 * New-style (2.4.x) PCI/hot-pluggable PCI/CardBus registration
207 struct pci_device_id {
208 unsigned int vendor, device; /* Vendor and device ID or PCI_ANY_ID */
209 unsigned int subvendor, subdevice; /* Subsystem ID's or PCI_ANY_ID */
210 unsigned int class, class_mask; /* (class,subclass,prog-if) triplet */
211 unsigned long driver_data; /* Data private to the driver */
214 struct pci_driver {
215 struct list_head node;
216 char *name;
217 const struct pci_device_id *id_table; /* NULL if wants all devices */
218 int (*probe)(struct pci_dev *dev,
219 const struct pci_device_id *id); /* New device inserted */
220 void (*remove)(struct pci_dev *dev); /* Device removed (NULL if not a hot-plug
221 * capable driver)
223 void (*suspend)(struct pci_dev *dev); /* Device suspended */
224 void (*resume)(struct pci_dev *dev); /* Device woken up */
227 #define MODULE_DEVICE_TABLE(type, name)
228 #define PCI_ANY_ID (~0)
230 /* compatpci.c */
231 #define pci_module_init pci_register_driver
232 extern int pci_register_driver(struct pci_driver *drv);
233 extern void pci_unregister_driver(struct pci_driver *drv);
235 #endif /* PCI registration */
237 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 18))
238 #define pci_module_init pci_register_driver
239 #endif
241 #if (LINUX_VERSION_CODE < KERNEL_VERSION(2, 2, 18))
242 #ifdef MODULE
243 #define module_init(x) int init_module(void) { return x(); }
244 #define module_exit(x) void cleanup_module(void) { x(); }
245 #else
246 #define module_init(x) __initcall(x);
247 #define module_exit(x) __exitcall(x);
248 #endif
249 #endif /* LINUX_VERSION_CODE < KERNEL_VERSION(2, 2, 18) */
251 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 31)
252 #define WL_USE_NETDEV_OPS
253 #else
254 #undef WL_USE_NETDEV_OPS
255 #endif
257 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 31)) && defined(CONFIG_RFKILL)
258 #define WL_CONFIG_RFKILL
259 #else
260 #undef WL_CONFIG_RFKILL
261 #endif
263 #if (LINUX_VERSION_CODE < KERNEL_VERSION(2, 3, 48))
264 #define list_for_each(pos, head) \
265 for (pos = (head)->next; pos != (head); pos = pos->next)
266 #endif
268 #if (LINUX_VERSION_CODE < KERNEL_VERSION(2, 3, 13))
269 #define pci_resource_start(dev, bar) ((dev)->base_address[(bar)])
270 #elif (LINUX_VERSION_CODE < KERNEL_VERSION(2, 3, 44))
271 #define pci_resource_start(dev, bar) ((dev)->resource[(bar)].start)
272 #endif
274 #if (LINUX_VERSION_CODE < KERNEL_VERSION(2, 3, 23))
275 #define pci_enable_device(dev) do { } while (0)
276 #endif
278 #if (LINUX_VERSION_CODE < KERNEL_VERSION(2, 3, 14))
279 #define net_device device
280 #endif
282 #if (LINUX_VERSION_CODE < KERNEL_VERSION(2, 3, 42))
285 * DMA mapping
287 * See linux/Documentation/DMA-mapping.txt
290 #ifndef PCI_DMA_TODEVICE
291 #define PCI_DMA_TODEVICE 1
292 #define PCI_DMA_FROMDEVICE 2
293 #endif
295 typedef u32 dma_addr_t;
297 /* Pure 2^n version of get_order */
298 static inline int get_order(unsigned long size)
300 int order;
302 size = (size-1) >> (PAGE_SHIFT-1);
303 order = -1;
304 do {
305 size >>= 1;
306 order++;
307 } while (size);
308 return order;
311 static inline void *pci_alloc_consistent(struct pci_dev *hwdev, size_t size,
312 dma_addr_t *dma_handle)
314 void *ret;
315 int gfp = GFP_ATOMIC | GFP_DMA;
317 ret = (void *)__get_free_pages(gfp, get_order(size));
319 if (ret != NULL) {
320 memset(ret, 0, size);
321 *dma_handle = virt_to_bus(ret);
323 return ret;
325 static inline void pci_free_consistent(struct pci_dev *hwdev, size_t size,
326 void *vaddr, dma_addr_t dma_handle)
328 free_pages((unsigned long)vaddr, get_order(size));
330 #ifdef ILSIM
331 extern uint pci_map_single(void *dev, void *va, uint size, int direction);
332 extern void pci_unmap_single(void *dev, uint pa, uint size, int direction);
333 #else
334 #define pci_map_single(cookie, address, size, dir) virt_to_bus(address)
335 #define pci_unmap_single(cookie, address, size, dir)
336 #endif
338 #endif /* DMA mapping */
340 #if (LINUX_VERSION_CODE < KERNEL_VERSION(2, 3, 43))
342 #define dev_kfree_skb_any(a) dev_kfree_skb(a)
343 #define netif_down(dev) do { (dev)->start = 0; } while (0)
345 /* pcmcia-cs provides its own netdevice compatibility layer */
346 #ifndef _COMPAT_NETDEVICE_H
349 * SoftNet
351 * For pre-softnet kernels we need to tell the upper layer not to
352 * re-enter start_xmit() while we are in there. However softnet
353 * guarantees not to enter while we are in there so there is no need
354 * to do the netif_stop_queue() dance unless the transmit queue really
355 * gets stuck. This should also improve performance according to tests
356 * done by Aman Singla.
359 #define dev_kfree_skb_irq(a) dev_kfree_skb(a)
360 #define netif_wake_queue(dev) \
361 do { clear_bit(0, &(dev)->tbusy); mark_bh(NET_BH); } while (0)
362 #define netif_stop_queue(dev) set_bit(0, &(dev)->tbusy)
364 static inline void netif_start_queue(struct net_device *dev)
366 dev->tbusy = 0;
367 dev->interrupt = 0;
368 dev->start = 1;
371 #define netif_queue_stopped(dev) (dev)->tbusy
372 #define netif_running(dev) (dev)->start
374 #endif /* _COMPAT_NETDEVICE_H */
376 #define netif_device_attach(dev) netif_start_queue(dev)
377 #define netif_device_detach(dev) netif_stop_queue(dev)
379 /* 2.4.x renamed bottom halves to tasklets */
380 #define tasklet_struct tq_struct
381 static inline void tasklet_schedule(struct tasklet_struct *tasklet)
383 queue_task(tasklet, &tq_immediate);
384 mark_bh(IMMEDIATE_BH);
387 static inline void tasklet_init(struct tasklet_struct *tasklet,
388 void (*func)(unsigned long),
389 unsigned long data)
391 tasklet->next = NULL;
392 tasklet->sync = 0;
393 tasklet->routine = (void (*)(void *))func;
394 tasklet->data = (void *)data;
396 #define tasklet_kill(tasklet) { do {} while (0); }
398 /* 2.4.x introduced del_timer_sync() */
399 #define del_timer_sync(timer) del_timer(timer)
401 #else
403 #define netif_down(dev)
405 #endif /* SoftNet */
407 #if (LINUX_VERSION_CODE < KERNEL_VERSION(2, 4, 3))
410 * Emit code to initialise a tq_struct's routine and data pointers
412 #define PREPARE_TQUEUE(_tq, _routine, _data) \
413 do { \
414 (_tq)->routine = _routine; \
415 (_tq)->data = _data; \
416 } while (0)
419 * Emit code to initialise all of a tq_struct
421 #define INIT_TQUEUE(_tq, _routine, _data) \
422 do { \
423 INIT_LIST_HEAD(&(_tq)->list); \
424 (_tq)->sync = 0; \
425 PREPARE_TQUEUE((_tq), (_routine), (_data)); \
426 } while (0)
428 #endif /* LINUX_VERSION_CODE < KERNEL_VERSION(2, 4, 3) */
430 /* Power management related macro & routines */
431 #if LINUX_VERSION_CODE > KERNEL_VERSION(2, 6, 9)
432 #define PCI_SAVE_STATE(a, b) pci_save_state(a)
433 #define PCI_RESTORE_STATE(a, b) pci_restore_state(a)
434 #else
435 #define PCI_SAVE_STATE(a, b) pci_save_state(a, b)
436 #define PCI_RESTORE_STATE(a, b) pci_restore_state(a, b)
437 #endif
439 #if (LINUX_VERSION_CODE < KERNEL_VERSION(2, 4, 6))
440 static inline int
441 pci_save_state(struct pci_dev *dev, u32 *buffer)
443 int i;
444 if (buffer) {
445 for (i = 0; i < 16; i++)
446 pci_read_config_dword(dev, i * 4, &buffer[i]);
448 return 0;
451 static inline int
452 pci_restore_state(struct pci_dev *dev, u32 *buffer)
454 int i;
456 if (buffer) {
457 for (i = 0; i < 16; i++)
458 pci_write_config_dword(dev, i * 4, buffer[i]);
461 * otherwise, write the context information we know from bootup.
462 * This works around a problem where warm-booting from Windows
463 * combined with a D3(hot)->D0 transition causes PCI config
464 * header data to be forgotten.
466 else {
467 for (i = 0; i < 6; i ++)
468 pci_write_config_dword(dev,
469 PCI_BASE_ADDRESS_0 + (i * 4),
470 pci_resource_start(dev, i));
471 pci_write_config_byte(dev, PCI_INTERRUPT_LINE, dev->irq);
473 return 0;
475 #endif /* PCI power management */
477 /* Old cp0 access macros deprecated in 2.4.19 */
478 #if (LINUX_VERSION_CODE < KERNEL_VERSION(2, 4, 19))
479 #define read_c0_count() read_32bit_cp0_register(CP0_COUNT)
480 #endif
482 /* Module refcount handled internally in 2.6.x */
483 #if (LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 24))
484 #ifndef SET_MODULE_OWNER
485 #define SET_MODULE_OWNER(dev) do {} while (0)
486 #define OLD_MOD_INC_USE_COUNT MOD_INC_USE_COUNT
487 #define OLD_MOD_DEC_USE_COUNT MOD_DEC_USE_COUNT
488 #else
489 #define OLD_MOD_INC_USE_COUNT do {} while (0)
490 #define OLD_MOD_DEC_USE_COUNT do {} while (0)
491 #endif
492 #else /* LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 24) */
493 #ifndef SET_MODULE_OWNER
494 #define SET_MODULE_OWNER(dev) do {} while (0)
495 #endif
496 #ifndef MOD_INC_USE_COUNT
497 #define MOD_INC_USE_COUNT do {} while (0)
498 #endif
499 #ifndef MOD_DEC_USE_COUNT
500 #define MOD_DEC_USE_COUNT do {} while (0)
501 #endif
502 #define OLD_MOD_INC_USE_COUNT MOD_INC_USE_COUNT
503 #define OLD_MOD_DEC_USE_COUNT MOD_DEC_USE_COUNT
504 #endif /* LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 24) */
506 #ifndef SET_NETDEV_DEV
507 #define SET_NETDEV_DEV(net, pdev) do {} while (0)
508 #endif
510 #ifndef HAVE_FREE_NETDEV
511 #define free_netdev(dev) kfree(dev)
512 #endif
514 #if (LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 0))
515 /* struct packet_type redefined in 2.6.x */
516 #define af_packet_priv data
517 #endif
519 /* suspend args */
520 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 11)
521 #define DRV_SUSPEND_STATE_TYPE pm_message_t
522 #else
523 #define DRV_SUSPEND_STATE_TYPE uint32
524 #endif
526 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 19)
527 #define CHECKSUM_HW CHECKSUM_PARTIAL
528 #endif
530 typedef struct {
531 void *parent; /* some external entity that the thread supposed to work for */
532 struct task_struct *p_task;
533 long thr_pid;
534 int prio; /* priority */
535 struct semaphore sema;
536 int terminated;
537 struct completion completed;
538 } tsk_ctl_t;
541 /* requires tsk_ctl_t tsk argument, the caller's priv data is passed in owner ptr */
542 /* note this macro assumes there may be only one context waiting on thread's completion */
543 #ifdef DHD_DEBUG
544 #define DBG_THR(x) printk x
545 #else
546 #define DBG_THR(x)
547 #endif
549 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 0))
550 #define SMP_RD_BARRIER_DEPENDS(x) smp_read_barrier_depends(x)
551 #else
552 #define SMP_RD_BARRIER_DEPENDS(x) smp_rmb(x)
553 #endif
556 #define PROC_START(thread_func, owner, tsk_ctl, flags) \
558 sema_init(&((tsk_ctl)->sema), 0); \
559 init_completion(&((tsk_ctl)->completed)); \
560 (tsk_ctl)->parent = owner; \
561 (tsk_ctl)->terminated = FALSE; \
562 (tsk_ctl)->thr_pid = kernel_thread(thread_func, tsk_ctl, flags); \
563 if ((tsk_ctl)->thr_pid > 0) \
564 wait_for_completion(&((tsk_ctl)->completed)); \
565 DBG_THR(("%s thr:%lx started\n", __FUNCTION__, (tsk_ctl)->thr_pid)); \
568 #define PROC_STOP(tsk_ctl) \
570 (tsk_ctl)->terminated = TRUE; \
571 smp_wmb(); \
572 up(&((tsk_ctl)->sema)); \
573 wait_for_completion(&((tsk_ctl)->completed)); \
574 DBG_THR(("%s thr:%lx terminated OK\n", __FUNCTION__, (tsk_ctl)->thr_pid)); \
575 (tsk_ctl)->thr_pid = -1; \
578 /* ----------------------- */
580 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 31))
581 #define KILL_PROC(nr, sig) \
583 struct task_struct *tsk; \
584 struct pid *pid; \
585 pid = find_get_pid((pid_t)nr); \
586 tsk = pid_task(pid, PIDTYPE_PID); \
587 if (tsk) send_sig(sig, tsk, 1); \
589 #else
590 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 27)) && (LINUX_VERSION_CODE <= \
591 KERNEL_VERSION(2, 6, 30))
592 #define KILL_PROC(pid, sig) \
594 struct task_struct *tsk; \
595 tsk = find_task_by_vpid(pid); \
596 if (tsk) send_sig(sig, tsk, 1); \
598 #else
599 #define KILL_PROC(pid, sig) \
601 kill_proc(pid, sig, 1); \
603 #endif
604 #endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 31) */
606 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 0))
607 #include <linux/time.h>
608 #include <linux/wait.h>
609 #else
610 #include <linux/sched.h>
612 #define __wait_event_interruptible_timeout(wq, condition, ret) \
613 do { \
614 wait_queue_t __wait; \
615 init_waitqueue_entry(&__wait, current); \
617 add_wait_queue(&wq, &__wait); \
618 for (;;) { \
619 set_current_state(TASK_INTERRUPTIBLE); \
620 if (condition) \
621 break; \
622 if (!signal_pending(current)) { \
623 ret = schedule_timeout(ret); \
624 if (!ret) \
625 break; \
626 continue; \
628 ret = -ERESTARTSYS; \
629 break; \
631 current->state = TASK_RUNNING; \
632 remove_wait_queue(&wq, &__wait); \
633 } while (0)
635 #define wait_event_interruptible_timeout(wq, condition, timeout) \
636 ({ \
637 long __ret = timeout; \
638 if (!(condition)) \
639 __wait_event_interruptible_timeout(wq, condition, __ret); \
640 __ret; \
643 #endif /* (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 0)) */
646 For < 2.6.24, wl creates its own netdev but doesn't
647 align the priv area like the genuine alloc_netdev().
648 Since netdev_priv() always gives us the aligned address, it will
649 not match our unaligned address for < 2.6.24
651 #if (LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 24))
652 #define DEV_PRIV(dev) (dev->priv)
653 #else
654 #define DEV_PRIV(dev) netdev_priv(dev)
655 #endif
657 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 20)
658 #define WL_ISR(i, d, p) wl_isr((i), (d))
659 #else
660 #define WL_ISR(i, d, p) wl_isr((i), (d), (p))
661 #endif /* < 2.6.20 */
663 #if (LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 0))
664 #define netdev_priv(dev) dev->priv
665 #endif /* (LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 0)) */
667 #endif /* _linuxver_h_ */