[PATCH] wifi: mac80211: Remove unused wdev_to_ieee80211_vif

linux@treblig.org posted 1 patch 7 months, 3 weeks ago
include/net/mac80211.h | 13 -------------
net/mac80211/util.c    | 11 -----------
2 files changed, 24 deletions(-)
[PATCH] wifi: mac80211: Remove unused wdev_to_ieee80211_vif
Posted by linux@treblig.org 7 months, 3 weeks ago
From: "Dr. David Alan Gilbert" <linux@treblig.org>

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

Remove it.

Signed-off-by: Dr. David Alan Gilbert <linux@treblig.org>
---
 include/net/mac80211.h | 13 -------------
 net/mac80211/util.c    | 11 -----------
 2 files changed, 24 deletions(-)

diff --git a/include/net/mac80211.h b/include/net/mac80211.h
index 286c944d90ad..544a28336b93 100644
--- a/include/net/mac80211.h
+++ b/include/net/mac80211.h
@@ -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
diff --git a/net/mac80211/util.c b/net/mac80211/util.c
index 27d414efa3fd..39a25fe20959 100644
--- a/net/mac80211/util.c
+++ b/net/mac80211/util.c
@@ -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)
-- 
2.49.0
Re: [PATCH] wifi: mac80211: Remove unused wdev_to_ieee80211_vif
Posted by Dr. David Alan Gilbert 3 months, 3 weeks ago
* linux@treblig.org (linux@treblig.org) wrote:
> From: "Dr. David Alan Gilbert" <linux@treblig.org>
> 
> wdev_to_ieee80211_vif() was added in 2013 by
> commit ad7e718c9b4f ("nl80211: vendor command support")
> but has remained unused.
> 
> Remove it.
> 
> Signed-off-by: Dr. David Alan Gilbert <linux@treblig.org>

Hi,
  Gentle ping on this one please.

Dave

> ---
>  include/net/mac80211.h | 13 -------------
>  net/mac80211/util.c    | 11 -----------
>  2 files changed, 24 deletions(-)
> 
> diff --git a/include/net/mac80211.h b/include/net/mac80211.h
> index 286c944d90ad..544a28336b93 100644
> --- a/include/net/mac80211.h
> +++ b/include/net/mac80211.h
> @@ -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
> diff --git a/net/mac80211/util.c b/net/mac80211/util.c
> index 27d414efa3fd..39a25fe20959 100644
> --- a/net/mac80211/util.c
> +++ b/net/mac80211/util.c
> @@ -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)
> -- 
> 2.49.0
> 
-- 
 -----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   |_______/
Re: [PATCH] wifi: mac80211: Remove unused wdev_to_ieee80211_vif
Posted by Johannes Berg 3 months, 2 weeks ago
On Sun, 2025-10-12 at 16:40 +0000, Dr. David Alan Gilbert wrote:
> * linux@treblig.org (linux@treblig.org) wrote:
> > From: "Dr. David Alan Gilbert" <linux@treblig.org>
> > 
> > wdev_to_ieee80211_vif() was added in 2013 by
> > commit ad7e718c9b4f ("nl80211: vendor command support")
> > but has remained unused.
> > 
> > Remove it.
> > 
> > Signed-off-by: Dr. David Alan Gilbert <linux@treblig.org>
> 
> 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
Re: [PATCH] wifi: mac80211: Remove unused wdev_to_ieee80211_vif
Posted by Dr. David Alan Gilbert 3 months, 2 weeks ago
* Johannes Berg (johannes@sipsolutions.net) wrote:
> On Sun, 2025-10-12 at 16:40 +0000, Dr. David Alan Gilbert wrote:
> > * linux@treblig.org (linux@treblig.org) wrote:
> > > From: "Dr. David Alan Gilbert" <linux@treblig.org>
> > > 
> > > wdev_to_ieee80211_vif() was added in 2013 by
> > > commit ad7e718c9b4f ("nl80211: vendor command support")
> > > but has remained unused.
> > > 
> > > Remove it.
> > > 
> > > Signed-off-by: Dr. David Alan Gilbert <linux@treblig.org>
> > 
> > Hi,
> >   Gentle ping on this one please.

Hi Johannes,
  Thanks for the reply,

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

OK, I've made a note.

> 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

> 
> 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
-- 
 -----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   |_______/
Re: [PATCH] wifi: mac80211: Remove unused wdev_to_ieee80211_vif
Posted by Johannes Berg 3 months, 2 weeks ago
On Mon, 2025-10-20 at 16:39 +0000, Dr. David Alan Gilbert wrote:
> 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