diff mbox series

[net-next] net: gianfar: Use __be64 * to store pointers to big endian values

Message ID 20241011-gianfar-be64-v1-1-a77ebe972176@kernel.org (mailing list archive)
State Accepted
Commit de306f0051ae947680a13c13a9fd9373d7460bb1
Delegated to: Netdev Maintainers
Headers show
Series [net-next] net: gianfar: Use __be64 * to store pointers to big endian values | expand

Checks

Context Check Description
netdev/series_format success Single patches do not need cover letters
netdev/tree_selection success Clearly marked for net-next
netdev/ynl success Generated files up to date; no warnings/errors; no diff in generated;
netdev/fixes_present success Fixes tag not required for -next series
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 5 this patch: 5
netdev/build_tools success No tools touched, skip
netdev/cc_maintainers success CCed 5 of 5 maintainers
netdev/build_clang success Errors and warnings before: 3 this patch: 3
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/deprecated_api success None detected
netdev/check_selftest success No net selftest shell script
netdev/verify_fixes success No Fixes tag
netdev/build_allmodconfig_warn success Errors and warnings before: 6 this patch: 4
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 19 lines checked
netdev/build_clang_rust success No Rust files in patch. Skipping build
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0
netdev/contest success net-next-2024-10-12--12-00 (tests: 777)

Commit Message

Simon Horman Oct. 11, 2024, 9:20 a.m. UTC
Timestamp values are read using pointers to 64-bit big endian values.
But the type of these pointers is u64 *, host byte order.
Use __be64 * instead.

Flagged by Sparse:

.../gianfar.c:2212:60: warning: cast to restricted __be64
.../gianfar.c:2475:53: warning: cast to restricted __be64

Introduced by
commit cc772ab7cdca ("gianfar: Add hardware RX timestamping support").

Compile tested only.
No functional change intended.

Signed-off-by: Simon Horman <horms@kernel.org>
---
 drivers/net/ethernet/freescale/gianfar.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

Comments

Claudiu Manoil Oct. 11, 2024, 10:01 p.m. UTC | #1
> -----Original Message-----
> From: Simon Horman <horms@kernel.org>
> Sent: Friday, October 11, 2024 12:20 PM
> To: Claudiu Manoil <claudiu.manoil@nxp.com>
> Cc: David S. Miller <davem@davemloft.net>; Eric Dumazet
> <edumazet@google.com>; Jakub Kicinski <kuba@kernel.org>; Paolo Abeni
> <pabeni@redhat.com>; netdev@vger.kernel.org
> Subject: [PATCH net-next] net: gianfar: Use __be64 * to store pointers to big
> endian values
> 
> Timestamp values are read using pointers to 64-bit big endian values.
> But the type of these pointers is u64 *, host byte order.
> Use __be64 * instead.
> 
> Flagged by Sparse:
> 
> .../gianfar.c:2212:60: warning: cast to restricted __be64
> .../gianfar.c:2475:53: warning: cast to restricted __be64
> 
> Introduced by
> commit cc772ab7cdca ("gianfar: Add hardware RX timestamping support").
> 
> Compile tested only.
> No functional change intended.
> 
> Signed-off-by: Simon Horman <horms@kernel.org>

Reviewed-by: Claudiu Manoil <claudiu.manoil@nxp.com>
patchwork-bot+netdevbpf@kernel.org Oct. 15, 2024, 1:20 p.m. UTC | #2
Hello:

This patch was applied to netdev/net-next.git (main)
by Paolo Abeni <pabeni@redhat.com>:

On Fri, 11 Oct 2024 10:20:00 +0100 you wrote:
> Timestamp values are read using pointers to 64-bit big endian values.
> But the type of these pointers is u64 *, host byte order.
> Use __be64 * instead.
> 
> Flagged by Sparse:
> 
> .../gianfar.c:2212:60: warning: cast to restricted __be64
> .../gianfar.c:2475:53: warning: cast to restricted __be64
> 
> [...]

Here is the summary with links:
  - [net-next] net: gianfar: Use __be64 * to store pointers to big endian values
    https://git.kernel.org/netdev/net-next/c/de306f0051ae

You are awesome, thank you!
diff mbox series

Patch

diff --git a/drivers/net/ethernet/freescale/gianfar.c b/drivers/net/ethernet/freescale/gianfar.c
index 092db6995824..435138f4699d 100644
--- a/drivers/net/ethernet/freescale/gianfar.c
+++ b/drivers/net/ethernet/freescale/gianfar.c
@@ -2207,8 +2207,9 @@  static void gfar_clean_tx_ring(struct gfar_priv_tx_q *tx_queue)
 
 		if (unlikely(do_tstamp)) {
 			struct skb_shared_hwtstamps shhwtstamps;
-			u64 *ns = (u64 *)(((uintptr_t)skb->data + 0x10) &
-					  ~0x7UL);
+			__be64 *ns;
+
+			ns = (__be64 *)(((uintptr_t)skb->data + 0x10) & ~0x7UL);
 
 			memset(&shhwtstamps, 0, sizeof(shhwtstamps));
 			shhwtstamps.hwtstamp = ns_to_ktime(be64_to_cpu(*ns));
@@ -2471,7 +2472,7 @@  static void gfar_process_frame(struct net_device *ndev, struct sk_buff *skb)
 	/* Get receive timestamp from the skb */
 	if (priv->hwts_rx_en) {
 		struct skb_shared_hwtstamps *shhwtstamps = skb_hwtstamps(skb);
-		u64 *ns = (u64 *) skb->data;
+		__be64 *ns = (__be64 *)skb->data;
 
 		memset(shhwtstamps, 0, sizeof(*shhwtstamps));
 		shhwtstamps->hwtstamp = ns_to_ktime(be64_to_cpu(*ns));