[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <ZDVJeJd3mM0kBdE4@corigine.com>
Date: Tue, 11 Apr 2023 13:50:16 +0200
From: Simon Horman <simon.horman@...igine.com>
To: Mika Westerberg <mika.westerberg@...ux.intel.com>
Cc: "David S . Miller" <davem@...emloft.net>,
Eric Dumazet <edumazet@...gle.com>,
Jakub Kicinski <kuba@...nel.org>,
Paolo Abeni <pabeni@...hat.com>,
Michael Jamet <michael.jamet@...el.com>,
Yehezkel Bernat <YehezkelShB@...il.com>,
Andy Shevchenko <andriy.shevchenko@...ux.intel.com>,
netdev@...r.kernel.org
Subject: Re: [PATCH v2 2/3] net: thunderbolt: Fix sparse warnings in
tbnet_xmit_csum_and_map()
On Tue, Apr 11, 2023 at 12:10:48PM +0300, Mika Westerberg wrote:
> Fixes the following warning when the driver is built with sparse checks
> enabled:
>
> main.c:993:23: warning: incorrect type in initializer (different base types)
> main.c:993:23: expected restricted __wsum [usertype] wsum
> main.c:993:23: got restricted __be32 [usertype]
>
> No functional changes intended.
This seems nice.
After you posted v1 I was wondering if, as a follow-up, it would be worth
creating a helper for this, say cpu_to_wsum(), as I think this pattern
occurs a few times. I'm thinking of a trivial wrapper around cpu_to_be32().
>
> Signed-off-by: Mika Westerberg <mika.westerberg@...ux.intel.com>
> Reviewed-by: Simon Horman <simon.horman@...igine.com>
> Reviewed-by: Andy Shevchenko <andriy.shevchenko@...ux.intel.com>
> ---
> drivers/net/thunderbolt/main.c | 4 +++-
> 1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/net/thunderbolt/main.c b/drivers/net/thunderbolt/main.c
> index 27f8573a2b6e..6a43ced74881 100644
> --- a/drivers/net/thunderbolt/main.c
> +++ b/drivers/net/thunderbolt/main.c
> @@ -991,8 +991,10 @@ static bool tbnet_xmit_csum_and_map(struct tbnet *net, struct sk_buff *skb,
> {
> struct thunderbolt_ip_frame_header *hdr = page_address(frames[0]->page);
> struct device *dma_dev = tb_ring_dma_device(net->tx_ring.ring);
> - __wsum wsum = htonl(skb->len - skb_transport_offset(skb));
> unsigned int i, len, offset = skb_transport_offset(skb);
> + /* Remove payload length from checksum */
> + u32 paylen = skb->len - skb_transport_offset(skb);
> + __wsum wsum = (__force __wsum)htonl(paylen);
> __be16 protocol = skb->protocol;
> void *data = skb->data;
> void *dest = hdr + 1;
> --
> 2.39.2
>
Powered by blists - more mailing lists