staging: wilc1000: remove unnecessary netdev validation check in del_key()
PATCH 1/3 staging: wilc1000: remove unnecessary netdev validation check in del_key()
From: Ajay Singh <[email protected]>
Removed unnecessary check to compare vif interface with zeroth index element in vif array. Already the caller takes care of passing the appropriate netdev handler during the del key operation.
--- .../staging/wilc1000/wilc_wfi_cfgoperations.c | 33 +++++++++---------- 1 file changed, 15 insertions(+), 18 deletions(-)
drivers/staging/wilc1000/wilc_wfi_cfgoperations.c +15 -18
@@ -620,29 +620,26 @@ static int del_key(struct wiphy *wiphy, struct net_device *netdev,bool pairwise, const u8 *mac_addr) { - struct wilc *wl = wiphy_priv(wiphy); struct wilc_vif *vif = netdev_priv(netdev);struct wilc_priv *priv = &vif->priv; -if (netdev == wl->vif[0 ]->ndev) { -if (priv->wilc_gtk[key_index]) { -kfree (priv->wilc_gtk[key_index]->key); - priv->wilc_gtk[key_index]->key =NULL ; -kfree (priv->wilc_gtk[key_index]->seq); - priv->wilc_gtk[key_index]->seq =NULL ; +if (priv->wilc_gtk[key_index]) { +kfree (priv->wilc_gtk[key_index]->key); + priv->wilc_gtk[key_index]->key =NULL ; +kfree (priv->wilc_gtk[key_index]->seq); + priv->wilc_gtk[key_index]->seq =NULL ; -kfree (priv->wilc_gtk[key_index]); - priv->wilc_gtk[key_index] =NULL ; - } +kfree (priv->wilc_gtk[key_index]); + priv->wilc_gtk[key_index] =NULL ; + } -if (priv->wilc_ptk[key_index]) { -kfree (priv->wilc_ptk[key_index]->key); - priv->wilc_ptk[key_index]->key =NULL ; -kfree (priv->wilc_ptk[key_index]->seq); - priv->wilc_ptk[key_index]->seq =NULL ; -kfree (priv->wilc_ptk[key_index]); - priv->wilc_ptk[key_index] =NULL ; - } +if (priv->wilc_ptk[key_index]) { +kfree (priv->wilc_ptk[key_index]->key); + priv->wilc_ptk[key_index]->key =NULL ; +kfree (priv->wilc_ptk[key_index]->seq); + priv->wilc_ptk[key_index]->seq =NULL ; +kfree (priv->wilc_ptk[key_index]); + priv->wilc_ptk[key_index] =NULL ; }if (key_index <=3 && priv->wep_key_len[key_index]) {
Signature · 1 line
2.22.0
PATCH 2/3 staging: wilc1000: move wlan_deinit_locks() in wilc_netdev_cleanup()
From: Ajay Singh <[email protected]>
Move deinitialization of lock during the module remove and the initialization of lock wilc_cfg80211_init(). This to ensure locks are available during module load and gets free during unload.
--- drivers/staging/wilc1000/wilc_netdev.c | 14 +------------- drivers/staging/wilc1000/wilc_wfi_cfgoperations.c | 14 ++++++++++++-- drivers/staging/wilc1000/wilc_wfi_cfgoperations.h | 1 + 3 files changed, 14 insertions(+), 15 deletions(-)
drivers/staging/wilc1000/wilc_netdev.c +1 -13
@@ -424,18 +424,6 @@ static int wilc_init_fw_config(struct net_device *dev, struct wilc_vif *vif)return -1 ; } -static void wlan_deinit_locks (struct net_device *dev) -{ -struct wilc_vif *vif =netdev_priv (dev); -struct wilc *wilc = vif->wilc; - -mutex_destroy (&wilc->hif_cs); -mutex_destroy (&wilc->rxq_cs); -mutex_destroy (&wilc->cfg_cmd_lock); -mutex_destroy (&wilc->txq_add_to_head_cs); -mutex_destroy (&wilc->vif_mutex); -} -static void wlan_deinitialize_threads (struct net_device *dev) {struct wilc_vif *vif =netdev_priv (dev);
@@ -477,7 +465,6 @@ static void wilc_wlan_deinitialize(struct net_device *dev)wilc_wlan_stop (wl, vif);wilc_wlan_cleanup (dev); -wlan_deinit_locks (dev); wl->initialized = false;
@@ -875,6 +862,7 @@ void wilc_netdev_cleanup(struct wilc *wilc)flush_workqueue (wilc->hif_workqueue);destroy_workqueue (wilc->hif_workqueue);wilc_wlan_cfg_deinit (wilc); +wlan_deinit_locks (wilc);kfree (wilc->bus_data);wiphy_unregister (wilc->wiphy);wiphy_free (wilc->wiphy);
drivers/staging/wilc1000/wilc_wfi_cfgoperations.c +12 -2
@@ -1802,6 +1802,15 @@ static void wlan_init_locks(struct wilc *wl)init_completion (&wl->txq_thread_started); } +void wlan_deinit_locks (struct wilc *wilc) +{ +mutex_destroy (&wilc->hif_cs); +mutex_destroy (&wilc->rxq_cs); +mutex_destroy (&wilc->cfg_cmd_lock); +mutex_destroy (&wilc->txq_add_to_head_cs); +mutex_destroy (&wilc->vif_mutex); +} +int wilc_cfg80211_init (struct wilc **wilc,struct device *dev,int io_type,const struct wilc_hif_func *ops) {
@@ -1813,6 +1822,8 @@ int wilc_cfg80211_init(struct wilc **wilc, struct device *dev, int io_type,if (!wl)return -EINVAL ; +wlan_init_locks (wl); + ret =wilc_wlan_cfg_init (wl);if (ret) goto free_wl;
@@ -1836,8 +1847,6 @@ int wilc_cfg80211_init(struct wilc **wilc, struct device *dev, int io_type, goto free_hq; } -wlan_init_locks (wl); -return 0 ; free_hq:
@@ -1847,6 +1856,7 @@ int wilc_cfg80211_init(struct wilc **wilc, struct device *dev, int io_type,wilc_wlan_cfg_deinit (wl); free_wl: +wlan_deinit_locks (wl);wiphy_unregister (wl->wiphy);wiphy_free (wl->wiphy);return ret;
drivers/staging/wilc1000/wilc_wfi_cfgoperations.h +1 -0
@@ -24,4 +24,5 @@ struct net_device *wilc_wfi_init_mon_interface(struct wilc *wl,void wilc_mgmt_frame_register (struct wiphy *wiphy,struct wireless_dev *wdev,u16 frame_type,bool reg);struct wilc_vif *wilc_get_interface (struct wilc *wl); +void wlan_deinit_locks (struct wilc *wilc);#endif
Signature · 1 line
2.22.0
PATCH 3/3 staging: wilc1000: use RCU list to maintain vif interfaces list
In reply to [email protected]From: Ajay Singh <[email protected]>
Make use of RCU list to maintain virtual interfaces instead of an array. The update operation on 'vif' list is less compare to the read operations. Mostly the 'vif' list elements are accessed for the read operation, so RCU list is more suited for this requirement. The shifting of interface index id's during the delete interface is not required. As the firmware only supports 2 interfaces so make use of available free slot index id during add interface.
--- drivers/staging/wilc1000/wilc_hif.c | 8 +- drivers/staging/wilc1000/wilc_netdev.c | 117 ++++++++++----- .../staging/wilc1000/wilc_wfi_cfgoperations.c | 141 ++++++++---------- .../staging/wilc1000/wilc_wfi_cfgoperations.h | 1 + drivers/staging/wilc1000/wilc_wfi_netdevice.h | 4 +- 5 files changed, 148 insertions(+), 123 deletions(-)
drivers/staging/wilc1000/wilc_hif.c +7 -1
@@ -183,11 +183,17 @@ int wilc_get_vif_idx(struct wilc_vif *vif)static struct wilc_vif *wilc_get_vif_from_idx (struct wilc *wilc,int idx) {int index = idx -1 ; +struct wilc_vif *vif;if (index <0 || index >=WILC_NUM_CONCURRENT_IFC )return NULL ; -return wilc->vif[index]; +list_for_each_entry_rcu (vif, &wilc->vif_list, list) { +if (vif->idx == index) +return vif; + } + +return NULL ; }static int handle_scan_done (struct wilc_vif *vif,enum scan_event evt)
drivers/staging/wilc1000/wilc_netdev.c +78 -39
208 lines not on this page · raw message
drivers/staging/wilc1000/wilc_wfi_cfgoperations.c +59 -82
289 lines not on this page · raw message
drivers/staging/wilc1000/wilc_wfi_cfgoperations.h +1 -0
@@ -24,5 +24,6 @@ struct net_device *wilc_wfi_init_mon_interface(struct wilc *wl,void wilc_mgmt_frame_register (struct wiphy *wiphy,struct wireless_dev *wdev,u16 frame_type,bool reg);struct wilc_vif *wilc_get_interface (struct wilc *wl); +struct wilc_vif *wilc_get_wl_to_vif (struct wilc *wl);void wlan_deinit_locks (struct wilc *wilc);#endif
drivers/staging/wilc1000/wilc_wfi_netdevice.h +3 -1
@@ -208,6 +208,7 @@ struct wilc_vif {struct tcp_ack_filter ack_filter;bool connecting;struct wilc_priv priv; +struct list_head list; };struct wilc {
@@ -221,9 +222,10 @@ struct wilc {int dev_irq_num;int close;u8 vif_num; -struct wilc_vif *vif[WILC_NUM_CONCURRENT_IFC ]; +struct list_head vif_list;/*protect vif list*/ struct mutex vif_mutex; +struct srcu_struct srcu;u8 open_ifcs;/*protect head of transmit queue*/ struct mutex txq_add_to_head_cs;
Signature · 1 line
2.22.0