diff mbox series

[v3,1/3] wifi: mwifiex: simplify WPA flags setting

Message ID 20240723-mwifiex-wpa-psk-sha256-v3-1-025168a91da1@pengutronix.de
State Superseded
Headers show
Series mwifiex: add support for WPA-PSK-SHA256 | expand

Commit Message

Sascha Hauer July 23, 2024, 7:09 a.m. UTC
The WPA flags setting only depends on the wpa_versions bitfield and not
on the AKM suite, so move it out of the switch/case to simplify the code
a bit. Also set bss_config->protocol to zero explicitly. This is done
only to make the code clearer, bss_config has been zero alloced by the
caller, so should be zero already. No functional change intended.

Reviewed-by: Francesco Dolcini <francesco.dolcini@toradex.com>
Acked-by: Brian Norris <briannorris@chromium.org>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
 drivers/net/wireless/marvell/mwifiex/uap_cmd.c | 28 ++++++++------------------
 1 file changed, 8 insertions(+), 20 deletions(-)

Comments

Kalle Valo Aug. 4, 2024, 8:57 a.m. UTC | #1
Sascha Hauer <s.hauer@pengutronix.de> wrote:

> The WPA flags setting only depends on the wpa_versions bitfield and not
> on the AKM suite, so move it out of the switch/case to simplify the code
> a bit. Also set bss_config->protocol to zero explicitly. This is done
> only to make the code clearer, bss_config has been zero alloced by the
> caller, so should be zero already. No functional change intended.
> 
> Reviewed-by: Francesco Dolcini <francesco.dolcini@toradex.com>
> Acked-by: Brian Norris <briannorris@chromium.org>
> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>

There were conflicts on wireless-next, please rebase.

Recorded preimage for 'drivers/net/wireless/marvell/mwifiex/fw.h'
Recorded preimage for 'drivers/net/wireless/marvell/mwifiex/uap_cmd.c'
error: Failed to merge in the changes.
hint: Use 'git am --show-current-patch=diff' to see the failed patch
Applying: wifi: mwifiex: add support for WPA-PSK-SHA256
Using index info to reconstruct a base tree...
M	drivers/net/wireless/marvell/mwifiex/fw.h
M	drivers/net/wireless/marvell/mwifiex/uap_cmd.c
Falling back to patching base and 3-way merge...
Auto-merging drivers/net/wireless/marvell/mwifiex/uap_cmd.c
CONFLICT (content): Merge conflict in drivers/net/wireless/marvell/mwifiex/uap_cmd.c
Auto-merging drivers/net/wireless/marvell/mwifiex/fw.h
CONFLICT (content): Merge conflict in drivers/net/wireless/marvell/mwifiex/fw.h
Patch failed at 0001 wifi: mwifiex: add support for WPA-PSK-SHA256

3 patches set to Changes Requested.

13739655 [v3,1/3] wifi: mwifiex: simplify WPA flags setting
13739654 [v3,2/3] wifi: mwifiex: fix key_mgmt setting
13739653 [v3,3/3] wifi: mwifiex: add support for WPA-PSK-SHA256
Sascha Hauer Aug. 5, 2024, 7:36 a.m. UTC | #2
On Sun, Aug 04, 2024 at 08:57:54AM +0000, Kalle Valo wrote:
> Sascha Hauer <s.hauer@pengutronix.de> wrote:
> 
> > The WPA flags setting only depends on the wpa_versions bitfield and not
> > on the AKM suite, so move it out of the switch/case to simplify the code
> > a bit. Also set bss_config->protocol to zero explicitly. This is done
> > only to make the code clearer, bss_config has been zero alloced by the
> > caller, so should be zero already. No functional change intended.
> > 
> > Reviewed-by: Francesco Dolcini <francesco.dolcini@toradex.com>
> > Acked-by: Brian Norris <briannorris@chromium.org>
> > Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
> 
> There were conflicts on wireless-next, please rebase.

Thanks for noting. Just sent out a v4.

I realized the host-mlme patches are merged in wireless-next. I had them
in my tree anyway already, so the necessary changes looked all familiar.

Sascha
diff mbox series

Patch

diff --git a/drivers/net/wireless/marvell/mwifiex/uap_cmd.c b/drivers/net/wireless/marvell/mwifiex/uap_cmd.c
index 491e366119096..7f822660fd955 100644
--- a/drivers/net/wireless/marvell/mwifiex/uap_cmd.c
+++ b/drivers/net/wireless/marvell/mwifiex/uap_cmd.c
@@ -46,31 +46,19 @@  int mwifiex_set_secure_params(struct mwifiex_private *priv,
 
 	bss_config->key_mgmt_operation |= KEY_MGMT_ON_HOST;
 
+	bss_config->protocol = 0;
+	if (params->crypto.wpa_versions & NL80211_WPA_VERSION_1)
+		bss_config->protocol |= PROTOCOL_WPA;
+	if (params->crypto.wpa_versions & NL80211_WPA_VERSION_2)
+		bss_config->protocol |= PROTOCOL_WPA2;
+
 	for (i = 0; i < params->crypto.n_akm_suites; i++) {
 		switch (params->crypto.akm_suites[i]) {
 		case WLAN_AKM_SUITE_8021X:
-			if (params->crypto.wpa_versions &
-			    NL80211_WPA_VERSION_1) {
-				bss_config->protocol = PROTOCOL_WPA;
-				bss_config->key_mgmt = KEY_MGMT_EAP;
-			}
-			if (params->crypto.wpa_versions &
-			    NL80211_WPA_VERSION_2) {
-				bss_config->protocol |= PROTOCOL_WPA2;
-				bss_config->key_mgmt = KEY_MGMT_EAP;
-			}
+			bss_config->key_mgmt = KEY_MGMT_EAP;
 			break;
 		case WLAN_AKM_SUITE_PSK:
-			if (params->crypto.wpa_versions &
-			    NL80211_WPA_VERSION_1) {
-				bss_config->protocol = PROTOCOL_WPA;
-				bss_config->key_mgmt = KEY_MGMT_PSK;
-			}
-			if (params->crypto.wpa_versions &
-			    NL80211_WPA_VERSION_2) {
-				bss_config->protocol |= PROTOCOL_WPA2;
-				bss_config->key_mgmt = KEY_MGMT_PSK;
-			}
+			bss_config->key_mgmt = KEY_MGMT_PSK;
 			break;
 		default:
 			break;