Skip to content

Commit

Permalink
Staging: vt6655: move channel mapping code from card.c to channel.c
Browse files Browse the repository at this point in the history
Move functions managing the channel mapping to a new channel.c file, as done in
the staging VT6656 driver. The function names contained in card.c were prefixed
with CARD followed by the first letter of the return code, remove this and use
more coherent function names.

The following functions moved and were renamed:

ChannelValid			-> is_channel_valid
CARDbSetChannel			-> set_channel
CARDvInitChannelTable		-> init_channel_table
CARDbyGetChannelMapping 	-> get_channel_mapping
CARDvSetCountryInfo		-> set_country_info
CARDbySetSupportChannels 	-> set_support_channels
CARDbChannelGetList		-> channel_get_list
CARDvSetCountryIE		-> set_country_IE
CARDbGetChannelMapInfo		-> get_channel_map_info
CARDvSetChannelMapInfo		-> set_channel_map_info
CARDvClearChannelMapInfo	-> clear_channel_map_info
CARDbyAutoChannelSelect		-> auto_channel_select
CARDbyGetChannelNumber		-> get_channel_number

Signed-off-by: Charles Clément <caratorn@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
  • Loading branch information
Charles Clément authored and Greg Kroah-Hartman committed Jun 22, 2010
1 parent 2a1a174 commit 79566eb
Show file tree
Hide file tree
Showing 12 changed files with 931 additions and 982 deletions.
3 changes: 2 additions & 1 deletion drivers/staging/vt6655/IEEE11h.c
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
#include "device.h"
#include "wmgr.h"
#include "rxtx.h"
#include "channel.h"

/*--------------------- Static Definitions -------------------------*/
static int msglevel =MSG_LEVEL_INFO;
Expand Down Expand Up @@ -245,7 +246,7 @@ IEEE11hbMgrRxAction (
// valid element id
CARDbChannelSwitch( pMgmt->pAdapter,
pChannelSwitch->byMode,
CARDbyGetChannelMapping(pMgmt->pAdapter, pChannelSwitch->byChannel, pMgmt->eCurrentPHYMode),
get_channel_mapping(pMgmt->pAdapter, pChannelSwitch->byChannel, pMgmt->eCurrentPHYMode),
pChannelSwitch->byCount
);
}
Expand Down
1 change: 1 addition & 0 deletions drivers/staging/vt6655/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ EXTRA_CFLAGS += -DHOSTAP

vt6655_stage-y += device_main.o \
card.o \
channel.o \
mac.o \
baseband.o \
wctl.o \
Expand Down
1 change: 0 additions & 1 deletion drivers/staging/vt6655/TODO
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ TODO:
- prepare for merge with vt6656 driver:
- rename DEVICE_PRT() to DBG_PRT() -- done
- share 80211*.h includes
- move code for channel mapping from card.c to channel.c
- split rf.c
- remove dead code
- abstract VT3253 chipset specific code
Expand Down
7 changes: 3 additions & 4 deletions drivers/staging/vt6655/bssdb.c
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@
#include "baseband.h"
#include "rf.h"
#include "card.h"
#include "channel.h"
#include "mac.h"
#include "wpa2.h"
#include "iowpa.h"
Expand Down Expand Up @@ -527,8 +528,7 @@ BSSbInsertToBSSList (

if ((pIE_Country != NULL) &&
(pMgmt->b11hEnable == TRUE)) {
CARDvSetCountryInfo(pMgmt->pAdapter,
pBSSList->eNetworkTypeInUse,
set_country_info(pMgmt->pAdapter, pBSSList->eNetworkTypeInUse,
pIE_Country);
}

Expand Down Expand Up @@ -704,8 +704,7 @@ BSSbUpdateToBSSList (

if ((pIE_Country != NULL) &&
(pMgmt->b11hEnable == TRUE)) {
CARDvSetCountryInfo(pMgmt->pAdapter,
pBSSList->eNetworkTypeInUse,
set_country_info(pMgmt->pAdapter, pBSSList->eNetworkTypeInUse,
pIE_Country);
}

Expand Down
881 changes: 4 additions & 877 deletions drivers/staging/vt6655/card.c

Large diffs are not rendered by default.

59 changes: 0 additions & 59 deletions drivers/staging/vt6655/card.h
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,6 @@ typedef enum _CARD_OP_MODE {

/*--------------------- Export Functions --------------------------*/

BOOL ChannelValid(unsigned int ChannelIndex);
void CARDvSetRSPINF(void *pDeviceHandler, CARD_PHY_TYPE ePHYType);
void vUpdateIFS(void *pDeviceHandler);
void CARDvUpdateBasicTopRate(void *pDeviceHandler);
Expand All @@ -107,7 +106,6 @@ void CARDvSafeResetRx(void *pDeviceHandler);
//xxx
BOOL CARDbRadioPowerOff(void *pDeviceHandler);
BOOL CARDbRadioPowerOn(void *pDeviceHandler);
BOOL CARDbSetChannel(void *pDeviceHandler, unsigned int uConnectionChannel);
//BOOL CARDbSendPacket(void *pDeviceHandler, void *pPacket, CARD_PKT_TYPE ePktType, unsigned int uLength);
BOOL CARDbIsShortPreamble(void *pDeviceHandler);
BOOL CARDbIsShorSlotTime(void *pDeviceHandler);
Expand Down Expand Up @@ -144,10 +142,6 @@ CARDpGetCurrentAddress (
void *pDeviceHandler
);


void CARDvInitChannelTable(void *pDeviceHandler);
BYTE CARDbyGetChannelMapping(void *pDeviceHandler, BYTE byChannelNumber, CARD_PHY_TYPE ePhyType);

BOOL
CARDbStartMeasure (
void *pDeviceHandler,
Expand Down Expand Up @@ -178,13 +172,6 @@ CARDbStartQuiet (
void *pDeviceHandler
);

void
CARDvSetCountryInfo (
void *pDeviceHandler,
CARD_PHY_TYPE ePHYType,
void *pIE
);

void
CARDvSetPowerConstraint (
void *pDeviceHandler,
Expand All @@ -199,57 +186,11 @@ CARDvGetPowerCapability (
unsigned char *pbyMaxPower
);

BYTE
CARDbySetSupportChannels (
void *pDeviceHandler,
unsigned char *pbyIEs
);

char
CARDbyGetTransmitPower (
void *pDeviceHandler
);

BOOL
CARDbChannelGetList (
unsigned int uCountryCodeIdx,
unsigned char *pbyChannelTable
);

void
CARDvSetCountryIE(
void *pDeviceHandler,
void *pIE
);

BOOL
CARDbGetChannelMapInfo(
void *pDeviceHandler,
unsigned int uChannelIndex,
unsigned char *pbyChannelNumber,
unsigned char *pbyMap
);

void
CARDvSetChannelMapInfo(
void *pDeviceHandler,
unsigned int uChannelIndex,
BYTE byMap
);

void
CARDvClearChannelMapInfo(
void *pDeviceHandler
);

BYTE
CARDbyAutoChannelSelect(
void *pDeviceHandler,
CARD_PHY_TYPE ePHYType
);

BYTE CARDbyGetChannelNumber(void *pDeviceHandler, BYTE byChannelIndex);

#endif // __CARD_H__


Expand Down
835 changes: 835 additions & 0 deletions drivers/staging/vt6655/channel.c

Large diffs are not rendered by default.

58 changes: 58 additions & 0 deletions drivers/staging/vt6655/channel.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
/*
* Copyright (c) 1996, 2003 VIA Networking Technologies, Inc.
* All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
* File: channel.h
*
*/

#ifndef _CHANNEL_H_
#define _CHANNEL_H_

#include "ttype.h"
#include "card.h"

/*--------------------- Export Classes ----------------------------*/

typedef struct tagSChannelTblElement {
BYTE byChannelNumber;
unsigned int uFrequency;
BOOL bValid;
BYTE byMAP;
}SChannelTblElement, *PSChannelTblElement;


/*--------------------- Export Functions --------------------------*/

BOOL is_channel_valid(unsigned int CountryCode);
void init_channel_table(void *pDeviceHandler);
BYTE get_channel_mapping(void *pDeviceHandler, BYTE byChannelNumber, CARD_PHY_TYPE ePhyType);
BOOL channel_get_list(unsigned int uCountryCodeIdx, unsigned char *pbyChannelTable);
BYTE get_channel_number(void *pDeviceHandler, BYTE byChannelIndex);
BOOL set_channel(void *pDeviceHandler, unsigned int uConnectionChannel);
void set_country_info(void *pDeviceHandler, CARD_PHY_TYPE ePHYType, void *pIE);
BYTE set_support_channels(void *pDeviceHandler, unsigned char *pbyIEs);
void set_country_IE(void *pDeviceHandler, void *pIE);
BOOL get_channel_map_info(void *pDeviceHandler, unsigned int uChannelIndex,
unsigned char *pbyChannelNumber, unsigned char *pbyMap);
void set_channel_map_info(void *pDeviceHandler, unsigned int uChannelIndex,
BYTE byMap);
void clear_channel_map_info(void *pDeviceHandler);
BYTE auto_channel_select(void *pDeviceHandler, CARD_PHY_TYPE ePHYType);


#endif /* _CHANNEL_H_ */
15 changes: 0 additions & 15 deletions drivers/staging/vt6655/country.h
Original file line number Diff line number Diff line change
Expand Up @@ -159,19 +159,4 @@ typedef enum _COUNTRY_CODE {
CCODE_MAX
} COUNTRY_CODE;

typedef struct tagSCountryTable
{
BYTE byChannelCountryCode; /* The country code */
char chCountryCode[2];
BYTE bChannelIdxList[CB_MAX_CHANNEL]; /* Available channels Index */
BYTE byPower[CB_MAX_CHANNEL];
} SCountryTable, *PSCountryTable;

/*--------------------- Export Classes ----------------------------*/

/*--------------------- Export Variables --------------------------*/
extern SCountryTable ChannelRuleTab[CCODE_MAX+1];

/*--------------------- Export Functions --------------------------*/

#endif /* __COUNTRY_H__ */
11 changes: 6 additions & 5 deletions drivers/staging/vt6655/device_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@

#include "device.h"
#include "card.h"
#include "channel.h"
#include "baseband.h"
#include "mac.h"
#include "tether.h"
Expand Down Expand Up @@ -730,7 +731,7 @@ else
pDevice->abyOFDMPwrTbl[ii+CB_MAX_CHANNEL_24G+1] = SROMbyReadEmbedded(pDevice->PortOffset, (BYTE)(ii + EEP_OFS_OFDMA_PWR_TBL));
pDevice->abyOFDMDefaultPwr[ii+CB_MAX_CHANNEL_24G+1] = SROMbyReadEmbedded(pDevice->PortOffset, (BYTE)(ii + EEP_OFS_OFDMA_PWR_dBm));
}
CARDvInitChannelTable((void *)pDevice);
init_channel_table((void *)pDevice);


if (pDevice->byLocalID > REV_ID_VT3253_B1) {
Expand Down Expand Up @@ -2749,7 +2750,7 @@ static irqreturn_t device_intr(int irq, void *dev_instance) {
MACvSelectPage0(pDevice->PortOffset);
//xxxx
// WCMDbFlushCommandQueue(pDevice->pMgmt, TRUE);
if (CARDbSetChannel(pDevice, pDevice->pCurrMeasureEID->sReq.byChannel) == TRUE) {
if (set_channel(pDevice, pDevice->pCurrMeasureEID->sReq.byChannel) == TRUE) {
pDevice->bMeasureInProgress = TRUE;
MACvSelectPage1(pDevice->PortOffset);
MACvRegBitsOn(pDevice->PortOffset, MAC_REG_MSRCTL, MSRCTL_READY);
Expand Down Expand Up @@ -2784,7 +2785,7 @@ static irqreturn_t device_intr(int irq, void *dev_instance) {
// clear measure control
MACvRegBitsOff(pDevice->PortOffset, MAC_REG_MSRCTL, MSRCTL_EN);
MACvSelectPage0(pDevice->PortOffset);
CARDbSetChannel(pDevice, pDevice->byOrgChannel);
set_channel(pDevice, pDevice->byOrgChannel);
// WCMDbResetCommandQueue(pDevice->pMgmt);
MACvSelectPage1(pDevice->PortOffset);
MACvRegBitsOn(pDevice->PortOffset, MAC_REG_MSRCTL+1, MSRCTL1_TXPAUSE);
Expand Down Expand Up @@ -2819,7 +2820,7 @@ static irqreturn_t device_intr(int irq, void *dev_instance) {
pDevice->byChannelSwitchCount--;
if (pDevice->byChannelSwitchCount == 0) {
pDevice->bChannelSwitch = FALSE;
CARDbSetChannel(pDevice, pDevice->byNewChannel);
set_channel(pDevice, pDevice->byNewChannel);
VNTWIFIbChannelSwitch(pDevice->pMgmt, pDevice->byNewChannel);
MACvSelectPage1(pDevice->PortOffset);
MACvRegBitsOn(pDevice->PortOffset, MAC_REG_MSRCTL+1, MSRCTL1_TXPAUSE);
Expand Down Expand Up @@ -2905,7 +2906,7 @@ static irqreturn_t device_intr(int irq, void *dev_instance) {
pDevice->byChannelSwitchCount--;
if (pDevice->byChannelSwitchCount == 0) {
pDevice->bChannelSwitch = FALSE;
CARDbSetChannel(pDevice, pDevice->byNewChannel);
set_channel(pDevice, pDevice->byNewChannel);
VNTWIFIbChannelSwitch(pDevice->pMgmt, pDevice->byNewChannel);
MACvSelectPage1(pDevice->PortOffset);
MACvRegBitsOn(pDevice->PortOffset, MAC_REG_MSRCTL+1, MSRCTL1_TXPAUSE);
Expand Down
11 changes: 6 additions & 5 deletions drivers/staging/vt6655/wcmd.c
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@
#include "rxtx.h"
#include "rf.h"
#include "iowpa.h"
#include "channel.h"

/*--------------------- Static Definitions -------------------------*/

Expand Down Expand Up @@ -396,7 +397,7 @@ vCommandTimer (

// Set Baseband's sensitivity back.
// Set channel back
CARDbSetChannel(pMgmt->pAdapter, pMgmt->uCurrChannel);
set_channel(pMgmt->pAdapter, pMgmt->uCurrChannel);
DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Scanning, set back to channel: [%d]\n", pMgmt->uCurrChannel);
if (pMgmt->eCurrMode == WMAC_MODE_IBSS_STA) {
CARDbSetBSSID(pMgmt->pAdapter, pMgmt->abyCurrBSSID, OP_MODE_ADHOC);
Expand All @@ -408,7 +409,7 @@ vCommandTimer (

} else {
//2008-8-4 <add> by chester
if (!ChannelValid(pMgmt->uScanChannel)) {
if (!is_channel_valid(pMgmt->uScanChannel)) {
DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Invalid channel pMgmt->uScanChannel = %d \n",pMgmt->uScanChannel);
s_bCommandComplete(pDevice);
return;
Expand All @@ -431,7 +432,7 @@ vCommandTimer (

vAdHocBeaconStop(pDevice);

if (CARDbSetChannel(pMgmt->pAdapter, pMgmt->uScanChannel) == TRUE) {
if (set_channel(pMgmt->pAdapter, pMgmt->uScanChannel) == TRUE) {
DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"SCAN Channel: %d\n", pMgmt->uScanChannel);
} else {
DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"SET SCAN Channel Fail: %d\n", pMgmt->uScanChannel);
Expand All @@ -441,7 +442,7 @@ vCommandTimer (
// printk("chester-ch=%d\n",pMgmt->uScanChannel);
pMgmt->uScanChannel++;
//2008-8-4 <modify> by chester
if (!ChannelValid(pMgmt->uScanChannel) &&
if (!is_channel_valid(pMgmt->uScanChannel) &&
pMgmt->uScanChannel <= pDevice->byMaxChannel ){
pMgmt->uScanChannel=pDevice->byMaxChannel+1;
pMgmt->eCommandState = WLAN_CMD_SCAN_END;
Expand Down Expand Up @@ -469,7 +470,7 @@ vCommandTimer (

// Set Baseband's sensitivity back.
// Set channel back
CARDbSetChannel(pMgmt->pAdapter, pMgmt->uCurrChannel);
set_channel(pMgmt->pAdapter, pMgmt->uCurrChannel);
DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Scanning, set back to channel: [%d]\n", pMgmt->uCurrChannel);
if (pMgmt->eCurrMode == WMAC_MODE_IBSS_STA) {
CARDbSetBSSID(pMgmt->pAdapter, pMgmt->abyCurrBSSID, OP_MODE_ADHOC);
Expand Down
Loading

0 comments on commit 79566eb

Please sign in to comment.