BCM WL 6.30.102.9 (r366174)
[tomato.git] / release / src-rt / include / linuxver.h
blobe7c6c1f44b8c916f2c24b7e322ab9a1682c293f1
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) 2011, 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 312774 2012-02-03 22:20:14Z $
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)) */
35 #include <linux/module.h>
37 #if (LINUX_VERSION_CODE < KERNEL_VERSION(2, 3, 0))
38 /* __NO_VERSION__ must be defined for all linkables except one in 2.2 */
39 #ifdef __UNDEF_NO_VERSION__
40 #undef __NO_VERSION__
41 #else
42 #define __NO_VERSION__
43 #endif
44 #endif /* LINUX_VERSION_CODE < KERNEL_VERSION(2, 3, 0) */
46 #if LINUX_VERSION_CODE < KERNEL_VERSION(2, 5, 0)
47 #define module_param(_name_, _type_, _perm_) MODULE_PARM(_name_, "i")
48 #define module_param_string(_name_, _string_, _size_, _perm_) \
49 MODULE_PARM(_string_, "c" __MODULE_STRING(_size_))
50 #endif
52 /* linux/malloc.h is deprecated, use linux/slab.h instead. */
53 #if (LINUX_VERSION_CODE < KERNEL_VERSION(2, 4, 9))
54 #include <linux/malloc.h>
55 #else
56 #include <linux/slab.h>
57 #endif
59 #include <linux/types.h>
60 #include <linux/init.h>
61 #include <linux/mm.h>
62 #include <linux/string.h>
63 #include <linux/pci.h>
64 #include <linux/interrupt.h>
65 #include <linux/netdevice.h>
66 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 27))
67 #include <linux/semaphore.h>
68 #else
69 #include <asm/semaphore.h>
70 #endif /* (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 27)) */
71 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 28))
72 #undef IP_TOS
73 #endif /* (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 28)) */
74 #include <asm/io.h>
76 #if (LINUX_VERSION_CODE > KERNEL_VERSION(2, 5, 41))
77 #include <linux/workqueue.h>
78 #else
79 #include <linux/tqueue.h>
80 #ifndef work_struct
81 #define work_struct tq_struct
82 #endif
83 #ifndef INIT_WORK
84 #define INIT_WORK(_work, _func, _data) INIT_TQUEUE((_work), (_func), (_data))
85 #endif
86 #ifndef schedule_work
87 #define schedule_work(_work) schedule_task((_work))
88 #endif
89 #ifndef flush_scheduled_work
90 #define flush_scheduled_work() flush_scheduled_tasks()
91 #endif
92 #endif /* LINUX_VERSION_CODE > KERNEL_VERSION(2, 5, 41) */
94 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 19)
95 #define MY_INIT_WORK(_work, _func) INIT_WORK(_work, _func)
96 #else
97 #define MY_INIT_WORK(_work, _func) INIT_WORK(_work, _func, _work)
98 typedef void (*work_func_t)(void *work);
99 #endif /* >= 2.6.20 */
101 #if (LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 0))
102 /* Some distributions have their own 2.6.x compatibility layers */
103 #ifndef IRQ_NONE
104 typedef void irqreturn_t;
105 #define IRQ_NONE
106 #define IRQ_HANDLED
107 #define IRQ_RETVAL(x)
108 #endif
109 #else
110 typedef irqreturn_t(*FN_ISR) (int irq, void *dev_id, struct pt_regs *ptregs);
111 #endif /* LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 0) */
113 #if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 18)
114 #define IRQF_SHARED SA_SHIRQ
115 #endif /* < 2.6.18 */
117 #if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 17)
118 #ifdef CONFIG_NET_RADIO
119 #define CONFIG_WIRELESS_EXT
120 #endif
121 #endif /* < 2.6.17 */
123 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 5, 67)
124 #define MOD_INC_USE_COUNT
125 #define MOD_DEC_USE_COUNT
126 #endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(2, 5, 67) */
128 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 32)
129 #include <linux/sched.h>
130 #endif
132 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 29)
133 #include <net/lib80211.h>
134 #endif
135 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 29)
136 #include <linux/ieee80211.h>
137 #else
138 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 14)
139 #include <net/ieee80211.h>
140 #endif
141 #endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 30) */
143 #if defined(CONFIG_PCMCIA) || defined(CONFIG_PCMCIA_MODULE)
145 #if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 27)
146 #include <pcmcia/version.h>
147 #endif /* LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 27) */
149 #if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 36)
150 #include <pcmcia/cs_types.h>
151 #include <pcmcia/cs.h>
152 #endif
153 #include <pcmcia/cistpl.h>
154 #include <pcmcia/cisreg.h>
155 #include <pcmcia/ds.h>
157 #if (LINUX_VERSION_CODE < KERNEL_VERSION(2, 5, 69))
158 /* In 2.5 (as of 2.5.69 at least) there is a cs_error exported which
159 * does this, but it's not in 2.4 so we do our own for now.
161 static inline void
162 cs_error(client_handle_t handle, int func, int ret)
164 error_info_t err = { func, ret };
165 CardServices(ReportError, handle, &err);
167 #endif
169 #if (LINUX_VERSION_CODE > KERNEL_VERSION(2, 6, 16))
171 typedef struct pcmcia_device dev_link_t;
173 #endif
175 #endif /* CONFIG_PCMCIA */
177 #ifndef __exit
178 #define __exit
179 #endif
180 #ifndef __devexit
181 #define __devexit
182 #endif
183 #ifndef __devinit
184 #define __devinit __init
185 #endif
186 #ifndef __devinitdata
187 #define __devinitdata
188 #endif
189 #ifndef __devexit_p
190 #define __devexit_p(x) x
191 #endif
193 #if (LINUX_VERSION_CODE < KERNEL_VERSION(2, 4, 0))
195 #define pci_get_drvdata(dev) (dev)->sysdata
196 #define pci_set_drvdata(dev, value) (dev)->sysdata = (value)
199 * New-style (2.4.x) PCI/hot-pluggable PCI/CardBus registration
202 struct pci_device_id {
203 unsigned int vendor, device; /* Vendor and device ID or PCI_ANY_ID */
204 unsigned int subvendor, subdevice; /* Subsystem ID's or PCI_ANY_ID */
205 unsigned int class, class_mask; /* (class,subclass,prog-if) triplet */
206 unsigned long driver_data; /* Data private to the driver */
209 struct pci_driver {
210 struct list_head node;
211 char *name;
212 const struct pci_device_id *id_table; /* NULL if wants all devices */
213 int (*probe)(struct pci_dev *dev,
214 const struct pci_device_id *id); /* New device inserted */
215 void (*remove)(struct pci_dev *dev); /* Device removed (NULL if not a hot-plug
216 * capable driver)
218 void (*suspend)(struct pci_dev *dev); /* Device suspended */
219 void (*resume)(struct pci_dev *dev); /* Device woken up */
222 #define MODULE_DEVICE_TABLE(type, name)
223 #define PCI_ANY_ID (~0)
225 /* compatpci.c */
226 #define pci_module_init pci_register_driver
227 extern int pci_register_driver(struct pci_driver *drv);
228 extern void pci_unregister_driver(struct pci_driver *drv);
230 #endif /* PCI registration */
232 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 18))
233 #define pci_module_init pci_register_driver
234 #endif
236 #if (LINUX_VERSION_CODE < KERNEL_VERSION(2, 2, 18))
237 #ifdef MODULE
238 #define module_init(x) int init_module(void) { return x(); }
239 #define module_exit(x) void cleanup_module(void) { x(); }
240 #else
241 #define module_init(x) __initcall(x);
242 #define module_exit(x) __exitcall(x);
243 #endif
244 #endif /* LINUX_VERSION_CODE < KERNEL_VERSION(2, 2, 18) */
246 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 31)
247 #define WL_USE_NETDEV_OPS
248 #else
249 #undef WL_USE_NETDEV_OPS
250 #endif
252 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 31)) && defined(CONFIG_RFKILL)
253 #define WL_CONFIG_RFKILL
254 #else
255 #undef WL_CONFIG_RFKILL
256 #endif
258 #if (LINUX_VERSION_CODE < KERNEL_VERSION(2, 3, 48))
259 #define list_for_each(pos, head) \
260 for (pos = (head)->next; pos != (head); pos = pos->next)
261 #endif
263 #if (LINUX_VERSION_CODE < KERNEL_VERSION(2, 3, 13))
264 #define pci_resource_start(dev, bar) ((dev)->base_address[(bar)])
265 #elif (LINUX_VERSION_CODE < KERNEL_VERSION(2, 3, 44))
266 #define pci_resource_start(dev, bar) ((dev)->resource[(bar)].start)
267 #endif
269 #if (LINUX_VERSION_CODE < KERNEL_VERSION(2, 3, 23))
270 #define pci_enable_device(dev) do { } while (0)
271 #endif
273 #if (LINUX_VERSION_CODE < KERNEL_VERSION(2, 3, 14))
274 #define net_device device
275 #endif
277 #if (LINUX_VERSION_CODE < KERNEL_VERSION(2, 3, 42))
280 * DMA mapping
282 * See linux/Documentation/DMA-mapping.txt
285 #ifndef PCI_DMA_TODEVICE
286 #define PCI_DMA_TODEVICE 1
287 #define PCI_DMA_FROMDEVICE 2
288 #endif
290 typedef u32 dma_addr_t;
292 /* Pure 2^n version of get_order */
293 static inline int get_order(unsigned long size)
295 int order;
297 size = (size-1) >> (PAGE_SHIFT-1);
298 order = -1;
299 do {
300 size >>= 1;
301 order++;
302 } while (size);
303 return order;
306 static inline void *pci_alloc_consistent(struct pci_dev *hwdev, size_t size,
307 dma_addr_t *dma_handle)
309 void *ret;
310 int gfp = GFP_ATOMIC | GFP_DMA;
312 ret = (void *)__get_free_pages(gfp, get_order(size));
314 if (ret != NULL) {
315 memset(ret, 0, size);
316 *dma_handle = virt_to_bus(ret);
318 return ret;
320 static inline void pci_free_consistent(struct pci_dev *hwdev, size_t size,
321 void *vaddr, dma_addr_t dma_handle)
323 free_pages((unsigned long)vaddr, get_order(size));
325 #ifdef ILSIM
326 extern uint pci_map_single(void *dev, void *va, uint size, int direction);
327 extern void pci_unmap_single(void *dev, uint pa, uint size, int direction);
328 #else
329 #define pci_map_single(cookie, address, size, dir) virt_to_bus(address)
330 #define pci_unmap_single(cookie, address, size, dir)
331 #endif
333 #endif /* DMA mapping */
335 #if (LINUX_VERSION_CODE < KERNEL_VERSION(2, 3, 43))
337 #define dev_kfree_skb_any(a) dev_kfree_skb(a)
338 #define netif_down(dev) do { (dev)->start = 0; } while (0)
340 /* pcmcia-cs provides its own netdevice compatibility layer */
341 #ifndef _COMPAT_NETDEVICE_H
344 * SoftNet
346 * For pre-softnet kernels we need to tell the upper layer not to
347 * re-enter start_xmit() while we are in there. However softnet
348 * guarantees not to enter while we are in there so there is no need
349 * to do the netif_stop_queue() dance unless the transmit queue really
350 * gets stuck. This should also improve performance according to tests
351 * done by Aman Singla.
354 #define dev_kfree_skb_irq(a) dev_kfree_skb(a)
355 #define netif_wake_queue(dev) \
356 do { clear_bit(0, &(dev)->tbusy); mark_bh(NET_BH); } while (0)
357 #define netif_stop_queue(dev) set_bit(0, &(dev)->tbusy)
359 static inline void netif_start_queue(struct net_device *dev)
361 dev->tbusy = 0;
362 dev->interrupt = 0;
363 dev->start = 1;
366 #define netif_queue_stopped(dev) (dev)->tbusy
367 #define netif_running(dev) (dev)->start
369 #endif /* _COMPAT_NETDEVICE_H */
371 #define netif_device_attach(dev) netif_start_queue(dev)
372 #define netif_device_detach(dev) netif_stop_queue(dev)
374 /* 2.4.x renamed bottom halves to tasklets */
375 #define tasklet_struct tq_struct
376 static inline void tasklet_schedule(struct tasklet_struct *tasklet)
378 queue_task(tasklet, &tq_immediate);
379 mark_bh(IMMEDIATE_BH);
382 static inline void tasklet_init(struct tasklet_struct *tasklet,
383 void (*func)(unsigned long),
384 unsigned long data)
386 tasklet->next = NULL;
387 tasklet->sync = 0;
388 tasklet->routine = (void (*)(void *))func;
389 tasklet->data = (void *)data;
391 #define tasklet_kill(tasklet) { do {} while (0); }
393 /* 2.4.x introduced del_timer_sync() */
394 #define del_timer_sync(timer) del_timer(timer)
396 #else
398 #define netif_down(dev)
400 #endif /* SoftNet */
402 #if (LINUX_VERSION_CODE < KERNEL_VERSION(2, 4, 3))
405 * Emit code to initialise a tq_struct's routine and data pointers
407 #define PREPARE_TQUEUE(_tq, _routine, _data) \
408 do { \
409 (_tq)->routine = _routine; \
410 (_tq)->data = _data; \
411 } while (0)
414 * Emit code to initialise all of a tq_struct
416 #define INIT_TQUEUE(_tq, _routine, _data) \
417 do { \
418 INIT_LIST_HEAD(&(_tq)->list); \
419 (_tq)->sync = 0; \
420 PREPARE_TQUEUE((_tq), (_routine), (_data)); \
421 } while (0)
423 #endif /* LINUX_VERSION_CODE < KERNEL_VERSION(2, 4, 3) */
425 /* Power management related macro & routines */
426 #if LINUX_VERSION_CODE > KERNEL_VERSION(2, 6, 9)
427 #define PCI_SAVE_STATE(a, b) pci_save_state(a)
428 #define PCI_RESTORE_STATE(a, b) pci_restore_state(a)
429 #else
430 #define PCI_SAVE_STATE(a, b) pci_save_state(a, b)
431 #define PCI_RESTORE_STATE(a, b) pci_restore_state(a, b)
432 #endif
434 #if (LINUX_VERSION_CODE < KERNEL_VERSION(2, 4, 6))
435 static inline int
436 pci_save_state(struct pci_dev *dev, u32 *buffer)
438 int i;
439 if (buffer) {
440 for (i = 0; i < 16; i++)
441 pci_read_config_dword(dev, i * 4, &buffer[i]);
443 return 0;
446 static inline int
447 pci_restore_state(struct pci_dev *dev, u32 *buffer)
449 int i;
451 if (buffer) {
452 for (i = 0; i < 16; i++)
453 pci_write_config_dword(dev, i * 4, buffer[i]);
456 * otherwise, write the context information we know from bootup.
457 * This works around a problem where warm-booting from Windows
458 * combined with a D3(hot)->D0 transition causes PCI config
459 * header data to be forgotten.
461 else {
462 for (i = 0; i < 6; i ++)
463 pci_write_config_dword(dev,
464 PCI_BASE_ADDRESS_0 + (i * 4),
465 pci_resource_start(dev, i));
466 pci_write_config_byte(dev, PCI_INTERRUPT_LINE, dev->irq);
468 return 0;
470 #endif /* PCI power management */
472 /* Old cp0 access macros deprecated in 2.4.19 */
473 #if (LINUX_VERSION_CODE < KERNEL_VERSION(2, 4, 19))
474 #define read_c0_count() read_32bit_cp0_register(CP0_COUNT)
475 #endif
477 /* Module refcount handled internally in 2.6.x */
478 #if (LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 24))
479 #ifndef SET_MODULE_OWNER
480 #define SET_MODULE_OWNER(dev) do {} while (0)
481 #define OLD_MOD_INC_USE_COUNT MOD_INC_USE_COUNT
482 #define OLD_MOD_DEC_USE_COUNT MOD_DEC_USE_COUNT
483 #else
484 #define OLD_MOD_INC_USE_COUNT do {} while (0)
485 #define OLD_MOD_DEC_USE_COUNT do {} while (0)
486 #endif
487 #else /* LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 24) */
488 #ifndef SET_MODULE_OWNER
489 #define SET_MODULE_OWNER(dev) do {} while (0)
490 #endif
491 #ifndef MOD_INC_USE_COUNT
492 #define MOD_INC_USE_COUNT do {} while (0)
493 #endif
494 #ifndef MOD_DEC_USE_COUNT
495 #define MOD_DEC_USE_COUNT do {} while (0)
496 #endif
497 #define OLD_MOD_INC_USE_COUNT MOD_INC_USE_COUNT
498 #define OLD_MOD_DEC_USE_COUNT MOD_DEC_USE_COUNT
499 #endif /* LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 24) */
501 #ifndef SET_NETDEV_DEV
502 #define SET_NETDEV_DEV(net, pdev) do {} while (0)
503 #endif
505 #ifndef HAVE_FREE_NETDEV
506 #define free_netdev(dev) kfree(dev)
507 #endif
509 #if (LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 0))
510 /* struct packet_type redefined in 2.6.x */
511 #define af_packet_priv data
512 #endif
514 /* suspend args */
515 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 11)
516 #define DRV_SUSPEND_STATE_TYPE pm_message_t
517 #else
518 #define DRV_SUSPEND_STATE_TYPE uint32
519 #endif
521 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 19)
522 #define CHECKSUM_HW CHECKSUM_PARTIAL
523 #endif
525 typedef struct {
526 void *parent; /* some external entity that the thread supposed to work for */
527 struct task_struct *p_task;
528 long thr_pid;
529 int prio; /* priority */
530 struct semaphore sema;
531 int terminated;
532 struct completion completed;
533 } tsk_ctl_t;
536 /* requires tsk_ctl_t tsk argument, the caller's priv data is passed in owner ptr */
537 /* note this macro assumes there may be only one context waiting on thread's completion */
538 #ifdef DHD_DEBUG
539 #define DBG_THR(x) printk x
540 #else
541 #define DBG_THR(x)
542 #endif
544 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 0))
545 #define SMP_RD_BARRIER_DEPENDS(x) smp_read_barrier_depends(x)
546 #else
547 #define SMP_RD_BARRIER_DEPENDS(x) smp_rmb(x)
548 #endif
551 #define PROC_START(thread_func, owner, tsk_ctl, flags) \
553 sema_init(&((tsk_ctl)->sema), 0); \
554 init_completion(&((tsk_ctl)->completed)); \
555 (tsk_ctl)->parent = owner; \
556 (tsk_ctl)->terminated = FALSE; \
557 (tsk_ctl)->thr_pid = kernel_thread(thread_func, tsk_ctl, flags); \
558 if ((tsk_ctl)->thr_pid > 0) \
559 wait_for_completion(&((tsk_ctl)->completed)); \
560 DBG_THR(("%s thr:%lx started\n", __FUNCTION__, (tsk_ctl)->thr_pid)); \
563 #define PROC_STOP(tsk_ctl) \
565 (tsk_ctl)->terminated = TRUE; \
566 smp_wmb(); \
567 up(&((tsk_ctl)->sema)); \
568 wait_for_completion(&((tsk_ctl)->completed)); \
569 DBG_THR(("%s thr:%lx terminated OK\n", __FUNCTION__, (tsk_ctl)->thr_pid)); \
570 (tsk_ctl)->thr_pid = -1; \
573 /* ----------------------- */
575 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 31))
576 #define KILL_PROC(nr, sig) \
578 struct task_struct *tsk; \
579 struct pid *pid; \
580 pid = find_get_pid((pid_t)nr); \
581 tsk = pid_task(pid, PIDTYPE_PID); \
582 if (tsk) send_sig(sig, tsk, 1); \
584 #else
585 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 27)) && (LINUX_VERSION_CODE <= \
586 KERNEL_VERSION(2, 6, 30))
587 #define KILL_PROC(pid, sig) \
589 struct task_struct *tsk; \
590 tsk = find_task_by_vpid(pid); \
591 if (tsk) send_sig(sig, tsk, 1); \
593 #else
594 #define KILL_PROC(pid, sig) \
596 kill_proc(pid, sig, 1); \
598 #endif
599 #endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 31) */
601 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 0))
602 #include <linux/time.h>
603 #include <linux/wait.h>
604 #else
605 #include <linux/sched.h>
607 #define __wait_event_interruptible_timeout(wq, condition, ret) \
608 do { \
609 wait_queue_t __wait; \
610 init_waitqueue_entry(&__wait, current); \
612 add_wait_queue(&wq, &__wait); \
613 for (;;) { \
614 set_current_state(TASK_INTERRUPTIBLE); \
615 if (condition) \
616 break; \
617 if (!signal_pending(current)) { \
618 ret = schedule_timeout(ret); \
619 if (!ret) \
620 break; \
621 continue; \
623 ret = -ERESTARTSYS; \
624 break; \
626 current->state = TASK_RUNNING; \
627 remove_wait_queue(&wq, &__wait); \
628 } while (0)
630 #define wait_event_interruptible_timeout(wq, condition, timeout) \
631 ({ \
632 long __ret = timeout; \
633 if (!(condition)) \
634 __wait_event_interruptible_timeout(wq, condition, __ret); \
635 __ret; \
638 #endif /* (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 0)) */
641 For < 2.6.24, wl creates its own netdev but doesn't
642 align the priv area like the genuine alloc_netdev().
643 Since netdev_priv() always gives us the aligned address, it will
644 not match our unaligned address for < 2.6.24
646 #if (LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 24))
647 #define DEV_PRIV(dev) (dev->priv)
648 #else
649 #define DEV_PRIV(dev) netdev_priv(dev)
650 #endif
652 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 20)
653 #define WL_ISR(i, d, p) wl_isr((i), (d))
654 #else
655 #define WL_ISR(i, d, p) wl_isr((i), (d), (p))
656 #endif /* < 2.6.20 */
658 #if (LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 0))
659 #define netdev_priv(dev) dev->priv
660 #endif /* (LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 0)) */
662 #endif /* _linuxver_h_ */