/*
* Marvell Wireless LAN device driver: major functions
*
* Copyright (C) 2011-2014, Marvell International Ltd.
*
* This software file (the "File") is distributed by Marvell International
* Ltd. under the terms of the GNU General Public License Version 2, June 1991
* (the "License"). You may use, redistribute and/or modify this File in
* accordance with the terms and conditions of the License, a copy of which
* is available by writing to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA or on the
* worldwide web at http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt.
*
* THE FILE IS DISTRIBUTED AS-IS, WITHOUT WARRANTY OF ANY KIND, AND THE
* IMPLIED WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE
* ARE EXPRESSLY DISCLAIMED. The License provides additional details about
* this warranty disclaimer.
*/
#include "main.h"
#include "wmm.h"
#include "cfg80211.h"
#include "11n.h"
#define VERSION "1.0"
const char driver_version[] = "mwifiex " VERSION " (%s) ";
static char *cal_data_cfg;
module_param(cal_data_cfg, charp, 0);
static unsigned short driver_mode;
module_param(driver_mode, ushort, 0);
MODULE_PARM_DESC(driver_mode,
"station=0x1(default), ap-sta=0x3, station-p2p=0x5, ap-sta-p2p=0x7");
/*
* This function registers the device and performs all the necessary
* initializations.
*
* The following initialization operations are performed -
* - Allocate adapter structure
* - Save interface specific operations table in adapter
* - Call interface specific initialization routine
* - Allocate private structures
* - Set default adapter structure parameters
* - Initialize locks
*
* In case of any errors during inittialization, this function also ensures
* proper cleanup before exiting.
*/
static int mwifiex_register(void *card, struct mwifiex_if_ops *if_ops,
void **padapter)
{
struct mwifiex_adapter *adapter;
int i;
adapter = kzalloc(sizeof(struct mwifiex_adapter), GFP_KERNEL);
if (!adapter)
return -ENOMEM;
*padapter = adapter;
adapter->card = card;
/* Save interface specific operations in adapter */
memmove(&adapter->if_ops, if_ops, sizeof(struct mwifiex_if_ops));
/* card specific initialization has been deferred until now .. */
if (adapter->if_ops.init_if)
if (adapter->if_ops.init_if(adapter))
goto error;
adapter->priv_num = 0;
for (i = 0; i < MWIFIEX_MAX_BSS_NUM; i++) {
/* Allocate memory for private structure */
adapter->priv[i] =
kzalloc(sizeof(struct mwifiex_private), GFP_KERNEL);
if (!adapter->priv[i])
goto error;
adapter->priv[i]->adapter = adapter;
adapter->priv_num++;
}
mwifiex_init_lock_list(adapter);
setup_timer(&adapter->cmd_timer, mwifiex_cmd_timeout_func,
(unsigned long)adapter);
return 0;
error:
dev_dbg(adapter->dev, "info: leave mwifiex_register with error\n");
for (i = 0; i < adapter->priv_num; i++)
kfree(adapter->priv[i]);
kfree(adapter);
return -1;
}
/*
* This function unregisters the device and performs all the necessary
* cleanups.