/* Supported drv_mode table */
static struct mwifiex_drv_mode mwifiex_drv_mode_tbl[] = {
{
- /* drv_mode */
- .drv_mode = DRV_MODE_STA,
- /* intf number */
- .intf_num = ARRAY_SIZE(mwifiex_bss_sta),
- /* bss_attr */
- .bss_attr = mwifiex_bss_sta,
- }
- ,
+ .drv_mode = DRV_MODE_STA,
+ .intf_num = ARRAY_SIZE(mwifiex_bss_sta),
+ .bss_attr = mwifiex_bss_sta,
+ },
};
/*
* proper cleanup before exiting.
*/
static int mwifiex_register(void *card, struct mwifiex_if_ops *if_ops,
- struct mwifiex_device *mdevice, void **padapter)
+ struct mwifiex_drv_mode *drv_mode_ptr)
{
- struct mwifiex_adapter *adapter = NULL;
- u8 i = 0;
+ struct mwifiex_adapter *adapter;
+ int i;
adapter = kzalloc(sizeof(struct mwifiex_adapter), GFP_KERNEL);
- /* Allocate memory for adapter structure */
if (!adapter)
return -1;
goto error;
adapter->priv_num = 0;
- for (i = 0; i < MWIFIEX_MAX_BSS_NUM; i++) {
+ for (i = 0; i < drv_mode_ptr->intf_num; i++) {
adapter->priv[i] = NULL;
- if (!mdevice->bss_attr[i].active)
+ if (!drv_mode_ptr->bss_attr[i].active)
continue;
- /* For valid bss_attr,
- allocate memory for private structure */
+ /* Allocate memory for private structure */
adapter->priv[i] = kzalloc(sizeof(struct mwifiex_private),
GFP_KERNEL);
if (!adapter->priv[i]) {
}
adapter->priv_num++;
- memset(adapter->priv[i], 0,
- sizeof(struct mwifiex_private));
adapter->priv[i]->adapter = adapter;
/* Save bss_type, frame_type & bss_priority */
- adapter->priv[i]->bss_type = (u8) mdevice->bss_attr[i].bss_type;
+ adapter->priv[i]->bss_type = drv_mode_ptr->bss_attr[i].bss_type;
adapter->priv[i]->frame_type =
- (u8) mdevice->bss_attr[i].frame_type;
+ drv_mode_ptr->bss_attr[i].frame_type;
adapter->priv[i]->bss_priority =
- (u8) mdevice->bss_attr[i].bss_priority;
- if (mdevice->bss_attr[i].bss_type == MWIFIEX_BSS_TYPE_STA)
+ drv_mode_ptr->bss_attr[i].bss_priority;
+
+ if (drv_mode_ptr->bss_attr[i].bss_type == MWIFIEX_BSS_TYPE_STA)
adapter->priv[i]->bss_role = MWIFIEX_BSS_ROLE_STA;
- else if (mdevice->bss_attr[i].bss_type == MWIFIEX_BSS_TYPE_UAP)
+ else if (drv_mode_ptr->bss_attr[i].bss_type ==
+ MWIFIEX_BSS_TYPE_UAP)
adapter->priv[i]->bss_role = MWIFIEX_BSS_ROLE_UAP;
/* Save bss_index & bss_num */
adapter->priv[i]->bss_index = i;
- adapter->priv[i]->bss_num = mdevice->bss_attr[i].bss_num;
+ adapter->priv[i]->bss_num = drv_mode_ptr->bss_attr[i].bss_num;
}
+ adapter->drv_mode = drv_mode_ptr;
- /* Initialize lock variables */
if (mwifiex_init_lock_list(adapter))
goto error;
adapter->cmd_timer.function = mwifiex_cmd_timeout_func;
adapter->cmd_timer.data = (unsigned long) adapter;
- /* Return pointer of struct mwifiex_adapter */
- *padapter = adapter;
return 0;
error:
dev_dbg(adapter->dev, "info: leave mwifiex_register with error\n");
- /* Free lock variables */
mwifiex_free_lock_list(adapter);
- for (i = 0; i < MWIFIEX_MAX_BSS_NUM; i++)
+ for (i = 0; i < drv_mode_ptr->intf_num; i++)
kfree(adapter->priv[i]);
kfree(adapter);
* and initializing the private structures.
*/
static int
-mwifiex_init_sw(void *card, struct mwifiex_if_ops *if_ops, void **pmwifiex)
+mwifiex_init_sw(void *card, struct mwifiex_if_ops *if_ops)
{
int i;
- struct mwifiex_device device;
struct mwifiex_drv_mode *drv_mode_ptr;
/* find mwifiex_drv_mode entry from mwifiex_drv_mode_tbl */
return -1;
}
- memset(&device, 0, sizeof(struct mwifiex_device));
-
- for (i = 0; i < drv_mode_ptr->intf_num; i++) {
- device.bss_attr[i].bss_type =
- drv_mode_ptr->bss_attr[i].bss_type;
- device.bss_attr[i].frame_type =
- drv_mode_ptr->bss_attr[i].frame_type;
- device.bss_attr[i].active = drv_mode_ptr->bss_attr[i].active;
- device.bss_attr[i].bss_priority =
- drv_mode_ptr->bss_attr[i].bss_priority;
- device.bss_attr[i].bss_num = drv_mode_ptr->bss_attr[i].bss_num;
- }
-
- if (mwifiex_register(card, if_ops, &device, pmwifiex))
+ if (mwifiex_register(card, if_ops, drv_mode_ptr))
return -1;
return 0;
struct mwifiex_if_ops *if_ops)
{
int i;
- struct mwifiex_adapter *adapter = NULL;
- struct mwifiex_drv_mode *drv_mode_info = &mwifiex_drv_mode_tbl[0];
+ struct mwifiex_adapter *adapter;
if (down_interruptible(sem))
goto exit_sem_err;
- if (mwifiex_init_sw(card, if_ops, (void **) &adapter)) {
+ if (mwifiex_init_sw(card, if_ops)) {
pr_err("%s: software init failed\n", __func__);
goto err_init_sw;
}
- adapter->drv_mode = drv_mode_info;
+ adapter = g_adapter;
adapter->hw_status = MWIFIEX_HW_STATUS_INITIALIZING;
- /* PnP and power profile */
adapter->surprise_removed = false;
init_waitqueue_head(&adapter->init_wait_q);
adapter->is_suspended = false;
adapter->cmd_wait_q.condition = false;
adapter->cmd_wait_q.status = 0;
- /* Create workqueue */
adapter->workqueue = create_workqueue("MWIFIEX_WORK_QUEUE");
if (!adapter->workqueue)
goto err_kmalloc;
goto err_registerdev;
}
- /* Init FW and HW */
if (mwifiex_init_hw_fw(adapter)) {
pr_err("%s: firmware init failed\n", __func__);
goto err_init_fw;
}
+
/* Add interfaces */
- for (i = 0; i < drv_mode_info->intf_num; i++) {
+ for (i = 0; i < adapter->drv_mode->intf_num; i++) {
if (!mwifiex_add_interface(adapter, i,
adapter->drv_mode->bss_attr[i].bss_type)) {
goto err_add_intf;
for (i = 0; i < adapter->priv_num; i++)
mwifiex_remove_interface(adapter, i);
err_init_fw:
- /* Unregister device */
pr_debug("info: %s: unregister device\n", __func__);
adapter->if_ops.unregister_dev(adapter);
err_registerdev: