Linux 2.4 series compatibility fixes

* Based on patches from nbd
 * av_beacon_alloc code has been reimplemented using atomic bit operations; I think this is safe for SMP


git-svn-id: http://madwifi-project.org/svn/madwifi/trunk@3310 0192ed92-7a03-0410-a25b-9323aeb14dbd
This commit is contained in:
mentor 2008-01-30 20:23:49 +00:00
parent 2b8281ba31
commit 0ad2c8981a
6 changed files with 47 additions and 17 deletions

View File

@ -526,7 +526,8 @@ ath_attach(u_int16_t devid, struct net_device *dev, HAL_BUS_TAG tag)
/* Allocate space for dynamically determined maximum VAP count */
sc->sc_bslot =
kzalloc(ath_maxvaps * sizeof(struct ieee80211vap), GFP_KERNEL);
kmalloc(ath_maxvaps * sizeof(struct ieee80211vap), GFP_KERNEL);
memset(sc->sc_bslot, 0, ath_maxvaps * sizeof(struct ieee80211vap));
/*
* Cache line size is used to size and align various
@ -1345,7 +1346,11 @@ ath_vap_create(struct ieee80211com *ic, const char *name,
}
}
avp->av_bslot = -1;
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,15)
atomic_set(&avp->av_beacon_alloc, 0);
#else
clear_bit(0, &avp->av_beacon_alloc);
#endif
STAILQ_INIT(&avp->av_mcastq.axq_q);
ATH_TXQ_LOCK_INIT(&avp->av_mcastq);
if (IEEE80211_IS_MODE_BEACON(opmode)) {
@ -4509,7 +4514,11 @@ ath_beacon_alloc(struct ath_softc *sc, struct ieee80211_node *ni)
{
struct ath_vap * avp = ATH_VAP(ni->ni_vap);
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,15)
atomic_set(&avp->av_beacon_alloc, 1);
#else
set_bit(0, &avp->av_beacon_alloc);
#endif
return 0;
}
@ -4754,9 +4763,12 @@ ath_beacon_generate(struct ath_softc *sc, struct ieee80211vap *vap, int *needmar
}
#endif
if (atomic_add_unless(&avp->av_beacon_alloc, -1, 0)) {
ath_beacon_alloc_internal(sc, vap->iv_bss);
}
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,15)
if (atomic_add_unless(&avp->av_beacon_alloc, -1, 0))
#else
if (test_and_clear_bit(0, &avp->av_beacon_alloc))
#endif
ath_beacon_alloc_internal(sc, vap->iv_bss);
/*
* Update dynamic beacon contents. If this returns

View File

@ -1532,9 +1532,11 @@ void ath_rp_init(struct ath_softc *sc)
ath_rp_clear(sc);
sc->sc_rp = (struct ath_rp *)kzalloc(
sizeof(struct ath_rp) *
sc->sc_rp = (struct ath_rp *)kmalloc(
sizeof(struct ath_rp) *
ATH_RADAR_PULSE_NR, GFP_KERNEL);
memset(sc->sc_rp, 0, sizeof(struct ath_rp) *
ATH_RADAR_PULSE_NR);
if (sc->sc_rp == NULL)
return;

View File

@ -49,6 +49,9 @@
#include "net80211/ieee80211.h" /* XXX for WME_NUM_AC */
#include <asm/io.h>
#include <linux/list.h>
#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,15)
# include <asm/bitops.h>
#endif
/*
* Deduce if tasklets are available. If not then
@ -123,11 +126,6 @@ typedef void irqreturn_t;
#define ATH_GET_NETDEV_DEV(ndev) ((ndev)->class_dev.dev)
#endif
#ifndef NETDEV_TX_OK
#define NETDEV_TX_OK 0
#define NETDEV_TX_BUSY 1
#endif
#if LINUX_VERSION_CODE < KERNEL_VERSION(2,4,23)
static inline struct net_device *_alloc_netdev(int sizeof_priv, const char *mask,
void (*setup)(struct net_device *))
@ -520,8 +518,12 @@ struct ath_vap {
struct ieee80211_beacon_offsets av_boff;/* dynamic update state */
int av_bslot; /* beacon slot index */
struct ath_txq av_mcastq; /* multicast transmit queue */
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,15)
atomic_t av_beacon_alloc; /* set to 1 when the next beacon needs
to be recomputed */
#else
unsigned int av_beacon_alloc;
#endif
};
#define ATH_VAP(_v) ((struct ath_vap *)(_v))

View File

@ -42,7 +42,9 @@
#ifdef __KERNEL__
#include <linux/types.h>
#include <linux/time.h>
#include <linux/netdevice.h>
#endif
#if !defined(__KERNEL__) || !defined (__bitwise)
#define __le16 u_int16_t
#define __le32 u_int32_t
@ -54,11 +56,23 @@
#endif
#ifndef container_of
#define container_of(ptr, type, member) ({ \
#define container_of(ptr, type, member) ({ \
const typeof( ((type *)0)->member ) *__mptr = (ptr); \
(type *)( (char *)__mptr - offsetof(type,member) );})
#endif
#ifndef list_for_each_entry_reverse
#define list_for_each_entry_reverse(pos, head, member) \
for (pos = list_entry((head)->prev, typeof(*pos), member); \
prefetch(pos->member.prev), &pos->member != (head); \
pos = list_entry(pos->member.prev, typeof(*pos), member))
#endif
#ifndef NETDEV_TX_OK
#define NETDEV_TX_OK 0
#define NETDEV_TX_BUSY 1
#endif
/*
* BSD/Linux compatibility shims. These are used mainly to
* minimize differences when importing necesary BSD code.

View File

@ -52,11 +52,6 @@
#include <net80211/ieee80211_var.h>
#include <net80211/ieee80211_proto.h>
#ifndef NETDEV_TX_OK
#define NETDEV_TX_OK 0
#define NETDEV_TX_BUSY 1
#endif
static void ieee80211_set_tim(struct ieee80211_node *ni, int set);
void

View File

@ -46,7 +46,12 @@
#include <linux/netdevice.h>
#include <linux/init.h>
#include <linux/delay.h>
#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,11)
#include "sort.c"
#else
#include <linux/sort.h>
#endif
#include "if_media.h"