From: Axel Rasmussen <axel.rasmussen1@gmail.com>
To: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: linux-kernel@vger.kernel.org, devel@driverdev.osuosl.org
Subject: [PATCH 9/9] drivers: staging: rtl8187se: refactor wmm_param_update
Date: Sat, 1 Mar 2014 22:22:53 -0700 [thread overview]
Message-ID: <1393737773-13937-10-git-send-email-axel.rasmussen1@gmail.com> (raw)
In-Reply-To: <1393737773-13937-1-git-send-email-axel.rasmussen1@gmail.com>
The function rtl8180_wmm_param_update contained two blocks of code which
were nearly identical. This patch combines those two blocks into a
single function, to reduce code duplication, and do fix some
checkpatch.pl warnings about excessively long lines due to the large
number of indents that were needed for the original blocks of code.
Signed-off-by: Axel Rasmussen <axel.rasmussen1@gmail.com>
---
drivers/staging/rtl8187se/r8180_core.c | 119 ++++++++++++++-------------------
1 file changed, 49 insertions(+), 70 deletions(-)
diff --git a/drivers/staging/rtl8187se/r8180_core.c b/drivers/staging/rtl8187se/r8180_core.c
index b6fdb6f..fc5d4d9 100644
--- a/drivers/staging/rtl8187se/r8180_core.c
+++ b/drivers/staging/rtl8187se/r8180_core.c
@@ -2114,16 +2114,49 @@ static void rtl8180_hw_sleep(struct net_device *dev, u32 th, u32 tl)
spin_unlock_irqrestore(&priv->ps_lock, flags);
}
+static void rtl8180_wmm_single_param_update(struct net_device *dev,
+ u8 mode, AC_CODING eACI, PAC_PARAM param)
+{
+ u8 u1bAIFS;
+ u32 u4bAcParam;
+
+ /* Retrieve parameters to update. */
+ /* Mode G/A: slotTimeTimer = 9; Mode B: 20 */
+ u1bAIFS = param->f.AciAifsn.f.AIFSN * ((mode & IEEE_G) == IEEE_G ?
+ 9 : 20) + aSifsTime;
+ u4bAcParam = (((u32)param->f.TXOPLimit << AC_PARAM_TXOP_LIMIT_OFFSET) |
+ ((u32)param->f.Ecw.f.ECWmax << AC_PARAM_ECW_MAX_OFFSET) |
+ ((u32)param->f.Ecw.f.ECWmin << AC_PARAM_ECW_MIN_OFFSET) |
+ ((u32)u1bAIFS << AC_PARAM_AIFS_OFFSET));
+
+ switch (eACI) {
+ case AC1_BK:
+ write_nic_dword(dev, AC_BK_PARAM, u4bAcParam);
+ break;
+ case AC0_BE:
+ write_nic_dword(dev, AC_BE_PARAM, u4bAcParam);
+ break;
+ case AC2_VI:
+ write_nic_dword(dev, AC_VI_PARAM, u4bAcParam);
+ break;
+ case AC3_VO:
+ write_nic_dword(dev, AC_VO_PARAM, u4bAcParam);
+ break;
+ default:
+ pr_warn("SetHwReg8185(): invalid ACI: %d!\n", eACI);
+ break;
+ }
+}
+
static void rtl8180_wmm_param_update(struct work_struct *work)
{
- struct ieee80211_device *ieee = container_of(work, struct ieee80211_device, wmm_param_update_wq);
+ struct ieee80211_device *ieee = container_of(work,
+ struct ieee80211_device, wmm_param_update_wq);
struct net_device *dev = ieee->dev;
u8 *ac_param = (u8 *)(ieee->current_network.wmm_param);
u8 mode = ieee->current_network.mode;
- AC_CODING eACI;
- AC_PARAM AcParam;
- PAC_PARAM pAcParam;
- u8 i;
+ AC_CODING eACI;
+ AC_PARAM AcParam;
if (!ieee->current_network.QoS_Enable) {
/* legacy ac_xx_param update */
@@ -2133,78 +2166,24 @@ static void rtl8180_wmm_param_update(struct work_struct *work)
AcParam.f.Ecw.f.ECWmin = 3; /* Follow 802.11 CWmin. */
AcParam.f.Ecw.f.ECWmax = 7; /* Follow 802.11 CWmax. */
AcParam.f.TXOPLimit = 0;
+
for (eACI = 0; eACI < AC_MAX; eACI++) {
AcParam.f.AciAifsn.f.ACI = (u8)eACI;
- {
- u8 u1bAIFS;
- u32 u4bAcParam;
- pAcParam = (PAC_PARAM)(&AcParam);
- /* Retrieve parameters to update. */
- u1bAIFS = pAcParam->f.AciAifsn.f.AIFSN * (((mode&IEEE_G) == IEEE_G) ? 9 : 20) + aSifsTime;
- u4bAcParam = ((((u32)(pAcParam->f.TXOPLimit))<<AC_PARAM_TXOP_LIMIT_OFFSET)|
- (((u32)(pAcParam->f.Ecw.f.ECWmax))<<AC_PARAM_ECW_MAX_OFFSET)|
- (((u32)(pAcParam->f.Ecw.f.ECWmin))<<AC_PARAM_ECW_MIN_OFFSET)|
- (((u32)u1bAIFS) << AC_PARAM_AIFS_OFFSET));
- switch (eACI) {
- case AC1_BK:
- write_nic_dword(dev, AC_BK_PARAM, u4bAcParam);
- break;
- case AC0_BE:
- write_nic_dword(dev, AC_BE_PARAM, u4bAcParam);
- break;
- case AC2_VI:
- write_nic_dword(dev, AC_VI_PARAM, u4bAcParam);
- break;
- case AC3_VO:
- write_nic_dword(dev, AC_VO_PARAM, u4bAcParam);
- break;
- default:
- pr_warn("SetHwReg8185():invalid ACI: %d!\n",
- eACI);
- break;
- }
- }
+
+ rtl8180_wmm_single_param_update(dev, mode, eACI,
+ (PAC_PARAM)&AcParam);
}
return;
}
- for (i = 0; i < AC_MAX; i++) {
+ for (eACI = 0; eACI < AC_MAX; eACI++) {
/* AcParam.longData = 0; */
- pAcParam = (AC_PARAM *)ac_param;
- {
- AC_CODING eACI;
- u8 u1bAIFS;
- u32 u4bAcParam;
-
- /* Retrieve parameters to update. */
- eACI = pAcParam->f.AciAifsn.f.ACI;
- /* Mode G/A: slotTimeTimer = 9; Mode B: 20 */
- u1bAIFS = pAcParam->f.AciAifsn.f.AIFSN * (((mode&IEEE_G) == IEEE_G) ? 9 : 20) + aSifsTime;
- u4bAcParam = ((((u32)(pAcParam->f.TXOPLimit)) << AC_PARAM_TXOP_LIMIT_OFFSET) |
- (((u32)(pAcParam->f.Ecw.f.ECWmax)) << AC_PARAM_ECW_MAX_OFFSET) |
- (((u32)(pAcParam->f.Ecw.f.ECWmin)) << AC_PARAM_ECW_MIN_OFFSET) |
- (((u32)u1bAIFS) << AC_PARAM_AIFS_OFFSET));
-
- switch (eACI) {
- case AC1_BK:
- write_nic_dword(dev, AC_BK_PARAM, u4bAcParam);
- break;
- case AC0_BE:
- write_nic_dword(dev, AC_BE_PARAM, u4bAcParam);
- break;
- case AC2_VI:
- write_nic_dword(dev, AC_VI_PARAM, u4bAcParam);
- break;
- case AC3_VO:
- write_nic_dword(dev, AC_VO_PARAM, u4bAcParam);
- break;
- default:
- pr_warn("SetHwReg8185(): invalid ACI: %d !\n",
- eACI);
- break;
- }
- }
- ac_param += (sizeof(AC_PARAM));
+
+ rtl8180_wmm_single_param_update(dev, mode,
+ ((PAC_PARAM)ac_param)->f.AciAifsn.f.ACI,
+ (PAC_PARAM)ac_param);
+
+ ac_param += sizeof(AC_PARAM);
}
}
--
1.8.3.2
next prev parent reply other threads:[~2014-03-02 5:24 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-03-02 5:22 [PATCH 0/9] drivers: staging: rtl8187se: various code cleanups Axel Rasmussen
2014-03-02 5:22 ` [PATCH 1/9] drivers: staging: rtl8187se: use netdev_* instead of prink Axel Rasmussen
2014-03-02 5:22 ` [PATCH 2/9] drivers: staging: rtl8187se: refactor/clean signal smoothing Axel Rasmussen
2014-03-02 5:22 ` [PATCH 3/9] drivers: staging: rtl8187se: wrap excessively long lines Axel Rasmussen
2014-03-03 8:58 ` Dan Carpenter
2014-03-02 5:22 ` [PATCH 4/9] " Axel Rasmussen
2014-03-03 9:02 ` Dan Carpenter
2014-03-02 5:22 ` [PATCH 5/9] " Axel Rasmussen
2014-03-02 5:22 ` [PATCH 6/9] drivers: staging: rtl8187se: fixed broken indentation Axel Rasmussen
2014-03-02 5:22 ` [PATCH 7/9] drivers: staging: rtl8187se: fixed checkpatch.pl errors Axel Rasmussen
2014-03-02 5:36 ` Joe Perches
2014-03-02 20:19 ` axel.rasmussen1
2014-03-02 5:22 ` [PATCH 8/9] drivers: staging: rtl8187se: wrap excessively long lines Axel Rasmussen
2014-03-02 5:22 ` Axel Rasmussen [this message]
2014-03-03 9:15 ` [PATCH 9/9] drivers: staging: rtl8187se: refactor wmm_param_update Dan Carpenter
2014-03-04 7:12 ` [PATCH v2 0/9] drivers: staging: rtl8187se: various code cleanups Axel Rasmussen
2014-03-04 9:51 ` Dan Carpenter
2014-03-04 7:12 ` [PATCH v2 1/9] drivers: staging: rtl8187se: use netdev_* instead of prink Axel Rasmussen
2014-03-04 7:12 ` [PATCH v2 2/9] drivers: staging: rtl8187se: refactor/clean signal smoothing Axel Rasmussen
2014-03-04 7:12 ` [PATCH v2 3/9] drivers: staging: rtl8187se: wrap excessively long lines Axel Rasmussen
2014-03-04 7:12 ` [PATCH v2 4/9] " Axel Rasmussen
2014-03-04 7:12 ` [PATCH v2 5/9] " Axel Rasmussen
2014-03-04 7:12 ` [PATCH v2 6/9] drivers: staging: rtl8187se: fixed broken indentation Axel Rasmussen
2014-03-04 7:12 ` [PATCH v2 7/9] drivers: staging: rtl8187se: fixed checkpatch.pl errors Axel Rasmussen
2014-03-04 7:12 ` [PATCH v2 8/9] drivers: staging: rtl8187se: wrap excessively long lines Axel Rasmussen
2014-03-04 7:12 ` [PATCH v2 9/9] drivers: staging: rtl8187se: refactor wmm_param_update Axel Rasmussen
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=1393737773-13937-10-git-send-email-axel.rasmussen1@gmail.com \
--to=axel.rasmussen1@gmail.com \
--cc=devel@driverdev.osuosl.org \
--cc=gregkh@linuxfoundation.org \
--cc=linux-kernel@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®