From nobody Fri Dec 19 14:17:54 2025 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 CDB48200120 for ; Mon, 2 Dec 2024 12:58:18 +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=1733144300; cv=none; b=roxkRIDfLzGw2IzijNetNiz74IPBzvuh5ZrFeNpXfyWYckSSbVGF8ar/A4cWV3ACHuNoDKmV6tn/n32RZq2iJ1Jkz/eWuPvPzQZQJjfm+QpV2bNwcNXr1B6R2OoSew30QZMUhsMLa9tgakq8ZGM9aBzpqJyYgB/zww34Gl2t0/I= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733144300; c=relaxed/simple; bh=YJf7CTJU9cjm7wgH3iWlza8QlTGiJ6PyQ1angbO+zjg=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=hhAD93UDazehZLXAwuEv/n0s0GvVSTFuspu8YCu6qJu0PtOerrfF9G3q3aSbN+Jzc/9wD0B+ctSGH06+dMXTRVgw4HMNhhZPHdNdoJJmG2/8p+F22qDG8BN3buehzDkJGiywNmhatr1quWxa4dXxwjBlrbDdLX1nAjKfg6Z/KmA= 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 1tI608-0000Za-NL; Mon, 02 Dec 2024 13:58:08 +0100 Received: from dude02.red.stw.pengutronix.de ([2a0a:edc0:0:1101:1d::28]) by drehscheibe.grey.stw.pengutronix.de with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1tI607-001IdM-13; Mon, 02 Dec 2024 13:58:08 +0100 Received: from localhost ([::1] helo=dude02.red.stw.pengutronix.de) by dude02.red.stw.pengutronix.de with esmtp (Exim 4.96) (envelope-from ) id 1tI607-00Boj9-39; Mon, 02 Dec 2024 13:58:07 +0100 From: Sascha Hauer Date: Mon, 02 Dec 2024 13:58:02 +0100 Subject: [PATCH v3 03/12] wifi: mwifiex: deduplicate code in mwifiex_cmd_tx_rate_cfg() 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: <20241202-mwifiex-cleanup-1-v3-3-317a6ce0dd5b@pengutronix.de> References: <20241202-mwifiex-cleanup-1-v3-0-317a6ce0dd5b@pengutronix.de> In-Reply-To: <20241202-mwifiex-cleanup-1-v3-0-317a6ce0dd5b@pengutronix.de> To: Brian Norris , Francesco Dolcini , Kalle Valo Cc: linux-wireless@vger.kernel.org, linux-kernel@vger.kernel.org, David Lin , kernel@pengutronix.de, Sascha Hauer , Francesco Dolcini X-Mailer: b4 0.12.3 X-Developer-Signature: v=1; a=ed25519-sha256; t=1733144287; l=3171; i=s.hauer@pengutronix.de; s=20230412; h=from:subject:message-id; bh=YJf7CTJU9cjm7wgH3iWlza8QlTGiJ6PyQ1angbO+zjg=; b=VARDq5Xft/qSGfQzk0oUyKjFLspr5l4aZGgSHQFhHL7VEvJscQvPRJj5GNS9JKCDQ0Jc2M1le WvgPqUnHg+2BG7DazXGEOQ12vTsJP+oHTGx8TEbygYA8lY+YEPvj8pf 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 The code block inside the if/else is the same with just using pbitmap_rates if non NULL or priv->bitmap_rates otherwise. Deduplicate the code by picking the correct pointer first and then using it unconditionally. Reviewed-by: Francesco Dolcini Signed-off-by: Sascha Hauer --- drivers/net/wireless/marvell/mwifiex/sta_cmd.c | 43 +++++++++-------------= ---- 1 file changed, 14 insertions(+), 29 deletions(-) diff --git a/drivers/net/wireless/marvell/mwifiex/sta_cmd.c b/drivers/net/w= ireless/marvell/mwifiex/sta_cmd.c index e2800a831c8ed..30dd4e58e2b1d 100644 --- a/drivers/net/wireless/marvell/mwifiex/sta_cmd.c +++ b/drivers/net/wireless/marvell/mwifiex/sta_cmd.c @@ -157,7 +157,7 @@ mwifiex_cmd_802_11_get_log(struct host_cmd_ds_command *= cmd) */ static int mwifiex_cmd_tx_rate_cfg(struct mwifiex_private *priv, struct host_cmd_ds_command *cmd, - u16 cmd_action, u16 *pbitmap_rates) + u16 cmd_action, const u16 *pbitmap_rates) { struct host_cmd_ds_tx_rate_cfg *rate_cfg =3D &cmd->params.tx_rate_cfg; struct mwifiex_rate_scope *rate_scope; @@ -174,34 +174,19 @@ static int mwifiex_cmd_tx_rate_cfg(struct mwifiex_pri= vate *priv, rate_scope->type =3D cpu_to_le16(TLV_TYPE_RATE_SCOPE); rate_scope->length =3D cpu_to_le16 (sizeof(*rate_scope) - sizeof(struct mwifiex_ie_types_header)); - if (pbitmap_rates !=3D NULL) { - rate_scope->hr_dsss_rate_bitmap =3D cpu_to_le16(pbitmap_rates[0]); - rate_scope->ofdm_rate_bitmap =3D cpu_to_le16(pbitmap_rates[1]); - for (i =3D 0; i < ARRAY_SIZE(rate_scope->ht_mcs_rate_bitmap); i++) - rate_scope->ht_mcs_rate_bitmap[i] =3D - cpu_to_le16(pbitmap_rates[2 + i]); - if (priv->adapter->fw_api_ver =3D=3D MWIFIEX_FW_V15) { - for (i =3D 0; - i < ARRAY_SIZE(rate_scope->vht_mcs_rate_bitmap); - i++) - rate_scope->vht_mcs_rate_bitmap[i] =3D - cpu_to_le16(pbitmap_rates[10 + i]); - } - } else { - rate_scope->hr_dsss_rate_bitmap =3D - cpu_to_le16(priv->bitmap_rates[0]); - rate_scope->ofdm_rate_bitmap =3D - cpu_to_le16(priv->bitmap_rates[1]); - for (i =3D 0; i < ARRAY_SIZE(rate_scope->ht_mcs_rate_bitmap); i++) - rate_scope->ht_mcs_rate_bitmap[i] =3D - cpu_to_le16(priv->bitmap_rates[2 + i]); - if (priv->adapter->fw_api_ver =3D=3D MWIFIEX_FW_V15) { - for (i =3D 0; - i < ARRAY_SIZE(rate_scope->vht_mcs_rate_bitmap); - i++) - rate_scope->vht_mcs_rate_bitmap[i] =3D - cpu_to_le16(priv->bitmap_rates[10 + i]); - } + if (!pbitmap_rates) + pbitmap_rates =3D priv->bitmap_rates; + + rate_scope->hr_dsss_rate_bitmap =3D cpu_to_le16(pbitmap_rates[0]); + rate_scope->ofdm_rate_bitmap =3D cpu_to_le16(pbitmap_rates[1]); + + for (i =3D 0; i < ARRAY_SIZE(rate_scope->ht_mcs_rate_bitmap); i++) + rate_scope->ht_mcs_rate_bitmap[i] =3D cpu_to_le16(pbitmap_rates[2 + i]); + + if (priv->adapter->fw_api_ver =3D=3D MWIFIEX_FW_V15) { + for (i =3D 0; i < ARRAY_SIZE(rate_scope->vht_mcs_rate_bitmap); i++) + rate_scope->vht_mcs_rate_bitmap[i] =3D + cpu_to_le16(pbitmap_rates[10 + i]); } =20 rate_drop =3D (struct mwifiex_rate_drop_pattern *) ((u8 *) rate_scope + --=20 2.39.5