netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Simon Horman <simon.horman@corigine.com>
To: Mika Westerberg <mika.westerberg@linux.intel.com>
Cc: "David S . Miller" <davem@davemloft.net>,
	Eric Dumazet <edumazet@google.com>,
	Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
	Michael Jamet <michael.jamet@intel.com>,
	Yehezkel Bernat <YehezkelShB@gmail.com>,
	Andy Shevchenko <andriy.shevchenko@linux.intel.com>,
	netdev@vger.kernel.org
Subject: Re: [PATCH v2 2/3] net: thunderbolt: Fix sparse warnings in tbnet_xmit_csum_and_map()
Date: Tue, 11 Apr 2023 13:50:16 +0200	[thread overview]
Message-ID: <ZDVJeJd3mM0kBdE4@corigine.com> (raw)
In-Reply-To: <20230411091049.12998-3-mika.westerberg@linux.intel.com>

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@linux.intel.com>
> Reviewed-by: Simon Horman <simon.horman@corigine.com>
> Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.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
> 

  reply	other threads:[~2023-04-11 11:50 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-04-11  9:10 [PATCH v2 0/3] net: thunderbolt: Fix for sparse warnings and typos Mika Westerberg
2023-04-11  9:10 ` [PATCH v2 1/3] net: thunderbolt: Fix sparse warnings in tbnet_check_frame() and tbnet_poll() Mika Westerberg
2023-04-11  9:10 ` [PATCH v2 2/3] net: thunderbolt: Fix sparse warnings in tbnet_xmit_csum_and_map() Mika Westerberg
2023-04-11 11:50   ` Simon Horman [this message]
2023-04-11 11:58     ` Andy Shevchenko
2023-04-11 12:37       ` Simon Horman
2023-04-12  8:03         ` Mika Westerberg
2023-04-11  9:10 ` [PATCH v2 3/3] net: thunderbolt: Fix typos in comments Mika Westerberg
2023-04-13  4:20 ` [PATCH v2 0/3] net: thunderbolt: Fix for sparse warnings and typos patchwork-bot+netdevbpf

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=ZDVJeJd3mM0kBdE4@corigine.com \
    --to=simon.horman@corigine.com \
    --cc=YehezkelShB@gmail.com \
    --cc=andriy.shevchenko@linux.intel.com \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=kuba@kernel.org \
    --cc=michael.jamet@intel.com \
    --cc=mika.westerberg@linux.intel.com \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).