Main Page | Data Structures | Directories | File List | Data Fields | Globals

hostap_compat.h

Go to the documentation of this file.
00001 #ifndef HOSTAP_COMPAT_H
00002 #define HOSTAP_COMPAT_H
00003 
00004 #if (LINUX_VERSION_CODE > KERNEL_VERSION(2,5,47))
00005 #define NEW_MODULE_CODE
00006 #endif
00007 
00008 #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,4,0))
00009 /* 2.2 compatibility */
00010 
00011 #include <linux/skbuff.h>
00012 #include <linux/kcomp.h>
00013 #include <asm/hardirq.h>
00014 
00015 #ifndef spin_lock_bh
00016 #define spin_lock_bh(lock) spin_lock_irq(lock)
00017 #define spin_unlock_bh(lock) spin_unlock_irq(lock)
00018 #endif
00019 
00020 #ifndef read_lock_bh
00021 #define read_lock_bh(lock) read_lock_irq(lock)
00022 #define read_unlock_bh(lock) read_unlock_irq(lock)
00023 #define rwlock_init(l)
00024 #endif
00025 
00026 #ifndef __constant_cpu_to_le16
00027 #define __constant_cpu_to_le16 __cpu_to_le16
00028 #endif
00029 
00030 #ifndef dev_get_by_name
00031 #define dev_get_by_name(dev) dev_get(dev)
00032 #endif
00033 
00034 #define PRISM2_NETDEV_EXTRA IFNAMSIZ
00035 #define prism2_set_dev_name(dev, pos) (dev)->name = (char *) (pos)
00036 
00037 #define HOSTAP_QUEUE struct tq_struct
00038 
00039 /* tq_scheduler was removed in 2.4.0-test12 */
00040 #define PRISM2_SCHEDULE_TASK(q) \
00041 MOD_INC_USE_COUNT; \
00042 queue_task((q), &tq_scheduler);
00043 
00044 static inline void flush_scheduled_work(void)
00045 {
00046         schedule();
00047         schedule();
00048 }
00049 
00050 static inline void INIT_WORK(struct tq_struct *tq,
00051                              void (*routine)(void *), void *data)
00052 {
00053         tq->next = NULL;
00054         tq->sync = 0;
00055         tq->routine = routine;
00056         tq->data = data;
00057 }
00058 
00059 #define HOSTAP_TASKLET struct tq_struct
00060 
00061 static inline void tasklet_schedule(struct tq_struct *q)
00062 {
00063         queue_task(q, &tq_immediate);
00064         mark_bh(IMMEDIATE_BH);
00065 }
00066 
00067 typedef void (*tasklet_func)(void *);
00068 
00069 #define HOSTAP_TASKLET_INIT(q, f, d) \
00070 do { memset((q), 0, sizeof(*(q))); \
00071 (q)->routine = (tasklet_func) (f); \
00072 (q)->data = (void *) (d); } \
00073 while (0)
00074 
00075 
00076 static inline void dev_kfree_skb_any(struct sk_buff *skb)
00077 {
00078         if (in_interrupt())
00079                 dev_kfree_skb_irq(skb);
00080         else
00081                 dev_kfree_skb(skb);
00082 }
00083 
00084 static __inline__ void list_del_init(struct list_head *entry)
00085 {
00086         __list_del(entry->prev, entry->next);
00087         INIT_LIST_HEAD(entry);
00088 }
00089 
00090 #ifndef list_for_each_safe
00091 #define list_for_each_safe(pos, n, head) \
00092         for (pos = (head)->next, n = pos->next; pos != (head); \
00093                 pos = n, n = pos->next)
00094 #endif
00095 
00096 /* end 2.2 compatibility */
00097 
00098 #else /* kernel < 2.4.0 */
00099 
00100 /* no extra space needed for 2.4.x net_device */
00101 #define PRISM2_NETDEV_EXTRA 0
00102 #define prism2_set_dev_name(dev, pos) do { } while (0)
00103 
00104 #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,5,44))
00105 
00106 #define HOSTAP_QUEUE struct tq_struct
00107 
00108 #define PRISM2_SCHEDULE_TASK(q) \
00109 MOD_INC_USE_COUNT; \
00110 if (schedule_task((q)) == 0) \
00111         MOD_DEC_USE_COUNT;
00112 
00113 static inline void flush_scheduled_work(void)
00114 {
00115         flush_scheduled_tasks();
00116 }
00117 
00118 static inline void INIT_WORK(struct tq_struct *tq,
00119                              void (*routine)(void *), void *data)
00120 {
00121         INIT_LIST_HEAD(&tq->list);
00122         tq->sync = 0;
00123         tq->routine = routine;
00124         tq->data = data;
00125 }
00126 
00127 #else /* kernel < 2.5.44 */
00128 
00129 #define HOSTAP_QUEUE struct work_struct
00130 
00131 #ifdef NEW_MODULE_CODE
00132 #define PRISM2_SCHEDULE_TASK(q) schedule_work(q);
00133 #else /* NEW_MODULE_CODE */
00134 #define PRISM2_SCHEDULE_TASK(q) \
00135 MOD_INC_USE_COUNT; \
00136 if (schedule_work((q)) == 0) \
00137         MOD_DEC_USE_COUNT;
00138 #endif /* NEW_MODULE_CODE */
00139 
00140 #endif /* kernel < 2.5.44 */
00141 
00142 #define HOSTAP_TASKLET struct tasklet_struct
00143 
00144 #define HOSTAP_TASKLET_INIT(q, f, d) \
00145 do { memset((q), 0, sizeof(*(q))); (q)->func = (f); (q)->data = (d); } \
00146 while (0)
00147 
00148 #endif /* kernel < 2.4.0 */
00149 
00150 
00151 #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,4,19))
00152 #define yield() schedule()
00153 #endif
00154 
00155 
00156 /* Interrupt handler backwards compatibility for Linux < 2.5.69 */
00157 #ifndef IRQ_NONE
00158 #define IRQ_NONE
00159 #define IRQ_HANDLED
00160 #define IRQ_RETVAL(x)
00161 typedef void irqreturn_t;
00162 #endif
00163 
00164 #ifndef MODULE_LICENSE
00165 #define MODULE_LICENSE(var)
00166 #endif
00167 
00168 #if WIRELESS_EXT > 12
00169 #if IW_HANDLER_VERSION < 3
00170 extern void wireless_send_event(struct net_device *dev,
00171                                 unsigned int cmd,
00172                                 union iwreq_data *wrqu,
00173                                 char *extra);
00174 #endif /* IW_HANDLER_VERSION < 3 */
00175 #endif /* WIRELESS_EXT > 12 */
00176 
00177 
00178 #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,4,23))
00179 struct net_device;
00180 static inline void free_netdev(struct net_device *dev)
00181 {
00182         kfree(dev);
00183 }
00184 #endif
00185 
00186 
00187 #ifdef __IN_PCMCIA_PACKAGE__
00188 #undef pcmcia_access_configuration_register
00189 #undef pcmcia_register_client
00190 #undef pcmcia_deregister_client
00191 #undef pcmcia_get_first_tuple
00192 #undef pcmcia_get_next_tuple
00193 #undef pcmcia_get_tuple_data
00194 #undef pcmcia_parse_tuple
00195 #undef pcmcia_get_configuration_info
00196 #undef pcmcia_request_io
00197 #undef pcmcia_request_irq
00198 #undef pcmcia_request_configuration
00199 #undef pcmcia_release_configuration
00200 #undef pcmcia_release_io
00201 #undef pcmcia_release_irq
00202 #undef pcmcia_release_window
00203 #undef pcmcia_get_card_services_info
00204 #undef pcmcia_report_error
00205 #endif /* __IN_PCMCIA_PACKAGE__ */
00206 
00207 #if defined(__IN_PCMCIA_PACKAGE__) || \
00208 (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,0))
00209 
00210 #define pcmcia_access_configuration_register(handle, reg) \
00211         CardServices(AccessConfigurationRegister, handle, reg)
00212 
00213 #define pcmcia_register_client(handle, reg) \
00214         CardServices(RegisterClient, handle, reg)
00215 
00216 #define pcmcia_deregister_client(handle) \
00217         CardServices(DeregisterClient, handle)
00218 
00219 #define pcmcia_get_first_tuple(handle, tuple) \
00220         CardServices(GetFirstTuple, handle, tuple)
00221 
00222 #define pcmcia_get_next_tuple(handle, tuple) \
00223         CardServices(GetNextTuple, handle, tuple)
00224 
00225 #define pcmcia_get_tuple_data(handle, tuple) \
00226         CardServices(GetTupleData, handle, tuple)
00227 
00228 #define pcmcia_parse_tuple(handle, tuple, parse) \
00229         CardServices(ParseTuple, handle, tuple, parse)
00230 
00231 #define pcmcia_get_configuration_info(handle, config) \
00232         CardServices(GetConfigurationInfo, handle, config)
00233 
00234 #define pcmcia_request_io(handle, req) \
00235         CardServices(RequestIO, handle, req)
00236 
00237 #define pcmcia_request_irq(handle, req) \
00238         CardServices(RequestIRQ, handle, req)
00239 
00240 #define pcmcia_request_configuration(handle, req) \
00241         CardServices(RequestConfiguration, handle, req)
00242 
00243 #define pcmcia_release_configuration(handle) \
00244         CardServices(ReleaseConfiguration, handle)
00245 
00246 #define pcmcia_release_io(handle, req) \
00247         CardServices(ReleaseIO, handle, req)
00248 
00249 #define pcmcia_release_irq(handle, req) \
00250         CardServices(ReleaseIRQ, handle, req)
00251 
00252 #define pcmcia_release_window(win) \
00253         CardServices(ReleaseWindow, win)
00254 
00255 #define pcmcia_get_card_services_info(info) \
00256         CardServices(GetCardServicesInfo, info)
00257 
00258 #define pcmcia_report_error(handle, err) \
00259         CardServices(ReportError, handle, err)
00260 #endif /* __IN_PCMCIA_PACKAGE__ or Linux < 2.6.0 */
00261 
00262 #endif /* HOSTAP_COMPAT_H */

Generated on Mon Nov 21 15:58:09 2005 for openwifi by  doxygen 1.4.1