libertas: dynamically allocate scan command structure
Dan Williams
dcbw at localhost.unroutablelocaldomain
Tue Nov 28 02:56:38 EST 2006
Commit: 5847546f1a1382aee884fb60e9b999a0bcfa9510
Parent: 247567d3476d75794324ac07d971250062a8e5c4
commit 5847546f1a1382aee884fb60e9b999a0bcfa9510
Author: Dan Williams <dcbw at localhost.localdomain>
AuthorDate: Wed Nov 15 12:15:04 2006 -0500
Commit: Dan Williams <dcbw at localhost.localdomain>
CommitDate: Wed Nov 15 12:15:04 2006 -0500
libertas: dynamically allocate scan command structure
---
drivers/net/wireless/libertas/wlan_scan.c | 68 ++++++++++++++++-------------
1 files changed, 37 insertions(+), 31 deletions(-)
diff --git a/drivers/net/wireless/libertas/wlan_scan.c b/drivers/net/wireless/libertas/wlan_scan.c
index 9804a6e..30d8ccc 100644
--- a/drivers/net/wireless/libertas/wlan_scan.c
+++ b/drivers/net/wireless/libertas/wlan_scan.c
@@ -97,14 +97,6 @@ #define CHECK_SSID_IS_VALID(x) 1
#endif
/**
- * @brief Interally used to send a configured scan cmd between driver routines
- */
-union wlan_scan_cmd_config_tlv {
- struct wlan_scan_cmd_config config; //!< Scan configuration (variable length)
- u8 configAllocBuf[MAX_SCAN_CFG_ALLOC]; //!< Max allocated block
-};
-
-/**
* @brief Check if a scanned network compatible with the driver settings
*
* WEP WPA WPA2 ad-hoc encrypt Network
@@ -444,7 +436,6 @@ static void wlan_scan_create_channel_lis
*
* @param priv A pointer to wlan_private structure
* @param pUserScanIn NULL or pointer to scan configuration parameters
- * @param pScanCfgOut Output parameter: Resulting scan configuration
* @param ppChanTlvOut Output parameter: Pointer to the start of the
* channel TLV portion of the output scan config
* @param pScanChanList Output parameter: Pointer to the resulting channel
@@ -459,21 +450,22 @@ static void wlan_scan_create_channel_lis
* @param pScanCurrentOnly Output parameter: Flag indicating whether or not
* we are only scanning our current active channel
*
- * @return void
+ * @return resulting scan configuration
*/
-static
-void wlan_scan_setup_scan_config(wlan_private * priv,
- const struct wlan_ioctl_user_scan_cfg * pUserScanIn,
- struct wlan_scan_cmd_config * pScanCfgOut,
- struct MrvlIEtypes_ChanListParamSet ** ppChanTlvOut,
- struct ChanScanParamSet * pScanChanList,
- int *pMaxChanPerScan,
- u8 * pFilteredScan, u8 * pScanCurrentOnly)
+static struct wlan_scan_cmd_config *
+wlan_scan_setup_scan_config(wlan_private * priv,
+ const struct wlan_ioctl_user_scan_cfg * pUserScanIn,
+ struct MrvlIEtypes_ChanListParamSet ** ppChanTlvOut,
+ struct ChanScanParamSet * pScanChanList,
+ int *pMaxChanPerScan,
+ u8 * pFilteredScan,
+ u8 * pScanCurrentOnly)
{
wlan_adapter *Adapter = priv->adapter;
const u8 zeroMac[ETH_ALEN] = { 0, 0, 0, 0, 0, 0 };
struct MrvlIEtypes_NumProbes *pNumProbesTlv;
struct MrvlIEtypes_SsIdParamSet *pSsidTlv;
+ struct wlan_scan_cmd_config * pScanCfgOut = NULL;
u8 *pTlvPos;
u16 numProbes;
u16 ssidLen;
@@ -483,6 +475,10 @@ void wlan_scan_setup_scan_config(wlan_pr
int channel;
int radioType;
+ pScanCfgOut = kzalloc(MAX_SCAN_CFG_ALLOC, GFP_KERNEL);
+ if (pScanCfgOut == NULL)
+ goto out;
+
/* The tlvBufferLen is calculated for each scan command. The TLVs added
* in this routine will be preserved since the routine that sends
* the command will append channelTLVs at *ppChanTlvOut. The difference
@@ -639,6 +635,9 @@ void wlan_scan_setup_scan_config(wlan_pr
wlan_scan_create_channel_list(priv, pScanChanList,
*pFilteredScan);
}
+
+out:
+ return pScanCfgOut;
}
/**
@@ -796,9 +795,8 @@ static int wlan_scan_networks(wlan_priva
{
wlan_adapter *Adapter = priv->adapter;
struct MrvlIEtypes_ChanListParamSet *pChanTlvOut;
-
struct ChanScanParamSet scanChanList[WLAN_IOCTL_USER_SCAN_CHAN_MAX];
- union wlan_scan_cmd_config_tlv scanCfgOut;
+ struct wlan_scan_cmd_config * scan_cfg = NULL;
u8 keepPreviousScan;
u8 filteredScan;
u8 scanCurrentChanOnly;
@@ -808,17 +806,20 @@ static int wlan_scan_networks(wlan_priva
ENTER();
memset(scanChanList, 0x00, sizeof(scanChanList));
- memset(&scanCfgOut, 0x00, sizeof(scanCfgOut));
- keepPreviousScan = 0;
+ scan_cfg = wlan_scan_setup_scan_config(priv,
+ pUserScanIn,
+ &pChanTlvOut,
+ scanChanList,
+ &maxChanPerScan,
+ &filteredScan,
+ &scanCurrentChanOnly);
+ if (scan_cfg == NULL) {
+ ret = -ENOMEM;
+ goto out;
+ }
- wlan_scan_setup_scan_config(priv,
- pUserScanIn,
- &scanCfgOut.config,
- &pChanTlvOut,
- scanChanList,
- &maxChanPerScan,
- &filteredScan, &scanCurrentChanOnly);
+ keepPreviousScan = 0;
if (pUserScanIn) {
keepPreviousScan = pUserScanIn->keepPreviousScan;
@@ -839,8 +840,9 @@ static int wlan_scan_networks(wlan_priva
ret = wlan_scan_channel_list(priv,
maxChanPerScan,
filteredScan,
- &scanCfgOut.config,
- pChanTlvOut, scanChanList);
+ scan_cfg,
+ pChanTlvOut,
+ scanChanList);
/* Process the resulting scan table:
* - Remove any bad ssids
@@ -853,6 +855,10 @@ static int wlan_scan_networks(wlan_priva
netif_wake_queue(priv->wlan_dev.netdev);
}
+out:
+ if (scan_cfg)
+ kfree(scan_cfg);
+
LEAVE();
return ret;
}
More information about the Commits-kernel
mailing list