Staging: add wlan-ng prism2 usb driver
[linux-2.6/linux-acpi-2.6/ibm-acpi-2.6.git] / drivers / staging / wlan-ng / wlan_compat.h
blob17026570708fda05f9f0e1fdff17000fad3d41ed
1 /* wlan_compat.h
3 * Types and macros to aid in portability
5 * Copyright (C) 1999 AbsoluteValue Systems, Inc. All Rights Reserved.
6 * --------------------------------------------------------------------
8 * linux-wlan
10 * The contents of this file are subject to the Mozilla Public
11 * License Version 1.1 (the "License"); you may not use this file
12 * except in compliance with the License. You may obtain a copy of
13 * the License at http://www.mozilla.org/MPL/
15 * Software distributed under the License is distributed on an "AS
16 * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
17 * implied. See the License for the specific language governing
18 * rights and limitations under the License.
20 * Alternatively, the contents of this file may be used under the
21 * terms of the GNU Public License version 2 (the "GPL"), in which
22 * case the provisions of the GPL are applicable instead of the
23 * above. If you wish to allow the use of your version of this file
24 * only under the terms of the GPL and not to allow others to use
25 * your version of this file under the MPL, indicate your decision
26 * by deleting the provisions above and replace them with the notice
27 * and other provisions required by the GPL. If you do not delete
28 * the provisions above, a recipient may use your version of this
29 * file under either the MPL or the GPL.
31 * --------------------------------------------------------------------
33 * Inquiries regarding the linux-wlan Open Source project can be
34 * made directly to:
36 * AbsoluteValue Systems Inc.
37 * info@linux-wlan.com
38 * http://www.linux-wlan.com
40 * --------------------------------------------------------------------
42 * Portions of the development of this software were funded by
43 * Intersil Corporation as part of PRISM(R) chipset product development.
45 * --------------------------------------------------------------------
48 #ifndef _WLAN_COMPAT_H
49 #define _WLAN_COMPAT_H
51 /*=============================================================*/
52 /*------ Establish Platform Identity --------------------------*/
53 /*=============================================================*/
54 /* Key macros: */
55 /* WLAN_CPU_FAMILY */
56 #define WLAN_Ix86 1
57 #define WLAN_PPC 2
58 #define WLAN_Ix96 3
59 #define WLAN_ARM 4
60 #define WLAN_ALPHA 5
61 #define WLAN_MIPS 6
62 #define WLAN_HPPA 7
63 #define WLAN_SPARC 8
64 #define WLAN_SH 9
65 #define WLAN_x86_64 10
66 /* WLAN_SYSARCH */
67 #define WLAN_PCAT 1
68 #define WLAN_MBX 2
69 #define WLAN_RPX 3
70 #define WLAN_LWARCH 4
71 #define WLAN_PMAC 5
72 #define WLAN_SKIFF 6
73 #define WLAN_BITSY 7
74 #define WLAN_ALPHAARCH 7
75 #define WLAN_MIPSARCH 9
76 #define WLAN_HPPAARCH 10
77 #define WLAN_SPARCARCH 11
78 #define WLAN_SHARCH 12
80 /* Note: the PLX HOSTIF above refers to some vendors implementations for */
81 /* PCI. It's a PLX chip that is a PCI to PCMCIA adapter, but it */
82 /* isn't a real PCMCIA host interface adapter providing all the */
83 /* card&socket services. */
85 #if (defined(CONFIG_PPC) || defined(CONFIG_8xx) || defined(__powerpc__))
86 #ifndef __ppc__
87 #define __ppc__
88 #endif
89 #endif
91 #if defined(__KERNEL__)
93 #ifndef AUTOCONF_INCLUDED
94 #include <linux/config.h>
95 #endif
97 #if defined(__x86_64__)
98 #define WLAN_CPU_FAMILY WLAN_x86_64
99 #define WLAN_SYSARCH WLAN_PCAT
100 #elif defined(__i386__) || defined(__i486__) || defined(__i586__) || defined(__i686__)
101 #define WLAN_CPU_FAMILY WLAN_Ix86
102 #define WLAN_SYSARCH WLAN_PCAT
103 #elif defined(__ppc__)
104 #define WLAN_CPU_FAMILY WLAN_PPC
105 #if defined(CONFIG_MBX)
106 #define WLAN_SYSARCH WLAN_MBX
107 #elif defined(CONFIG_RPXLITE)
108 #define WLAN_SYSARCH WLAN_RPX
109 #elif defined(CONFIG_RPXCLASSIC)
110 #define WLAN_SYSARCH WLAN_RPX
111 #else
112 #define WLAN_SYSARCH WLAN_PMAC
113 #endif
114 #elif defined(__arm__)
115 #define WLAN_CPU_FAMILY WLAN_ARM
116 #define WLAN_SYSARCH WLAN_SKIFF
117 #elif defined(__alpha__)
118 #define WLAN_CPU_FAMILY WLAN_ALPHA
119 #define WLAN_SYSARCH WLAN_ALPHAARCH
120 #elif defined(__mips__)
121 #define WLAN_CPU_FAMILY WLAN_MIPS
122 #define WLAN_SYSARCH WLAN_MIPSARCH
123 #elif defined(__hppa__)
124 #define WLAN_CPU_FAMILY WLAN_HPPA
125 #define WLAN_SYSARCH WLAN_HPPAARCH
126 #elif defined(__sparc__)
127 #define WLAN_CPU_FAMILY WLAN_SPARC
128 #define WLAN_SYSARCH WLAN_SPARC
129 #elif defined(__sh__)
130 #define WLAN_CPU_FAMILY WLAN_SH
131 #define WLAN_SYSARCH WLAN_SHARCH
132 #ifndef __LITTLE_ENDIAN__
133 #define __LITTLE_ENDIAN__
134 #endif
135 #else
136 #error "No CPU identified!"
137 #endif
138 #endif /* __KERNEL__ */
141 Some big endian machines implicitly do all I/O in little endian mode.
143 In particular:
144 Linux/PPC on PowerMacs (PCI)
145 Arm/Intel Xscale (PCI)
147 This may also affect PLX boards and other BE &| PPC platforms;
148 as new ones are discovered, add them below.
151 #if defined(WLAN_HOSTIF)
152 #if ((WLAN_HOSTIF == WLAN_PCI) || (WLAN_HOSTIF == WLAN_PLX))
153 #if ((WLAN_SYSARCH == WLAN_SKIFF) || (WLAN_SYSARCH == WLAN_PMAC) || (WLAN_SYSARCH == WLAN_SPARC))
154 #define REVERSE_ENDIAN
155 #endif
156 #endif
157 #endif
159 /*=============================================================*/
160 /*------ Bit settings -----------------------------------------*/
161 /*=============================================================*/
163 #define BIT0 0x00000001
164 #define BIT1 0x00000002
165 #define BIT2 0x00000004
166 #define BIT3 0x00000008
167 #define BIT4 0x00000010
168 #define BIT5 0x00000020
169 #define BIT6 0x00000040
170 #define BIT7 0x00000080
171 #define BIT8 0x00000100
172 #define BIT9 0x00000200
173 #define BIT10 0x00000400
174 #define BIT11 0x00000800
175 #define BIT12 0x00001000
176 #define BIT13 0x00002000
177 #define BIT14 0x00004000
178 #define BIT15 0x00008000
179 #define BIT16 0x00010000
180 #define BIT17 0x00020000
181 #define BIT18 0x00040000
182 #define BIT19 0x00080000
183 #define BIT20 0x00100000
184 #define BIT21 0x00200000
185 #define BIT22 0x00400000
186 #define BIT23 0x00800000
187 #define BIT24 0x01000000
188 #define BIT25 0x02000000
189 #define BIT26 0x04000000
190 #define BIT27 0x08000000
191 #define BIT28 0x10000000
192 #define BIT29 0x20000000
193 #define BIT30 0x40000000
194 #define BIT31 0x80000000
196 #include <linux/types.h>
198 typedef u_int8_t UINT8;
199 typedef u_int16_t UINT16;
200 typedef u_int32_t UINT32;
202 typedef int8_t INT8;
203 typedef int16_t INT16;
204 typedef int32_t INT32;
206 typedef unsigned int UINT;
207 typedef signed int INT;
209 typedef u_int64_t UINT64;
210 typedef int64_t INT64;
212 #define UINT8_MAX (0xffUL)
213 #define UINT16_MAX (0xffffUL)
214 #define UINT32_MAX (0xffffffffUL)
216 #define INT8_MAX (0x7fL)
217 #define INT16_MAX (0x7fffL)
218 #define INT32_MAX (0x7fffffffL)
220 /*=============================================================*/
221 /*------ Compiler Portability Macros --------------------------*/
222 /*=============================================================*/
223 #define __WLAN_ATTRIB_PACK__ __attribute__ ((packed))
225 /*=============================================================*/
226 /*------ OS Portability Macros --------------------------------*/
227 /*=============================================================*/
229 #ifndef WLAN_DBVAR
230 #define WLAN_DBVAR wlan_debug
231 #endif
233 #ifndef KERNEL_VERSION
234 #define KERNEL_VERSION(a,b,c) (((a) << 16) + ((b) << 8) + (c))
235 #endif
237 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0))
238 # if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,8))
239 # include <linux/hardirq.h>
240 # else
241 # include <asm/hardirq.h>
242 # endif
243 #elif defined(__KERNEL__)
244 # define PREEMPT_MASK (0x000000FFUL)
245 # define preempt_count() (0UL)
246 #endif
248 #define WLAN_LOG_ERROR(x,args...) printk(KERN_ERR "%s: " x , __FUNCTION__ , ##args);
250 #define WLAN_LOG_WARNING(x,args...) printk(KERN_WARNING "%s: " x , __FUNCTION__ , ##args);
252 #define WLAN_LOG_NOTICE(x,args...) printk(KERN_NOTICE "%s: " x , __FUNCTION__ , ##args);
254 #define WLAN_LOG_INFO(args... ) printk(KERN_INFO args)
256 #if defined(WLAN_INCLUDE_DEBUG)
257 #define WLAN_ASSERT(c) if ((!(c)) && WLAN_DBVAR >= 1) { \
258 WLAN_LOG_DEBUG(1, "Assertion failure!\n"); }
259 #define WLAN_HEX_DUMP( l, x, p, n) if( WLAN_DBVAR >= (l) ){ \
260 int __i__; \
261 printk(KERN_DEBUG x ":"); \
262 for( __i__=0; __i__ < (n); __i__++) \
263 printk( " %02x", ((UINT8*)(p))[__i__]); \
264 printk("\n"); }
265 #define DBFENTER { if ( WLAN_DBVAR >= 5 ){ WLAN_LOG_DEBUG(3,"---->\n"); } }
266 #define DBFEXIT { if ( WLAN_DBVAR >= 5 ){ WLAN_LOG_DEBUG(3,"<----\n"); } }
268 #define WLAN_LOG_DEBUG(l,x,args...) if ( WLAN_DBVAR >= (l)) printk(KERN_DEBUG "%s(%lu): " x , __FUNCTION__, (preempt_count() & PREEMPT_MASK), ##args );
269 #else
270 #define WLAN_ASSERT(c)
271 #define WLAN_HEX_DUMP( l, s, p, n)
272 #define DBFENTER
273 #define DBFEXIT
275 #define WLAN_LOG_DEBUG(l, s, args...)
276 #endif
278 #ifdef CONFIG_SMP
279 #define __SMP__ 1
280 #endif
282 #if defined(__KERNEL__)
284 #if ((LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0)) || (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,19)))
285 #define URB_ONLY_CALLBACK
286 #endif
288 #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19))
289 #define PT_REGS , struct pt_regs *regs
290 #else
291 #define PT_REGS
292 #endif
294 #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,7))
295 # define del_singleshot_timer_sync(a) del_timer_sync(a)
296 #endif
298 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,17))
299 #define CONFIG_NETLINK 1
300 #endif
302 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,0))
303 #define kfree_s(a, b) kfree((a))
304 #endif
306 #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,2,18))
307 #ifndef init_waitqueue_head
308 #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,0,16))
309 #define init_waitqueue_head(p) (*(p) = NULL)
310 #else
311 #define init_waitqueue_head(p) init_waitqueue(p)
312 #endif
313 typedef struct wait_queue *wait_queue_head_t;
314 typedef struct wait_queue wait_queue_t;
315 #define set_current_state(b) { current->state = (b); mb(); }
316 #define init_waitqueue_entry(a, b) { (a)->task = current; }
317 #endif
318 #endif
320 #ifndef wait_event_interruptible_timeout
321 // retval == 0; signal met; we're good.
322 // retval < 0; interrupted by signal.
323 // retval > 0; timed out.
325 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,0)) // fixme?
327 #define __wait_event_interruptible_timeout(wq, condition, ret) \
328 do { \
329 wait_queue_t __wait; \
330 init_waitqueue_entry(&__wait, current); \
332 add_wait_queue(&wq, &__wait); \
333 for (;;) { \
334 set_current_state(TASK_INTERRUPTIBLE); \
335 if (condition) \
336 break; \
337 if (!signal_pending(current)) { \
338 ret = schedule_timeout(ret) ; \
339 if (!ret) \
340 break; \
341 continue; \
343 ret = -ERESTARTSYS; \
344 break; \
346 set_current_state(TASK_RUNNING); \
347 remove_wait_queue(&wq, &__wait); \
348 } while (0)
350 #else // 2.2
353 #define __wait_event_interruptible_timeout(wq, condition, ret) \
354 do { \
355 struct wait_queue __wait; \
357 __wait.task = current; \
358 add_wait_queue(&wq, &__wait); \
359 for (;;) { \
360 current->state = TASK_INTERRUPTIBLE; \
361 if (condition) \
362 break; \
363 if (!signal_pending(current)) { \
364 ret = schedule_timeout(ret); \
365 if (!ret) \
366 break; \
367 continue; \
369 ret = -ERESTARTSYS; \
370 break; \
372 current->state = TASK_RUNNING; \
373 remove_wait_queue(&wq, &__wait); \
374 } while (0)
376 #endif // version >= 2.4
378 #define wait_event_interruptible_timeout(wq, condition, timeout) \
379 ({ \
380 long __ret = timeout; \
381 if (!(condition)) \
382 __wait_event_interruptible_timeout(wq, condition, __ret); \
383 __ret; \
386 #endif
388 #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,4,20))
389 #ifdef _LINUX_LIST_H
391 static inline void list_move_tail(struct list_head *list,
392 struct list_head *head)
394 __list_del(list->prev, list->next);
395 list_add_tail(list, head);
398 static inline void __list_splice(struct list_head *list,
399 struct list_head *head)
401 struct list_head *first = list->next;
402 struct list_head *last = list->prev;
403 struct list_head *at = head->next;
405 first->prev = head;
406 head->next = first;
408 last->next = at;
409 at->prev = last;
412 static inline void list_move(struct list_head *list, struct list_head *head)
414 __list_del(list->prev, list->next);
415 list_add(list, head);
418 static inline void list_splice_init(struct list_head *list,
419 struct list_head *head)
421 if (!list_empty(list)) {
422 __list_splice(list, head);
423 INIT_LIST_HEAD(list);
428 #endif // LIST_H
429 #endif
431 #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,1,90))
432 #define spin_lock(l) do { } while (0)
433 #define spin_unlock(l) do { } while (0)
434 #define spin_lock_irqsave(l,f) do { save_flags(f); cli(); } while (0)
435 #define spin_unlock_irqrestore(l,f) do { restore_flags(f); } while (0)
436 #define spin_lock_init(s) do { } while (0)
437 #define spin_trylock(l) (1)
438 typedef int spinlock_t;
439 #endif
441 #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,4,0)) // XXX ???
442 #define spin_lock_bh spin_lock
443 #endif
445 #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,4,0))
446 #ifdef CONFIG_SMP
447 #define spin_is_locked(x) (*(volatile char *)(&(x)->lock) <= 0)
448 #else
449 #define spin_is_locked(l) (0)
450 #endif
451 #endif
453 #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,4,28))
454 #define __user
455 #define __iomem
456 #endif
458 #ifdef _LINUX_PROC_FS_H
459 #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,3,25))
461 extern inline struct proc_dir_entry *
462 create_proc_read_entry(const char *name, mode_t mode,
463 struct proc_dir_entry *base,
464 read_proc_t *read_proc, void *data)
466 struct proc_dir_entry *res = create_proc_entry(name, mode, base);
467 if (res) {
468 res->read_proc = read_proc;
469 res->data = data;
471 return res;
473 #endif
475 #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,3,29))
476 #ifndef proc_mkdir
477 #define proc_mkdir(name, root) create_proc_entry(name, S_IFDIR, root)
478 #endif
479 #endif
480 #endif /* _LINUX_PROC_FS_H */
482 #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0))
483 #ifndef INIT_TQUEUE
484 #define PREPARE_TQUEUE(_tq, _routine, _data) \
485 do { \
486 (_tq)->routine = _routine; \
487 (_tq)->data = _data; \
488 } while (0)
489 #define INIT_TQUEUE(_tq, _routine, _data) \
490 do { \
491 INIT_LIST_HEAD(&(_tq)->list); \
492 (_tq)->sync = 0; \
493 PREPARE_TQUEUE((_tq), (_routine), (_data)); \
494 } while (0)
495 #endif
497 #ifndef container_of
498 #define container_of(ptr, type, member) ({ \
499 const typeof( ((type *)0)->member ) *__mptr = (ptr); \
500 (type *)( (char *)__mptr - offsetof(type,member) );})
501 #endif
503 #ifndef INIT_WORK
504 #define work_struct tq_struct
506 #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,4,0))
507 #define schedule_work(a) queue_task(a, &tq_scheduler)
508 #else
509 #define schedule_work(a) schedule_task(a)
510 #endif
512 #define flush_scheduled_work flush_scheduled_tasks
513 #define INIT_WORK2(_wq, _routine) INIT_TQUEUE(_wq, (void (*)(void *))_routine, _wq)
514 #endif
516 #else // >= 2.5 kernel
518 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,20)
519 #define INIT_WORK2(_wq, _routine) INIT_WORK(_wq, (void (*)(void *))_routine, _wq)
520 #else
521 #define INIT_WORK2(_wq, _routine) INIT_WORK(_wq, _routine)
522 #endif
524 #endif // >= 2.5 kernel
526 #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,3,38))
527 typedef struct device netdevice_t;
528 #elif (LINUX_VERSION_CODE < KERNEL_VERSION(2,4,4))
529 typedef struct net_device netdevice_t;
530 #else
531 #undef netdevice_t
532 typedef struct net_device netdevice_t;
533 #endif
535 #ifdef WIRELESS_EXT
536 #if (WIRELESS_EXT < 13)
537 struct iw_request_info
539 __u16 cmd; /* Wireless Extension command */
540 __u16 flags; /* More to come ;-) */
542 #endif
543 #endif
546 #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,1,18))
547 #define MODULE_PARM(a,b) extern int __bogus_decl
548 #define MODULE_AUTHOR(a) extern int __bogus_decl
549 #define MODULE_DESCRIPTION(a) extern int __bogus_decl
550 #define MODULE_SUPPORTED_DEVICE(a) extern int __bogus_decl
551 #undef GET_USE_COUNT
552 #define GET_USE_COUNT(m) mod_use_count_
553 #endif
555 #ifndef MODULE_OWNER
556 #define MODULE_OWNER(a) extern int __bogus_decl
557 #define ANCIENT_MODULE_CODE
558 #endif
560 #ifndef MODULE_LICENSE
561 #define MODULE_LICENSE(m) extern int __bogus_decl
562 #endif
564 /* TODO: Do we care about this? */
565 #ifndef MODULE_DEVICE_TABLE
566 #define MODULE_DEVICE_TABLE(foo,bar)
567 #endif
569 #define wlan_minutes2ticks(a) ((a)*(wlan_ticks_per_sec * 60))
570 #define wlan_seconds2ticks(a) ((a)*(wlan_ticks_per_sec))
572 #if (LINUX_VERSION_CODE > KERNEL_VERSION(2,5,47))
573 #define NEW_MODULE_CODE
574 #ifdef ANCIENT_MODULE_CODE
575 #undef ANCIENT_MODULE_CODE
576 #endif
577 #elif (LINUX_VERSION_CODE < KERNEL_VERSION(2,4,25))
578 #define module_param(name, type, perm) \
579 static inline void *__check_existence_##name(void) { return &name; } \
580 MODULE_PARM(name, _MODULE_PARM_STRING_ ## type)
582 #define _MODULE_PARM_STRING_byte "b"
583 #define _MODULE_PARM_STRING_short "h"
584 #define _MODULE_PARM_STRING_ushort "h"
585 #define _MODULE_PARM_STRING_int "i"
586 #define _MODULE_PARM_STRING_uint "i"
587 #define _MODULE_PARM_STRING_long "l"
588 #define _MODULE_PARM_STRING_ulong "l"
589 #define _MODULE_PARM_STRING_bool "i"
590 #endif
592 /* linux < 2.5.69 */
593 #ifndef IRQ_NONE
594 typedef void irqreturn_t;
595 #define IRQ_NONE
596 #define IRQ_HANDLED
597 #define IRQ_RETVAL(x)
598 #endif
600 #ifndef in_atomic
601 #define in_atomic() 0
602 #endif
604 #if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,13))
605 #define URB_ASYNC_UNLINK 0
606 #endif
608 #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,7))
609 #define URB_ASYNC_UNLINK USB_ASYNC_UNLINK
610 #define usb_fill_bulk_urb FILL_BULK_URB
611 #define usb_kill_urb usb_unlink_urb
612 #else
613 #define USB_QUEUE_BULK 0
614 #endif
616 #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,11))
617 typedef u32 pm_message_t;
618 #endif
620 #if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,9))
621 #define hotplug_path "/etc/hotplug/wlan.agent"
622 #endif
624 #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,0))
625 #define free_netdev(x) kfree(x)
626 #endif
628 #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,9))
629 #define eth_hdr(x) (x)->mac.ethernet
630 #endif
632 #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,4,0))
633 #define del_timer_sync(a) del_timer(a)
634 #endif
636 #ifndef might_sleep
637 #define might_sleep(a) do { } while (0)
638 #endif
640 /* Apparently 2.4.2 ethtool is quite different, maybe newer too? */
641 #if (defined(SIOETHTOOL) && !defined(ETHTOOL_GDRVINFO))
642 #undef SIOETHTOOL
643 #endif
645 // pcmcia-cs stuff
646 #if ((LINUX_VERSION_CODE < KERNEL_VERSION(2,5,68)) && \
647 !defined(pcmcia_access_configuration_register))
648 #define pcmcia_access_configuration_register(handle, reg) \
649 CardServices(AccessConfigurationRegister, handle, reg)
650 #define pcmcia_register_client(handle, reg) \
651 CardServices(RegisterClient, handle, reg)
652 #define pcmcia_deregister_client(handle) \
653 CardServices(DeregisterClient, handle)
654 #define pcmcia_get_first_tuple(handle, tuple) \
655 CardServices(GetFirstTuple, handle, tuple)
656 #define pcmcia_get_next_tuple(handle, tuple) \
657 CardServices(GetNextTuple, handle, tuple)
658 #define pcmcia_get_tuple_data(handle, tuple) \
659 CardServices(GetTupleData, handle, tuple)
660 #define pcmcia_parse_tuple(handle, tuple, parse) \
661 CardServices(ParseTuple, handle, tuple, parse)
662 #define pcmcia_get_configuration_info(handle, config) \
663 CardServices(GetConfigurationInfo, handle, config)
664 #define pcmcia_request_io(handle, req) \
665 CardServices(RequestIO, handle, req)
666 #define pcmcia_request_irq(handle, req) \
667 CardServices(RequestIRQ, handle, req)
668 #define pcmcia_request_configuration(handle, req) \
669 CardServices(RequestConfiguration, handle, req)
670 #define pcmcia_release_configuration(handle) \
671 CardServices(ReleaseConfiguration, handle)
672 #define pcmcia_release_io(handle, req) \
673 CardServices(ReleaseIO, handle, req)
674 #define pcmcia_release_irq(handle, req) \
675 CardServices(ReleaseIRQ, handle, req)
676 #define pcmcia_release_window(win) \
677 CardServices(ReleaseWindow, win)
678 #define pcmcia_get_card_services_info(info) \
679 CardServices(GetCardServicesInfo, info)
680 #define pcmcia_report_error(handle, err) \
681 CardServices(ReportError, handle, err)
682 #endif
684 #endif /* __KERNEL__ */
686 /*=============================================================*/
687 /*------ Hardware Portability Macros --------------------------*/
688 /*=============================================================*/
690 #define ieee2host16(n) __le16_to_cpu(n)
691 #define ieee2host32(n) __le32_to_cpu(n)
692 #define host2ieee16(n) __cpu_to_le16(n)
693 #define host2ieee32(n) __cpu_to_le32(n)
695 #if (WLAN_CPU_FAMILY != WLAN_MIPS)
696 typedef UINT32 phys_t;
697 #endif
699 #if (WLAN_CPU_FAMILY == WLAN_PPC)
700 #define wlan_inw(a) in_be16((unsigned short *)((a)+_IO_BASE))
701 #define wlan_inw_le16_to_cpu(a) inw((a))
702 #define wlan_outw(v,a) out_be16((unsigned short *)((a)+_IO_BASE), (v))
703 #define wlan_outw_cpu_to_le16(v,a) outw((v),(a))
704 #else
705 #define wlan_inw(a) inw((a))
706 #define wlan_inw_le16_to_cpu(a) __cpu_to_le16(inw((a)))
707 #define wlan_outw(v,a) outw((v),(a))
708 #define wlan_outw_cpu_to_le16(v,a) outw(__cpu_to_le16((v)),(a))
709 #endif
711 /*=============================================================*/
712 /*--- General Macros ------------------------------------------*/
713 /*=============================================================*/
715 #define wlan_max(a, b) (((a) > (b)) ? (a) : (b))
716 #define wlan_min(a, b) (((a) < (b)) ? (a) : (b))
718 #define wlan_isprint(c) (((c) > (0x19)) && ((c) < (0x7f)))
720 #define wlan_hexchar(x) (((x) < 0x0a) ? ('0' + (x)) : ('a' + ((x) - 0x0a)))
722 /* Create a string of printable chars from something that might not be */
723 /* It's recommended that the str be 4*len + 1 bytes long */
724 #define wlan_mkprintstr(buf, buflen, str, strlen) \
726 int i = 0; \
727 int j = 0; \
728 memset(str, 0, (strlen)); \
729 for (i = 0; i < (buflen); i++) { \
730 if ( wlan_isprint((buf)[i]) ) { \
731 (str)[j] = (buf)[i]; \
732 j++; \
733 } else { \
734 (str)[j] = '\\'; \
735 (str)[j+1] = 'x'; \
736 (str)[j+2] = wlan_hexchar(((buf)[i] & 0xf0) >> 4); \
737 (str)[j+3] = wlan_hexchar(((buf)[i] & 0x0f)); \
738 j += 4; \
743 /*=============================================================*/
744 /*--- Variables -----------------------------------------------*/
745 /*=============================================================*/
747 #ifdef WLAN_INCLUDE_DEBUG
748 extern int wlan_debug;
749 #endif
751 extern int wlan_ethconv; /* What's the default ethconv? */
753 /*=============================================================*/
754 /*--- Functions -----------------------------------------------*/
755 /*=============================================================*/
756 #endif /* _WLAN_COMPAT_H */