diff options
author | Ingo Molnar <mingo@kernel.org> | 2012-11-23 13:19:07 -0500 |
---|---|---|
committer | Ingo Molnar <mingo@kernel.org> | 2015-04-20 02:41:37 -0400 |
commit | 94d4b4765b7ddb8478b0d57663cf7a08e2263bbf (patch) | |
tree | 24623ba9c1edeb13d491b036ec8c2c5f7557f953 /arch/x86 | |
parent | a6dfa128ce5c414ab46b1d690f7a1b8decb8526d (diff) |
x86/mm: Clean up types in xlate_dev_mem_ptr()
Pavel Machek reported the following compiler warning on
x86/32 CONFIG_HIGHMEM64G=y builds:
arch/x86/mm/ioremap.c:344:10: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
Clean up the types in this function by using a single natural type for
internal calculations (unsigned long), to make it more apparent what's
happening, and also to remove fragile casts.
Reported-by: Pavel Machek <pavel@ucw.cz>
Cc: jgross@suse.com
Cc: roland@purestorage.com
Link: http://lkml.kernel.org/r/20150416080440.GA507@amd
Signed-off-by: Ingo Molnar <mingo@kernel.org>
Diffstat (limited to 'arch/x86')
-rw-r--r-- | arch/x86/mm/ioremap.c | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/arch/x86/mm/ioremap.c b/arch/x86/mm/ioremap.c index fdf617c00e2f..4bf037b20f47 100644 --- a/arch/x86/mm/ioremap.c +++ b/arch/x86/mm/ioremap.c | |||
@@ -332,18 +332,20 @@ EXPORT_SYMBOL(iounmap); | |||
332 | */ | 332 | */ |
333 | void *xlate_dev_mem_ptr(phys_addr_t phys) | 333 | void *xlate_dev_mem_ptr(phys_addr_t phys) |
334 | { | 334 | { |
335 | void *addr; | 335 | unsigned long start = phys & PAGE_MASK; |
336 | unsigned long start = phys & PAGE_MASK; | 336 | unsigned long offset = phys & ~PAGE_MASK; |
337 | unsigned long vaddr; | ||
337 | 338 | ||
338 | /* If page is RAM, we can use __va. Otherwise ioremap and unmap. */ | 339 | /* If page is RAM, we can use __va. Otherwise ioremap and unmap. */ |
339 | if (page_is_ram(start >> PAGE_SHIFT)) | 340 | if (page_is_ram(start >> PAGE_SHIFT)) |
340 | return __va(phys); | 341 | return __va(phys); |
341 | 342 | ||
342 | addr = (void __force *)ioremap_cache(start, PAGE_SIZE); | 343 | vaddr = (unsigned long)ioremap_cache(start, PAGE_SIZE); |
343 | if (addr) | 344 | /* Only add the offset on success and return NULL if the ioremap() failed: */ |
344 | addr = (void *)((unsigned long)addr | (phys & ~PAGE_MASK)); | 345 | if (vaddr) |
346 | vaddr += offset; | ||
345 | 347 | ||
346 | return addr; | 348 | return (void *)vaddr; |
347 | } | 349 | } |
348 | 350 | ||
349 | void unxlate_dev_mem_ptr(phys_addr_t phys, void *addr) | 351 | void unxlate_dev_mem_ptr(phys_addr_t phys, void *addr) |