📄 wlan_compat.h
字号:
({ \ long __ret = timeout; \ if (!(condition)) \ __wait_event_interruptible_timeout(wq, condition, __ret); \ __ret; \})#endif#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,4,20))#ifdef _LINUX_LIST_Hstatic inline void list_move_tail(struct list_head *list, struct list_head *head){ __list_del(list->prev, list->next); list_add_tail(list, head);}static inline void __list_splice(struct list_head *list, struct list_head *head){ struct list_head *first = list->next; struct list_head *last = list->prev; struct list_head *at = head->next; first->prev = head; head->next = first; last->next = at; at->prev = last;}static inline void list_move(struct list_head *list, struct list_head *head){ __list_del(list->prev, list->next); list_add(list, head);}static inline void list_splice_init(struct list_head *list, struct list_head *head){ if (!list_empty(list)) { __list_splice(list, head); INIT_LIST_HEAD(list); }}#endif // LIST_H#endif#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,1,90))#define spin_lock(l) do { } while (0)#define spin_unlock(l) do { } while (0)#define spin_lock_irqsave(l,f) do { save_flags(f); cli(); } while (0)#define spin_unlock_irqrestore(l,f) do { restore_flags(f); } while (0)#define spin_lock_init(s) do { } while (0)#define spin_trylock(l) (1)typedef int spinlock_t;#endif#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,4,0)) // XXX ???#define spin_lock_bh spin_lock#endif#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,4,0))#ifdef CONFIG_SMP#define spin_is_locked(x) (*(volatile char *)(&(x)->lock) <= 0)#else#define spin_is_locked(l) (0)#endif#endif#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,4,28))#define __user#define __iomem#endif#ifdef _LINUX_PROC_FS_H#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,3,25))extern inline struct proc_dir_entry *create_proc_read_entry(const char *name, mode_t mode, struct proc_dir_entry *base, read_proc_t *read_proc, void *data){ struct proc_dir_entry *res = create_proc_entry(name, mode, base); if (res) { res->read_proc = read_proc; res->data = data; } return res;}#endif#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,3,29))#ifndef proc_mkdir#define proc_mkdir(name, root) create_proc_entry(name, S_IFDIR, root)#endif#endif#endif /* _LINUX_PROC_FS_H */#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0))#ifndef INIT_TQUEUE#define PREPARE_TQUEUE(_tq, _routine, _data) \ do { \ (_tq)->routine = _routine; \ (_tq)->data = _data; \ } while (0)#define INIT_TQUEUE(_tq, _routine, _data) \ do { \ INIT_LIST_HEAD(&(_tq)->list); \ (_tq)->sync = 0; \ PREPARE_TQUEUE((_tq), (_routine), (_data)); \ } while (0)#endif#ifndef INIT_WORK#define work_struct tq_struct#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,4,0))#define schedule_work(a) queue_task(a, &tq_scheduler)#else#define schedule_work(a) schedule_task(a)#endif#define flush_scheduled_work flush_scheduled_tasks#define INIT_WORK(_wq, _routine, _data) INIT_TQUEUE(_wq, _routine, _data)#define PREPARE_WORK(_wq, _routine, _data) PREPARE_TQUEUE(_wq, _routine, _data)#endif#endif // < 2.5 kernel#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,3,38))typedef struct device netdevice_t;#elif (LINUX_VERSION_CODE < KERNEL_VERSION(2,4,4))typedef struct net_device netdevice_t;#else#undef netdevice_ttypedef struct net_device netdevice_t;#endif#ifdef WIRELESS_EXT#if (WIRELESS_EXT < 13)struct iw_request_info{ __u16 cmd; /* Wireless Extension command */ __u16 flags; /* More to come ;-) */};#endif#endif#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,1,18))#define MODULE_PARM(a,b) extern int __bogus_decl#define MODULE_AUTHOR(a) extern int __bogus_decl#define MODULE_DESCRIPTION(a) extern int __bogus_decl#define MODULE_SUPPORTED_DEVICE(a) extern int __bogus_decl#undef GET_USE_COUNT#define GET_USE_COUNT(m) mod_use_count_#endif#ifndef MODULE_OWNER#define MODULE_OWNER(a) extern int __bogus_decl#define ANCIENT_MODULE_CODE#endif#ifndef MODULE_LICENSE#define MODULE_LICENSE(m) extern int __bogus_decl#endif/* TODO: Do we care about this? */#ifndef MODULE_DEVICE_TABLE#define MODULE_DEVICE_TABLE(foo,bar)#endif#define wlan_minutes2ticks(a) ((a)*(wlan_ticks_per_sec * 60))#define wlan_seconds2ticks(a) ((a)*(wlan_ticks_per_sec))#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,5,47))#define NEW_MODULE_CODE#ifdef ANCIENT_MODULE_CODE#undef ANCIENT_MODULE_CODE#endif#elif (LINUX_VERSION_CODE < KERNEL_VERSION(2,4,25))#define module_param(name, type, perm) \ static inline void *__check_existence_##name(void) { return &name; } \ MODULE_PARM(name, _MODULE_PARM_STRING_ ## type)#define _MODULE_PARM_STRING_byte "b"#define _MODULE_PARM_STRING_short "h"#define _MODULE_PARM_STRING_ushort "h"#define _MODULE_PARM_STRING_int "i"#define _MODULE_PARM_STRING_uint "i"#define _MODULE_PARM_STRING_long "l"#define _MODULE_PARM_STRING_ulong "l"#define _MODULE_PARM_STRING_bool "i"#endif/* linux < 2.5.69 */#ifndef IRQ_NONEtypedef void irqreturn_t;#define IRQ_NONE#define IRQ_HANDLED#define IRQ_RETVAL(x)#endif#ifndef in_atomic#define in_atomic() 0#endif#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,13)) #define URB_ASYNC_UNLINK 0#endif#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,7))#define URB_ASYNC_UNLINK USB_ASYNC_UNLINK#define usb_fill_bulk_urb FILL_BULK_URB#define usb_kill_urb usb_unlink_urb#else#define USB_QUEUE_BULK 0#endif#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,11)) typedef u32 pm_message_t;#endif#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,9)) #define hotplug_path "/etc/hotplug/wlan.agent"#endif#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,0))#define free_netdev(x) kfree(x) #endif#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,9))#define eth_hdr(x) (x)->mac.ethernet#endif#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,4,0))#define del_timer_sync(a) del_timer(a)#endif#ifndef might_sleep#define might_sleep(a) do { } while (0)#endif/* Apparently 2.4.2 ethtool is quite different, maybe newer too? */#if (defined(SIOETHTOOL) && !defined(ETHTOOL_GDRVINFO))#undef SIOETHTOOL#endif// pcmcia-cs stuff#if ((LINUX_VERSION_CODE < KERNEL_VERSION(2,5,68)) && \ !defined(pcmcia_access_configuration_register))#define pcmcia_access_configuration_register(handle, reg) \ CardServices(AccessConfigurationRegister, handle, reg)#define pcmcia_register_client(handle, reg) \ CardServices(RegisterClient, handle, reg)#define pcmcia_deregister_client(handle) \ CardServices(DeregisterClient, handle)#define pcmcia_get_first_tuple(handle, tuple) \ CardServices(GetFirstTuple, handle, tuple)#define pcmcia_get_next_tuple(handle, tuple) \ CardServices(GetNextTuple, handle, tuple)#define pcmcia_get_tuple_data(handle, tuple) \ CardServices(GetTupleData, handle, tuple)#define pcmcia_parse_tuple(handle, tuple, parse) \ CardServices(ParseTuple, handle, tuple, parse)#define pcmcia_get_configuration_info(handle, config) \ CardServices(GetConfigurationInfo, handle, config)#define pcmcia_request_io(handle, req) \ CardServices(RequestIO, handle, req)#define pcmcia_request_irq(handle, req) \ CardServices(RequestIRQ, handle, req)#define pcmcia_request_configuration(handle, req) \ CardServices(RequestConfiguration, handle, req)#define pcmcia_release_configuration(handle) \ CardServices(ReleaseConfiguration, handle)#define pcmcia_release_io(handle, req) \ CardServices(ReleaseIO, handle, req)#define pcmcia_release_irq(handle, req) \ CardServices(ReleaseIRQ, handle, req)#define pcmcia_release_window(win) \ CardServices(ReleaseWindow, win)#define pcmcia_get_card_services_info(info) \ CardServices(GetCardServicesInfo, info)#define pcmcia_report_error(handle, err) \ CardServices(ReportError, handle, err)#endif#endif /* __KERNEL__ *//*=============================================================*//*------ Hardware Portability Macros --------------------------*//*=============================================================*/#define ieee2host16(n) __le16_to_cpu(n)#define ieee2host32(n) __le32_to_cpu(n)#define host2ieee16(n) __cpu_to_le16(n)#define host2ieee32(n) __cpu_to_le32(n)#if (WLAN_CPU_FAMILY != WLAN_MIPS)typedef UINT32 phys_t;#endif#if (WLAN_CPU_FAMILY == WLAN_PPC) #define wlan_inw(a) in_be16((unsigned short *)((a)+_IO_BASE)) #define wlan_inw_le16_to_cpu(a) inw((a)) #define wlan_outw(v,a) out_be16((unsigned short *)((a)+_IO_BASE), (v)) #define wlan_outw_cpu_to_le16(v,a) outw((v),(a))#else #define wlan_inw(a) inw((a)) #define wlan_inw_le16_to_cpu(a) __cpu_to_le16(inw((a))) #define wlan_outw(v,a) outw((v),(a)) #define wlan_outw_cpu_to_le16(v,a) outw(__cpu_to_le16((v)),(a))#endif/*=============================================================*//*--- General Macros ------------------------------------------*//*=============================================================*/#define wlan_max(a, b) (((a) > (b)) ? (a) : (b))#define wlan_min(a, b) (((a) < (b)) ? (a) : (b))#define wlan_isprint(c) (((c) > (0x19)) && ((c) < (0x7f)))#define wlan_hexchar(x) (((x) < 0x0a) ? ('0' + (x)) : ('a' + ((x) - 0x0a)))/* Create a string of printable chars from something that might not be *//* It's recommended that the str be 4*len + 1 bytes long */#define wlan_mkprintstr(buf, buflen, str, strlen) \{ \ int i = 0; \ int j = 0; \ memset(str, 0, (strlen)); \ for (i = 0; i < (buflen); i++) { \ if ( wlan_isprint((buf)[i]) ) { \ (str)[j] = (buf)[i]; \ j++; \ } else { \ (str)[j] = '\\'; \ (str)[j+1] = 'x'; \ (str)[j+2] = wlan_hexchar(((buf)[i] & 0xf0) >> 4); \ (str)[j+3] = wlan_hexchar(((buf)[i] & 0x0f)); \ j += 4; \ } \ } \}/*=============================================================*//*--- Variables -----------------------------------------------*//*=============================================================*/#ifdef WLAN_INCLUDE_DEBUGextern int wlan_debug;#endifextern int wlan_ethconv; /* What's the default ethconv? *//*=============================================================*//*--- Functions -----------------------------------------------*//*=============================================================*/#endif /* _WLAN_COMPAT_H */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -