* [PATCH 00/12] staging: ks7010: Some clean ups
@ 2018-03-28 15:24 Sergio Paracuellos
2018-03-28 15:24 ` [PATCH 01/12] staging: ks7010: avoid camel cases in MichaelMICFunction Sergio Paracuellos
` (11 more replies)
0 siblings, 12 replies; 13+ messages in thread
From: Sergio Paracuellos @ 2018-03-28 15:24 UTC (permalink / raw)
To: gregkh; +Cc: driverdev-devel, wsa
This are some clean ups for this driver. Changes are as follows:
- Some camel cases fixes
- remove some macros to use inline functions or functions which
exists in linux kernel itself
- Use u8 types instead of uint8_t
There was a previous patch series including some of these patches
which wasn't be applied so just send a new one with all of those
reviewed in order to be applied if procceed.
Sergio Paracuellos (12):
staging: ks7010: avoid camel cases in MichaelMICFunction
staging: ks7010: avoid camel cases for MichaelInitFunction
staging: ks7010: avoid camel cases in MichaelAppend function
staging: ks7010: replace macro MichaelClear with inline function
staging: ks7010: avoid camel cases in MichaelGetMIC function
staging: ks7010: replace PutUInt32 macro with put_unaligned_le32()
staging: ks7010: replace GetUInt32 macro with get_unaligned_le32
staging: ks7010: replace MichaelBlockFunction macro with inline
function
staging: ks7010: remove some dead code from ks_wlan_set_essid function
staging: ks7010: replace uint8_t in favour of u8 in michael_init
staging: ks7010: replace uint8_t in favour of u8 in michael_append
staging: ks7010: replace uint8_t in favour of u8 in michael_get_mic
drivers/staging/ks7010/ks_hostif.c | 24 +++---
drivers/staging/ks7010/ks_wlan_net.c | 15 ----
drivers/staging/ks7010/michael_mic.c | 140 ++++++++++++++++-------------------
drivers/staging/ks7010/michael_mic.h | 5 +-
4 files changed, 77 insertions(+), 107 deletions(-)
--
2.7.4
_______________________________________________
devel mailing list
devel@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
^ permalink raw reply [flat|nested] 13+ messages in thread
* [PATCH 01/12] staging: ks7010: avoid camel cases in MichaelMICFunction
2018-03-28 15:24 [PATCH 00/12] staging: ks7010: Some clean ups Sergio Paracuellos
@ 2018-03-28 15:24 ` Sergio Paracuellos
2018-03-28 15:24 ` [PATCH 02/12] staging: ks7010: avoid camel cases for MichaelInitFunction Sergio Paracuellos
` (10 subsequent siblings)
11 siblings, 0 replies; 13+ messages in thread
From: Sergio Paracuellos @ 2018-03-28 15:24 UTC (permalink / raw)
To: gregkh; +Cc: driverdev-devel, wsa
This commit replace camel cases for name and params used in
MichaelMICFunction. This improves a bit readability.
Signed-off-by: Sergio Paracuellos <sergio.paracuellos@gmail.com>
---
drivers/staging/ks7010/ks_hostif.c | 24 ++++++++++++------------
drivers/staging/ks7010/michael_mic.c | 15 +++++++--------
drivers/staging/ks7010/michael_mic.h | 5 ++---
3 files changed, 21 insertions(+), 23 deletions(-)
diff --git a/drivers/staging/ks7010/ks_hostif.c b/drivers/staging/ks7010/ks_hostif.c
index a02b73e..923f196 100644
--- a/drivers/staging/ks7010/ks_hostif.c
+++ b/drivers/staging/ks7010/ks_hostif.c
@@ -341,12 +341,12 @@ int hostif_data_indication_wpa(struct ks_wlan_private *priv,
memcpy(&recv_mic[0], (priv->rxp) + ((priv->rx_size) - 8), 8);
priv->rx_size = priv->rx_size - 8;
if (auth_type > 0 && auth_type < 4) { /* auth_type check */
- MichaelMICFunction(&michael_mic,
- (uint8_t *)key->rx_mic_key,
- (uint8_t *)priv->rxp,
- (int)priv->rx_size,
- (uint8_t)0, /* priority */
- (uint8_t *)michael_mic.result);
+ michael_mic_function(&michael_mic,
+ (uint8_t *)key->rx_mic_key,
+ (uint8_t *)priv->rxp,
+ (int)priv->rx_size,
+ (uint8_t)0, /* priority */
+ (uint8_t *)michael_mic.result);
}
if (memcmp(michael_mic.result, recv_mic, 8) != 0) {
now = jiffies;
@@ -1172,12 +1172,12 @@ int hostif_data_request(struct ks_wlan_private *priv, struct sk_buff *skb)
pp->auth_type = cpu_to_le16((uint16_t)TYPE_AUTH);
} else {
if (priv->wpa.pairwise_suite == IW_AUTH_CIPHER_TKIP) {
- MichaelMICFunction(&michael_mic,
- (uint8_t *)priv->wpa.key[0].tx_mic_key,
- (uint8_t *)&pp->data[0],
- (int)skb_len,
- (uint8_t)0, /* priority */
- (uint8_t *)michael_mic.result);
+ michael_mic_function(&michael_mic,
+ (uint8_t *)priv->wpa.key[0].tx_mic_key,
+ (uint8_t *)&pp->data[0],
+ (int)skb_len,
+ (uint8_t)0, /* priority */
+ (uint8_t *)michael_mic.result);
memcpy(p, michael_mic.result, 8);
length += 8;
skb_len += 8;
diff --git a/drivers/staging/ks7010/michael_mic.c b/drivers/staging/ks7010/michael_mic.c
index 861721d..f795043 100644
--- a/drivers/staging/ks7010/michael_mic.c
+++ b/drivers/staging/ks7010/michael_mic.c
@@ -123,9 +123,8 @@ void MichaelGetMIC(struct michael_mic_t *Mic, uint8_t *dst)
MichaelClear(Mic);
}
-void MichaelMICFunction(struct michael_mic_t *Mic, u8 *Key,
- u8 *Data, int Len, u8 priority,
- u8 *Result)
+void michael_mic_function(struct michael_mic_t *mic, u8 *key,
+ u8 *data, int len, u8 priority, u8 *result)
{
u8 pad_data[4] = { priority, 0, 0, 0 };
// Compute the MIC value
@@ -138,9 +137,9 @@ void MichaelMICFunction(struct michael_mic_t *Mic, u8 *Key,
* |DA|SA|Priority|0 |Data|M0|M1|M2|M3|M4|M5|M6|M7|
* +--+--+--------+--+----+--+--+--+--+--+--+--+--+
*/
- MichaelInitializeFunction(Mic, Key);
- MichaelAppend(Mic, (uint8_t *)Data, 12); /* |DA|SA| */
- MichaelAppend(Mic, pad_data, 4); /* |Priority|0|0|0| */
- MichaelAppend(Mic, (uint8_t *)(Data + 12), Len - 12); /* |Data| */
- MichaelGetMIC(Mic, Result);
+ MichaelInitializeFunction(mic, key);
+ MichaelAppend(mic, (uint8_t *)data, 12); /* |DA|SA| */
+ MichaelAppend(mic, pad_data, 4); /* |Priority|0|0|0| */
+ MichaelAppend(mic, (uint8_t *)(data + 12), len - 12); /* |Data| */
+ MichaelGetMIC(mic, result);
}
diff --git a/drivers/staging/ks7010/michael_mic.h b/drivers/staging/ks7010/michael_mic.h
index 64db7d1..894a8d4 100644
--- a/drivers/staging/ks7010/michael_mic.h
+++ b/drivers/staging/ks7010/michael_mic.h
@@ -20,6 +20,5 @@ struct michael_mic_t {
u8 result[8];
};
-void MichaelMICFunction(struct michael_mic_t *Mic, u8 *Key,
- u8 *Data, int Len, u8 priority,
- u8 *Result);
+void michael_mic_function(struct michael_mic_t *mic, u8 *key,
+ u8 *data, int len, u8 priority, u8 *result);
--
2.7.4
_______________________________________________
devel mailing list
devel@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
^ permalink raw reply related [flat|nested] 13+ messages in thread
* [PATCH 02/12] staging: ks7010: avoid camel cases for MichaelInitFunction
2018-03-28 15:24 [PATCH 00/12] staging: ks7010: Some clean ups Sergio Paracuellos
2018-03-28 15:24 ` [PATCH 01/12] staging: ks7010: avoid camel cases in MichaelMICFunction Sergio Paracuellos
@ 2018-03-28 15:24 ` Sergio Paracuellos
2018-03-28 15:24 ` [PATCH 03/12] staging: ks7010: avoid camel cases in MichaelAppend function Sergio Paracuellos
` (9 subsequent siblings)
11 siblings, 0 replies; 13+ messages in thread
From: Sergio Paracuellos @ 2018-03-28 15:24 UTC (permalink / raw)
To: gregkh; +Cc: driverdev-devel, wsa
This commit avoid camel cases in MichaelInitFunction signature and params
renaming it to michael_init.
Signed-off-by: Sergio Paracuellos <sergio.paracuellos@gmail.com>
---
drivers/staging/ks7010/michael_mic.c | 11 +++++------
1 file changed, 5 insertions(+), 6 deletions(-)
diff --git a/drivers/staging/ks7010/michael_mic.c b/drivers/staging/ks7010/michael_mic.c
index f795043..bc92db1 100644
--- a/drivers/staging/ks7010/michael_mic.c
+++ b/drivers/staging/ks7010/michael_mic.c
@@ -35,15 +35,14 @@ do { \
A->m_bytes = 0; \
} while (0)
-static
-void MichaelInitializeFunction(struct michael_mic_t *Mic, uint8_t *key)
+static void michael_init(struct michael_mic_t *mic, uint8_t *key)
{
// Set the key
- Mic->k0 = getUInt32(key, 0);
- Mic->k1 = getUInt32(key, 4);
+ mic->k0 = getUInt32(key, 0);
+ mic->k1 = getUInt32(key, 4);
//clear();
- MichaelClear(Mic);
+ MichaelClear(mic);
}
#define MichaelBlockFunction(L, R) \
@@ -137,7 +136,7 @@ void michael_mic_function(struct michael_mic_t *mic, u8 *key,
* |DA|SA|Priority|0 |Data|M0|M1|M2|M3|M4|M5|M6|M7|
* +--+--+--------+--+----+--+--+--+--+--+--+--+--+
*/
- MichaelInitializeFunction(mic, key);
+ michael_init(mic, key);
MichaelAppend(mic, (uint8_t *)data, 12); /* |DA|SA| */
MichaelAppend(mic, pad_data, 4); /* |Priority|0|0|0| */
MichaelAppend(mic, (uint8_t *)(data + 12), len - 12); /* |Data| */
--
2.7.4
_______________________________________________
devel mailing list
devel@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
^ permalink raw reply related [flat|nested] 13+ messages in thread
* [PATCH 03/12] staging: ks7010: avoid camel cases in MichaelAppend function
2018-03-28 15:24 [PATCH 00/12] staging: ks7010: Some clean ups Sergio Paracuellos
2018-03-28 15:24 ` [PATCH 01/12] staging: ks7010: avoid camel cases in MichaelMICFunction Sergio Paracuellos
2018-03-28 15:24 ` [PATCH 02/12] staging: ks7010: avoid camel cases for MichaelInitFunction Sergio Paracuellos
@ 2018-03-28 15:24 ` Sergio Paracuellos
2018-03-28 15:24 ` [PATCH 04/12] staging: ks7010: replace macro MichaelClear with inline function Sergio Paracuellos
` (8 subsequent siblings)
11 siblings, 0 replies; 13+ messages in thread
From: Sergio Paracuellos @ 2018-03-28 15:24 UTC (permalink / raw)
To: gregkh; +Cc: driverdev-devel, wsa
This commit avoid camel cases in MichaelAppend function and params
renaming it to michael_append.
Signed-off-by: Sergio Paracuellos <sergio.paracuellos@gmail.com>
---
drivers/staging/ks7010/michael_mic.c | 45 ++++++++++++++++++------------------
1 file changed, 22 insertions(+), 23 deletions(-)
diff --git a/drivers/staging/ks7010/michael_mic.c b/drivers/staging/ks7010/michael_mic.c
index bc92db1..276ecd9 100644
--- a/drivers/staging/ks7010/michael_mic.c
+++ b/drivers/staging/ks7010/michael_mic.c
@@ -57,38 +57,37 @@ do { \
L += R; \
} while (0)
-static
-void MichaelAppend(struct michael_mic_t *Mic, uint8_t *src, int nBytes)
+static void michael_append(struct michael_mic_t *mic, uint8_t *src, int bytes)
{
int addlen;
- if (Mic->m_bytes) {
- addlen = 4 - Mic->m_bytes;
- if (addlen > nBytes)
- addlen = nBytes;
- memcpy(&Mic->m[Mic->m_bytes], src, addlen);
- Mic->m_bytes += addlen;
+ if (mic->m_bytes) {
+ addlen = 4 - mic->m_bytes;
+ if (addlen > bytes)
+ addlen = bytes;
+ memcpy(&mic->m[mic->m_bytes], src, addlen);
+ mic->m_bytes += addlen;
src += addlen;
- nBytes -= addlen;
+ bytes -= addlen;
- if (Mic->m_bytes < 4)
+ if (mic->m_bytes < 4)
return;
- Mic->l ^= getUInt32(Mic->m, 0);
- MichaelBlockFunction(Mic->l, Mic->r);
- Mic->m_bytes = 0;
+ mic->l ^= getUInt32(mic->m, 0);
+ MichaelBlockFunction(mic->l, mic->r);
+ mic->m_bytes = 0;
}
- while (nBytes >= 4) {
- Mic->l ^= getUInt32(src, 0);
- MichaelBlockFunction(Mic->l, Mic->r);
+ while (bytes >= 4) {
+ mic->l ^= getUInt32(src, 0);
+ MichaelBlockFunction(mic->l, mic->r);
src += 4;
- nBytes -= 4;
+ bytes -= 4;
}
- if (nBytes > 0) {
- Mic->m_bytes = nBytes;
- memcpy(Mic->m, src, nBytes);
+ if (bytes > 0) {
+ mic->m_bytes = bytes;
+ memcpy(mic->m, src, bytes);
}
}
@@ -137,8 +136,8 @@ void michael_mic_function(struct michael_mic_t *mic, u8 *key,
* +--+--+--------+--+----+--+--+--+--+--+--+--+--+
*/
michael_init(mic, key);
- MichaelAppend(mic, (uint8_t *)data, 12); /* |DA|SA| */
- MichaelAppend(mic, pad_data, 4); /* |Priority|0|0|0| */
- MichaelAppend(mic, (uint8_t *)(data + 12), len - 12); /* |Data| */
+ michael_append(mic, (uint8_t *)data, 12); /* |DA|SA| */
+ michael_append(mic, pad_data, 4); /* |Priority|0|0|0| */
+ michael_append(mic, (uint8_t *)(data + 12), len - 12); /* |Data| */
MichaelGetMIC(mic, result);
}
--
2.7.4
_______________________________________________
devel mailing list
devel@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
^ permalink raw reply related [flat|nested] 13+ messages in thread
* [PATCH 04/12] staging: ks7010: replace macro MichaelClear with inline function
2018-03-28 15:24 [PATCH 00/12] staging: ks7010: Some clean ups Sergio Paracuellos
` (2 preceding siblings ...)
2018-03-28 15:24 ` [PATCH 03/12] staging: ks7010: avoid camel cases in MichaelAppend function Sergio Paracuellos
@ 2018-03-28 15:24 ` Sergio Paracuellos
2018-03-28 15:24 ` [PATCH 05/12] staging: ks7010: avoid camel cases in MichaelGetMIC function Sergio Paracuellos
` (7 subsequent siblings)
11 siblings, 0 replies; 13+ messages in thread
From: Sergio Paracuellos @ 2018-03-28 15:24 UTC (permalink / raw)
To: gregkh; +Cc: driverdev-devel, wsa
This commit replaces MichaelClear macro with similar inline function
renaming it to michael_clear.
Signed-off-by: Sergio Paracuellos <sergio.paracuellos@gmail.com>
---
drivers/staging/ks7010/michael_mic.c | 16 ++++++++--------
1 file changed, 8 insertions(+), 8 deletions(-)
diff --git a/drivers/staging/ks7010/michael_mic.c b/drivers/staging/ks7010/michael_mic.c
index 276ecd9..af36b12d 100644
--- a/drivers/staging/ks7010/michael_mic.c
+++ b/drivers/staging/ks7010/michael_mic.c
@@ -28,12 +28,12 @@ do { \
} while (0)
// Reset the state to the empty message.
-#define MichaelClear(A) \
-do { \
- A->l = A->k0; \
- A->r = A->k1; \
- A->m_bytes = 0; \
-} while (0)
+static inline void michael_clear(struct michael_mic_t *mic)
+{
+ mic->l = mic->k0;
+ mic->r = mic->k1;
+ mic->m_bytes = 0;
+}
static void michael_init(struct michael_mic_t *mic, uint8_t *key)
{
@@ -42,7 +42,7 @@ static void michael_init(struct michael_mic_t *mic, uint8_t *key)
mic->k1 = getUInt32(key, 4);
//clear();
- MichaelClear(mic);
+ michael_clear(mic);
}
#define MichaelBlockFunction(L, R) \
@@ -118,7 +118,7 @@ void MichaelGetMIC(struct michael_mic_t *Mic, uint8_t *dst)
putUInt32(dst, 4, Mic->r);
// Reset to the empty message.
- MichaelClear(Mic);
+ michael_clear(Mic);
}
void michael_mic_function(struct michael_mic_t *mic, u8 *key,
--
2.7.4
_______________________________________________
devel mailing list
devel@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
^ permalink raw reply related [flat|nested] 13+ messages in thread
* [PATCH 05/12] staging: ks7010: avoid camel cases in MichaelGetMIC function
2018-03-28 15:24 [PATCH 00/12] staging: ks7010: Some clean ups Sergio Paracuellos
` (3 preceding siblings ...)
2018-03-28 15:24 ` [PATCH 04/12] staging: ks7010: replace macro MichaelClear with inline function Sergio Paracuellos
@ 2018-03-28 15:24 ` Sergio Paracuellos
2018-03-28 15:24 ` [PATCH 06/12] staging: ks7010: replace PutUInt32 macro with put_unaligned_le32() Sergio Paracuellos
` (6 subsequent siblings)
11 siblings, 0 replies; 13+ messages in thread
From: Sergio Paracuellos @ 2018-03-28 15:24 UTC (permalink / raw)
To: gregkh; +Cc: driverdev-devel, wsa
This commit avoid camel cases in MichaelGetMIC function and params
renaming it to michael_get_mic.
Signed-off-by: Sergio Paracuellos <sergio.paracuellos@gmail.com>
---
drivers/staging/ks7010/michael_mic.c | 27 +++++++++++++--------------
1 file changed, 13 insertions(+), 14 deletions(-)
diff --git a/drivers/staging/ks7010/michael_mic.c b/drivers/staging/ks7010/michael_mic.c
index af36b12d..82ac122 100644
--- a/drivers/staging/ks7010/michael_mic.c
+++ b/drivers/staging/ks7010/michael_mic.c
@@ -91,34 +91,33 @@ static void michael_append(struct michael_mic_t *mic, uint8_t *src, int bytes)
}
}
-static
-void MichaelGetMIC(struct michael_mic_t *Mic, uint8_t *dst)
+static void michael_get_mic(struct michael_mic_t *mic, uint8_t *dst)
{
- u8 *data = Mic->m;
+ u8 *data = mic->m;
- switch (Mic->m_bytes) {
+ switch (mic->m_bytes) {
case 0:
- Mic->l ^= 0x5a;
+ mic->l ^= 0x5a;
break;
case 1:
- Mic->l ^= data[0] | 0x5a00;
+ mic->l ^= data[0] | 0x5a00;
break;
case 2:
- Mic->l ^= data[0] | (data[1] << 8) | 0x5a0000;
+ mic->l ^= data[0] | (data[1] << 8) | 0x5a0000;
break;
case 3:
- Mic->l ^= data[0] | (data[1] << 8) | (data[2] << 16) |
+ mic->l ^= data[0] | (data[1] << 8) | (data[2] << 16) |
0x5a000000;
break;
}
- MichaelBlockFunction(Mic->l, Mic->r);
- MichaelBlockFunction(Mic->l, Mic->r);
+ MichaelBlockFunction(mic->l, mic->r);
+ MichaelBlockFunction(mic->l, mic->r);
// The appendByte function has already computed the result.
- putUInt32(dst, 0, Mic->l);
- putUInt32(dst, 4, Mic->r);
+ putUInt32(dst, 0, mic->l);
+ putUInt32(dst, 4, mic->r);
// Reset to the empty message.
- michael_clear(Mic);
+ michael_clear(mic);
}
void michael_mic_function(struct michael_mic_t *mic, u8 *key,
@@ -139,5 +138,5 @@ void michael_mic_function(struct michael_mic_t *mic, u8 *key,
michael_append(mic, (uint8_t *)data, 12); /* |DA|SA| */
michael_append(mic, pad_data, 4); /* |Priority|0|0|0| */
michael_append(mic, (uint8_t *)(data + 12), len - 12); /* |Data| */
- MichaelGetMIC(mic, result);
+ michael_get_mic(mic, result);
}
--
2.7.4
_______________________________________________
devel mailing list
devel@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
^ permalink raw reply related [flat|nested] 13+ messages in thread
* [PATCH 06/12] staging: ks7010: replace PutUInt32 macro with put_unaligned_le32()
2018-03-28 15:24 [PATCH 00/12] staging: ks7010: Some clean ups Sergio Paracuellos
` (4 preceding siblings ...)
2018-03-28 15:24 ` [PATCH 05/12] staging: ks7010: avoid camel cases in MichaelGetMIC function Sergio Paracuellos
@ 2018-03-28 15:24 ` Sergio Paracuellos
2018-03-28 15:24 ` [PATCH 07/12] staging: ks7010: replace GetUInt32 macro with get_unaligned_le32 Sergio Paracuellos
` (5 subsequent siblings)
11 siblings, 0 replies; 13+ messages in thread
From: Sergio Paracuellos @ 2018-03-28 15:24 UTC (permalink / raw)
To: gregkh; +Cc: driverdev-devel, wsa
This commit replaces PutUInt32 custom macro with put_unaligned_le32
function included in the linux kernel.
Signed-off-by: Sergio Paracuellos <sergio.paracuellos@gmail.com>
---
drivers/staging/ks7010/michael_mic.c | 14 +++-----------
1 file changed, 3 insertions(+), 11 deletions(-)
diff --git a/drivers/staging/ks7010/michael_mic.c b/drivers/staging/ks7010/michael_mic.c
index 82ac122..79efaf3 100644
--- a/drivers/staging/ks7010/michael_mic.c
+++ b/drivers/staging/ks7010/michael_mic.c
@@ -12,21 +12,13 @@
#include <linux/types.h>
#include <linux/string.h>
#include <linux/bitops.h>
+#include <asm/unaligned.h>
#include "michael_mic.h"
// Convert from Byte[] to UInt32 in a portable way
#define getUInt32(A, B) ((uint32_t)(A[B + 0] << 0) \
+ (A[B + 1] << 8) + (A[B + 2] << 16) + (A[B + 3] << 24))
-// Convert from UInt32 to Byte[] in a portable way
-#define putUInt32(A, B, C) \
-do { \
- A[B + 0] = (uint8_t)(C & 0xff); \
- A[B + 1] = (uint8_t)((C >> 8) & 0xff); \
- A[B + 2] = (uint8_t)((C >> 16) & 0xff); \
- A[B + 3] = (uint8_t)((C >> 24) & 0xff); \
-} while (0)
-
// Reset the state to the empty message.
static inline void michael_clear(struct michael_mic_t *mic)
{
@@ -113,8 +105,8 @@ static void michael_get_mic(struct michael_mic_t *mic, uint8_t *dst)
MichaelBlockFunction(mic->l, mic->r);
MichaelBlockFunction(mic->l, mic->r);
// The appendByte function has already computed the result.
- putUInt32(dst, 0, mic->l);
- putUInt32(dst, 4, mic->r);
+ put_unaligned_le32(mic->l, dst);
+ put_unaligned_le32(mic->r, dst + 4);
// Reset to the empty message.
michael_clear(mic);
--
2.7.4
_______________________________________________
devel mailing list
devel@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
^ permalink raw reply related [flat|nested] 13+ messages in thread
* [PATCH 07/12] staging: ks7010: replace GetUInt32 macro with get_unaligned_le32
2018-03-28 15:24 [PATCH 00/12] staging: ks7010: Some clean ups Sergio Paracuellos
` (5 preceding siblings ...)
2018-03-28 15:24 ` [PATCH 06/12] staging: ks7010: replace PutUInt32 macro with put_unaligned_le32() Sergio Paracuellos
@ 2018-03-28 15:24 ` Sergio Paracuellos
2018-03-28 15:24 ` [PATCH 08/12] staging: ks7010: replace MichaelBlockFunction macro with inline function Sergio Paracuellos
` (4 subsequent siblings)
11 siblings, 0 replies; 13+ messages in thread
From: Sergio Paracuellos @ 2018-03-28 15:24 UTC (permalink / raw)
To: gregkh; +Cc: driverdev-devel, wsa
This commit replaces custom GetUInt32 macro with get_unaligned_le32
which is included in the linux kernel.
Signed-off-by: Sergio Paracuellos <sergio.paracuellos@gmail.com>
---
drivers/staging/ks7010/michael_mic.c | 11 ++++-------
1 file changed, 4 insertions(+), 7 deletions(-)
diff --git a/drivers/staging/ks7010/michael_mic.c b/drivers/staging/ks7010/michael_mic.c
index 79efaf3..490438d 100644
--- a/drivers/staging/ks7010/michael_mic.c
+++ b/drivers/staging/ks7010/michael_mic.c
@@ -15,9 +15,6 @@
#include <asm/unaligned.h>
#include "michael_mic.h"
-// Convert from Byte[] to UInt32 in a portable way
-#define getUInt32(A, B) ((uint32_t)(A[B + 0] << 0) \
- + (A[B + 1] << 8) + (A[B + 2] << 16) + (A[B + 3] << 24))
// Reset the state to the empty message.
static inline void michael_clear(struct michael_mic_t *mic)
@@ -30,8 +27,8 @@ static inline void michael_clear(struct michael_mic_t *mic)
static void michael_init(struct michael_mic_t *mic, uint8_t *key)
{
// Set the key
- mic->k0 = getUInt32(key, 0);
- mic->k1 = getUInt32(key, 4);
+ mic->k0 = get_unaligned_le32(key);
+ mic->k1 = get_unaligned_le32(key + 4);
//clear();
michael_clear(mic);
@@ -65,13 +62,13 @@ static void michael_append(struct michael_mic_t *mic, uint8_t *src, int bytes)
if (mic->m_bytes < 4)
return;
- mic->l ^= getUInt32(mic->m, 0);
+ mic->l ^= get_unaligned_le32(mic->m);
MichaelBlockFunction(mic->l, mic->r);
mic->m_bytes = 0;
}
while (bytes >= 4) {
- mic->l ^= getUInt32(src, 0);
+ mic->l ^= get_unaligned_le32(src);
MichaelBlockFunction(mic->l, mic->r);
src += 4;
bytes -= 4;
--
2.7.4
_______________________________________________
devel mailing list
devel@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
^ permalink raw reply related [flat|nested] 13+ messages in thread
* [PATCH 08/12] staging: ks7010: replace MichaelBlockFunction macro with inline function
2018-03-28 15:24 [PATCH 00/12] staging: ks7010: Some clean ups Sergio Paracuellos
` (6 preceding siblings ...)
2018-03-28 15:24 ` [PATCH 07/12] staging: ks7010: replace GetUInt32 macro with get_unaligned_le32 Sergio Paracuellos
@ 2018-03-28 15:24 ` Sergio Paracuellos
2018-03-28 15:24 ` [PATCH 09/12] staging: ks7010: remove some dead code from ks_wlan_set_essid function Sergio Paracuellos
` (3 subsequent siblings)
11 siblings, 0 replies; 13+ messages in thread
From: Sergio Paracuellos @ 2018-03-28 15:24 UTC (permalink / raw)
To: gregkh; +Cc: driverdev-devel, wsa
This commit replaces MichaelBlockFunction macro with similar
inline function renaming it to michael_block.
Signed-off-by: Sergio Paracuellos <sergio.paracuellos@gmail.com>
---
drivers/staging/ks7010/michael_mic.c | 31 ++++++++++++++++---------------
1 file changed, 16 insertions(+), 15 deletions(-)
diff --git a/drivers/staging/ks7010/michael_mic.c b/drivers/staging/ks7010/michael_mic.c
index 490438d..5eac356 100644
--- a/drivers/staging/ks7010/michael_mic.c
+++ b/drivers/staging/ks7010/michael_mic.c
@@ -34,17 +34,18 @@ static void michael_init(struct michael_mic_t *mic, uint8_t *key)
michael_clear(mic);
}
-#define MichaelBlockFunction(L, R) \
-do { \
- R ^= rol32(L, 17); \
- L += R; \
- R ^= ((L & 0xff00ff00) >> 8) | ((L & 0x00ff00ff) << 8); \
- L += R; \
- R ^= rol32(L, 3); \
- L += R; \
- R ^= ror32(L, 2); \
- L += R; \
-} while (0)
+static inline void michael_block(struct michael_mic_t *mic)
+{
+ mic->r ^= rol32(mic->l, 17);
+ mic->l += mic->r;
+ mic->r ^= ((mic->l & 0xff00ff00) >> 8) |
+ ((mic->l & 0x00ff00ff) << 8);
+ mic->l += mic->r;
+ mic->r ^= rol32(mic->l, 3); \
+ mic->l += mic->r;
+ mic->r ^= ror32(mic->l, 2); \
+ mic->l += mic->r;
+}
static void michael_append(struct michael_mic_t *mic, uint8_t *src, int bytes)
{
@@ -63,13 +64,13 @@ static void michael_append(struct michael_mic_t *mic, uint8_t *src, int bytes)
return;
mic->l ^= get_unaligned_le32(mic->m);
- MichaelBlockFunction(mic->l, mic->r);
+ michael_block(mic);
mic->m_bytes = 0;
}
while (bytes >= 4) {
mic->l ^= get_unaligned_le32(src);
- MichaelBlockFunction(mic->l, mic->r);
+ michael_block(mic);
src += 4;
bytes -= 4;
}
@@ -99,8 +100,8 @@ static void michael_get_mic(struct michael_mic_t *mic, uint8_t *dst)
0x5a000000;
break;
}
- MichaelBlockFunction(mic->l, mic->r);
- MichaelBlockFunction(mic->l, mic->r);
+ michael_block(mic);
+ michael_block(mic);
// The appendByte function has already computed the result.
put_unaligned_le32(mic->l, dst);
put_unaligned_le32(mic->r, dst + 4);
--
2.7.4
_______________________________________________
devel mailing list
devel@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
^ permalink raw reply related [flat|nested] 13+ messages in thread
* [PATCH 09/12] staging: ks7010: remove some dead code from ks_wlan_set_essid function
2018-03-28 15:24 [PATCH 00/12] staging: ks7010: Some clean ups Sergio Paracuellos
` (7 preceding siblings ...)
2018-03-28 15:24 ` [PATCH 08/12] staging: ks7010: replace MichaelBlockFunction macro with inline function Sergio Paracuellos
@ 2018-03-28 15:24 ` Sergio Paracuellos
2018-03-28 15:24 ` [PATCH 10/12] staging: ks7010: replace uint8_t in favour of u8 in michael_init Sergio Paracuellos
` (2 subsequent siblings)
11 siblings, 0 replies; 13+ messages in thread
From: Sergio Paracuellos @ 2018-03-28 15:24 UTC (permalink / raw)
To: gregkh; +Cc: driverdev-devel, wsa
This commit removes death code which is not being used at all. The
statements which are contained inside the else block of preprocessor
#if 1 directive are no sense. Also remove #if 1 preprocessor stuff
just because it is just true and being executed always.
This change improves a bit readability of ks_wlan_set_essid function.
Signed-off-by: Sergio Paracuellos <sergio.paracuellos@gmail.com>
---
drivers/staging/ks7010/ks_wlan_net.c | 15 ---------------
1 file changed, 15 deletions(-)
diff --git a/drivers/staging/ks7010/ks_wlan_net.c b/drivers/staging/ks7010/ks_wlan_net.c
index 6106e79..4019f3a 100644
--- a/drivers/staging/ks7010/ks_wlan_net.c
+++ b/drivers/staging/ks7010/ks_wlan_net.c
@@ -276,7 +276,6 @@ static int ks_wlan_set_essid(struct net_device *dev,
memset(priv->reg.ssid.body, 0, sizeof(priv->reg.ssid.body));
priv->reg.ssid.size = 0;
} else {
-#if 1
len = dwrq->length;
/* iwconfig uses nul termination in SSID.. */
if (len > 0 && extra[len - 1] == '\0')
@@ -286,28 +285,14 @@ static int ks_wlan_set_essid(struct net_device *dev,
if (len > IW_ESSID_MAX_SIZE)
return -EINVAL;
-#else
- /* Check the size of the string */
- if (dwrq->length > IW_ESSID_MAX_SIZE + 1)
- return -E2BIG;
-
-#endif
-
/* Set the SSID */
memset(priv->reg.ssid.body, 0, sizeof(priv->reg.ssid.body));
-
-#if 1
memcpy(priv->reg.ssid.body, extra, len);
priv->reg.ssid.size = len;
-#else
- memcpy(priv->reg.ssid.body, extra, dwrq->length);
- priv->reg.ssid.size = dwrq->length;
-#endif
}
/* Write it to the card */
priv->need_commit |= SME_MODE_SET;
-// return -EINPROGRESS; /* Call commit handler */
ks_wlan_setup_parameter(priv, priv->need_commit);
priv->need_commit = 0;
return 0;
--
2.7.4
_______________________________________________
devel mailing list
devel@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
^ permalink raw reply related [flat|nested] 13+ messages in thread
* [PATCH 10/12] staging: ks7010: replace uint8_t in favour of u8 in michael_init
2018-03-28 15:24 [PATCH 00/12] staging: ks7010: Some clean ups Sergio Paracuellos
` (8 preceding siblings ...)
2018-03-28 15:24 ` [PATCH 09/12] staging: ks7010: remove some dead code from ks_wlan_set_essid function Sergio Paracuellos
@ 2018-03-28 15:24 ` Sergio Paracuellos
2018-03-28 15:24 ` [PATCH 11/12] staging: ks7010: replace uint8_t in favour of u8 in michael_append Sergio Paracuellos
2018-03-28 15:24 ` [PATCH 12/12] staging: ks7010: replace uint8_t in favour of u8 in michael_get_mic Sergio Paracuellos
11 siblings, 0 replies; 13+ messages in thread
From: Sergio Paracuellos @ 2018-03-28 15:24 UTC (permalink / raw)
To: gregkh; +Cc: driverdev-devel, wsa
This commit replaces uint8_t for preferred one u8 in parameter
of michael_init function.
Signed-off-by: Sergio Paracuellos <sergio.paracuellos@gmail.com>
---
drivers/staging/ks7010/michael_mic.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/staging/ks7010/michael_mic.c b/drivers/staging/ks7010/michael_mic.c
index 5eac356..0b59865 100644
--- a/drivers/staging/ks7010/michael_mic.c
+++ b/drivers/staging/ks7010/michael_mic.c
@@ -24,7 +24,7 @@ static inline void michael_clear(struct michael_mic_t *mic)
mic->m_bytes = 0;
}
-static void michael_init(struct michael_mic_t *mic, uint8_t *key)
+static void michael_init(struct michael_mic_t *mic, u8 *key)
{
// Set the key
mic->k0 = get_unaligned_le32(key);
--
2.7.4
_______________________________________________
devel mailing list
devel@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
^ permalink raw reply related [flat|nested] 13+ messages in thread
* [PATCH 11/12] staging: ks7010: replace uint8_t in favour of u8 in michael_append
2018-03-28 15:24 [PATCH 00/12] staging: ks7010: Some clean ups Sergio Paracuellos
` (9 preceding siblings ...)
2018-03-28 15:24 ` [PATCH 10/12] staging: ks7010: replace uint8_t in favour of u8 in michael_init Sergio Paracuellos
@ 2018-03-28 15:24 ` Sergio Paracuellos
2018-03-28 15:24 ` [PATCH 12/12] staging: ks7010: replace uint8_t in favour of u8 in michael_get_mic Sergio Paracuellos
11 siblings, 0 replies; 13+ messages in thread
From: Sergio Paracuellos @ 2018-03-28 15:24 UTC (permalink / raw)
To: gregkh; +Cc: driverdev-devel, wsa
This commit replaces param which is uint8_t in michael_append
function in favour of preferred one u8. It also removes no more
needed casts when calling this function.
Signed-off-by: Sergio Paracuellos <sergio.paracuellos@gmail.com>
---
drivers/staging/ks7010/michael_mic.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/drivers/staging/ks7010/michael_mic.c b/drivers/staging/ks7010/michael_mic.c
index 0b59865..d171cba 100644
--- a/drivers/staging/ks7010/michael_mic.c
+++ b/drivers/staging/ks7010/michael_mic.c
@@ -47,7 +47,7 @@ static inline void michael_block(struct michael_mic_t *mic)
mic->l += mic->r;
}
-static void michael_append(struct michael_mic_t *mic, uint8_t *src, int bytes)
+static void michael_append(struct michael_mic_t *mic, u8 *src, int bytes)
{
int addlen;
@@ -125,8 +125,8 @@ void michael_mic_function(struct michael_mic_t *mic, u8 *key,
* +--+--+--------+--+----+--+--+--+--+--+--+--+--+
*/
michael_init(mic, key);
- michael_append(mic, (uint8_t *)data, 12); /* |DA|SA| */
+ michael_append(mic, data, 12); /* |DA|SA| */
michael_append(mic, pad_data, 4); /* |Priority|0|0|0| */
- michael_append(mic, (uint8_t *)(data + 12), len - 12); /* |Data| */
+ michael_append(mic, data + 12, len - 12); /* |Data| */
michael_get_mic(mic, result);
}
--
2.7.4
_______________________________________________
devel mailing list
devel@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
^ permalink raw reply related [flat|nested] 13+ messages in thread
* [PATCH 12/12] staging: ks7010: replace uint8_t in favour of u8 in michael_get_mic
2018-03-28 15:24 [PATCH 00/12] staging: ks7010: Some clean ups Sergio Paracuellos
` (10 preceding siblings ...)
2018-03-28 15:24 ` [PATCH 11/12] staging: ks7010: replace uint8_t in favour of u8 in michael_append Sergio Paracuellos
@ 2018-03-28 15:24 ` Sergio Paracuellos
11 siblings, 0 replies; 13+ messages in thread
From: Sergio Paracuellos @ 2018-03-28 15:24 UTC (permalink / raw)
To: gregkh; +Cc: driverdev-devel, wsa
This commit replaces uint8_t parameter for preferred one u8 in
michael_get_mic function.
Signed-off-by: Sergio Paracuellos <sergio.paracuellos@gmail.com>
---
drivers/staging/ks7010/michael_mic.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/staging/ks7010/michael_mic.c b/drivers/staging/ks7010/michael_mic.c
index d171cba..292eae2 100644
--- a/drivers/staging/ks7010/michael_mic.c
+++ b/drivers/staging/ks7010/michael_mic.c
@@ -81,7 +81,7 @@ static void michael_append(struct michael_mic_t *mic, u8 *src, int bytes)
}
}
-static void michael_get_mic(struct michael_mic_t *mic, uint8_t *dst)
+static void michael_get_mic(struct michael_mic_t *mic, u8 *dst)
{
u8 *data = mic->m;
--
2.7.4
_______________________________________________
devel mailing list
devel@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
^ permalink raw reply related [flat|nested] 13+ messages in thread
end of thread, other threads:[~2018-03-28 15:24 UTC | newest]
Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-03-28 15:24 [PATCH 00/12] staging: ks7010: Some clean ups Sergio Paracuellos
2018-03-28 15:24 ` [PATCH 01/12] staging: ks7010: avoid camel cases in MichaelMICFunction Sergio Paracuellos
2018-03-28 15:24 ` [PATCH 02/12] staging: ks7010: avoid camel cases for MichaelInitFunction Sergio Paracuellos
2018-03-28 15:24 ` [PATCH 03/12] staging: ks7010: avoid camel cases in MichaelAppend function Sergio Paracuellos
2018-03-28 15:24 ` [PATCH 04/12] staging: ks7010: replace macro MichaelClear with inline function Sergio Paracuellos
2018-03-28 15:24 ` [PATCH 05/12] staging: ks7010: avoid camel cases in MichaelGetMIC function Sergio Paracuellos
2018-03-28 15:24 ` [PATCH 06/12] staging: ks7010: replace PutUInt32 macro with put_unaligned_le32() Sergio Paracuellos
2018-03-28 15:24 ` [PATCH 07/12] staging: ks7010: replace GetUInt32 macro with get_unaligned_le32 Sergio Paracuellos
2018-03-28 15:24 ` [PATCH 08/12] staging: ks7010: replace MichaelBlockFunction macro with inline function Sergio Paracuellos
2018-03-28 15:24 ` [PATCH 09/12] staging: ks7010: remove some dead code from ks_wlan_set_essid function Sergio Paracuellos
2018-03-28 15:24 ` [PATCH 10/12] staging: ks7010: replace uint8_t in favour of u8 in michael_init Sergio Paracuellos
2018-03-28 15:24 ` [PATCH 11/12] staging: ks7010: replace uint8_t in favour of u8 in michael_append Sergio Paracuellos
2018-03-28 15:24 ` [PATCH 12/12] staging: ks7010: replace uint8_t in favour of u8 in michael_get_mic Sergio Paracuellos
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.