Commit c0eb0558 authored by Florian Fainelli's avatar Florian Fainelli Committed by David S. Miller

net: systemport: Fix sparse warnings in bcm_sysport_insert_tsb()

skb->protocol is a __be16 which we would be calling htons() against,
while this is not wrong per-se as it correctly results in swapping the
value on LE hosts, this still upsets sparse. Adopt a similar pattern to
what other drivers do and just assign ip_ver to skb->protocol, and then
use htons() against the different constants such that the compiler can
resolve the values at build time.

Fixes: 80105bef ("net: systemport: add Broadcom SYSTEMPORT Ethernet MAC driver")
Signed-off-by: default avatarFlorian Fainelli <f.fainelli@gmail.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 6f894211
...@@ -1192,7 +1192,7 @@ static struct sk_buff *bcm_sysport_insert_tsb(struct sk_buff *skb, ...@@ -1192,7 +1192,7 @@ static struct sk_buff *bcm_sysport_insert_tsb(struct sk_buff *skb,
u32 csum_info; u32 csum_info;
u8 ip_proto; u8 ip_proto;
u16 csum_start; u16 csum_start;
u16 ip_ver; __be16 ip_ver;
/* Re-allocate SKB if needed */ /* Re-allocate SKB if needed */
if (unlikely(skb_headroom(skb) < sizeof(*tsb))) { if (unlikely(skb_headroom(skb) < sizeof(*tsb))) {
...@@ -1211,12 +1211,12 @@ static struct sk_buff *bcm_sysport_insert_tsb(struct sk_buff *skb, ...@@ -1211,12 +1211,12 @@ static struct sk_buff *bcm_sysport_insert_tsb(struct sk_buff *skb,
memset(tsb, 0, sizeof(*tsb)); memset(tsb, 0, sizeof(*tsb));
if (skb->ip_summed == CHECKSUM_PARTIAL) { if (skb->ip_summed == CHECKSUM_PARTIAL) {
ip_ver = htons(skb->protocol); ip_ver = skb->protocol;
switch (ip_ver) { switch (ip_ver) {
case ETH_P_IP: case htons(ETH_P_IP):
ip_proto = ip_hdr(skb)->protocol; ip_proto = ip_hdr(skb)->protocol;
break; break;
case ETH_P_IPV6: case htons(ETH_P_IPV6):
ip_proto = ipv6_hdr(skb)->nexthdr; ip_proto = ipv6_hdr(skb)->nexthdr;
break; break;
default: default:
...@@ -1230,7 +1230,8 @@ static struct sk_buff *bcm_sysport_insert_tsb(struct sk_buff *skb, ...@@ -1230,7 +1230,8 @@ static struct sk_buff *bcm_sysport_insert_tsb(struct sk_buff *skb,
if (ip_proto == IPPROTO_TCP || ip_proto == IPPROTO_UDP) { if (ip_proto == IPPROTO_TCP || ip_proto == IPPROTO_UDP) {
csum_info |= L4_LENGTH_VALID; csum_info |= L4_LENGTH_VALID;
if (ip_proto == IPPROTO_UDP && ip_ver == ETH_P_IP) if (ip_proto == IPPROTO_UDP &&
ip_ver == htons(ETH_P_IP))
csum_info |= L4_UDP; csum_info |= L4_UDP;
} else { } else {
csum_info = 0; csum_info = 0;
......
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