From nobody Tue Feb 10 10:03:51 2026 Received: from metis.whiteo.stw.pengutronix.de (metis.whiteo.stw.pengutronix.de [185.203.201.7]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8381418F2EB for ; Tue, 20 Aug 2024 12:00:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.203.201.7 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724155233; cv=none; b=C98M/MebUxqR23YZ8hTiOw0N1pFHYo4GKRKsi0Yh2mm7j8JRyoRxAN94KnJCHwVQn1j5GBhW1aMLAY8EwBcIfzsTCanuDy1CnDnvZCm4pq5TY+UC+VSupairl0MBDBxaVLumnUEibsX4/9FlFJcHFz9usaPuVBZ0QTMGUhoJDzM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724155233; c=relaxed/simple; bh=vqxhDFbYSzTeyfcEHZVDl4FpS/x8cflMA1VyvVQPBwY=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=cdmQuek1Ks1YMplLTIZhLWQABYpQTBoxn4DzZRD+pQDCzecqk1R0+TM5N09yI59nMPE4OkGvMDbX3tG2kkZ11WMn25fsKiG2iB8FQn2RoOm0gqhQnFplkgsG/p0oeu/WiHoGH/upxyXIj4u4xF2WW5kPzxZdY50wizEq+bJVVDE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=pengutronix.de; spf=pass smtp.mailfrom=pengutronix.de; arc=none smtp.client-ip=185.203.201.7 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=pengutronix.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=pengutronix.de Received: from drehscheibe.grey.stw.pengutronix.de ([2a0a:edc0:0:c01:1d::a2]) by metis.whiteo.stw.pengutronix.de with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1sgNXH-0000xp-HF; Tue, 20 Aug 2024 14:00:27 +0200 Received: from [2a0a:edc0:0:1101:1d::28] (helo=dude02.red.stw.pengutronix.de) by drehscheibe.grey.stw.pengutronix.de with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1sgNXH-001lNv-13; Tue, 20 Aug 2024 14:00:27 +0200 Received: from localhost ([::1] helo=dude02.red.stw.pengutronix.de) by dude02.red.stw.pengutronix.de with esmtp (Exim 4.96) (envelope-from ) id 1sgNSR-00GnIQ-1a; Tue, 20 Aug 2024 13:55:27 +0200 From: Sascha Hauer Date: Tue, 20 Aug 2024 13:55:55 +0200 Subject: [PATCH 30/31] wifi: mwifiex: move common settings out of switch/case Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20240820-mwifiex-cleanup-v1-30-320d8de4a4b7@pengutronix.de> References: <20240820-mwifiex-cleanup-v1-0-320d8de4a4b7@pengutronix.de> In-Reply-To: <20240820-mwifiex-cleanup-v1-0-320d8de4a4b7@pengutronix.de> To: Brian Norris , Francesco Dolcini , Kalle Valo Cc: linux-wireless@vger.kernel.org, linux-kernel@vger.kernel.org, kernel@pengutronix.de, Sascha Hauer X-Mailer: b4 0.12.3 X-Developer-Signature: v=1; a=ed25519-sha256; t=1724154927; l=3401; i=s.hauer@pengutronix.de; s=20230412; h=from:subject:message-id; bh=vqxhDFbYSzTeyfcEHZVDl4FpS/x8cflMA1VyvVQPBwY=; b=8K2aPQKSCDVmNk6pujH7L+S3sQQ75dBem19rjkBH/jhkOGaMDxLM200+y9wKLS0XmwO1LIi9/ CvHZtua/yhnCWo8uooK1DgwhQTAfF1umT7JQNK4bUU8b1JDnwLjSOLN X-Developer-Key: i=s.hauer@pengutronix.de; a=ed25519; pk=4kuc9ocmECiBJKWxYgqyhtZOHj5AWi7+d0n/UjhkwTg= X-SA-Exim-Connect-IP: 2a0a:edc0:0:c01:1d::a2 X-SA-Exim-Mail-From: s.hauer@pengutronix.de X-SA-Exim-Scanned: No (on metis.whiteo.stw.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-kernel@vger.kernel.org In mwifiex_add_virtual_intf() several settings done in a switch/case are the same in all cases. Move them out of the switch/case to deduplicate the code. Signed-off-by: Sascha Hauer --- drivers/net/wireless/marvell/mwifiex/cfg80211.c | 43 +++++++--------------= ---- 1 file changed, 12 insertions(+), 31 deletions(-) diff --git a/drivers/net/wireless/marvell/mwifiex/cfg80211.c b/drivers/net/= wireless/marvell/mwifiex/cfg80211.c index a704886049c64..45f85493985b9 100644 --- a/drivers/net/wireless/marvell/mwifiex/cfg80211.c +++ b/drivers/net/wireless/marvell/mwifiex/cfg80211.c @@ -2849,18 +2849,18 @@ struct wireless_dev *mwifiex_add_virtual_intf(struc= t wiphy *wiphy, if (!adapter) return ERR_PTR(-EFAULT); =20 + priv =3D mwifiex_get_unused_priv(adapter); + if (!priv) { + mwifiex_dbg(adapter, ERROR, + "could not get free private struct\n"); + return ERR_PTR(-EFAULT); + } + switch (type) { case NL80211_IFTYPE_UNSPECIFIED: case NL80211_IFTYPE_STATION: case NL80211_IFTYPE_ADHOC: - priv =3D mwifiex_get_unused_priv(adapter); - if (!priv) { - mwifiex_dbg(adapter, ERROR, - "could not get free private struct\n"); - return ERR_PTR(-EFAULT); - } =20 - priv->wdev.wiphy =3D wiphy; priv->wdev.iftype =3D NL80211_IFTYPE_STATION; =20 if (type =3D=3D NL80211_IFTYPE_UNSPECIFIED) @@ -2869,39 +2869,18 @@ struct wireless_dev *mwifiex_add_virtual_intf(struc= t wiphy *wiphy, priv->bss_mode =3D type; =20 priv->bss_type =3D MWIFIEX_BSS_TYPE_STA; - priv->frame_type =3D MWIFIEX_DATA_FRAME_TYPE_ETH_II; - priv->bss_priority =3D 0; priv->bss_role =3D MWIFIEX_BSS_ROLE_STA; =20 break; case NL80211_IFTYPE_AP: - priv =3D mwifiex_get_unused_priv(adapter); - if (!priv) { - mwifiex_dbg(adapter, ERROR, - "could not get free private struct\n"); - return ERR_PTR(-EFAULT); - } - - priv->wdev.wiphy =3D wiphy; priv->wdev.iftype =3D NL80211_IFTYPE_AP; =20 priv->bss_type =3D MWIFIEX_BSS_TYPE_UAP; - priv->frame_type =3D MWIFIEX_DATA_FRAME_TYPE_ETH_II; - priv->bss_priority =3D 0; priv->bss_role =3D MWIFIEX_BSS_ROLE_UAP; - priv->bss_started =3D 0; priv->bss_mode =3D type; =20 break; case NL80211_IFTYPE_P2P_CLIENT: - priv =3D mwifiex_get_unused_priv(adapter); - if (!priv) { - mwifiex_dbg(adapter, ERROR, - "could not get free private struct\n"); - return ERR_PTR(-EFAULT); - } - - priv->wdev.wiphy =3D wiphy; /* At start-up, wpa_supplicant tries to change the interface * to NL80211_IFTYPE_STATION if it is not managed mode. */ @@ -2914,10 +2893,7 @@ struct wireless_dev *mwifiex_add_virtual_intf(struct= wiphy *wiphy, */ priv->bss_type =3D MWIFIEX_BSS_TYPE_P2P; =20 - priv->frame_type =3D MWIFIEX_DATA_FRAME_TYPE_ETH_II; - priv->bss_priority =3D 0; priv->bss_role =3D MWIFIEX_BSS_ROLE_STA; - priv->bss_started =3D 0; =20 if (mwifiex_cfg80211_init_p2p_client(priv)) { memset(&priv->wdev, 0, sizeof(priv->wdev)); @@ -2931,6 +2907,11 @@ struct wireless_dev *mwifiex_add_virtual_intf(struct= wiphy *wiphy, return ERR_PTR(-EINVAL); } =20 + priv->wdev.wiphy =3D wiphy; + priv->bss_priority =3D 0; + priv->bss_started =3D 0; + priv->frame_type =3D MWIFIEX_DATA_FRAME_TYPE_ETH_II; + dev =3D alloc_netdev_mqs(sizeof(struct mwifiex_private *), name, name_assign_type, ether_setup, IEEE80211_NUM_ACS, 1); --=20 2.39.2