Skip to content

Commit ca5a45c

Browse files
author
Santosh Shilimkar
committed
ARM: mm: use phys_addr_t appropriately in p2v and v2p conversions
Fix remainder types used when converting back and forth between physical and virtual addresses. Cc: Russell King <linux@arm.linux.org.uk> Acked-by: Nicolas Pitre <nico@linaro.org> Signed-off-by: Santosh Shilimkar <santosh.shilimkar@ti.com>
1 parent 4a10c2a commit ca5a45c

File tree

1 file changed

+16
-6
lines changed

1 file changed

+16
-6
lines changed

arch/arm/include/asm/memory.h

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -185,22 +185,32 @@ extern unsigned long __pv_phys_offset;
185185
: "=r" (to) \
186186
: "r" (from), "I" (type))
187187

188-
static inline unsigned long __virt_to_phys(unsigned long x)
188+
static inline phys_addr_t __virt_to_phys(unsigned long x)
189189
{
190190
unsigned long t;
191191
__pv_stub(x, t, "add", __PV_BITS_31_24);
192192
return t;
193193
}
194194

195-
static inline unsigned long __phys_to_virt(unsigned long x)
195+
static inline unsigned long __phys_to_virt(phys_addr_t x)
196196
{
197197
unsigned long t;
198198
__pv_stub(x, t, "sub", __PV_BITS_31_24);
199199
return t;
200200
}
201+
201202
#else
202-
#define __virt_to_phys(x) ((x) - PAGE_OFFSET + PHYS_OFFSET)
203-
#define __phys_to_virt(x) ((x) - PHYS_OFFSET + PAGE_OFFSET)
203+
204+
static inline phys_addr_t __virt_to_phys(unsigned long x)
205+
{
206+
return (phys_addr_t)x - PAGE_OFFSET + PHYS_OFFSET;
207+
}
208+
209+
static inline unsigned long __phys_to_virt(phys_addr_t x)
210+
{
211+
return x - PHYS_OFFSET + PAGE_OFFSET;
212+
}
213+
204214
#endif
205215
#endif
206216
#endif /* __ASSEMBLY__ */
@@ -238,14 +248,14 @@ static inline phys_addr_t virt_to_phys(const volatile void *x)
238248

239249
static inline void *phys_to_virt(phys_addr_t x)
240250
{
241-
return (void *)(__phys_to_virt((unsigned long)(x)));
251+
return (void *)__phys_to_virt(x);
242252
}
243253

244254
/*
245255
* Drivers should NOT use these either.
246256
*/
247257
#define __pa(x) __virt_to_phys((unsigned long)(x))
248-
#define __va(x) ((void *)__phys_to_virt((unsigned long)(x)))
258+
#define __va(x) ((void *)__phys_to_virt((phys_addr_t)(x)))
249259
#define pfn_to_kaddr(pfn) __va((pfn) << PAGE_SHIFT)
250260

251261
/*

0 commit comments

Comments
 (0)