Skip to contentSkip to conversation

wifi: mac80211: Remove unused wdev_to_ieee80211_vif

PATCH In review [email protected] 2 participants 5 messages Jun 19, 2025 – Oct 21, 2025 mac80211

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 wifi: mac80211: Remove unused wdev_to_ieee80211_vif

From: "Dr. David Alan Gilbert" <[email protected]>

wdev_to_ieee80211_vif() was added in 2013 by commit ad7e718c9b4f ("nl80211: vendor command support") but has remained unused.

Remove it.

---
 include/net/mac80211.h | 13 -------------
 net/mac80211/util.c    | 11 -----------
 2 files changed, 24 deletions(-)
include/net/mac80211.h +0 -13
index 286c944d90ad..544a28336b93 100644
@@ -2112,19 +2112,6 @@ static inline bool ieee80211_vif_is_mesh(struct ieee80211_vif *vif)
 	return false;
 }
 
-/**
- * wdev_to_ieee80211_vif - return a vif struct from a wdev
- * @wdev: the wdev to get the vif for
- *
- * This can be used by mac80211 drivers with direct cfg80211 APIs
- * (like the vendor commands) that get a wdev.
- *
- * Return: pointer to the wdev, or %NULL if the given wdev isn't
- * associated with a vif that the driver knows about (e.g. monitor
- * or AP_VLAN interfaces.)
- */
-struct ieee80211_vif *wdev_to_ieee80211_vif(struct wireless_dev *wdev);
-
 /**
  * ieee80211_vif_to_wdev - return a wdev struct from a vif
  * @vif: the vif to get the wdev for
net/mac80211/util.c +0 -11
index 27d414efa3fd..39a25fe20959 100644
@@ -857,17 +857,6 @@ void ieee80211_iterate_stations_mtx(struct ieee80211_hw *hw,
 }
 EXPORT_SYMBOL_GPL(ieee80211_iterate_stations_mtx);
 
-struct ieee80211_vif *wdev_to_ieee80211_vif(struct wireless_dev *wdev)
-{
-	struct ieee80211_sub_if_data *sdata = IEEE80211_WDEV_TO_SUB_IF(wdev);
-
-	if (!ieee80211_sdata_running(sdata) ||
-	    !(sdata->flags & IEEE80211_SDATA_IN_DRIVER))
-		return NULL;
-	return &sdata->vif;
-}
-EXPORT_SYMBOL_GPL(wdev_to_ieee80211_vif);
-
 struct wireless_dev *ieee80211_vif_to_wdev(struct ieee80211_vif *vif)
 {
 	if (!vif)
Signature · 1 line
2.49.0
#1 lore raw
Quoted 9 lines · * [email protected] ([email protected]) wrote:

From: "Dr. David Alan Gilbert" <[email protected]>

wdev_to_ieee80211_vif() was added in 2013 by commit ad7e718c9b4f ("nl80211: vendor command support") but has remained unused.

Remove it.

Hi,
Gentle ping on this one please.

Dave

Quoted 54 lines
---
 include/net/mac80211.h | 13 -------------
 net/mac80211/util.c    | 11 -----------
 2 files changed, 24 deletions(-)
include/net/mac80211.h +0 -13
index 286c944d90ad..544a28336b93 100644
@@ -2112,19 +2112,6 @@ static inline bool ieee80211_vif_is_mesh(struct ieee80211_vif *vif)
 	return false;
 }
 
-/**
- * wdev_to_ieee80211_vif - return a vif struct from a wdev
- * @wdev: the wdev to get the vif for
- *
- * This can be used by mac80211 drivers with direct cfg80211 APIs
- * (like the vendor commands) that get a wdev.
- *
- * Return: pointer to the wdev, or %NULL if the given wdev isn't
- * associated with a vif that the driver knows about (e.g. monitor
- * or AP_VLAN interfaces.)
- */
-struct ieee80211_vif *wdev_to_ieee80211_vif(struct wireless_dev *wdev);
-
 /**
  * ieee80211_vif_to_wdev - return a wdev struct from a vif
  * @vif: the vif to get the wdev for
net/mac80211/util.c +0 -11
index 27d414efa3fd..39a25fe20959 100644
@@ -857,17 +857,6 @@ void ieee80211_iterate_stations_mtx(struct ieee80211_hw *hw,
 }
 EXPORT_SYMBOL_GPL(ieee80211_iterate_stations_mtx);
 
-struct ieee80211_vif *wdev_to_ieee80211_vif(struct wireless_dev *wdev)
-{
-	struct ieee80211_sub_if_data *sdata = IEEE80211_WDEV_TO_SUB_IF(wdev);
-
-	if (!ieee80211_sdata_running(sdata) ||
-	    !(sdata->flags & IEEE80211_SDATA_IN_DRIVER))
-		return NULL;
-	return &sdata->vif;
-}
-EXPORT_SYMBOL_GPL(wdev_to_ieee80211_vif);
-
 struct wireless_dev *ieee80211_vif_to_wdev(struct ieee80211_vif *vif)
 {
 	if (!vif)
Signature · 1 line
2.49.0
Signature · 4 lines
 -----Open up your eyes, open up your mind, open up your code -------   
/ Dr. David Alan Gilbert    |       Running GNU/Linux       | Happy  \ 
\        dave @ treblig.org |                               | In Hex /
 \ _________________________|_____ http://www.treblig.org   |_______/
maintainer
#2 lore raw
Quoted 7 lines · Dr. David Alan Gilbert
Quoted 6 lines · * [email protected] ([email protected]) wrote:

From: "Dr. David Alan Gilbert" <[email protected]>

wdev_to_ieee80211_vif() was added in 2013 by commit ad7e718c9b4f ("nl80211: vendor command support") but has remained unused.

Quoted 6 lines
Quoted 3 lines

Remove it.

Hi,
Gentle ping on this one please.

This was/is used elsewhere out-of-tree, so I had dropped this change, at least for now. I guess that's really not a good excuse though.

I guess drivers could instead ieee80211_iterate_active_interfaces_mtx() and find the right wdev from that list, like

struct wdev_find_vif_iter {
	struct wireless_dev *wdev;
	struct ieee80211_vif *vif;
};

static void wdev_find_vif_iter_fn(void *data, u8 *mac, struct ieee80211_vif *vif)

{
	struct wdev_find_vif_iter *iter = data;

	if (ieee80211_vif_to_wdev(vif) == iter->wdev)
		iter->vif = vif;
}

struct ieee80211_vif *wdev_to_ieee80211_vif(struct wireless_dev *wdev)

{
	struct wdev_find_vif_iter iter = {
		.wdev = wdev,
	};

	ieee80211_iterate_active_interfaces_mtx(wiphy_to_ieee80211_hw(wdev->wiphy),
						IEEE80211_IFACE_SKIP_SDATA_NOT_IN_DRIVER,
						wdev_find_vif_iter_fn, &iter);

	return iter.vif;
}

but I guess I'm not sure it's really better for drivers to have that vs. upstream carrying the unused function.

johannes

#3 lore raw
Quoted 8 lines · * Johannes Berg ([email protected]) wrote:
Quoted 7 lines · Dr. David Alan Gilbert
Quoted 6 lines · * [email protected] ([email protected]) wrote:

From: "Dr. David Alan Gilbert" <[email protected]>

wdev_to_ieee80211_vif() was added in 2013 by commit ad7e718c9b4f ("nl80211: vendor command support") but has remained unused.

Quoted 6 lines
Quoted 6 lines
Quoted 3 lines

Remove it.

Hi,
Gentle ping on this one please.

Hi Johannes,
Thanks for the reply,

Quoted 2 lines

This was/is used elsewhere out-of-tree, so I had dropped this change, at least for now.

OK, I've made a note.

Quoted 1 line

I guess that's really not a good excuse though.

So what is it about these out of tree things that needs these calls; why don't the in tree ones need it?

Dave

Quoted 36 lines

I guess drivers could instead ieee80211_iterate_active_interfaces_mtx() and find the right wdev from that list, like

struct wdev_find_vif_iter {
	struct wireless_dev *wdev;
	struct ieee80211_vif *vif;
};

static void wdev_find_vif_iter_fn(void *data, u8 *mac, struct ieee80211_vif *vif)

{
	struct wdev_find_vif_iter *iter = data;

	if (ieee80211_vif_to_wdev(vif) == iter->wdev)
		iter->vif = vif;
}

struct ieee80211_vif *wdev_to_ieee80211_vif(struct wireless_dev *wdev)

{
	struct wdev_find_vif_iter iter = {
		.wdev = wdev,
	};

	ieee80211_iterate_active_interfaces_mtx(wiphy_to_ieee80211_hw(wdev->wiphy),
						IEEE80211_IFACE_SKIP_SDATA_NOT_IN_DRIVER,
						wdev_find_vif_iter_fn, &iter);

	return iter.vif;
}

but I guess I'm not sure it's really better for drivers to have that vs. upstream carrying the unused function.

johannes

Signature · 4 lines
 -----Open up your eyes, open up your mind, open up your code -------   
/ Dr. David Alan Gilbert    |       Running GNU/Linux       | Happy  \ 
\        dave @ treblig.org |                               | In Hex /
 \ _________________________|_____ http://www.treblig.org   |_______/
maintainer
#4 lore raw
Quoted 2 lines · Dr. David Alan Gilbert

So what is it about these out of tree things that needs these calls; why don't the in tree ones need it?

If you have a mac80211 driver that has cfg80211 vendor commands, it'll be called with just the wdev, but will need to have the mac80211 corresponding vif in most cases, and if it's e.g. called for a monitor interface, there might not even _be_ a vif (and get NULL here.)

johannes