[PATCH] staging: octeon: cvmx_ptr_to_phys() should return physaddr_t

From: Geert Uytterhoeven
Date: Tue Nov 01 2022 - 04:01:51 EST


On 32-bit without physical address extensions (e.g. sh-allmodconfig):

drivers/staging/octeon/ethernet-mem.c: In function ‘cvm_oct_free_hw_memory’:
./arch/sh/include/asm/io.h:239:32: error: cast to pointer from integer of different size [-Werror=int-to-pointer-cast]
239 | #define phys_to_virt(address) ((void *)(address))
| ^
drivers/staging/octeon/ethernet-mem.c:123:18: note: in expansion of macro ‘phys_to_virt’
123 | fpa = (char *)phys_to_virt(cvmx_ptr_to_phys(fpa));
| ^~~~~~~~~~~~

Fix this by making cvmx_ptr_to_phys() return physaddr_t instead of
uint64_t.

Signed-off-by: Geert Uytterhoeven <geert@xxxxxxxxxxxxxx>
---
Compile-tested only (sh, mips allmodconfig, mips
allmodconfig+CONFIG_CAVIUM_OCTEON_=y)
---
arch/mips/include/asm/octeon/cvmx.h | 4 ++--
drivers/staging/octeon/octeon-stubs.h | 2 +-
2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/arch/mips/include/asm/octeon/cvmx.h b/arch/mips/include/asm/octeon/cvmx.h
index 25854abc95f8a2cd..72e775bf31e6008b 100644
--- a/arch/mips/include/asm/octeon/cvmx.h
+++ b/arch/mips/include/asm/octeon/cvmx.h
@@ -154,13 +154,13 @@ static inline uint64_t cvmx_build_bits(uint64_t high_bit,

/**
* Convert a memory pointer (void*) into a hardware compatible
- * memory address (uint64_t). Octeon hardware widgets don't
+ * memory address (phys_addr_t). Octeon hardware widgets don't
* understand logical addresses.
*
* @ptr: C style memory pointer
* Returns Hardware physical address
*/
-static inline uint64_t cvmx_ptr_to_phys(void *ptr)
+static inline phys_addr_t cvmx_ptr_to_phys(void *ptr)
{
if (sizeof(void *) == 8) {
/*
diff --git a/drivers/staging/octeon/octeon-stubs.h b/drivers/staging/octeon/octeon-stubs.h
index 3f8e5713b8a850f0..7a02e59e283fbae8 100644
--- a/drivers/staging/octeon/octeon-stubs.h
+++ b/drivers/staging/octeon/octeon-stubs.h
@@ -1212,7 +1212,7 @@ static inline void *cvmx_phys_to_ptr(uint64_t physical_address)
return (void *)(uintptr_t)(physical_address);
}

-static inline uint64_t cvmx_ptr_to_phys(void *ptr)
+static inline phys_addr_t cvmx_ptr_to_phys(void *ptr)
{
return (unsigned long)ptr;
}
--
2.25.1