Commit 227041c5 authored by Deepak R Varma's avatar Deepak R Varma Committed by Greg Kroah-Hartman

staging: r8188eu: use htons macro instead of __constant_htons

Macro "htons" is more efficient and clearer. It should be used for
constants instead of the __constant_htons macro. Resolves following
checkpatch script complaint:
        WARNING: __constant_htons should be htons
Signed-off-by: default avatarDeepak R Varma <drv@mailo.com>
Tested-by: Philipp Hortmann <philipp.g.hortmann@gmail.com> # Edimax N150
Link: https://lore.kernel.org/r/b46adfbdce0362ed0dbe0fc957ef2f47a93c24bb.1666299151.git.drv@mailo.comSigned-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 3c480b32
...@@ -606,14 +606,14 @@ void dhcp_flag_bcast(struct adapter *priv, struct sk_buff *skb) ...@@ -606,14 +606,14 @@ void dhcp_flag_bcast(struct adapter *priv, struct sk_buff *skb)
if (!priv->ethBrExtInfo.dhcp_bcst_disable) { if (!priv->ethBrExtInfo.dhcp_bcst_disable) {
__be16 protocol = *((__be16 *)(skb->data + 2 * ETH_ALEN)); __be16 protocol = *((__be16 *)(skb->data + 2 * ETH_ALEN));
if (protocol == __constant_htons(ETH_P_IP)) { /* IP */ if (protocol == htons(ETH_P_IP)) { /* IP */
struct iphdr *iph = (struct iphdr *)(skb->data + ETH_HLEN); struct iphdr *iph = (struct iphdr *)(skb->data + ETH_HLEN);
if (iph->protocol == IPPROTO_UDP) { /* UDP */ if (iph->protocol == IPPROTO_UDP) { /* UDP */
struct udphdr *udph = (struct udphdr *)((size_t)iph + (iph->ihl << 2)); struct udphdr *udph = (struct udphdr *)((size_t)iph + (iph->ihl << 2));
if ((udph->source == __constant_htons(CLIENT_PORT)) && if ((udph->source == htons(CLIENT_PORT)) &&
(udph->dest == __constant_htons(SERVER_PORT))) { /* DHCP request */ (udph->dest == htons(SERVER_PORT))) { /* DHCP request */
struct dhcpMessage *dhcph = struct dhcpMessage *dhcph =
(struct dhcpMessage *)((size_t)udph + sizeof(struct udphdr)); (struct dhcpMessage *)((size_t)udph + sizeof(struct udphdr));
u32 cookie = be32_to_cpu((__be32)dhcph->cookie); u32 cookie = be32_to_cpu((__be32)dhcph->cookie);
......
...@@ -1622,14 +1622,14 @@ static int rtw_br_client_tx(struct adapter *padapter, struct sk_buff **pskb) ...@@ -1622,14 +1622,14 @@ static int rtw_br_client_tx(struct adapter *padapter, struct sk_buff **pskb)
spin_lock_bh(&padapter->br_ext_lock); spin_lock_bh(&padapter->br_ext_lock);
if (!(skb->data[0] & 1) && br_port && if (!(skb->data[0] & 1) && br_port &&
memcmp(skb->data + ETH_ALEN, padapter->br_mac, ETH_ALEN) && memcmp(skb->data + ETH_ALEN, padapter->br_mac, ETH_ALEN) &&
*((__be16 *)(skb->data + ETH_ALEN * 2)) != __constant_htons(ETH_P_8021Q) && *((__be16 *)(skb->data + ETH_ALEN * 2)) != htons(ETH_P_8021Q) &&
*((__be16 *)(skb->data + ETH_ALEN * 2)) == __constant_htons(ETH_P_IP) && *((__be16 *)(skb->data + ETH_ALEN * 2)) == htons(ETH_P_IP) &&
!memcmp(padapter->scdb_mac, skb->data + ETH_ALEN, ETH_ALEN) && padapter->scdb_entry) { !memcmp(padapter->scdb_mac, skb->data + ETH_ALEN, ETH_ALEN) && padapter->scdb_entry) {
memcpy(skb->data + ETH_ALEN, GET_MY_HWADDR(padapter), ETH_ALEN); memcpy(skb->data + ETH_ALEN, GET_MY_HWADDR(padapter), ETH_ALEN);
padapter->scdb_entry->ageing_timer = jiffies; padapter->scdb_entry->ageing_timer = jiffies;
spin_unlock_bh(&padapter->br_ext_lock); spin_unlock_bh(&padapter->br_ext_lock);
} else { } else {
if (*((__be16 *)(skb->data + ETH_ALEN * 2)) == __constant_htons(ETH_P_8021Q)) { if (*((__be16 *)(skb->data + ETH_ALEN * 2)) == htons(ETH_P_8021Q)) {
is_vlan_tag = 1; is_vlan_tag = 1;
vlan_hdr = *((unsigned short *)(skb->data + ETH_ALEN * 2 + 2)); vlan_hdr = *((unsigned short *)(skb->data + ETH_ALEN * 2 + 2));
for (i = 0; i < 6; i++) for (i = 0; i < 6; i++)
...@@ -1637,10 +1637,10 @@ static int rtw_br_client_tx(struct adapter *padapter, struct sk_buff **pskb) ...@@ -1637,10 +1637,10 @@ static int rtw_br_client_tx(struct adapter *padapter, struct sk_buff **pskb)
skb_pull(skb, 4); skb_pull(skb, 4);
} }
if (!memcmp(skb->data + ETH_ALEN, padapter->br_mac, ETH_ALEN) && if (!memcmp(skb->data + ETH_ALEN, padapter->br_mac, ETH_ALEN) &&
(*((__be16 *)(skb->data + ETH_ALEN * 2)) == __constant_htons(ETH_P_IP))) (*((__be16 *)(skb->data + ETH_ALEN * 2)) == htons(ETH_P_IP)))
memcpy(padapter->br_ip, skb->data + WLAN_ETHHDR_LEN + 12, 4); memcpy(padapter->br_ip, skb->data + WLAN_ETHHDR_LEN + 12, 4);
if (*((__be16 *)(skb->data + ETH_ALEN * 2)) == __constant_htons(ETH_P_IP)) { if (*((__be16 *)(skb->data + ETH_ALEN * 2)) == htons(ETH_P_IP)) {
if (memcmp(padapter->scdb_mac, skb->data + ETH_ALEN, ETH_ALEN)) { if (memcmp(padapter->scdb_mac, skb->data + ETH_ALEN, ETH_ALEN)) {
padapter->scdb_entry = (struct nat25_network_db_entry *)scdb_findEntry(padapter, padapter->scdb_entry = (struct nat25_network_db_entry *)scdb_findEntry(padapter,
skb->data + WLAN_ETHHDR_LEN + 12); skb->data + WLAN_ETHHDR_LEN + 12);
...@@ -1669,7 +1669,7 @@ static int rtw_br_client_tx(struct adapter *padapter, struct sk_buff **pskb) ...@@ -1669,7 +1669,7 @@ static int rtw_br_client_tx(struct adapter *padapter, struct sk_buff **pskb)
skb_push(skb, 4); skb_push(skb, 4);
for (i = 0; i < 6; i++) for (i = 0; i < 6; i++)
*((unsigned short *)(skb->data + i * 2)) = *((unsigned short *)(skb->data + 4 + i * 2)); *((unsigned short *)(skb->data + i * 2)) = *((unsigned short *)(skb->data + 4 + i * 2));
*((__be16 *)(skb->data + ETH_ALEN * 2)) = __constant_htons(ETH_P_8021Q); *((__be16 *)(skb->data + ETH_ALEN * 2)) = htons(ETH_P_8021Q);
*((unsigned short *)(skb->data + ETH_ALEN * 2 + 2)) = vlan_hdr; *((unsigned short *)(skb->data + ETH_ALEN * 2 + 2)) = vlan_hdr;
} }
...@@ -1708,7 +1708,7 @@ static int rtw_br_client_tx(struct adapter *padapter, struct sk_buff **pskb) ...@@ -1708,7 +1708,7 @@ static int rtw_br_client_tx(struct adapter *padapter, struct sk_buff **pskb)
skb_push(skb, 4); skb_push(skb, 4);
for (i = 0; i < 6; i++) for (i = 0; i < 6; i++)
*((unsigned short *)(skb->data + i * 2)) = *((unsigned short *)(skb->data + 4 + i * 2)); *((unsigned short *)(skb->data + i * 2)) = *((unsigned short *)(skb->data + 4 + i * 2));
*((__be16 *)(skb->data + ETH_ALEN * 2)) = __constant_htons(ETH_P_8021Q); *((__be16 *)(skb->data + ETH_ALEN * 2)) = htons(ETH_P_8021Q);
*((unsigned short *)(skb->data + ETH_ALEN * 2 + 2)) = vlan_hdr; *((unsigned short *)(skb->data + ETH_ALEN * 2 + 2)) = vlan_hdr;
} }
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment