#include <linux/time.h>
#include <linux/netdevice.h>
#include <linux/kernel.h>
+#include <linux/kmod.h>
#endif
#include <linux/version.h>
#define __force
#endif
-#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,14)
-typedef int gfp_t;
-#endif
-
-#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,3)
-static inline void *kzalloc(size_t size, gfp_t flags)
-{
- void *p = kmalloc(size, flags);
- if (likely(p != NULL))
- memset(p, 0, size);
- return p;
-}
-#endif
-
#ifndef container_of
#define container_of(ptr, type, member) ({ \
const typeof( ((type *)0)->member ) *__mptr = (ptr); \
#define howmany(x, y) (((x)+((y)-1))/(y))
+/* roundup() and howmany() macros that works both with positive and negative
+ * values. */
+#define roundup_s(x,y) _roundup_s((signed)(x),(signed)(y))
+#define howmany_s(x,y) _howmany_s((signed)(x),(signed)(y))
+#define _roundup_s(x,y) \
+ ((x) >= 0 ? (((x)+((y)-1))/(y))*(y) : ((x)/(y))*(y))
+#define _howmany_s(x, y) \
+ ((x) >= 0 ? (((x)+((y)-1))/(y)) : ((x)/(y)))
+
/* Bit map related macros. */
#define setbit(a,i) ((a)[(i)/NBBY] |= 1<<((i)%NBBY))
#define clrbit(a,i) ((a)[(i)/NBBY] &= ~(1<<((i)%NBBY)))
#define __offsetof(t,m) offsetof(t,m)
-#ifdef __KERNEL__
-#define KASSERT(exp, msg) do { \
- if (unlikely(!(exp))) { \
- printk msg; \
- BUG(); \
- } \
-} while (0)
-#endif /* __KERNEL__ */
-
/*
* NetBSD/FreeBSD defines for file version.
*/
*/
#ifdef __KERNEL__
+#define KASSERT(exp, msg) do { \
+ if (unlikely(!(exp))) { \
+ printk msg; \
+ printk("\n"); \
+ BUG(); \
+ } \
+} while (0)
+
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,14)
+#define gfp_t unsigned int
+
+static inline void *_kzalloc(size_t size, gfp_t flags)
+{
+ void *p = kmalloc(size, flags);
+ if (likely(p != NULL))
+ memset(p, 0, size);
+ return p;
+}
+
+#define kzalloc(size, flags) _kzalloc(size, flags)
+#endif
+
#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,21)
#define ATH_REGISTER_SYSCTL_TABLE(t) register_sysctl_table(t, 1)
#else
#define IRQF_SHARED SA_SHIRQ
#endif
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,4,27)
+#define netdev_priv(_netdev) ((_netdev)->priv)
+#endif
+
#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,22)
#define skb_end_pointer(_skb) ((_skb)->end)
#define skb_tail_pointer(_skb) ((_skb)->tail)
#define DEV_ATH CTL_UNNUMBERED
#endif
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,33)
+#define ATH_INIT_CTL_NAME(val)
+#define ATH_SET_CTL_NAME(ctl, val)
+#else
+#define ATH_INIT_CTL_NAME(val) .ctl_name = val,
+#define ATH_SET_CTL_NAME(ctl, val) ctl.ctl_name = val
+#endif
+
/* __skb_append got a third parameter in 2.6.14 */
#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,14)
#define __skb_queue_after(_list, _old, _new) __skb_append(_old, _new)
#define __skb_queue_after(_list, _old, _new) __skb_append(_old, _new, _list)
#endif
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,0)
+#define request_module(_fmt, _modname) request_module(_modname)
+#endif
+
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19)
+#ifndef spin_lock_irqsave_nested
+#define spin_lock_irqsave_nested(_lock, _flags, _subclass) \
+ spin_lock_irqsave(_lock, _flags)
+#endif
+#endif
+
#endif /* __KERNEL__ */
#endif /* _ATH_COMPAT_H_ */