of: Make explicit cpu_to_be32 conversion to mute sparse warning

Message ID 20240205024033.3572617-1-dawei.li@shingroup.cn
State New
Headers
Series of: Make explicit cpu_to_be32 conversion to mute sparse warning |

Commit Message

Dawei Li Feb. 5, 2024, 2:40 a.m. UTC
  Kernel test robot reports sparse warning:
sparse warnings: (new ones prefixed by >>)
>> drivers/of/base.c:1337:73: sparse: sparse: incorrect type in initializer
   (different base types) @@  expected restricted __be32 @@  got int @@
   drivers/of/base.c:1337:73: sparse:     expected restricted __be32
   drivers/of/base.c:1337:73: sparse:     got int

Thus, Make explicit conversions to mute warning(Although BE and LE are
exactly same in binary representation for 0/~0).

Reported-by: kernel test robot <lkp@intel.com>
Closes: https://lore.kernel.org/oe-kbuild-all/202402042134.GEb3Bgwl-lkp@intel.com/
Signed-off-by: Dawei Li <dawei.li@shingroup.cn>
---
 drivers/of/base.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
  

Comments

Rob Herring Feb. 13, 2024, 2:44 p.m. UTC | #1
On Mon, 05 Feb 2024 10:40:33 +0800, Dawei Li wrote:
> Kernel test robot reports sparse warning:
> sparse warnings: (new ones prefixed by >>)
> >> drivers/of/base.c:1337:73: sparse: sparse: incorrect type in initializer
>    (different base types) @@  expected restricted __be32 @@  got int @@
>    drivers/of/base.c:1337:73: sparse:     expected restricted __be32
>    drivers/of/base.c:1337:73: sparse:     got int
> 
> Thus, Make explicit conversions to mute warning(Although BE and LE are
> exactly same in binary representation for 0/~0).
> 
> Reported-by: kernel test robot <lkp@intel.com>
> Closes: https://lore.kernel.org/oe-kbuild-all/202402042134.GEb3Bgwl-lkp@intel.com/
> Signed-off-by: Dawei Li <dawei.li@shingroup.cn>
> ---
>  drivers/of/base.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 

Applied, thanks!
  

Patch

diff --git a/drivers/of/base.c b/drivers/of/base.c
index b0ad8fc06e80..f71cda9ac09d 100644
--- a/drivers/of/base.c
+++ b/drivers/of/base.c
@@ -1345,8 +1345,8 @@  int of_parse_phandle_with_args_map(const struct device_node *np,
 	char *pass_name = NULL;
 	struct device_node *cur, *new = NULL;
 	const __be32 *map, *mask, *pass;
-	static const __be32 dummy_mask[] = { [0 ... MAX_PHANDLE_ARGS] = ~0 };
-	static const __be32 dummy_pass[] = { [0 ... MAX_PHANDLE_ARGS] = 0 };
+	static const __be32 dummy_mask[] = { [0 ... MAX_PHANDLE_ARGS] = cpu_to_be32(~0) };
+	static const __be32 dummy_pass[] = { [0 ... MAX_PHANDLE_ARGS] = cpu_to_be32(0) };
 	__be32 initial_match_array[MAX_PHANDLE_ARGS];
 	const __be32 *match_array = initial_match_array;
 	int i, ret, map_len, match;