[PATCH] x86: asm/io.h: Harden virt_to_phys/isa_virt_to_bus prototypes

From: Stanislav Kinsburskii
Date: Fri Apr 21 2023 - 18:29:32 EST


From: Stanislav Kinsburskii <stanislav.kinsburskii@xxxxxxxxx>

These two helper functions - virt_to_phys and isa_virt_to_bus - don't need the
address pointer to be mutable.

In the same time expecting it to be mutable leads to the following build
warning for constant pointers:

warning: passing argument 1 of ‘virt_to_phys’ discards ‘const’ qualifier from pointer target type

Signed-off-by: Stanislav Kinsburskii <stanislav.kinsburskii@xxxxxxxxx>
CC: Thomas Gleixner <tglx@xxxxxxxxxxxxx>
CC: Ingo Molnar <mingo@xxxxxxxxxx>
CC: Borislav Petkov <bp@xxxxxxxxx>
CC: Dave Hansen <dave.hansen@xxxxxxxxxxxxxxx>
CC: x86@xxxxxxxxxx
CC: "H. Peter Anvin" <hpa@xxxxxxxxx>
CC: Geert Uytterhoeven <geert@xxxxxxxxxxxxxx>
CC: Arnd Bergmann <arnd@xxxxxxxx>
CC: Chris Down <chris@xxxxxxxxxxxxxx>
CC: Helge Deller <deller@xxxxxx>
CC: Omar Sandoval <osandov@xxxxxx>
CC: linux-kernel@xxxxxxxxxxxxxxx
---
arch/x86/include/asm/io.h | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/arch/x86/include/asm/io.h b/arch/x86/include/asm/io.h
index e9025640f634..0e6f5b48f517 100644
--- a/arch/x86/include/asm/io.h
+++ b/arch/x86/include/asm/io.h
@@ -128,7 +128,7 @@ extern int valid_mmap_phys_addr_range(unsigned long pfn, size_t size);
* this function
*/

-static inline phys_addr_t virt_to_phys(volatile void *address)
+static inline phys_addr_t virt_to_phys(const volatile void *address)
{
return __pa(address);
}
@@ -163,7 +163,7 @@ static inline void *phys_to_virt(phys_addr_t address)
* However, we truncate the address to unsigned int to avoid undesirable
* promotions in legacy drivers.
*/
-static inline unsigned int isa_virt_to_bus(volatile void *address)
+static inline unsigned int isa_virt_to_bus(const volatile void *address)
{
return (unsigned int)virt_to_phys(address);
}