Skip to content

Commit

Permalink
Staging: rtl8192su: remove kernel version compatibility wrappers
Browse files Browse the repository at this point in the history
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
  • Loading branch information
Bartlomiej Zolnierkiewicz authored and Greg Kroah-Hartman committed Sep 15, 2009
1 parent 7fdb78d commit 1ec9e48
Show file tree
Hide file tree
Showing 27 changed files with 77 additions and 1,488 deletions.
11 changes: 1 addition & 10 deletions drivers/staging/rtl8192su/ieee80211/dot11d.c
Original file line number Diff line number Diff line change
Expand Up @@ -218,22 +218,13 @@ int ToLegalChannel(

return default_chn;
}
#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,5,0))

EXPORT_SYMBOL(Dot11d_Init);
EXPORT_SYMBOL(Dot11d_Reset);
EXPORT_SYMBOL(Dot11d_UpdateCountryIe);
EXPORT_SYMBOL(DOT11D_GetMaxTxPwrInDbm);
EXPORT_SYMBOL(DOT11D_ScanComplete);
EXPORT_SYMBOL(IsLegalChannel);
EXPORT_SYMBOL(ToLegalChannel);
#else
EXPORT_SYMBOL_NOVERS(Dot11d_Init);
EXPORT_SYMBOL_NOVERS(Dot11d_Reset);
EXPORT_SYMBOL_NOVERS(Dot11d_UpdateCountryIe);
EXPORT_SYMBOL_NOVERS(DOT11D_GetMaxTxPwrInDbm);
EXPORT_SYMBOL_NOVERS(DOT11D_ScanComplete);
EXPORT_SYMBOL_NOVERS(IsLegalChannel);
EXPORT_SYMBOL_NOVERS(ToLegalChannel);
#endif

#endif
120 changes: 0 additions & 120 deletions drivers/staging/rtl8192su/ieee80211/ieee80211.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,7 @@
#include <linux/kernel.h> /* ARRAY_SIZE */
#include <linux/version.h>
#include <linux/module.h>
#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,5,0))
#include <linux/jiffies.h>
#else
#include <linux/jffs.h>
#include <linux/tqueue.h>
#endif
#include <linux/timer.h>
#include <linux/sched.h>

Expand All @@ -43,12 +38,6 @@
#include "rtl819x_BA.h"
#include "rtl819x_TS.h"

#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,20))
#ifndef bool
typedef enum{false = 0, true} bool;
#endif
#endif

#ifndef IW_MODE_MONITOR
#define IW_MODE_MONITOR 6
#endif
Expand All @@ -57,25 +46,6 @@ typedef enum{false = 0, true} bool;
#define IWEVCUSTOM 0x8c02
#endif

#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0))
#ifndef __bitwise
#define __bitwise __attribute__((bitwise))
#endif
typedef __u16 __le16;
#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,4,27))
struct iw_spy_data{
/* --- Standard spy support --- */
int spy_number;
u_char spy_address[IW_MAX_SPY][ETH_ALEN];
struct iw_quality spy_stat[IW_MAX_SPY];
/* --- Enhanced spy support (event) */
struct iw_quality spy_thr_low; /* Low threshold */
struct iw_quality spy_thr_high; /* High threshold */
u_char spy_thr_under[IW_MAX_SPY];
};
#endif
#endif

#ifndef container_of
/**
* container_of - cast a member of a structure out to the containing structure
Expand Down Expand Up @@ -456,46 +426,8 @@ typedef struct ieee_param {
#define IW_QUAL_NOISE_UPDATED 0x4
#endif

#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0))
static inline void tq_init(struct tq_struct * task, void(*func)(void *), void *data)
{
task->routine = func;
task->data = data;
//task->next = NULL;
INIT_LIST_HEAD(&task->list);
task->sync = 0;
}
#endif

// linux under 2.6.9 release may not support it, so modify it for common use
#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,9))
//#define MSECS(t) (1000 * ((t) / HZ) + 1000 * ((t) % HZ) / HZ)
#define MSECS(t) (HZ * ((t) / 1000) + (HZ * ((t) % 1000)) / 1000)
static inline unsigned long msleep_interruptible_rsl(unsigned int msecs)
{
unsigned long timeout = MSECS(msecs) + 1;

while (timeout) {
set_current_state(TASK_INTERRUPTIBLE);
timeout = schedule_timeout(timeout);
}
return timeout;
}
#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,4,31))
static inline void msleep(unsigned int msecs)
{
unsigned long timeout = MSECS(msecs) + 1;

while (timeout) {
set_current_state(TASK_UNINTERRUPTIBLE);
timeout = schedule_timeout(timeout);
}
}
#endif
#else
#define MSECS(t) msecs_to_jiffies(t)
#define msleep_interruptible_rsl msleep_interruptible
#endif

#define IEEE80211_DATA_LEN 2304
/* Maximum size for the MA-UNITDATA primitive, 802.11 standard section
Expand Down Expand Up @@ -1787,21 +1719,6 @@ enum ieee80211_state {
#define IEEE80211_52GHZ_CHANNELS (IEEE80211_52GHZ_MAX_CHANNEL - \
IEEE80211_52GHZ_MIN_CHANNEL + 1)

#if (LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,11))
extern inline int is_multicast_ether_addr(const u8 *addr)
{
return ((addr[0] != 0xff) && (0x01 & addr[0]));
}
#endif

#if (LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,13))
extern inline int is_broadcast_ether_addr(const u8 *addr)
{
return ((addr[0] == 0xff) && (addr[1] == 0xff) && (addr[2] == 0xff) && \
(addr[3] == 0xff) && (addr[4] == 0xff) && (addr[5] == 0xff));
}
#endif

typedef struct tx_pending_t{
int frag;
struct ieee80211_txb *txb;
Expand Down Expand Up @@ -1879,11 +1796,7 @@ typedef struct _RT_POWER_SAVE_CONTROL
bool bHaltAdapterClkRQ;
bool bSwRfProcessing;
RT_RF_POWER_STATE eInactivePowerState;
#if LINUX_VERSION_CODE > KERNEL_VERSION(2,5,0)
struct work_struct InactivePsWorkItem;
#else
struct tq_struct InactivePsWorkItem;
#endif
struct timer_list InactivePsTimer;

// Return point for join action
Expand Down Expand Up @@ -2290,41 +2203,17 @@ struct ieee80211_device {

/* used if IEEE_SOFTMAC_BEACONS is set */
struct timer_list beacon_timer;
#if LINUX_VERSION_CODE > KERNEL_VERSION(2,5,0)
struct work_struct associate_complete_wq;
struct work_struct associate_procedure_wq;
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)
struct delayed_work softmac_scan_wq;
struct delayed_work associate_retry_wq;
struct delayed_work start_ibss_wq;
struct delayed_work hw_wakeup_wq;
struct delayed_work hw_sleep_wq;
struct delayed_work link_change_wq;
#else
struct work_struct softmac_scan_wq;
struct work_struct associate_retry_wq;
struct work_struct start_ibss_wq;
struct work_struct hw_wakeup_wq;
struct work_struct hw_sleep_wq;
struct work_struct link_change_wq;
#endif
struct work_struct wx_sync_scan_wq;
struct workqueue_struct *wq;
#else
/* used for periodly scan */
struct timer_list scan_timer;

struct tq_struct associate_complete_wq;
struct tq_struct associate_retry_wq;
struct tq_struct start_ibss_wq;
struct tq_struct associate_procedure_wq;
struct tq_struct softmac_scan_wq;
struct tq_struct wx_sync_scan_wq;
struct tq_struct hw_wakeup_wq;
struct tq_struct hw_sleep_wq;
struct tq_struct link_change_wq;

#endif
// Qos related. Added by Annie, 2005-11-01.
//STA_QOS StaQos;

Expand Down Expand Up @@ -2512,11 +2401,7 @@ struct ieee80211_device {

static inline void *ieee80211_priv(struct net_device *dev)
{
#if LINUX_VERSION_CODE > KERNEL_VERSION(2,5,0)
return ((struct ieee80211_device *)netdev_priv(dev))->priv;
#else
return ((struct ieee80211_device *)dev->priv)->priv;
#endif
}

extern inline int ieee80211_is_empty_essid(const char *essid, int essid_len)
Expand Down Expand Up @@ -2769,12 +2654,7 @@ extern int ieee80211_wx_get_freq(struct ieee80211_device *ieee, struct iw_reques
union iwreq_data *wrqu, char *b);

//extern void ieee80211_wx_sync_scan_wq(struct ieee80211_device *ieee);
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20))
extern void ieee80211_wx_sync_scan_wq(struct work_struct *work);
#else
extern void ieee80211_wx_sync_scan_wq(struct ieee80211_device *ieee);
#endif


extern int ieee80211_wx_set_rawtx(struct ieee80211_device *ieee,
struct iw_request_info *info,
Expand Down
14 changes: 0 additions & 14 deletions drivers/staging/rtl8192su/ieee80211/ieee80211_crypt.c
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,7 @@ void ieee80211_crypt_deinit_entries(struct ieee80211_device *ieee,

if (entry->ops) {
entry->ops->deinit(entry->priv);
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0)
module_put(entry->ops->owner);
#else
__MOD_DEC_USE_COUNT(entry->ops->owner);
#endif
}
kfree(entry);
}
Expand Down Expand Up @@ -251,23 +247,13 @@ static void __exit ieee80211_crypto_deinit(void)
kfree(hcrypt);
}

#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,5,0))
EXPORT_SYMBOL(ieee80211_crypt_deinit_entries);
EXPORT_SYMBOL(ieee80211_crypt_deinit_handler);
EXPORT_SYMBOL(ieee80211_crypt_delayed_deinit);

EXPORT_SYMBOL(ieee80211_register_crypto_ops);
EXPORT_SYMBOL(ieee80211_unregister_crypto_ops);
EXPORT_SYMBOL(ieee80211_get_crypto_ops);
#else
EXPORT_SYMBOL_NOVERS(ieee80211_crypt_deinit_entries);
EXPORT_SYMBOL_NOVERS(ieee80211_crypt_deinit_handler);
EXPORT_SYMBOL_NOVERS(ieee80211_crypt_delayed_deinit);

EXPORT_SYMBOL_NOVERS(ieee80211_register_crypto_ops);
EXPORT_SYMBOL_NOVERS(ieee80211_unregister_crypto_ops);
EXPORT_SYMBOL_NOVERS(ieee80211_get_crypto_ops);
#endif

module_init(ieee80211_crypto_init);
module_exit(ieee80211_crypto_deinit);
7 changes: 0 additions & 7 deletions drivers/staging/rtl8192su/ieee80211/ieee80211_crypt.h
Original file line number Diff line number Diff line change
Expand Up @@ -82,12 +82,5 @@ void ieee80211_crypt_deinit_entries(struct ieee80211_device *, int);
void ieee80211_crypt_deinit_handler(unsigned long);
void ieee80211_crypt_delayed_deinit(struct ieee80211_device *ieee,
struct ieee80211_crypt_data **crypt);
#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0))
#define offset_in_page(p) ((unsigned long)(p) & ~PAGE_MASK)
#endif
#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,4,31))
#define crypto_alloc_tfm crypto_alloc_tfm_rsl
#define crypto_free_tfm crypto_free_tfm_rsl
#endif

#endif
51 changes: 4 additions & 47 deletions drivers/staging/rtl8192su/ieee80211/ieee80211_crypt_ccmp.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,18 +24,8 @@

#include "ieee80211.h"

#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0))
#include "rtl_crypto.h"
#else
#include <linux/crypto.h>
#endif

#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,20)
#include <asm/scatterlist.h>
#else
#include <linux/scatterlist.h>
#endif
//#include <asm/scatterlist.h>
#include <linux/scatterlist.h>

MODULE_AUTHOR("Jouni Malinen");
MODULE_DESCRIPTION("Host AP crypt: CCMP");
Expand Down Expand Up @@ -75,21 +65,7 @@ struct ieee80211_ccmp_data {
void ieee80211_ccmp_aes_encrypt(struct crypto_tfm *tfm,
const u8 pt[16], u8 ct[16])
{
#if((LINUX_VERSION_CODE < KERNEL_VERSION(2,6,21)) && (!OPENSUSE_SLED))
struct scatterlist src, dst;

src.page = virt_to_page(pt);
src.offset = offset_in_page(pt);
src.length = AES_BLOCK_LEN;

dst.page = virt_to_page(ct);
dst.offset = offset_in_page(ct);
dst.length = AES_BLOCK_LEN;

crypto_cipher_encrypt(tfm, &dst, &src, AES_BLOCK_LEN);
#else
crypto_cipher_encrypt_one((void*)tfm, ct, pt);
#endif
}

static void * ieee80211_ccmp_init(int key_idx)
Expand All @@ -102,32 +78,20 @@ static void * ieee80211_ccmp_init(int key_idx)
memset(priv, 0, sizeof(*priv));
priv->key_idx = key_idx;

#if((LINUX_VERSION_CODE < KERNEL_VERSION(2,6,21)) && (!OPENSUSE_SLED))
priv->tfm = crypto_alloc_tfm("aes", 0);
if (priv->tfm == NULL) {
printk(KERN_DEBUG "ieee80211_crypt_ccmp: could not allocate "
"crypto API aes\n");
goto fail;
}
#else
priv->tfm = (void*)crypto_alloc_cipher("aes", 0, CRYPTO_ALG_ASYNC);
priv->tfm = (void *)crypto_alloc_cipher("aes", 0, CRYPTO_ALG_ASYNC);
if (IS_ERR(priv->tfm)) {
printk(KERN_DEBUG "ieee80211_crypt_ccmp: could not allocate "
"crypto API aes\n");
priv->tfm = NULL;
goto fail;
}
#endif

return priv;

fail:
if (priv) {
if (priv->tfm)
#if(LINUX_VERSION_CODE < KERNEL_VERSION(2,6,21))
crypto_free_tfm(priv->tfm);
#else
crypto_free_cipher((void*)priv->tfm);
#endif
kfree(priv);
}

Expand All @@ -138,12 +102,9 @@ static void * ieee80211_ccmp_init(int key_idx)
static void ieee80211_ccmp_deinit(void *priv)
{
struct ieee80211_ccmp_data *_priv = priv;

if (_priv && _priv->tfm)
#if(LINUX_VERSION_CODE < KERNEL_VERSION(2,6,21))
crypto_free_tfm(_priv->tfm);
#else
crypto_free_cipher((void*)_priv->tfm);
#endif
kfree(priv);
}

Expand Down Expand Up @@ -524,11 +485,7 @@ static void __exit ieee80211_crypto_ccmp_exit(void)
ieee80211_unregister_crypto_ops(&ieee80211_crypt_ccmp);
}

#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,5,0))
EXPORT_SYMBOL(ieee80211_ccmp_null);
#else
EXPORT_SYMBOL_NOVERS(ieee80211_ccmp_null);
#endif

module_init(ieee80211_crypto_ccmp_init);
module_exit(ieee80211_crypto_ccmp_exit);
Loading

0 comments on commit 1ec9e48

Please sign in to comment.