提交 e66aadbe 编写于 作者: T Thomas Gleixner 提交者: Ingo Molnar

x86: simplify __ioremap

Remove tons of castings which make the code hard to read.
Signed-off-by: NThomas Gleixner <tglx@linutronix.de>
Signed-off-by: NIngo Molnar <mingo@elte.hu>
上级 63c1dcf4
...@@ -114,9 +114,8 @@ static int ioremap_change_attr(unsigned long paddr, unsigned long size, ...@@ -114,9 +114,8 @@ static int ioremap_change_attr(unsigned long paddr, unsigned long size,
static void __iomem *__ioremap(unsigned long phys_addr, unsigned long size, static void __iomem *__ioremap(unsigned long phys_addr, unsigned long size,
enum ioremap_mode mode) enum ioremap_mode mode)
{ {
void __iomem *addr; unsigned long pfn, offset, last_addr, vaddr;
struct vm_struct *area; struct vm_struct *area;
unsigned long pfn, offset, last_addr;
pgprot_t prot; pgprot_t prot;
/* Don't allow wraparound or zero size */ /* Don't allow wraparound or zero size */
...@@ -164,19 +163,18 @@ static void __iomem *__ioremap(unsigned long phys_addr, unsigned long size, ...@@ -164,19 +163,18 @@ static void __iomem *__ioremap(unsigned long phys_addr, unsigned long size,
if (!area) if (!area)
return NULL; return NULL;
area->phys_addr = phys_addr; area->phys_addr = phys_addr;
addr = (void __iomem *) area->addr; vaddr = (unsigned long) area->addr;
if (ioremap_page_range((unsigned long)addr, (unsigned long)addr + size, if (ioremap_page_range(vaddr, vaddr + size, phys_addr, prot)) {
phys_addr, prot)) { remove_vm_area((void *)(vaddr & PAGE_MASK));
remove_vm_area((void *)(PAGE_MASK & (unsigned long) addr));
return NULL; return NULL;
} }
if (ioremap_change_attr(phys_addr, size, mode) < 0) { if (ioremap_change_attr(phys_addr, size, mode) < 0) {
vunmap(addr); vunmap(area->addr);
return NULL; return NULL;
} }
return (void __iomem *) (offset + (char __iomem *)addr); return (void __iomem *) (vaddr + offset);
} }
/** /**
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册