Skip to content

Commit

Permalink
net: macb: fixup sparse warnings on __be16 ports
Browse files Browse the repository at this point in the history
The port fields in the ethool flow structures are defined
to be __be16 types, so sparse is showing issues where these
are being passed to htons(). Fix these warnings by passing
them to be16_to_cpu() instead.

These are being used in netdev_dbg() so should only effect
anyone doing debug.

Fixes the following sparse warnings:

drivers/net/ethernet/cadence/macb_main.c:3366:9: warning: cast from restricted __be16
drivers/net/ethernet/cadence/macb_main.c:3366:9: warning: cast from restricted __be16
drivers/net/ethernet/cadence/macb_main.c:3366:9: warning: cast from restricted __be16
drivers/net/ethernet/cadence/macb_main.c:3419:25: warning: cast from restricted __be16
drivers/net/ethernet/cadence/macb_main.c:3419:25: warning: cast from restricted __be16
drivers/net/ethernet/cadence/macb_main.c:3419:25: warning: cast from restricted __be16
drivers/net/ethernet/cadence/macb_main.c:3419:25: warning: cast from restricted __be16

Signed-off-by: Ben Dooks <ben.dooks@sifive.com>
Link: https://lore.kernel.org/r/20220715173009.526126-1-ben.dooks@sifive.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
  • Loading branch information
Ben Dooks authored and Jakub Kicinski committed Jul 19, 2022
1 parent 71c47aa commit 6ee49d6
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions drivers/net/ethernet/cadence/macb_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -3482,7 +3482,8 @@ static int gem_add_flow_filter(struct net_device *netdev,
fs->flow_type, (int)fs->ring_cookie, fs->location,
htonl(fs->h_u.tcp_ip4_spec.ip4src),
htonl(fs->h_u.tcp_ip4_spec.ip4dst),
htons(fs->h_u.tcp_ip4_spec.psrc), htons(fs->h_u.tcp_ip4_spec.pdst));
be16_to_cpu(fs->h_u.tcp_ip4_spec.psrc),
be16_to_cpu(fs->h_u.tcp_ip4_spec.pdst));

spin_lock_irqsave(&bp->rx_fs_lock, flags);

Expand Down Expand Up @@ -3535,8 +3536,8 @@ static int gem_del_flow_filter(struct net_device *netdev,
fs->flow_type, (int)fs->ring_cookie, fs->location,
htonl(fs->h_u.tcp_ip4_spec.ip4src),
htonl(fs->h_u.tcp_ip4_spec.ip4dst),
htons(fs->h_u.tcp_ip4_spec.psrc),
htons(fs->h_u.tcp_ip4_spec.pdst));
be16_to_cpu(fs->h_u.tcp_ip4_spec.psrc),
be16_to_cpu(fs->h_u.tcp_ip4_spec.pdst));

gem_writel_n(bp, SCRT2, fs->location, 0);

Expand Down

0 comments on commit 6ee49d6

Please sign in to comment.