提交 51508179 编写于 作者: D David S. Miller

Merge branch 'net-Broadcom-drivers-sparse-fixes'

Florian Fainelli says:

====================
net: Broadcom drivers sparse fixes

This patch series fixes the same warning reported by sparse in bcmsysport and
bcmgenet in the code that deals with inserting the TX checksum pointers:

drivers/net/ethernet/broadcom/bcmsysport.c:1155:26: warning: cast from restricted __be16
drivers/net/ethernet/broadcom/bcmsysport.c:1155:26: warning: incorrect type in argument 1 (different base types)
drivers/net/ethernet/broadcom/bcmsysport.c:1155:26:    expected unsigned short [unsigned] [usertype] val
drivers/net/ethernet/broadcom/bcmsysport.c:1155:26:    got restricted __be16 [usertype] protocol

This patch fixes both issues by using the same construct and not swapping
skb->protocol but instead the values we are checking against.
====================
Signed-off-by: NDavid S. Miller <davem@davemloft.net>
...@@ -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;
......
...@@ -1489,7 +1489,7 @@ static struct sk_buff *bcmgenet_put_tx_csum(struct net_device *dev, ...@@ -1489,7 +1489,7 @@ static struct sk_buff *bcmgenet_put_tx_csum(struct net_device *dev,
struct sk_buff *new_skb; struct sk_buff *new_skb;
u16 offset; u16 offset;
u8 ip_proto; u8 ip_proto;
u16 ip_ver; __be16 ip_ver;
u32 tx_csum_info; u32 tx_csum_info;
if (unlikely(skb_headroom(skb) < sizeof(*status))) { if (unlikely(skb_headroom(skb) < sizeof(*status))) {
...@@ -1509,12 +1509,12 @@ static struct sk_buff *bcmgenet_put_tx_csum(struct net_device *dev, ...@@ -1509,12 +1509,12 @@ static struct sk_buff *bcmgenet_put_tx_csum(struct net_device *dev,
status = (struct status_64 *)skb->data; status = (struct status_64 *)skb->data;
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:
...@@ -1530,7 +1530,8 @@ static struct sk_buff *bcmgenet_put_tx_csum(struct net_device *dev, ...@@ -1530,7 +1530,8 @@ static struct sk_buff *bcmgenet_put_tx_csum(struct net_device *dev,
*/ */
if (ip_proto == IPPROTO_TCP || ip_proto == IPPROTO_UDP) { if (ip_proto == IPPROTO_TCP || ip_proto == IPPROTO_UDP) {
tx_csum_info |= STATUS_TX_CSUM_LV; tx_csum_info |= STATUS_TX_CSUM_LV;
if (ip_proto == IPPROTO_UDP && ip_ver == ETH_P_IP) if (ip_proto == IPPROTO_UDP &&
ip_ver == htons(ETH_P_IP))
tx_csum_info |= STATUS_TX_CSUM_PROTO_UDP; tx_csum_info |= STATUS_TX_CSUM_PROTO_UDP;
} else { } else {
tx_csum_info = 0; tx_csum_info = 0;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册