Skip to contentSkip to conversation

MIPS: Make phys_to_virt utilize __va()

PATCH Applied Florian Fainelli 3 participants 4 messages Jul 7, 2022 – Jul 11, 2022 MIPS

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 MIPS: Make phys_to_virt utilize __va()

The implementation is exactly the same, so avoid open-coding it in two different locations.

---
 arch/mips/include/asm/io.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/mips/include/asm/io.h +1 -1
index 6f5c86d2bab4..880048a54362 100644
@@ -131,7 +131,7 @@ static inline phys_addr_t virt_to_phys(const volatile void *x)
  */
 static inline void * phys_to_virt(unsigned long address)
 {
-	return (void *)(address + PAGE_OFFSET - PHYS_OFFSET);
+	return __va(address);
 }
 
 /*
Signature · 1 line
2.25.1
Reviewed-by on v1 1/1
#1 lore raw
Quoted 4 lines · Florian Fainelli

The implementation is exactly the same, so avoid open-coding it in two different locations.

Seems reasonable. Thanks.

*Note it now looks exactly as the generic phys_to_virt().

-Sergey

Quoted 20 lines
---
 arch/mips/include/asm/io.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/mips/include/asm/io.h +1 -1
index 6f5c86d2bab4..880048a54362 100644
@@ -131,7 +131,7 @@ static inline phys_addr_t virt_to_phys(const volatile void *x)
  */
 static inline void * phys_to_virt(unsigned long address)
 {
-	return (void *)(address + PAGE_OFFSET - PHYS_OFFSET);
+	return __va(address);
 }
 
 /*
Signature · 1 line
2.25.1
#2 lore raw
Quoted 11 lines · Serge Semin
Quoted 4 lines · Florian Fainelli

The implementation is exactly the same, so avoid open-coding it in two different locations.

Seems reasonable. Thanks.

*Note it now looks exactly as the generic phys_to_virt().

True, though switching to asm-generic/io.h is a slightly bigger undertaking. I will cook something towards that goal however.

Signature · 1 line
Florian
maintainer Applied
#3 lore raw
In reply to Florian Fainelli
Quoted 23 lines · Florian Fainelli

The implementation is exactly the same, so avoid open-coding it in two different locations.

---
 arch/mips/include/asm/io.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/mips/include/asm/io.h +1 -1
index 6f5c86d2bab4..880048a54362 100644
@@ -131,7 +131,7 @@ static inline phys_addr_t virt_to_phys(const volatile void *x)
  */
 static inline void * phys_to_virt(unsigned long address)
 {
-	return (void *)(address + PAGE_OFFSET - PHYS_OFFSET);
+	return __va(address);
 }
 
 /*
Signature · 1 line
2.25.1

applied to mips-next.

Thomas.

Signature · 2 lines
Crap can work. Given enough thrust pigs will fly, but it's not necessarily a
good idea.                                                [ RFC1925, 2.3 ]