summaryrefslogtreecommitdiffstats
path: root/drivers/staging/ks7010/ks_hostif.c
diff options
context:
space:
mode:
authorTobin C. Harding <me@tobin.cc>2017-04-27 11:25:15 +1000
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2017-04-28 11:45:49 +0200
commit08484ef41927a52fbd0d46c5cd19a65535d768ea (patch)
tree08910900a042f8ebff2b96a7dc9525cf13e01611 /drivers/staging/ks7010/ks_hostif.c
parent8cd1dbe1db97ad74c5265e09c3490eeb7986f623 (diff)
downloadop-kernel-dev-08484ef41927a52fbd0d46c5cd19a65535d768ea.zip
op-kernel-dev-08484ef41927a52fbd0d46c5cd19a65535d768ea.tar.gz
staging: ks7010: remove magic numbers
Driver includes magic numbers. Defining constants or using existing constants aids the readability of the code. Magic number '12' is used for two ethernet addresses (6 bytes each). ETH_ALEN is already defined within the kernel to 6. We can us the expression '2 * ETH_ALEN' to make this code explicit. Magic number '20' refers to the data size, in bytes, of a struct ether_hdr (described in eap_packet.h). We can define a constant for this purpose, making the code explicit and easier to read. Define constant. Remove magic numbers, using newly defined constant and/or expression using existing kernel constant. Signed-off-by: Tobin C. Harding <me@tobin.cc> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/staging/ks7010/ks_hostif.c')
-rw-r--r--drivers/staging/ks7010/ks_hostif.c25
1 files changed, 16 insertions, 9 deletions
diff --git a/drivers/staging/ks7010/ks_hostif.c b/drivers/staging/ks7010/ks_hostif.c
index 7c20585..8cfda60 100644
--- a/drivers/staging/ks7010/ks_hostif.c
+++ b/drivers/staging/ks7010/ks_hostif.c
@@ -399,6 +399,7 @@ void hostif_data_indication(struct ks_wlan_private *priv)
struct ether_hdr *eth_hdr;
unsigned short eth_proto;
struct ieee802_1x_hdr *aa1x_hdr;
+ size_t size;
int ret;
DPRINTK(3, "\n");
@@ -452,12 +453,15 @@ void hostif_data_indication(struct ks_wlan_private *priv)
}
DPRINTK(4, "SNAP, rx_ind_size = %d\n", rx_ind_size);
- memcpy(skb_put(skb, 12), priv->rxp, 12); /* 8802/FDDI MAC copy */
+ size = ETH_ALEN * 2;
+ memcpy(skb_put(skb, size), priv->rxp, size);
+
/* (SNAP+UI..) skip */
- memcpy(skb_put(skb, rx_ind_size - 12), priv->rxp + 18,
- rx_ind_size - 12); /* copy after Type */
- aa1x_hdr = (struct ieee802_1x_hdr *)(priv->rxp + 20);
+ size = rx_ind_size - (ETH_ALEN * 2);
+ memcpy(skb_put(skb, size), &eth_hdr->h_proto, size);
+
+ aa1x_hdr = (struct ieee802_1x_hdr *)(priv->rxp + ETHER_HDR_SIZE);
if (aa1x_hdr->type == IEEE802_1X_TYPE_EAPOL_KEY &&
priv->wpa.rsn_enabled)
atomic_set(&priv->psstatus.snooze_guard, 1);
@@ -1113,6 +1117,7 @@ int hostif_data_request(struct ks_wlan_private *priv, struct sk_buff *skb)
struct ieee802_1x_hdr *aa1x_hdr;
struct wpa_eapol_key *eap_key;
struct ethhdr *eth;
+ size_t size;
int ret;
skb_len = skb->len;
@@ -1164,11 +1169,13 @@ int hostif_data_request(struct ks_wlan_private *priv, struct sk_buff *skb)
goto err_kfree;
}
- /* MAC address copy */
- memcpy(p, buffer, 12); /* DST/SRC MAC address */
- p += 12;
- buffer += 12;
- length -= 12;
+ /* dest and src MAC address copy */
+ size = ETH_ALEN * 2;
+ memcpy(p, buffer, size);
+ p += size;
+ buffer += size;
+ length -= size;
+
/* EtherType/Length check */
if (*(buffer + 1) + (*buffer << 8) > 1500) {
/* ProtocolEAP = *(buffer+1) + (*buffer << 8); */
OpenPOWER on IntegriCloud