IB/mthca: Use DEFINE_MUTEX() instead of mutex_init()
[linux-2.6/kvm.git] / arch / s390 / mm / ioremap.c
blob3d2100a4e2097dc5f52e49f97db94ed7b51e0b28
1 /*
2 * arch/s390/mm/ioremap.c
4 * S390 version
5 * Copyright (C) 1999 IBM Deutschland Entwicklung GmbH, IBM Corporation
6 * Author(s): Hartmut Penner (hp@de.ibm.com)
8 * Derived from "arch/i386/mm/extable.c"
9 * (C) Copyright 1995 1996 Linus Torvalds
11 * Re-map IO memory to kernel address space so that we can access it.
12 * This is needed for high PCI addresses that aren't mapped in the
13 * 640k-1MB IO memory area on PC's
16 #include <linux/vmalloc.h>
17 #include <linux/mm.h>
18 #include <linux/io.h>
19 #include <asm/pgalloc.h>
22 * Generic mapping function (not visible outside):
26 * Remap an arbitrary physical address space into the kernel virtual
27 * address space. Needed when the kernel wants to access high addresses
28 * directly.
30 void * __ioremap(unsigned long phys_addr, unsigned long size, unsigned long flags)
32 void * addr;
33 struct vm_struct * area;
35 if (phys_addr < virt_to_phys(high_memory))
36 return phys_to_virt(phys_addr);
37 if (phys_addr & ~PAGE_MASK)
38 return NULL;
39 size = PAGE_ALIGN(size);
40 if (!size || size > phys_addr + size)
41 return NULL;
42 area = get_vm_area(size, VM_IOREMAP);
43 if (!area)
44 return NULL;
45 addr = area->addr;
46 if (ioremap_page_range((unsigned long)addr, (unsigned long)addr + size,
47 phys_addr, __pgprot(flags))) {
48 vfree(addr);
49 return NULL;
51 return addr;
54 void iounmap(void *addr)
56 if (addr > high_memory)
57 vfree(addr);