From 08c2eb8ec800b1b5447728af0ffeebf6346bdcf2 Mon Sep 17 00:00:00 2001 From: Kees Cook Date: Tue, 24 Oct 2017 02:29:19 -0700 Subject: mwifiex: Convert timers to use timer_setup() In preparation for unconditionally passing the struct timer_list pointer to all timer callbacks, switch to using the new timer_setup() and from_timer() to pass the timer pointer explicitly. Cc: Kalle Valo Cc: Amitkumar Karwar Cc: Nishant Sarmukadam Cc: Ganapathi Bhat Cc: Xinming Hu Cc: Arvind Yadav Cc: Ingo Molnar Cc: Johannes Berg Cc: "David S. Miller" Cc: Andrew Zaborowski Cc: libertas-dev@lists.infradead.org Cc: linux-wireless@vger.kernel.org Cc: netdev@vger.kernel.org Signed-off-by: Kees Cook Signed-off-by: Kalle Valo --- drivers/net/wireless/marvell/mwifiex/11n_rxreorder.c | 7 +++---- drivers/net/wireless/marvell/mwifiex/cmdevt.c | 5 ++--- drivers/net/wireless/marvell/mwifiex/init.c | 7 +++---- drivers/net/wireless/marvell/mwifiex/main.c | 3 +-- drivers/net/wireless/marvell/mwifiex/main.h | 4 ++-- drivers/net/wireless/marvell/mwifiex/tdls.c | 7 +++---- drivers/net/wireless/marvell/mwifiex/usb.c | 9 ++++----- 7 files changed, 18 insertions(+), 24 deletions(-) (limited to 'drivers/net/wireless/marvell') diff --git a/drivers/net/wireless/marvell/mwifiex/11n_rxreorder.c b/drivers/net/wireless/marvell/mwifiex/11n_rxreorder.c index d87df2dfcfa4..1edcddaf7b4b 100644 --- a/drivers/net/wireless/marvell/mwifiex/11n_rxreorder.c +++ b/drivers/net/wireless/marvell/mwifiex/11n_rxreorder.c @@ -312,10 +312,10 @@ mwifiex_11n_find_last_seq_num(struct reorder_tmr_cnxt *ctx) * them and then dumps the Rx reordering table. */ static void -mwifiex_flush_data(unsigned long context) +mwifiex_flush_data(struct timer_list *t) { struct reorder_tmr_cnxt *ctx = - (struct reorder_tmr_cnxt *) context; + from_timer(ctx, t, timer); int start_win, seq_num; ctx->timer_is_set = false; @@ -412,8 +412,7 @@ mwifiex_11n_create_rx_reorder_tbl(struct mwifiex_private *priv, u8 *ta, new_node->timer_context.priv = priv; new_node->timer_context.timer_is_set = false; - setup_timer(&new_node->timer_context.timer, mwifiex_flush_data, - (unsigned long)&new_node->timer_context); + timer_setup(&new_node->timer_context.timer, mwifiex_flush_data, 0); for (i = 0; i < win_size; ++i) new_node->rx_reorder_ptr[i] = NULL; diff --git a/drivers/net/wireless/marvell/mwifiex/cmdevt.c b/drivers/net/wireless/marvell/mwifiex/cmdevt.c index a9a1a736e6e8..dcc529e9c0ef 100644 --- a/drivers/net/wireless/marvell/mwifiex/cmdevt.c +++ b/drivers/net/wireless/marvell/mwifiex/cmdevt.c @@ -920,10 +920,9 @@ int mwifiex_process_cmdresp(struct mwifiex_adapter *adapter) * It will re-send the same command again. */ void -mwifiex_cmd_timeout_func(unsigned long function_context) +mwifiex_cmd_timeout_func(struct timer_list *t) { - struct mwifiex_adapter *adapter = - (struct mwifiex_adapter *) function_context; + struct mwifiex_adapter *adapter = from_timer(adapter, t, cmd_timer); struct cmd_ctrl_node *cmd_node; adapter->is_cmd_timedout = 1; diff --git a/drivers/net/wireless/marvell/mwifiex/init.c b/drivers/net/wireless/marvell/mwifiex/init.c index 1176706ab094..e1aa86042469 100644 --- a/drivers/net/wireless/marvell/mwifiex/init.c +++ b/drivers/net/wireless/marvell/mwifiex/init.c @@ -52,9 +52,9 @@ static int mwifiex_add_bss_prio_tbl(struct mwifiex_private *priv) return 0; } -static void wakeup_timer_fn(unsigned long data) +static void wakeup_timer_fn(struct timer_list *t) { - struct mwifiex_adapter *adapter = (struct mwifiex_adapter *)data; + struct mwifiex_adapter *adapter = from_timer(adapter, t, wakeup_timer); mwifiex_dbg(adapter, ERROR, "Firmware wakeup failed\n"); adapter->hw_status = MWIFIEX_HW_STATUS_RESET; @@ -313,8 +313,7 @@ static void mwifiex_init_adapter(struct mwifiex_adapter *adapter) adapter->iface_limit.uap_intf = MWIFIEX_MAX_UAP_NUM; adapter->iface_limit.p2p_intf = MWIFIEX_MAX_P2P_NUM; adapter->active_scan_triggered = false; - setup_timer(&adapter->wakeup_timer, wakeup_timer_fn, - (unsigned long)adapter); + timer_setup(&adapter->wakeup_timer, wakeup_timer_fn, 0); } /* diff --git a/drivers/net/wireless/marvell/mwifiex/main.c b/drivers/net/wireless/marvell/mwifiex/main.c index ee40b739b289..a96bd7e653bf 100644 --- a/drivers/net/wireless/marvell/mwifiex/main.c +++ b/drivers/net/wireless/marvell/mwifiex/main.c @@ -100,8 +100,7 @@ static int mwifiex_register(void *card, struct device *dev, } mwifiex_init_lock_list(adapter); - setup_timer(&adapter->cmd_timer, mwifiex_cmd_timeout_func, - (unsigned long)adapter); + timer_setup(&adapter->cmd_timer, mwifiex_cmd_timeout_func, 0); return 0; diff --git a/drivers/net/wireless/marvell/mwifiex/main.h b/drivers/net/wireless/marvell/mwifiex/main.h index a34de8582e91..154c0796c0c5 100644 --- a/drivers/net/wireless/marvell/mwifiex/main.h +++ b/drivers/net/wireless/marvell/mwifiex/main.h @@ -1072,7 +1072,7 @@ int mwifiex_complete_cmd(struct mwifiex_adapter *adapter, int mwifiex_send_cmd(struct mwifiex_private *priv, u16 cmd_no, u16 cmd_action, u32 cmd_oid, void *data_buf, bool sync); -void mwifiex_cmd_timeout_func(unsigned long function_context); +void mwifiex_cmd_timeout_func(struct timer_list *t); int mwifiex_get_debug_info(struct mwifiex_private *, struct mwifiex_debug_info *); @@ -1617,7 +1617,7 @@ void mwifiex_auto_tdls_update_peer_status(struct mwifiex_private *priv, const u8 *mac, u8 link_status); void mwifiex_auto_tdls_update_peer_signal(struct mwifiex_private *priv, u8 *mac, s8 snr, s8 nflr); -void mwifiex_check_auto_tdls(unsigned long context); +void mwifiex_check_auto_tdls(struct timer_list *t); void mwifiex_add_auto_tdls_peer(struct mwifiex_private *priv, const u8 *mac); void mwifiex_setup_auto_tdls_timer(struct mwifiex_private *priv); void mwifiex_clean_auto_tdls(struct mwifiex_private *priv); diff --git a/drivers/net/wireless/marvell/mwifiex/tdls.c b/drivers/net/wireless/marvell/mwifiex/tdls.c index 9fe0bae957b7..27779d7317fd 100644 --- a/drivers/net/wireless/marvell/mwifiex/tdls.c +++ b/drivers/net/wireless/marvell/mwifiex/tdls.c @@ -1389,9 +1389,9 @@ void mwifiex_auto_tdls_update_peer_signal(struct mwifiex_private *priv, spin_unlock_irqrestore(&priv->auto_tdls_lock, flags); } -void mwifiex_check_auto_tdls(unsigned long context) +void mwifiex_check_auto_tdls(struct timer_list *t) { - struct mwifiex_private *priv = (struct mwifiex_private *)context; + struct mwifiex_private *priv = from_timer(priv, t, auto_tdls_timer); struct mwifiex_auto_tdls_peer *tdls_peer; unsigned long flags; u16 reason = WLAN_REASON_TDLS_TEARDOWN_UNSPECIFIED; @@ -1456,8 +1456,7 @@ void mwifiex_check_auto_tdls(unsigned long context) void mwifiex_setup_auto_tdls_timer(struct mwifiex_private *priv) { - setup_timer(&priv->auto_tdls_timer, mwifiex_check_auto_tdls, - (unsigned long)priv); + timer_setup(&priv->auto_tdls_timer, mwifiex_check_auto_tdls, 0); priv->auto_tdls_timer_active = true; mod_timer(&priv->auto_tdls_timer, jiffies + msecs_to_jiffies(MWIFIEX_TIMER_10S)); diff --git a/drivers/net/wireless/marvell/mwifiex/usb.c b/drivers/net/wireless/marvell/mwifiex/usb.c index f4f2b9b27e32..4bc244801636 100644 --- a/drivers/net/wireless/marvell/mwifiex/usb.c +++ b/drivers/net/wireless/marvell/mwifiex/usb.c @@ -1096,12 +1096,12 @@ postcopy_cur_buf: return -EINPROGRESS; } -static void mwifiex_usb_tx_aggr_tmo(unsigned long context) +static void mwifiex_usb_tx_aggr_tmo(struct timer_list *t) { struct urb_context *urb_cnxt = NULL; struct sk_buff *skb_send = NULL; struct tx_aggr_tmr_cnxt *timer_context = - (struct tx_aggr_tmr_cnxt *)context; + from_timer(timer_context, t, hold_timer); struct mwifiex_adapter *adapter = timer_context->adapter; struct usb_tx_data_port *port = timer_context->port; unsigned long flags; @@ -1236,9 +1236,8 @@ static int mwifiex_usb_tx_init(struct mwifiex_adapter *adapter) port->tx_aggr.timer_cnxt.port = port; port->tx_aggr.timer_cnxt.is_hold_timer_set = false; port->tx_aggr.timer_cnxt.hold_tmo_msecs = 0; - setup_timer(&port->tx_aggr.timer_cnxt.hold_timer, - mwifiex_usb_tx_aggr_tmo, - (unsigned long)&port->tx_aggr.timer_cnxt); + timer_setup(&port->tx_aggr.timer_cnxt.hold_timer, + mwifiex_usb_tx_aggr_tmo, 0); } return 0; -- cgit v1.2.3 From 78ce6a9083c4f5ac1a73aa0b614c852db2d4e982 Mon Sep 17 00:00:00 2001 From: Kees Cook Date: Tue, 24 Oct 2017 02:29:28 -0700 Subject: libertas: Convert timers to use timer_setup() In preparation for unconditionally passing the struct timer_list pointer to all timer callbacks, switch to using the new timer_setup() and from_timer() to pass the timer pointer explicitly. Cc: Kalle Valo Cc: Arvind Yadav Cc: Ingo Molnar Cc: Johannes Berg Cc: "David S. Miller" Cc: Andrew Zaborowski Cc: libertas-dev@lists.infradead.org Cc: linux-wireless@vger.kernel.org Cc: netdev@vger.kernel.org Signed-off-by: Kees Cook Signed-off-by: Kalle Valo --- drivers/net/wireless/marvell/libertas/if_usb.c | 6 +++--- drivers/net/wireless/marvell/libertas/main.c | 21 +++++++++------------ drivers/net/wireless/marvell/libertas_tf/if_usb.c | 6 +++--- drivers/net/wireless/marvell/libertas_tf/main.c | 7 +++---- 4 files changed, 18 insertions(+), 22 deletions(-) (limited to 'drivers/net/wireless/marvell') diff --git a/drivers/net/wireless/marvell/libertas/if_usb.c b/drivers/net/wireless/marvell/libertas/if_usb.c index 16e54c757dd0..ffea610f67e2 100644 --- a/drivers/net/wireless/marvell/libertas/if_usb.c +++ b/drivers/net/wireless/marvell/libertas/if_usb.c @@ -161,9 +161,9 @@ static void if_usb_setup_firmware(struct lbs_private *priv) } } -static void if_usb_fw_timeo(unsigned long priv) +static void if_usb_fw_timeo(struct timer_list *t) { - struct if_usb_card *cardp = (void *)priv; + struct if_usb_card *cardp = from_timer(cardp, t, fw_timeout); if (cardp->fwdnldover) { lbs_deb_usb("Download complete, no event. Assuming success\n"); @@ -205,7 +205,7 @@ static int if_usb_probe(struct usb_interface *intf, if (!cardp) goto error; - setup_timer(&cardp->fw_timeout, if_usb_fw_timeo, (unsigned long)cardp); + timer_setup(&cardp->fw_timeout, if_usb_fw_timeo, 0); init_waitqueue_head(&cardp->fw_wq); cardp->udev = udev; diff --git a/drivers/net/wireless/marvell/libertas/main.c b/drivers/net/wireless/marvell/libertas/main.c index aefa88f4f29c..f22e1c220cba 100644 --- a/drivers/net/wireless/marvell/libertas/main.c +++ b/drivers/net/wireless/marvell/libertas/main.c @@ -722,9 +722,9 @@ EXPORT_SYMBOL_GPL(lbs_resume); * * @data: &struct lbs_private pointer */ -static void lbs_cmd_timeout_handler(unsigned long data) +static void lbs_cmd_timeout_handler(struct timer_list *t) { - struct lbs_private *priv = (struct lbs_private *)data; + struct lbs_private *priv = from_timer(priv, t, command_timer); unsigned long flags; spin_lock_irqsave(&priv->driver_lock, flags); @@ -756,9 +756,9 @@ out: * * @data: &struct lbs_private pointer */ -static void lbs_tx_lockup_handler(unsigned long data) +static void lbs_tx_lockup_handler(struct timer_list *t) { - struct lbs_private *priv = (struct lbs_private *)data; + struct lbs_private *priv = from_timer(priv, t, tx_lockup_timer); unsigned long flags; spin_lock_irqsave(&priv->driver_lock, flags); @@ -779,9 +779,9 @@ static void lbs_tx_lockup_handler(unsigned long data) * @data: &struct lbs_private pointer * returns: N/A */ -static void auto_deepsleep_timer_fn(unsigned long data) +static void auto_deepsleep_timer_fn(struct timer_list *t) { - struct lbs_private *priv = (struct lbs_private *)data; + struct lbs_private *priv = from_timer(priv, t, auto_deepsleep_timer); if (priv->is_activity_detected) { priv->is_activity_detected = 0; @@ -847,12 +847,9 @@ static int lbs_init_adapter(struct lbs_private *priv) init_waitqueue_head(&priv->fw_waitq); mutex_init(&priv->lock); - setup_timer(&priv->command_timer, lbs_cmd_timeout_handler, - (unsigned long)priv); - setup_timer(&priv->tx_lockup_timer, lbs_tx_lockup_handler, - (unsigned long)priv); - setup_timer(&priv->auto_deepsleep_timer, auto_deepsleep_timer_fn, - (unsigned long)priv); + timer_setup(&priv->command_timer, lbs_cmd_timeout_handler, 0); + timer_setup(&priv->tx_lockup_timer, lbs_tx_lockup_handler, 0); + timer_setup(&priv->auto_deepsleep_timer, auto_deepsleep_timer_fn, 0); INIT_LIST_HEAD(&priv->cmdfreeq); INIT_LIST_HEAD(&priv->cmdpendingq); diff --git a/drivers/net/wireless/marvell/libertas_tf/if_usb.c b/drivers/net/wireless/marvell/libertas_tf/if_usb.c index e9104eca327b..5153922e7ce1 100644 --- a/drivers/net/wireless/marvell/libertas_tf/if_usb.c +++ b/drivers/net/wireless/marvell/libertas_tf/if_usb.c @@ -115,9 +115,9 @@ static void if_usb_setup_firmware(struct lbtf_private *priv) lbtf_deb_leave(LBTF_DEB_USB); } -static void if_usb_fw_timeo(unsigned long priv) +static void if_usb_fw_timeo(struct timer_list *t) { - struct if_usb_card *cardp = (void *)priv; + struct if_usb_card *cardp = from_timer(cardp, t, fw_timeout); lbtf_deb_enter(LBTF_DEB_USB); if (!cardp->fwdnldover) { @@ -156,7 +156,7 @@ static int if_usb_probe(struct usb_interface *intf, if (!cardp) goto error; - setup_timer(&cardp->fw_timeout, if_usb_fw_timeo, (unsigned long)cardp); + timer_setup(&cardp->fw_timeout, if_usb_fw_timeo, 0); init_waitqueue_head(&cardp->fw_wq); cardp->udev = udev; diff --git a/drivers/net/wireless/marvell/libertas_tf/main.c b/drivers/net/wireless/marvell/libertas_tf/main.c index 81228bf73043..1d45da187b9b 100644 --- a/drivers/net/wireless/marvell/libertas_tf/main.c +++ b/drivers/net/wireless/marvell/libertas_tf/main.c @@ -165,9 +165,9 @@ done: * This function handles the timeout of command sending. * It will re-send the same command again. */ -static void command_timer_fn(unsigned long data) +static void command_timer_fn(struct timer_list *t) { - struct lbtf_private *priv = (struct lbtf_private *)data; + struct lbtf_private *priv = from_timer(priv, t, command_timer); unsigned long flags; lbtf_deb_enter(LBTF_DEB_CMD); @@ -196,8 +196,7 @@ static int lbtf_init_adapter(struct lbtf_private *priv) mutex_init(&priv->lock); priv->vif = NULL; - setup_timer(&priv->command_timer, command_timer_fn, - (unsigned long)priv); + timer_setup(&priv->command_timer, command_timer_fn, 0); INIT_LIST_HEAD(&priv->cmdfreeq); INIT_LIST_HEAD(&priv->cmdpendingq); -- cgit v1.2.3 From 39a9cd5a0e4e64d02b1b201bb767fde22712405a Mon Sep 17 00:00:00 2001 From: Johannes Berg Date: Tue, 17 Oct 2017 21:37:45 +0200 Subject: libertas: don't write wdev->ssid/_len When joining an IBSS network, wdev->ssid/_len will already be set, so there's no need to write them. In any case, they are internal cfg80211 values, and have very little user-visible impact. Signed-off-by: Johannes Berg Signed-off-by: Kalle Valo --- drivers/net/wireless/marvell/libertas/cfg.c | 3 --- 1 file changed, 3 deletions(-) (limited to 'drivers/net/wireless/marvell') diff --git a/drivers/net/wireless/marvell/libertas/cfg.c b/drivers/net/wireless/marvell/libertas/cfg.c index 71ba2c8d09b5..bb76707881cd 100644 --- a/drivers/net/wireless/marvell/libertas/cfg.c +++ b/drivers/net/wireless/marvell/libertas/cfg.c @@ -1698,9 +1698,6 @@ static void lbs_join_post(struct lbs_private *priv, 0, GFP_KERNEL); cfg80211_put_bss(priv->wdev->wiphy, bss); - memcpy(priv->wdev->ssid, params->ssid, params->ssid_len); - priv->wdev->ssid_len = params->ssid_len; - cfg80211_ibss_joined(priv->dev, bssid, params->chandef.chan, GFP_KERNEL); -- cgit v1.2.3 From c6c65a8411cf0842c9036e30ed1e7a6ccd7fdf41 Mon Sep 17 00:00:00 2001 From: Ganapathi Bhat Date: Fri, 27 Oct 2017 15:32:49 +0530 Subject: mwifiex: do not transmit in 11N rates when connected in TKIP security Driver is transmitting in 11N rates, when connected to an AP in TKIP security mode. Add a check to disable_11n to fix the issue. Signed-off-by: Ganapathi Bhat Signed-off-by: Kalle Valo --- drivers/net/wireless/marvell/mwifiex/fw.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'drivers/net/wireless/marvell') diff --git a/drivers/net/wireless/marvell/mwifiex/fw.h b/drivers/net/wireless/marvell/mwifiex/fw.h index 6b765f3f37fd..13cd58e963b3 100644 --- a/drivers/net/wireless/marvell/mwifiex/fw.h +++ b/drivers/net/wireless/marvell/mwifiex/fw.h @@ -225,7 +225,8 @@ enum MWIFIEX_802_11_PRIVACY_FILTER { #define IS_11N_ENABLED(priv) ((priv->adapter->config_bands & BAND_GN || \ priv->adapter->config_bands & BAND_AN) && \ - priv->curr_bss_params.bss_descriptor.bcn_ht_cap) + priv->curr_bss_params.bss_descriptor.bcn_ht_cap && \ + !priv->curr_bss_params.bss_descriptor.disable_11n) #define INITIATOR_BIT(DelBAParamSet) (((DelBAParamSet) &\ BIT(DELBA_INITIATOR_POS)) >> DELBA_INITIATOR_POS) -- cgit v1.2.3