diff options
Diffstat (limited to 'drivers/staging/vt6656/iwctl.c')
| -rw-r--r-- | drivers/staging/vt6656/iwctl.c | 168 | 
1 files changed, 68 insertions, 100 deletions
diff --git a/drivers/staging/vt6656/iwctl.c b/drivers/staging/vt6656/iwctl.c index d0cf7d8a20e..c43718d788c 100644 --- a/drivers/staging/vt6656/iwctl.c +++ b/drivers/staging/vt6656/iwctl.c @@ -34,13 +34,12 @@  #include "iwctl.h"  #include "mac.h"  #include "card.h" -#include "hostap.h"  #include "power.h"  #include "rf.h"  #include "iowpa.h"  #include "wpactl.h" -#include "control.h" -#include "rndis.h" +#include "usbpipe.h" +#include "baseband.h"  static const long frequency_list[] = {  	2412, 2417, 2422, 2427, 2432, 2437, 2442, 2447, 2452, 2457, 2462, 2467, 2472, 2484, @@ -57,18 +56,14 @@ struct iw_statistics *iwctl_get_wireless_stats(struct net_device *dev)  	struct vnt_private *pDevice = netdev_priv(dev);  	long ldBm; -	pDevice->wstats.status = pDevice->eOPMode; -	if (pDevice->scStatistic.LinkQuality > 100) -		pDevice->scStatistic.LinkQuality = 100; -	pDevice->wstats.qual.qual =(u8)pDevice->scStatistic.LinkQuality; -	RFvRSSITodBm(pDevice, (u8)(pDevice->uCurrRSSI), &ldBm); +	pDevice->wstats.status = pDevice->op_mode; +	vnt_rf_rssi_to_dbm(pDevice, (u8)(pDevice->uCurrRSSI), &ldBm);  	pDevice->wstats.qual.level = ldBm;  	pDevice->wstats.qual.noise = 0;  	pDevice->wstats.qual.updated = 1;  	pDevice->wstats.discard.nwid = 0;  	pDevice->wstats.discard.code = 0;  	pDevice->wstats.discard.fragment = 0; -	pDevice->wstats.discard.retries = pDevice->scStatistic.dwTsrErr;  	pDevice->wstats.discard.misc = 0;  	pDevice->wstats.miss.beacon = 0;  	return &pDevice->wstats; @@ -96,6 +91,7 @@ int iwctl_siwscan(struct net_device *dev, struct iw_request_info *info,  	struct iw_scan_req *req = (struct iw_scan_req *)extra;  	u8 abyScanSSID[WLAN_IEHDR_LEN + WLAN_SSID_MAXLEN + 1];  	PWLAN_IE_SSID pItemSSID = NULL; +	unsigned long flags;  	if (!(pDevice->flags & DEVICE_FLAGS_OPENED))  		return -EINVAL; @@ -120,7 +116,7 @@ int iwctl_siwscan(struct net_device *dev, struct iw_request_info *info,  		return 0;  	} -	spin_lock_irq(&pDevice->lock); +	spin_lock_irqsave(&pDevice->lock, flags);  	BSSvClearBSSList((void *)pDevice, pDevice->bLinkPass); @@ -141,7 +137,8 @@ int iwctl_siwscan(struct net_device *dev, struct iw_request_info *info,  			PRINT_K("SIOCSIWSCAN:[desired_ssid=%s,len=%d]\n", ((PWLAN_IE_SSID)abyScanSSID)->abySSID,  				((PWLAN_IE_SSID)abyScanSSID)->len);  			bScheduleCommand((void *)pDevice, WLAN_CMD_BSSID_SCAN, abyScanSSID); -			spin_unlock_irq(&pDevice->lock); + +			spin_unlock_irqrestore(&pDevice->lock, flags);  			return 0;  		} else if (req->scan_type == IW_SCAN_TYPE_PASSIVE) { // passive scan @@ -153,7 +150,8 @@ int iwctl_siwscan(struct net_device *dev, struct iw_request_info *info,  	pMgmt->eScanType = WMAC_SCAN_PASSIVE;  	bScheduleCommand((void *)pDevice, WLAN_CMD_BSSID_SCAN, NULL); -	spin_unlock_irq(&pDevice->lock); + +	spin_unlock_irqrestore(&pDevice->lock, flags);  	return 0;  } @@ -190,7 +188,7 @@ int iwctl_giwscan(struct net_device *dev, struct iw_request_info *info,  		return -EAGAIN;  	}  	pBSS = &(pMgmt->sBSSList[0]); -	for (ii = 0, jj = 0; jj < MAX_BSS_NUM ; jj++) { +	for (ii = 0, jj = 0; jj < MAX_BSS_NUM; jj++) {  		if (current_ev >= end_buf)  			break;  		pBSS = &(pMgmt->sBSSList[jj]); @@ -225,7 +223,7 @@ int iwctl_giwscan(struct net_device *dev, struct iw_request_info *info,  			iwe.u.freq.m = pBSS->uChannel;  			iwe.u.freq.e = 0;  			iwe.u.freq.i = 0; -			current_ev = iwe_stream_add_event(info, current_ev,end_buf, &iwe, IW_EV_FREQ_LEN); +			current_ev = iwe_stream_add_event(info, current_ev, end_buf, &iwe, IW_EV_FREQ_LEN);  			{  				int f = (int)pBSS->uChannel - 1;  				if (f < 0) @@ -237,7 +235,7 @@ int iwctl_giwscan(struct net_device *dev, struct iw_request_info *info,  			// ADD quality  			memset(&iwe, 0, sizeof(iwe));  			iwe.cmd = IWEVQUAL; -			RFvRSSITodBm(pDevice, (u8)(pBSS->uRSSI), &ldBm); +			vnt_rf_rssi_to_dbm(pDevice, (u8)(pBSS->uRSSI), &ldBm);  			iwe.u.qual.level = ldBm;  			iwe.u.qual.noise = 0; @@ -380,6 +378,7 @@ int iwctl_siwmode(struct net_device *dev, struct iw_request_info *info,  	struct vnt_private *pDevice = netdev_priv(dev);  	__u32 *wmode = &wrqu->mode;  	struct vnt_manager *pMgmt = &pDevice->vnt_mgmt; +	unsigned long flags;  	int rc = 0;  	DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " SIOCSIWMODE\n"); @@ -387,12 +386,6 @@ int iwctl_siwmode(struct net_device *dev, struct iw_request_info *info,  	if (pMgmt == NULL)  		return -EFAULT; -	if (pMgmt->eCurrMode == WMAC_MODE_ESS_AP && pDevice->bEnableHostapd) { -		DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO -			"Can't set operation mode, hostapd is running\n"); -		return rc; -	} -  	switch (*wmode) {  	case IW_MODE_ADHOC:  		if (pMgmt->eConfigMode != WMAC_CONFIG_IBSS_STA) { @@ -400,7 +393,7 @@ int iwctl_siwmode(struct net_device *dev, struct iw_request_info *info,  			if (pDevice->flags & DEVICE_FLAGS_OPENED)  				pDevice->bCommit = true;  		} -		DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "set mode to ad-hoc \n"); +		DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "set mode to ad-hoc\n");  		break;  	case IW_MODE_AUTO:  	case IW_MODE_INFRA: @@ -409,22 +402,12 @@ int iwctl_siwmode(struct net_device *dev, struct iw_request_info *info,  			if (pDevice->flags & DEVICE_FLAGS_OPENED)  				pDevice->bCommit = true;  		} -		DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "set mode to infrastructure \n"); +		DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "set mode to infrastructure\n");  		break;  	case IW_MODE_MASTER: - -		pMgmt->eConfigMode = WMAC_CONFIG_ESS_STA;  		rc = -EOPNOTSUPP;  		break; -		if (pMgmt->eConfigMode != WMAC_CONFIG_AP) { -			pMgmt->eConfigMode = WMAC_CONFIG_AP; -			if (pDevice->flags & DEVICE_FLAGS_OPENED) -				pDevice->bCommit = true; -		} -		DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "set mode to Access Point \n"); -		break; -  	case IW_MODE_REPEAT:  		pMgmt->eConfigMode = WMAC_CONFIG_ESS_STA;  		rc = -EOPNOTSUPP; @@ -436,16 +419,17 @@ int iwctl_siwmode(struct net_device *dev, struct iw_request_info *info,  	if (pDevice->bCommit) {  		if (pMgmt->eConfigMode == WMAC_CONFIG_AP) {  			netif_stop_queue(pDevice->dev); -			spin_lock_irq(&pDevice->lock); + +			spin_lock_irqsave(&pDevice->lock, flags); +  			bScheduleCommand((void *) pDevice,  				WLAN_CMD_RUN_AP, NULL); -			spin_unlock_irq(&pDevice->lock); + +			spin_unlock_irqrestore(&pDevice->lock, flags);  		} else {  			DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO  				"Commit the settings\n"); -			spin_lock_irq(&pDevice->lock); -  			if (pDevice->bLinkPass &&  				memcmp(pMgmt->abyCurrSSID,  					pMgmt->abyDesireSSID, @@ -458,9 +442,7 @@ int iwctl_siwmode(struct net_device *dev, struct iw_request_info *info,  				memset(pMgmt->abyCurrBSSID, 0, 6);  			} -			ControlvMaskByte(pDevice, -				MESSAGE_REQUEST_MACREG,	MAC_REG_PAPEDELAY, -					LEDSTS_STS, LEDSTS_SLOW); +			vnt_mac_set_led(pDevice, LEDSTS_STS, LEDSTS_SLOW);  			netif_stop_queue(pDevice->dev); @@ -474,8 +456,6 @@ int iwctl_siwmode(struct net_device *dev, struct iw_request_info *info,  			bScheduleCommand((void *) pDevice,  				 WLAN_CMD_SSID,  				 NULL); - -			spin_unlock_irq(&pDevice->lock);  		}  		pDevice->bCommit = false;  	} @@ -657,8 +637,8 @@ int iwctl_siwap(struct net_device *dev, struct iw_request_info *info,  			unsigned uSameBssidNum = 0;  			for (ii = 0; ii < MAX_BSS_NUM; ii++) {  				if (pMgmt->sBSSList[ii].bActive && -					!compare_ether_addr(pMgmt->sBSSList[ii].abyBSSID, -							pMgmt->abyDesireBSSID)) { +					ether_addr_equal(pMgmt->sBSSList[ii].abyBSSID, +							 pMgmt->abyDesireBSSID)) {  					uSameBssidNum++;  				}  			} @@ -728,10 +708,10 @@ int iwctl_giwaplist(struct net_device *dev, struct iw_request_info *info,  	if (!wrq->pointer)  		return -EINVAL; -	sock = kzalloc(sizeof(struct sockaddr) * IW_MAX_AP, GFP_KERNEL); +	sock = kcalloc(IW_MAX_AP, sizeof(struct sockaddr), GFP_KERNEL);  	if (sock == NULL)  		return -ENOMEM; -	qual = kzalloc(sizeof(struct iw_quality) * IW_MAX_AP, GFP_KERNEL); +	qual = kcalloc(IW_MAX_AP, sizeof(struct iw_quality), GFP_KERNEL);  	if (qual == NULL) {  		kfree(sock);  		return -ENOMEM; @@ -786,8 +766,8 @@ int iwctl_siwessid(struct net_device *dev, struct iw_request_info *info,  	if (wrq->flags == 0) {  		// Just send an empty SSID list  		memset(pMgmt->abyDesireSSID, 0, WLAN_IEHDR_LEN + WLAN_SSID_MAXLEN + 1); -		memset(pMgmt->abyDesireBSSID, 0xFF,6); -		PRINT_K("set essid to 'any' \n"); +		memset(pMgmt->abyDesireBSSID, 0xFF, 6); +		PRINT_K("set essid to 'any'\n");  		// Unknown desired AP, so here need not associate??  		return 0;  	} else { @@ -798,15 +778,15 @@ int iwctl_siwessid(struct net_device *dev, struct iw_request_info *info,  		memcpy(pItemSSID->abySSID, extra, wrq->length);  		if (pItemSSID->abySSID[wrq->length] == '\0') { -			if (wrq->length>0) +			if (wrq->length > 0)  				pItemSSID->len = wrq->length;  		} else {  			pItemSSID->len = wrq->length;  		} -		PRINT_K("set essid to %s \n", pItemSSID->abySSID); +		PRINT_K("set essid to %s\n", pItemSSID->abySSID);  		// mike: need clear desiredBSSID -		if (pItemSSID->len==0) { +		if (pItemSSID->len == 0) {  			memset(pMgmt->abyDesireBSSID, 0xFF, 6);  			return 0;  		} @@ -840,8 +820,8 @@ int iwctl_siwessid(struct net_device *dev, struct iw_request_info *info,  				// are two same BSSID exist in list ?  				for (ii = 0; ii < MAX_BSS_NUM; ii++) {  					if (pMgmt->sBSSList[ii].bActive && -						!compare_ether_addr(pMgmt->sBSSList[ii].abyBSSID, -								pCurr->abyBSSID)) { +						ether_addr_equal(pMgmt->sBSSList[ii].abyBSSID, +								 pCurr->abyBSSID)) {  						uSameBssidNum++;  					}  				} @@ -860,7 +840,7 @@ int iwctl_siwessid(struct net_device *dev, struct iw_request_info *info,  			return 0;  		} -		DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "set essid = %s \n", pItemSSID->abySSID); +		DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "set essid = %s\n", pItemSSID->abySSID);  	}  	if (pDevice->flags & DEVICE_FLAGS_OPENED) @@ -893,7 +873,7 @@ int iwctl_giwessid(struct net_device *dev, struct iw_request_info *info,  	memcpy(extra, pItemSSID->abySSID, pItemSSID->len);  	extra[pItemSSID->len] = '\0'; -        wrq->length = pItemSSID->len; +	wrq->length = pItemSSID->len;  	wrq->flags = 1; // active  	return 0; @@ -915,7 +895,7 @@ int iwctl_siwrate(struct net_device *dev, struct iw_request_info *info,  		0x60, 0x6C, 0x90  	}; -	DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " SIOCSIWRATE \n"); +	DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " SIOCSIWRATE\n");  	if (!(pDevice->flags & DEVICE_FLAGS_OPENED)) {  		rc = -EINVAL;  		return rc; @@ -953,7 +933,7 @@ int iwctl_siwrate(struct net_device *dev, struct iw_request_info *info,  	}  	// Check that it is valid  	// brate is index of abySupportedRates[] -	if (brate > 13 ) { +	if (brate > 13) {  		rc = -EINVAL;  		return rc;  	} @@ -967,7 +947,7 @@ int iwctl_siwrate(struct net_device *dev, struct iw_request_info *info,  			pDevice->uConnectionRate = 3;  		} else {  			pDevice->uConnectionRate = brate; -			DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Fixed to Rate %d \n", pDevice->uConnectionRate); +			DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Fixed to Rate %d\n", pDevice->uConnectionRate);  		}  	} else {  		pDevice->bFixRate = false; @@ -1017,7 +997,7 @@ int iwctl_giwrate(struct net_device *dev, struct iw_request_info *info,  			if (pDevice->byBBType == BB_TYPE_11A)  				brate = 0x6C;  		} -    		if (pDevice->uConnectionRate == 13) +		if (pDevice->uConnectionRate == 13)  			brate = abySupportedRates[pDevice->wCurrentRate];  		wrq->value = brate * 500000;  		// If more than one rate, set auto @@ -1175,7 +1155,7 @@ int iwctl_siwencode(struct net_device *dev, struct iw_request_info *info,  	struct iw_point *wrq = &wrqu->encoding;  	u32 dwKeyIndex = (u32)(wrq->flags & IW_ENCODE_INDEX);  	int ii; -	int uu; +	u8 uu;  	int rc = 0;  	int index = (wrq->flags & IW_ENCODE_INDEX); @@ -1215,14 +1195,12 @@ int iwctl_siwencode(struct net_device *dev, struct iw_request_info *info,  			DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "%02x ", pDevice->abyKey[ii]);  		if (pDevice->flags & DEVICE_FLAGS_OPENED) { -			spin_lock_irq(&pDevice->lock);  			KeybSetDefaultKey(pDevice,  					&(pDevice->sKey),  					dwKeyIndex | (1 << 31),  					wrq->length, NULL,  					pDevice->abyKey,  					KEY_CTL_WEP); -			spin_unlock_irq(&pDevice->lock);  		}  		pDevice->byKeyIndex = (u8)dwKeyIndex;  		pDevice->uKeyLength = wrq->length; @@ -1245,10 +1223,8 @@ int iwctl_siwencode(struct net_device *dev, struct iw_request_info *info,  		pDevice->bEncryptionEnable = false;  		pDevice->eEncryptionStatus = Ndis802_11EncryptionDisabled;  		if (pDevice->flags & DEVICE_FLAGS_OPENED) { -			spin_lock_irq(&pDevice->lock);  			for (uu = 0; uu < MAX_KEY_TABLE; uu++)  				MACvDisableKeyEntry(pDevice, uu); -			spin_unlock_irq(&pDevice->lock);  		}  	}  	if (wrq->flags & IW_ENCODE_RESTRICTED) { @@ -1286,7 +1262,7 @@ int iwctl_giwencode(struct net_device *dev, struct iw_request_info *info,  	if (index < 1) { // get default key  		if (pDevice->byKeyIndex < WLAN_WEP_NKEYS)  			index = pDevice->byKeyIndex; -         	else +		else  			index = 0;  	} else {  		index--; @@ -1345,12 +1321,9 @@ int iwctl_siwpower(struct net_device *dev, struct iw_request_info *info,  		return rc;  	} -	spin_lock_irq(&pDevice->lock); -  	if (wrq->disabled) {  		pDevice->ePSMode = WMAC_POWER_CAM;  		PSvDisablePowerSaving(pDevice); -		spin_unlock_irq(&pDevice->lock);  		return rc;  	}  	if ((wrq->flags & IW_POWER_TYPE) == IW_POWER_TIMEOUT) { @@ -1362,18 +1335,16 @@ int iwctl_siwpower(struct net_device *dev, struct iw_request_info *info,  		PSvEnablePowerSaving((void *)pDevice, pMgmt->wListenInterval);  	} -	spin_unlock_irq(&pDevice->lock); -  	switch (wrq->flags & IW_POWER_MODE) {  	case IW_POWER_UNICAST_R: -		DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " SIOCSIWPOWER: IW_POWER_UNICAST_R \n"); +		DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " SIOCSIWPOWER: IW_POWER_UNICAST_R\n");  		rc = -EINVAL;  		break;  	case IW_POWER_ALL_R: -		DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " SIOCSIWPOWER: IW_POWER_ALL_R \n"); +		DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " SIOCSIWPOWER: IW_POWER_ALL_R\n");  		rc = -EINVAL;  	case IW_POWER_ON: -		DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " SIOCSIWPOWER: IW_POWER_ON \n"); +		DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " SIOCSIWPOWER: IW_POWER_ON\n");  		break;  	default:  		rc = -EINVAL; @@ -1398,7 +1369,8 @@ int iwctl_giwpower(struct net_device *dev, struct iw_request_info *info,  	if (pMgmt == NULL)  		return -EFAULT; -	if ((wrq->disabled = (mode == WMAC_POWER_CAM))) +	wrq->disabled = (mode == WMAC_POWER_CAM); +	if (wrq->disabled)  		return 0;  	if ((wrq->flags & IW_POWER_TYPE) == IW_POWER_TIMEOUT) { @@ -1427,7 +1399,7 @@ int iwctl_giwsens(struct net_device *dev, struct iw_request_info *info,  	DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " SIOCGIWSENS\n");  	if (pDevice->bLinkPass == true) { -		RFvRSSITodBm(pDevice, (u8)(pDevice->uCurrRSSI), &ldBm); +		vnt_rf_rssi_to_dbm(pDevice, (u8)(pDevice->uCurrRSSI), &ldBm);  		wrq->value = ldBm;  	} else {  		wrq->value = 0; @@ -1465,7 +1437,7 @@ int iwctl_siwauth(struct net_device *dev, struct iw_request_info *info,  	case IW_AUTH_CIPHER_PAIRWISE:  		pairwise = wrq->value;  		PRINT_K("iwctl_siwauth:set pairwise=%d\n", pairwise); -		if (pairwise == IW_AUTH_CIPHER_CCMP){ +		if (pairwise == IW_AUTH_CIPHER_CCMP) {  			pDevice->eEncryptionStatus = Ndis802_11Encryption3Enabled;  		} else if (pairwise == IW_AUTH_CIPHER_TKIP) {  			pDevice->eEncryptionStatus = Ndis802_11Encryption2Enabled; @@ -1490,13 +1462,13 @@ int iwctl_siwauth(struct net_device *dev, struct iw_request_info *info,  		}  		break;  	case IW_AUTH_KEY_MGMT: -		PRINT_K("iwctl_siwauth(wpa_version=%d):set KEY_MGMT=%d\n", wpa_version,wrq->value); -		if (wpa_version == IW_AUTH_WPA_VERSION_WPA2){ +		PRINT_K("iwctl_siwauth(wpa_version=%d):set KEY_MGMT=%d\n", wpa_version, wrq->value); +		if (wpa_version == IW_AUTH_WPA_VERSION_WPA2) {  			if (wrq->value == IW_AUTH_KEY_MGMT_PSK)  				pMgmt->eAuthenMode = WMAC_AUTH_WPA2PSK;  			else pMgmt->eAuthenMode = WMAC_AUTH_WPA2;  		} else if (wpa_version == IW_AUTH_WPA_VERSION_WPA) { -			if (wrq->value == 0){ +			if (wrq->value == 0) {  				pMgmt->eAuthenMode = WMAC_AUTH_WPANONE;  			} else if (wrq->value == IW_AUTH_KEY_MGMT_PSK)  				pMgmt->eAuthenMode = WMAC_AUTH_WPAPSK; @@ -1558,20 +1530,18 @@ int iwctl_siwgenie(struct net_device *dev, struct iw_request_info *info,  	if (pMgmt == NULL)  		return -EFAULT; -	if (wrq->length){ +	if (wrq->length) {  		if ((wrq->length < 2) || (extra[1] + 2 != wrq->length)) {  			ret = -EINVAL;  			goto out;  		} -		if (wrq->length > MAX_WPA_IE_LEN){ +		if (wrq->length > MAX_WPA_IE_LEN) {  			ret = -ENOMEM;  			goto out;  		}  		memset(pMgmt->abyWPAIE, 0, MAX_WPA_IE_LEN); -		if (copy_from_user(pMgmt->abyWPAIE, extra, wrq->length)){ -			ret = -EFAULT; -			goto out; -		} + +		memcpy(pMgmt->abyWPAIE, extra, wrq->length);  		pMgmt->wWPAIELen = wrq->length;  	} else {  		memset(pMgmt->abyWPAIE, 0, MAX_WPA_IE_LEN); @@ -1597,13 +1567,11 @@ int iwctl_giwgenie(struct net_device *dev, struct iw_request_info *info,  	wrq->length = 0;  	if (pMgmt->wWPAIELen > 0) {  		wrq->length = pMgmt->wWPAIELen; -		if (pMgmt->wWPAIELen <= space) { -			if (copy_to_user(extra, pMgmt->abyWPAIE, pMgmt->wWPAIELen)) { -				ret = -EFAULT; -			} -		} else { + +		if (pMgmt->wWPAIELen <= space) +			memcpy(extra, pMgmt->abyWPAIE, pMgmt->wWPAIELen); +		else  			ret = -E2BIG; -		}  	}  	return ret;  } @@ -1615,7 +1583,7 @@ int iwctl_siwencodeext(struct net_device *dev, struct iw_request_info *info,  	struct vnt_manager *pMgmt = &pDevice->vnt_mgmt;  	struct iw_point *wrq = &wrqu->encoding;  	struct iw_encode_ext *ext = (struct iw_encode_ext*)extra; -	struct viawget_wpa_param *param=NULL; +	struct viawget_wpa_param *param = NULL;  // original member  	wpa_alg alg_name;  	u8 addr[6]; @@ -1634,6 +1602,9 @@ int iwctl_siwencodeext(struct net_device *dev, struct iw_request_info *info,  	if (pMgmt == NULL)  		return -EFAULT; +	if (!(pDevice->flags & DEVICE_FLAGS_OPENED)) +		return -ENODEV; +  	buf = kzalloc(sizeof(struct viawget_wpa_param), GFP_KERNEL);  	if (buf == NULL)  		return -ENOMEM; @@ -1655,8 +1626,8 @@ int iwctl_siwencodeext(struct net_device *dev, struct iw_request_info *info,  		alg_name = WPA_ALG_CCMP;  		break;  	default: -		PRINT_K("Unknown alg = %d\n",ext->alg); -		ret= -ENOMEM; +		PRINT_K("Unknown alg = %d\n", ext->alg); +		ret = -ENOMEM;  		goto error;  	}  // recover addr @@ -1668,7 +1639,7 @@ int iwctl_siwencodeext(struct net_device *dev, struct iw_request_info *info,  		set_tx = 1;  // recover seq,seq_len  	if (ext->ext_flags & IW_ENCODE_EXT_RX_SEQ_VALID) { -		seq_len=IW_ENCODE_SEQ_MAX_SIZE; +		seq_len = IW_ENCODE_SEQ_MAX_SIZE;  		memcpy(seq, ext->rx_seq, seq_len);  	}  // recover key,key_len @@ -1699,7 +1670,7 @@ int iwctl_siwencodeext(struct net_device *dev, struct iw_request_info *info,  /****set if current action is Network Manager count?? */  /****this method is so foolish,but there is no other way??? */  	if (param->u.wpa_key.alg_name == WPA_ALG_NONE) { -		if (param->u.wpa_key.key_index ==0) { +		if (param->u.wpa_key.key_index == 0) {  			pDevice->bwextstep0 = true;  		}  		if ((pDevice->bwextstep0 == true) && (param->u.wpa_key.key_index == 1)) { @@ -1726,9 +1697,7 @@ int iwctl_siwencodeext(struct net_device *dev, struct iw_request_info *info,  		KeyvInitTable(pDevice, &pDevice->sKey);  	}  /*******/ -	spin_lock_irq(&pDevice->lock);  	ret = wpa_set_keys(pDevice, param); -	spin_unlock_irq(&pDevice->lock);  error:  	kfree(buf); @@ -1758,7 +1727,7 @@ int iwctl_siwmlme(struct net_device *dev, struct iw_request_info *info,  		ret = -EINVAL;  		return ret;  	} -	switch (mlme->cmd){ +	switch (mlme->cmd) {  	case IW_MLME_DEAUTH:  	case IW_MLME_DISASSOC:  		if (pDevice->bLinkPass == true) { @@ -1812,7 +1781,6 @@ static const iw_handler iwctl_handler[] = {  	IW_HANDLER(SIOCGIWPOWER, iwctl_giwpower),  	IW_HANDLER(SIOCSIWGENIE, iwctl_siwgenie),  	IW_HANDLER(SIOCGIWGENIE, iwctl_giwgenie), -	IW_HANDLER(SIOCSIWMLME, iwctl_siwmlme),  	IW_HANDLER(SIOCSIWAUTH, iwctl_siwauth),  	IW_HANDLER(SIOCGIWAUTH, iwctl_giwauth),  	IW_HANDLER(SIOCSIWENCODEEXT, iwctl_siwencodeext),  | 
