diff mbox series

[1/9] mwifiex: Small cleanup for handling virtual interface type changes

Message ID 20210914195909.36035-2-verdre@v0yd.nl (mailing list archive)
State Accepted
Commit babe2a332dc40b0e43035e529b357a232dbe7f7b
Delegated to: Kalle Valo
Headers show
Series mwifiex: Fixes for wifi p2p and AP mode | expand

Commit Message

Jonas Dreßler Sept. 14, 2021, 7:59 p.m. UTC
Handle the obvious invalid virtual interface type changes with a general
check instead of looking at the individual change.

For type changes from P2P_CLIENT to P2P_GO and the other way round, this
changes the behavior slightly: We now still do nothing, but return
-EOPNOTSUPP instead of 0. Now that behavior was incorrect before and
still is, because type changes between these two types are actually
possible and supported, which we'll fix in a following commit.

Signed-off-by: Jonas Dreßler <verdre@v0yd.nl>
---
 .../net/wireless/marvell/mwifiex/cfg80211.c   | 39 +++++++------------
 1 file changed, 14 insertions(+), 25 deletions(-)

Comments

Kalle Valo Sept. 21, 2021, 3:02 p.m. UTC | #1
Jonas Dreßler <verdre@v0yd.nl> wrote:

> Handle the obvious invalid virtual interface type changes with a general
> check instead of looking at the individual change.
> 
> For type changes from P2P_CLIENT to P2P_GO and the other way round, this
> changes the behavior slightly: We now still do nothing, but return
> -EOPNOTSUPP instead of 0. Now that behavior was incorrect before and
> still is, because type changes between these two types are actually
> possible and supported, which we'll fix in a following commit.
> 
> Signed-off-by: Jonas Dreßler <verdre@v0yd.nl>

9 patches applied to wireless-drivers-next.git, thanks.

babe2a332dc4 mwifiex: Small cleanup for handling virtual interface type changes
abe3a2c9ead8 mwifiex: Use function to check whether interface type change is allowed
c2e9666cdffd mwifiex: Run SET_BSS_MODE when changing from P2P to STATION vif-type
54350dac4e6a mwifiex: Use helper function for counting interface types
fae2aac8c740 mwifiex: Update virtual interface counters right after setting bss_type
25bbec30a2c7 mwifiex: Allow switching interface type from P2P_CLIENT to P2P_GO
5e2e1a4bf4a1 mwifiex: Handle interface type changes from AP to STATION
c606008b7062 mwifiex: Properly initialize private structure on interface type changes
72e717500f99 mwifiex: Fix copy-paste mistake when creating virtual interface
diff mbox series

Patch

diff --git a/drivers/net/wireless/marvell/mwifiex/cfg80211.c b/drivers/net/wireless/marvell/mwifiex/cfg80211.c
index 0961f4a5e415..e8deba119ff1 100644
--- a/drivers/net/wireless/marvell/mwifiex/cfg80211.c
+++ b/drivers/net/wireless/marvell/mwifiex/cfg80211.c
@@ -1141,6 +1141,20 @@  mwifiex_cfg80211_change_virtual_intf(struct wiphy *wiphy,
 		return -EBUSY;
 	}
 
+	if (type == NL80211_IFTYPE_UNSPECIFIED) {
+		mwifiex_dbg(priv->adapter, INFO,
+			    "%s: no new type specified, keeping old type %d\n",
+			    dev->name, curr_iftype);
+		return 0;
+	}
+
+	if (curr_iftype == type) {
+		mwifiex_dbg(priv->adapter, INFO,
+			    "%s: interface already is of type %d\n",
+			    dev->name, curr_iftype);
+		return 0;
+	}
+
 	switch (curr_iftype) {
 	case NL80211_IFTYPE_ADHOC:
 		switch (type) {
@@ -1160,12 +1174,6 @@  mwifiex_cfg80211_change_virtual_intf(struct wiphy *wiphy,
 		case NL80211_IFTYPE_AP:
 			return mwifiex_change_vif_to_ap(dev, curr_iftype, type,
 							params);
-		case NL80211_IFTYPE_UNSPECIFIED:
-			mwifiex_dbg(priv->adapter, INFO,
-				    "%s: kept type as IBSS\n", dev->name);
-			fallthrough;
-		case NL80211_IFTYPE_ADHOC:	/* This shouldn't happen */
-			return 0;
 		default:
 			mwifiex_dbg(priv->adapter, ERROR,
 				    "%s: changing to %d not supported\n",
@@ -1191,12 +1199,6 @@  mwifiex_cfg80211_change_virtual_intf(struct wiphy *wiphy,
 		case NL80211_IFTYPE_AP:
 			return mwifiex_change_vif_to_ap(dev, curr_iftype, type,
 							params);
-		case NL80211_IFTYPE_UNSPECIFIED:
-			mwifiex_dbg(priv->adapter, INFO,
-				    "%s: kept type as STA\n", dev->name);
-			fallthrough;
-		case NL80211_IFTYPE_STATION:	/* This shouldn't happen */
-			return 0;
 		default:
 			mwifiex_dbg(priv->adapter, ERROR,
 				    "%s: changing to %d not supported\n",
@@ -1214,12 +1216,6 @@  mwifiex_cfg80211_change_virtual_intf(struct wiphy *wiphy,
 		case NL80211_IFTYPE_P2P_GO:
 			return mwifiex_change_vif_to_p2p(dev, curr_iftype,
 							 type, params);
-		case NL80211_IFTYPE_UNSPECIFIED:
-			mwifiex_dbg(priv->adapter, INFO,
-				    "%s: kept type as AP\n", dev->name);
-			fallthrough;
-		case NL80211_IFTYPE_AP:		/* This shouldn't happen */
-			return 0;
 		default:
 			mwifiex_dbg(priv->adapter, ERROR,
 				    "%s: changing to %d not supported\n",
@@ -1254,13 +1250,6 @@  mwifiex_cfg80211_change_virtual_intf(struct wiphy *wiphy,
 				return -EFAULT;
 			return mwifiex_change_vif_to_ap(dev, curr_iftype, type,
 							params);
-		case NL80211_IFTYPE_UNSPECIFIED:
-			mwifiex_dbg(priv->adapter, INFO,
-				    "%s: kept type as P2P\n", dev->name);
-			fallthrough;
-		case NL80211_IFTYPE_P2P_CLIENT:
-		case NL80211_IFTYPE_P2P_GO:
-			return 0;
 		default:
 			mwifiex_dbg(priv->adapter, ERROR,
 				    "%s: changing to %d not supported\n",