diff mbox series

[net-next,2/3] net: ethernet: ti: am65-cpsw: Use __be64 type for id_temp

Message ID 20240910-ti-warn-v1-2-afd1e404abbe@kernel.org (mailing list archive)
State Changes Requested
Delegated to: Netdev Maintainers
Headers show
Series net: ethernet: ti: Address some warnings | expand

Checks

Context Check Description
netdev/series_format success Posting correctly formatted
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: 7 this patch: 7
netdev/build_tools success No tools touched, skip
netdev/cc_maintainers warning 1 maintainers not CCed: jpanis@baylibre.com
netdev/build_clang success Errors and warnings before: 7 this patch: 7
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: 7 this patch: 7
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 8 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-09-12--00-00 (tests: 764)

Commit Message

Simon Horman Sept. 10, 2024, 7:17 a.m. UTC
The id_temp local variable in am65_cpsw_nuss_probe() is
used to hold a 64-bit big-endian value as it is assigned using
cpu_to_be64().

It is read using memcpy(), where it is written as an identifier into a
byte-array.  So this can also be treated as big endian.

As it's type is currently host byte order (u64), sparse flags
an endian mismatch when compiling for little-endian systems:

.../am65-cpsw-nuss.c:3454:17: warning: incorrect type in assignment (different base types)
.../am65-cpsw-nuss.c:3454:17:    expected unsigned long long [usertype] id_temp
.../am65-cpsw-nuss.c:3454:17:    got restricted __be64 [usertype]

Address this by using __be64 as the type of id_temp.

No functional change intended.
Compile tested only.

Signed-off-by: Simon Horman <horms@kernel.org>
---
 drivers/net/ethernet/ti/am65-cpsw-nuss.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Kalesh Anakkur Purayil Sept. 10, 2024, 8:42 a.m. UTC | #1
On Tue, Sep 10, 2024 at 12:48 PM Simon Horman <horms@kernel.org> wrote:
>
> The id_temp local variable in am65_cpsw_nuss_probe() is
> used to hold a 64-bit big-endian value as it is assigned using
> cpu_to_be64().
>
> It is read using memcpy(), where it is written as an identifier into a
> byte-array.  So this can also be treated as big endian.
>
> As it's type is currently host byte order (u64), sparse flags
> an endian mismatch when compiling for little-endian systems:
>
> .../am65-cpsw-nuss.c:3454:17: warning: incorrect type in assignment (different base types)
> .../am65-cpsw-nuss.c:3454:17:    expected unsigned long long [usertype] id_temp
> .../am65-cpsw-nuss.c:3454:17:    got restricted __be64 [usertype]
>
> Address this by using __be64 as the type of id_temp.
>
> No functional change intended.
> Compile tested only.
>
> Signed-off-by: Simon Horman <horms@kernel.org>

Reviewed-by: Kalesh AP <kalesh-anakkur.purayil@broadcom.com>
> ---
>  drivers/net/ethernet/ti/am65-cpsw-nuss.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/net/ethernet/ti/am65-cpsw-nuss.c b/drivers/net/ethernet/ti/am65-cpsw-nuss.c
> index a4b0e4bb7529..9e6353e0361e 100644
> --- a/drivers/net/ethernet/ti/am65-cpsw-nuss.c
> +++ b/drivers/net/ethernet/ti/am65-cpsw-nuss.c
> @@ -3444,7 +3444,7 @@ static int am65_cpsw_nuss_probe(struct platform_device *pdev)
>         struct resource *res;
>         struct clk *clk;
>         int ale_entries;
> -       u64 id_temp;
> +       __be64 id_temp;
>         int ret, i;
>
>         common = devm_kzalloc(dev, sizeof(struct am65_cpsw_common), GFP_KERNEL);
>
> --
> 2.45.2
>
>
Roger Quadros Sept. 12, 2024, 7:10 a.m. UTC | #2
On 10/09/2024 10:17, Simon Horman wrote:
> The id_temp local variable in am65_cpsw_nuss_probe() is
> used to hold a 64-bit big-endian value as it is assigned using
> cpu_to_be64().
> 
> It is read using memcpy(), where it is written as an identifier into a
> byte-array.  So this can also be treated as big endian.
> 
> As it's type is currently host byte order (u64), sparse flags
> an endian mismatch when compiling for little-endian systems:
> 
> .../am65-cpsw-nuss.c:3454:17: warning: incorrect type in assignment (different base types)
> .../am65-cpsw-nuss.c:3454:17:    expected unsigned long long [usertype] id_temp
> .../am65-cpsw-nuss.c:3454:17:    got restricted __be64 [usertype]
> 
> Address this by using __be64 as the type of id_temp.
> 
> No functional change intended.
> Compile tested only.
> 
> Signed-off-by: Simon Horman <horms@kernel.org>

Reviewed-by: Roger Quadros <rogerq@kernel.org>
diff mbox series

Patch

diff --git a/drivers/net/ethernet/ti/am65-cpsw-nuss.c b/drivers/net/ethernet/ti/am65-cpsw-nuss.c
index a4b0e4bb7529..9e6353e0361e 100644
--- a/drivers/net/ethernet/ti/am65-cpsw-nuss.c
+++ b/drivers/net/ethernet/ti/am65-cpsw-nuss.c
@@ -3444,7 +3444,7 @@  static int am65_cpsw_nuss_probe(struct platform_device *pdev)
 	struct resource *res;
 	struct clk *clk;
 	int ale_entries;
-	u64 id_temp;
+	__be64 id_temp;
 	int ret, i;
 
 	common = devm_kzalloc(dev, sizeof(struct am65_cpsw_common), GFP_KERNEL);