Commit f30386a8 authored by Emmanuel Grumbach's avatar Emmanuel Grumbach Committed by Johannes Berg

mac80211: make ieee80211_vif_to_wdev work when the vif isn't in the driver

This will allow the low level driver to get the wdev during
the add_interface flow.
In order to do that, remove a few checks from there and do
not return NULL for vifs that were not yet added to the
driver. Note that all the current callers of this helper
function assume that the vif already exists:
 - The callers from the drivers already have a vif pointer.
 Before this change, ieee80211_vif_to_wdev would return NULL
 in some cases, but those callers don't even check they
 get a non-NULL pointer from ieee80211_vif_to_wdev.
 - The callers from net/mac80211/cfg.c assume the vif is
 already added to the driver as well.

So, this change has no impact on existing callers of this
helper function.
Signed-off-by: default avatarEmmanuel Grumbach <emmanuel.grumbach@intel.com>
Signed-off-by: default avatarLuca Coelho <luciano.coelho@intel.com>
Link: https://lore.kernel.org/r/iwlwifi.20210409123755.6078d3517095.I1907a45f267a62dab052bcc44428aa7a2005ffc9@changeidSigned-off-by: default avatarJohannes Berg <johannes.berg@intel.com>
parent 73807523
...@@ -1768,10 +1768,7 @@ struct ieee80211_vif *wdev_to_ieee80211_vif(struct wireless_dev *wdev); ...@@ -1768,10 +1768,7 @@ struct ieee80211_vif *wdev_to_ieee80211_vif(struct wireless_dev *wdev);
* *
* This can be used by mac80211 drivers with direct cfg80211 APIs * This can be used by mac80211 drivers with direct cfg80211 APIs
* (like the vendor commands) that needs to get the wdev for a vif. * (like the vendor commands) that needs to get the wdev for a vif.
* * This can also be useful to get the netdev associated to a vif.
* Note that this function may return %NULL if the given wdev isn't
* associated with a vif that the driver knows about (e.g. monitor
* or AP_VLAN interfaces.)
*/ */
struct wireless_dev *ieee80211_vif_to_wdev(struct ieee80211_vif *vif); struct wireless_dev *ieee80211_vif_to_wdev(struct ieee80211_vif *vif);
......
...@@ -888,18 +888,10 @@ EXPORT_SYMBOL_GPL(wdev_to_ieee80211_vif); ...@@ -888,18 +888,10 @@ EXPORT_SYMBOL_GPL(wdev_to_ieee80211_vif);
struct wireless_dev *ieee80211_vif_to_wdev(struct ieee80211_vif *vif) struct wireless_dev *ieee80211_vif_to_wdev(struct ieee80211_vif *vif)
{ {
struct ieee80211_sub_if_data *sdata;
if (!vif) if (!vif)
return NULL; return NULL;
sdata = vif_to_sdata(vif); return &vif_to_sdata(vif)->wdev;
if (!ieee80211_sdata_running(sdata) ||
!(sdata->flags & IEEE80211_SDATA_IN_DRIVER))
return NULL;
return &sdata->wdev;
} }
EXPORT_SYMBOL_GPL(ieee80211_vif_to_wdev); EXPORT_SYMBOL_GPL(ieee80211_vif_to_wdev);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment