From: Edmundo Carmona Antoranz <eantoranz@gmail.com>
To: gregkh@linuxfoundation.org, kernel-janitors@vger.kernel.org
Cc: Edmundo Carmona Antoranz <eantoranz@gmail.com>
Subject: [PATCH -next 3/3] staging: vt6655: remove duplicate code
Date: Sun, 14 Mar 2021 08:59:43 -0600 [thread overview]
Message-ID: <20210314145943.1933245-3-eantoranz@gmail.com> (raw)
In-Reply-To: <20210314145943.1933245-1-eantoranz@gmail.com>
In the definition of vnt_init_bands(), there are two sections of
code that are very similar. Unifying them through a new
function that takes care of initialization of a single band.
Signed-off-by: Edmundo Carmona Antoranz <eantoranz@gmail.com>
---
drivers/staging/vt6655/channel.c | 38 +++++++++++++++-----------------
1 file changed, 18 insertions(+), 20 deletions(-)
diff --git a/drivers/staging/vt6655/channel.c b/drivers/staging/vt6655/channel.c
index ba92b7259ec6..cf46ee63681a 100644
--- a/drivers/staging/vt6655/channel.c
+++ b/drivers/staging/vt6655/channel.c
@@ -114,40 +114,38 @@ static struct ieee80211_supported_band vnt_supported_5ghz_band = {
.n_bitrates = ARRAY_SIZE(vnt_rates_a),
};
-void vnt_init_bands(struct vnt_private *priv)
+static void vnt_init_band(struct vnt_private *priv,
+ struct ieee80211_supported_band *supported_band,
+ enum nl80211_band band)
{
- struct ieee80211_channel *ch;
int i;
+ for (i = 0; i < supported_band->n_channels; i++) {
+ supported_band->channels[i].max_power = 0x3f;
+ supported_band->channels[i].flags =
+ IEEE80211_CHAN_NO_HT40;
+ }
+
+ priv->hw->wiphy->bands[band] = supported_band;
+}
+
+void vnt_init_bands(struct vnt_private *priv)
+{
switch (priv->byRFType) {
case RF_AIROHA7230:
case RF_UW2452:
case RF_NOTHING:
default:
- ch = vnt_channels_5ghz;
-
- for (i = 0; i < ARRAY_SIZE(vnt_channels_5ghz); i++) {
- ch[i].max_power = 0x3f;
- ch[i].flags = IEEE80211_CHAN_NO_HT40;
- }
-
- priv->hw->wiphy->bands[NL80211_BAND_5GHZ] =
- &vnt_supported_5ghz_band;
+ vnt_init_band(priv, &vnt_supported_5ghz_band,
+ NL80211_BAND_5GHZ);
fallthrough;
case RF_RFMD2959:
case RF_AIROHA:
case RF_AL2230S:
case RF_UW2451:
case RF_VT3226:
- ch = vnt_channels_2ghz;
-
- for (i = 0; i < ARRAY_SIZE(vnt_channels_2ghz); i++) {
- ch[i].max_power = 0x3f;
- ch[i].flags = IEEE80211_CHAN_NO_HT40;
- }
-
- priv->hw->wiphy->bands[NL80211_BAND_2GHZ] =
- &vnt_supported_2ghz_band;
+ vnt_init_band(priv, &vnt_supported_2ghz_band,
+ NL80211_BAND_2GHZ);
break;
}
}
--
2.30.1
next prev parent reply other threads:[~2021-03-14 15:03 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-03-14 14:59 [PATCH -next 1/3] staging: vt6655: remove unused variable Edmundo Carmona Antoranz
2021-03-14 14:59 ` [PATCH -next 2/3] staging: vt6655: correct documentation warnings Edmundo Carmona Antoranz
2021-03-14 14:59 ` Edmundo Carmona Antoranz [this message]
2021-03-14 16:01 ` [PATCH -next 1/3] staging: vt6655: remove unused variable Greg KH
2021-03-16 1:46 ` Edmundo Carmona Antoranz
2021-03-16 11:24 ` Greg KH
2021-03-16 11:39 ` Dan Carpenter
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20210314145943.1933245-3-eantoranz@gmail.com \
--to=eantoranz@gmail.com \
--cc=gregkh@linuxfoundation.org \
--cc=kernel-janitors@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.