qcacld-3.0: Refactor wireless_handlers NULLing logic

Currently there is logic to set the net device wireless_handlers
pointer to NULL in both hdd_deinit_station_mode() and
hdd_deinit_ap_mode(). This is unnecessary duplication of code, and
worse, this is WEXT-specific logic that exists outside the
WEXT-specific source files. In order to address these issues refactor
the logic into a new function that is exposed by wlan_hdd_wext.h.

Change-Id: I0fab5a7f35941f282ddf2e286fb12bfb8c4c7c50
CRs-Fixed: 2620818
This commit is contained in:
Jeff Johnson 2020-02-12 14:35:04 -08:00 • committed by nshrivas
commit 9453a8fc58
4 changed files with 35 additions and 26 deletions

View file

@ -1,5 +1,5 @@
/*
* Copyright (c) 2012-2019 The Linux Foundation. All rights reserved.
* Copyright (c) 2012-2020 The Linux Foundation. All rights reserved.
*
* Permission to use, copy, modify, and/or distribute this software for
* any purpose with or without fee is hereby granted, provided that the
@ -184,6 +184,19 @@ void hdd_unregister_wext(struct net_device *dev);
*/
void hdd_register_wext(struct net_device *dev);
/**
* hdd_wext_unregister() - unregister wext context with rtnl lock dependency
* @dev: net device from which wireless extensions are being unregistered
* @rtnl_held: flag which indicates if caller is holding the rtnl_lock
*
* Unregisters wext context for a given net device. This behaves the
* same as hdd_unregister_wext() except it does not take the rtnl_lock
* if the caller is already holding it.
*
* Returns: None
*/
void hdd_wext_unregister(struct net_device *dev,
bool rtnl_held);
void hdd_wlan_get_stats(struct hdd_adapter *adapter, uint16_t *length,
char *buffer, uint16_t buf_len);
void hdd_wlan_list_fw_profile(uint16_t *length,
@ -363,6 +376,11 @@ static inline void hdd_unregister_wext(struct net_device *dev)
static inline void hdd_register_wext(struct net_device *dev)
{
}
static inline void hdd_wext_unregister(struct net_device *dev,
bool rtnl_locked)
{
}
#endif /* WLAN_WEXT_SUPPORT_ENABLE */
#if defined(WLAN_WEXT_SUPPORT_ENABLE) && defined(HASTINGS_BT_WAR)

View file

@ -3491,21 +3491,6 @@ void hdd_deinit_ap_mode(struct hdd_context *hdd_ctx,
qdf_atomic_set(&adapter->session.ap.acs_in_progress, 0);
hdd_softap_deinit_tx_rx(adapter);
/*
* if we are being called during driver unload,
* then the dev has already been invalidated.
* if we are being called at other times, then we can
* detach the wireless device handlers
*/
if (adapter->dev) {
if (rtnl_held) {
adapter->dev->wireless_handlers = NULL;
} else {
rtnl_lock();
adapter->dev->wireless_handlers = NULL;
rtnl_unlock();
}
}
if (hdd_hostapd_deinit_sap_session(adapter))
hdd_err("Failed:hdd_hostapd_deinit_sap_session");

View file

@ -4978,16 +4978,6 @@ static void hdd_deinit_station_mode(struct hdd_context *hdd_ctx,
{
hdd_enter_dev(adapter->dev);
if (adapter->dev) {
if (rtnl_held)
adapter->dev->wireless_handlers = NULL;
else {
rtnl_lock();
adapter->dev->wireless_handlers = NULL;
rtnl_unlock();
}
}
if (test_bit(INIT_TX_RX_SUCCESS, &adapter->event_flags)) {
hdd_deinit_tx_rx(adapter);
clear_bit(INIT_TX_RX_SUCCESS, &adapter->event_flags);
@ -5008,6 +4998,8 @@ void hdd_deinit_adapter(struct hdd_context *hdd_ctx,
{
hdd_enter();
hdd_wext_unregister(adapter->dev, rtnl_held);
switch (adapter->device_mode) {
case QDF_STA_MODE:
case QDF_P2P_CLIENT_MODE:

View file

@ -11053,3 +11053,17 @@ void hdd_unregister_wext(struct net_device *dev)
hdd_exit();
}
void hdd_wext_unregister(struct net_device *dev,
bool rtnl_held)
{
if (!dev)
return;
if (!rtnl_held)
rtnl_lock();
dev->wireless_handlers = NULL;
if (!rtnl_held)
rtnl_unlock();
}