[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <20200413030129.861-1-c.cantanheide@gmail.com>
Date: Mon, 13 Apr 2020 03:01:28 +0000
From: Camylla Goncalves Cantanheide <c.cantanheide@...il.com>
To: gregkh@...uxfoundation.org, navid.emamdoost@...il.com,
sylphrenadin@...il.com, nishkadg.linux@...il.com,
stephen@...nnan.io, devel@...verdev.osuosl.org,
linux-kernel@...r.kernel.org, lkcamp@...ts.libreplanetbr.org
Subject: [PATCH 1/2] staging: rtl8192u: Refactoring setKey function
Changes of the local variable value and
modification in the seletive repetition structure.
Signed-off-by: Camylla Goncalves Cantanheide <c.cantanheide@...il.com>
---
drivers/staging/rtl8192u/r8192U_core.c | 52 ++++++++++++--------------
1 file changed, 24 insertions(+), 28 deletions(-)
diff --git a/drivers/staging/rtl8192u/r8192U_core.c b/drivers/staging/rtl8192u/r8192U_core.c
index 9b8d85a4855d..87c02aee3854 100644
--- a/drivers/staging/rtl8192u/r8192U_core.c
+++ b/drivers/staging/rtl8192u/r8192U_core.c
@@ -4880,7 +4880,7 @@ void EnableHWSecurityConfig8192(struct net_device *dev)
void setKey(struct net_device *dev, u8 entryno, u8 keyindex, u16 keytype,
u8 *macaddr, u8 defaultkey, u32 *keycontent)
{
- u32 target_command = 0;
+ u32 target_command = CAM_CONTENT_COUNT * entryno | BIT(31) | BIT(16);
u32 target_content = 0;
u16 us_config = 0;
u8 i;
@@ -4890,39 +4890,35 @@ void setKey(struct net_device *dev, u8 entryno, u8 keyindex, u16 keytype,
RT_TRACE(COMP_SEC,
"====>to %s, dev:%p, EntryNo:%d, KeyIndex:%d, KeyType:%d, MacAddr%pM\n",
- __func__, dev, entryno, keyindex, keytype, macaddr);
+ __func__, dev, entryno, keyindex, keytype, macaddr);
if (defaultkey)
us_config |= BIT(15) | (keytype << 2);
else
us_config |= BIT(15) | (keytype << 2) | keyindex;
- for (i = 0; i < CAM_CONTENT_COUNT; i++) {
- target_command = i + CAM_CONTENT_COUNT * entryno;
- target_command |= BIT(31) | BIT(16);
-
- if (i == 0) { /* MAC|Config */
- target_content = (u32)(*(macaddr + 0)) << 16 |
- (u32)(*(macaddr + 1)) << 24 |
- (u32)us_config;
-
- write_nic_dword(dev, WCAMI, target_content);
- write_nic_dword(dev, RWCAM, target_command);
- } else if (i == 1) { /* MAC */
- target_content = (u32)(*(macaddr + 2)) |
- (u32)(*(macaddr + 3)) << 8 |
- (u32)(*(macaddr + 4)) << 16 |
- (u32)(*(macaddr + 5)) << 24;
- write_nic_dword(dev, WCAMI, target_content);
- write_nic_dword(dev, RWCAM, target_command);
- } else {
- /* Key Material */
- if (keycontent) {
- write_nic_dword(dev, WCAMI,
- *(keycontent + i - 2));
- write_nic_dword(dev, RWCAM, target_command);
- }
- }
+ target_content = macaddr[0] << 16 |
+ macaddr[0] << 24 |
+ (u32)us_config;
+
+ write_nic_dword(dev, WCAMI, target_content);
+ write_nic_dword(dev, RWCAM, target_command++);
+
+ /* MAC */
+ target_content = macaddr[2] |
+ macaddr[3] << 8 |
+ macaddr[4] << 16 |
+ macaddr[5] << 24;
+ write_nic_dword(dev, WCAMI, target_content);
+ write_nic_dword(dev, RWCAM, target_command++);
+
+ /* Key Material */
+ if (!keycontent)
+ return;
+
+ for (i = 2; i < CAM_CONTENT_COUNT; i++) {
+ write_nic_dword(dev, WCAMI, *keycontent++);
+ write_nic_dword(dev, RWCAM, target_command++);
}
}
--
2.20.1
Powered by blists - more mailing lists