Fixing "int-to-pointer-cast" warning in J2 code

John Paul Adrian Glaubitz <[email protected]>
Newsgroups gmane.linux.ports.sh.devel
Message-ID <eed749a0ec500edf4f70a50578eaa50803fdaf3c.camel@physik.fu-berlin.de>
Hi!

When building j2_defconfig, the following warning is issued:

arch/sh/kernel/cpu/sh2/probe.c: In function 'scan_cache':
arch/sh/kernel/cpu/sh2/probe.c:24:16: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
   24 |  j2_ccr_base = (u32 __iomem *)of_flat_dt_translate_address(node);
      |

Reading the code and look how other users of of_flat_dt_translate_address()
used the return code, I came up with the following patch which fixes the issue:

diff --git a/arch/sh/kernel/cpu/sh2/probe.c b/arch/sh/kernel/cpu/sh2/probe.c
index d342ea08843f..a0dc3675fc68 100644
--- a/arch/sh/kernel/cpu/sh2/probe.c
+++ b/arch/sh/kernel/cpu/sh2/probe.c
@@ -14,14 +14,14 @@
 #include <asm/cache.h>
 
 #if defined(CONFIG_CPU_J2)
-extern u32 __iomem *j2_ccr_base;
+extern phys_addr_t j2_ccr_base;
 static int __init scan_cache(unsigned long node, const char *uname,
                             int depth, void *data)
 {
        if (!of_flat_dt_is_compatible(node, "jcore,cache"))
                return 0;
 
-       j2_ccr_base = (u32 __iomem *)of_flat_dt_translate_address(node);
+       j2_ccr_base = of_flat_dt_translate_address(node);
 
        return 1;
 }
diff --git a/arch/sh/mm/cache-j2.c b/arch/sh/mm/cache-j2.c
index f277862a11f5..2bc6d38d6f7c 100644
--- a/arch/sh/mm/cache-j2.c
+++ b/arch/sh/mm/cache-j2.c
@@ -22,7 +22,7 @@
 #define DCACHE_FLUSH   0x200
 #define CACHE_FLUSH    (ICACHE_FLUSH | DCACHE_FLUSH)
 
-u32 __iomem *j2_ccr_base;
+phys_addr_t j2_ccr_base;
 
 static void j2_flush_icache(void *args)
 {

Does that look reasonable?

Adrian

-- 
 .''`.  John Paul Adrian Glaubitz
: :' :  Debian Developer
`. `'   Physicist
  `-    GPG: 62FF 8A75 84E0 2956 9546  0006 7426 3B37 F5B5 F913
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.