forked from Minki/linux
mwifiex: optimize driver initialization code
1) removal of unnecessary mwifiex_device structure 2) avoid passing adapter pointer to mwifiex_init_sw() 3) remove local variable drv_mode_info in mwifiex_add_card() 4) type change in mwifiex_bss_attr to match mwifiex_private 5) removal of more wordy comments Signed-off-by: Amitkumar Karwar <akarwar@marvell.com> Signed-off-by: Bing Zhao <bzhao@marvell.com> Signed-off-by: John W. Linville <linville@tuxdriver.com>
This commit is contained in:
parent
a37316586d
commit
2be7859f41
@ -113,11 +113,11 @@ struct mwifiex_txinfo {
|
|||||||
};
|
};
|
||||||
|
|
||||||
struct mwifiex_bss_attr {
|
struct mwifiex_bss_attr {
|
||||||
u32 bss_type;
|
u8 bss_type;
|
||||||
u32 frame_type;
|
u8 frame_type;
|
||||||
u32 active;
|
u8 active;
|
||||||
u32 bss_priority;
|
u8 bss_priority;
|
||||||
u32 bss_num;
|
u8 bss_num;
|
||||||
};
|
};
|
||||||
|
|
||||||
enum mwifiex_wmm_ac_e {
|
enum mwifiex_wmm_ac_e {
|
||||||
@ -126,8 +126,4 @@ enum mwifiex_wmm_ac_e {
|
|||||||
WMM_AC_VI,
|
WMM_AC_VI,
|
||||||
WMM_AC_VO
|
WMM_AC_VO
|
||||||
} __packed;
|
} __packed;
|
||||||
|
|
||||||
struct mwifiex_device {
|
|
||||||
struct mwifiex_bss_attr bss_attr[MWIFIEX_MAX_BSS_NUM];
|
|
||||||
};
|
|
||||||
#endif /* !_MWIFIEX_DECL_H_ */
|
#endif /* !_MWIFIEX_DECL_H_ */
|
||||||
|
@ -40,14 +40,10 @@ static char fw_name[32] = DEFAULT_FW_NAME;
|
|||||||
/* Supported drv_mode table */
|
/* Supported drv_mode table */
|
||||||
static struct mwifiex_drv_mode mwifiex_drv_mode_tbl[] = {
|
static struct mwifiex_drv_mode mwifiex_drv_mode_tbl[] = {
|
||||||
{
|
{
|
||||||
/* drv_mode */
|
.drv_mode = DRV_MODE_STA,
|
||||||
.drv_mode = DRV_MODE_STA,
|
.intf_num = ARRAY_SIZE(mwifiex_bss_sta),
|
||||||
/* intf number */
|
.bss_attr = mwifiex_bss_sta,
|
||||||
.intf_num = ARRAY_SIZE(mwifiex_bss_sta),
|
},
|
||||||
/* bss_attr */
|
|
||||||
.bss_attr = mwifiex_bss_sta,
|
|
||||||
}
|
|
||||||
,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -66,13 +62,12 @@ static struct mwifiex_drv_mode mwifiex_drv_mode_tbl[] = {
|
|||||||
* proper cleanup before exiting.
|
* proper cleanup before exiting.
|
||||||
*/
|
*/
|
||||||
static int mwifiex_register(void *card, struct mwifiex_if_ops *if_ops,
|
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;
|
struct mwifiex_adapter *adapter;
|
||||||
u8 i = 0;
|
int i;
|
||||||
|
|
||||||
adapter = kzalloc(sizeof(struct mwifiex_adapter), GFP_KERNEL);
|
adapter = kzalloc(sizeof(struct mwifiex_adapter), GFP_KERNEL);
|
||||||
/* Allocate memory for adapter structure */
|
|
||||||
if (!adapter)
|
if (!adapter)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
@ -87,14 +82,13 @@ static int mwifiex_register(void *card, struct mwifiex_if_ops *if_ops,
|
|||||||
goto error;
|
goto error;
|
||||||
|
|
||||||
adapter->priv_num = 0;
|
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;
|
adapter->priv[i] = NULL;
|
||||||
|
|
||||||
if (!mdevice->bss_attr[i].active)
|
if (!drv_mode_ptr->bss_attr[i].active)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
/* For valid bss_attr,
|
/* Allocate memory for private structure */
|
||||||
allocate memory for private structure */
|
|
||||||
adapter->priv[i] = kzalloc(sizeof(struct mwifiex_private),
|
adapter->priv[i] = kzalloc(sizeof(struct mwifiex_private),
|
||||||
GFP_KERNEL);
|
GFP_KERNEL);
|
||||||
if (!adapter->priv[i]) {
|
if (!adapter->priv[i]) {
|
||||||
@ -104,26 +98,26 @@ static int mwifiex_register(void *card, struct mwifiex_if_ops *if_ops,
|
|||||||
}
|
}
|
||||||
|
|
||||||
adapter->priv_num++;
|
adapter->priv_num++;
|
||||||
memset(adapter->priv[i], 0,
|
|
||||||
sizeof(struct mwifiex_private));
|
|
||||||
adapter->priv[i]->adapter = adapter;
|
adapter->priv[i]->adapter = adapter;
|
||||||
/* Save bss_type, frame_type & bss_priority */
|
/* 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 =
|
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 =
|
adapter->priv[i]->bss_priority =
|
||||||
(u8) mdevice->bss_attr[i].bss_priority;
|
drv_mode_ptr->bss_attr[i].bss_priority;
|
||||||
if (mdevice->bss_attr[i].bss_type == MWIFIEX_BSS_TYPE_STA)
|
|
||||||
|
if (drv_mode_ptr->bss_attr[i].bss_type == MWIFIEX_BSS_TYPE_STA)
|
||||||
adapter->priv[i]->bss_role = MWIFIEX_BSS_ROLE_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;
|
adapter->priv[i]->bss_role = MWIFIEX_BSS_ROLE_UAP;
|
||||||
|
|
||||||
/* Save bss_index & bss_num */
|
/* Save bss_index & bss_num */
|
||||||
adapter->priv[i]->bss_index = i;
|
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))
|
if (mwifiex_init_lock_list(adapter))
|
||||||
goto error;
|
goto error;
|
||||||
|
|
||||||
@ -131,16 +125,13 @@ static int mwifiex_register(void *card, struct mwifiex_if_ops *if_ops,
|
|||||||
adapter->cmd_timer.function = mwifiex_cmd_timeout_func;
|
adapter->cmd_timer.function = mwifiex_cmd_timeout_func;
|
||||||
adapter->cmd_timer.data = (unsigned long) adapter;
|
adapter->cmd_timer.data = (unsigned long) adapter;
|
||||||
|
|
||||||
/* Return pointer of struct mwifiex_adapter */
|
|
||||||
*padapter = adapter;
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
error:
|
error:
|
||||||
dev_dbg(adapter->dev, "info: leave mwifiex_register with error\n");
|
dev_dbg(adapter->dev, "info: leave mwifiex_register with error\n");
|
||||||
|
|
||||||
/* Free lock variables */
|
|
||||||
mwifiex_free_lock_list(adapter);
|
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->priv[i]);
|
||||||
kfree(adapter);
|
kfree(adapter);
|
||||||
|
|
||||||
@ -335,10 +326,9 @@ exit_main_proc:
|
|||||||
* and initializing the private structures.
|
* and initializing the private structures.
|
||||||
*/
|
*/
|
||||||
static int
|
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;
|
int i;
|
||||||
struct mwifiex_device device;
|
|
||||||
struct mwifiex_drv_mode *drv_mode_ptr;
|
struct mwifiex_drv_mode *drv_mode_ptr;
|
||||||
|
|
||||||
/* find mwifiex_drv_mode entry from mwifiex_drv_mode_tbl */
|
/* find mwifiex_drv_mode entry from mwifiex_drv_mode_tbl */
|
||||||
@ -355,20 +345,7 @@ mwifiex_init_sw(void *card, struct mwifiex_if_ops *if_ops, void **pmwifiex)
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
memset(&device, 0, sizeof(struct mwifiex_device));
|
if (mwifiex_register(card, if_ops, drv_mode_ptr))
|
||||||
|
|
||||||
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))
|
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
@ -892,21 +869,19 @@ mwifiex_add_card(void *card, struct semaphore *sem,
|
|||||||
struct mwifiex_if_ops *if_ops)
|
struct mwifiex_if_ops *if_ops)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
struct mwifiex_adapter *adapter = NULL;
|
struct mwifiex_adapter *adapter;
|
||||||
struct mwifiex_drv_mode *drv_mode_info = &mwifiex_drv_mode_tbl[0];
|
|
||||||
|
|
||||||
if (down_interruptible(sem))
|
if (down_interruptible(sem))
|
||||||
goto exit_sem_err;
|
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__);
|
pr_err("%s: software init failed\n", __func__);
|
||||||
goto err_init_sw;
|
goto err_init_sw;
|
||||||
}
|
}
|
||||||
|
|
||||||
adapter->drv_mode = drv_mode_info;
|
adapter = g_adapter;
|
||||||
|
|
||||||
adapter->hw_status = MWIFIEX_HW_STATUS_INITIALIZING;
|
adapter->hw_status = MWIFIEX_HW_STATUS_INITIALIZING;
|
||||||
/* PnP and power profile */
|
|
||||||
adapter->surprise_removed = false;
|
adapter->surprise_removed = false;
|
||||||
init_waitqueue_head(&adapter->init_wait_q);
|
init_waitqueue_head(&adapter->init_wait_q);
|
||||||
adapter->is_suspended = false;
|
adapter->is_suspended = false;
|
||||||
@ -917,7 +892,6 @@ mwifiex_add_card(void *card, struct semaphore *sem,
|
|||||||
adapter->cmd_wait_q.condition = false;
|
adapter->cmd_wait_q.condition = false;
|
||||||
adapter->cmd_wait_q.status = 0;
|
adapter->cmd_wait_q.status = 0;
|
||||||
|
|
||||||
/* Create workqueue */
|
|
||||||
adapter->workqueue = create_workqueue("MWIFIEX_WORK_QUEUE");
|
adapter->workqueue = create_workqueue("MWIFIEX_WORK_QUEUE");
|
||||||
if (!adapter->workqueue)
|
if (!adapter->workqueue)
|
||||||
goto err_kmalloc;
|
goto err_kmalloc;
|
||||||
@ -931,13 +905,13 @@ mwifiex_add_card(void *card, struct semaphore *sem,
|
|||||||
goto err_registerdev;
|
goto err_registerdev;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Init FW and HW */
|
|
||||||
if (mwifiex_init_hw_fw(adapter)) {
|
if (mwifiex_init_hw_fw(adapter)) {
|
||||||
pr_err("%s: firmware init failed\n", __func__);
|
pr_err("%s: firmware init failed\n", __func__);
|
||||||
goto err_init_fw;
|
goto err_init_fw;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Add interfaces */
|
/* 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,
|
if (!mwifiex_add_interface(adapter, i,
|
||||||
adapter->drv_mode->bss_attr[i].bss_type)) {
|
adapter->drv_mode->bss_attr[i].bss_type)) {
|
||||||
goto err_add_intf;
|
goto err_add_intf;
|
||||||
@ -952,7 +926,6 @@ err_add_intf:
|
|||||||
for (i = 0; i < adapter->priv_num; i++)
|
for (i = 0; i < adapter->priv_num; i++)
|
||||||
mwifiex_remove_interface(adapter, i);
|
mwifiex_remove_interface(adapter, i);
|
||||||
err_init_fw:
|
err_init_fw:
|
||||||
/* Unregister device */
|
|
||||||
pr_debug("info: %s: unregister device\n", __func__);
|
pr_debug("info: %s: unregister device\n", __func__);
|
||||||
adapter->if_ops.unregister_dev(adapter);
|
adapter->if_ops.unregister_dev(adapter);
|
||||||
err_registerdev:
|
err_registerdev:
|
||||||
|
@ -872,7 +872,7 @@ mwifiex_copy_rates(u8 *dest, u32 pos, u8 *src, int len)
|
|||||||
*/
|
*/
|
||||||
static inline struct mwifiex_private *
|
static inline struct mwifiex_private *
|
||||||
mwifiex_get_priv_by_id(struct mwifiex_adapter *adapter,
|
mwifiex_get_priv_by_id(struct mwifiex_adapter *adapter,
|
||||||
u32 bss_num, u32 bss_type)
|
u8 bss_num, u8 bss_type)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user