ia64/xen-unstable

view linux-2.6-xen-sparse/drivers/xen/util.c @ 13991:c4ed5b740a8d

linux: remove {lock,unlock}_vm_area(). Instead use vmalloc_sync_all()
in alloc_vm_area().
Signed-off-by: Keir Fraser <keir@xensource.com>
author kfraser@localhost.localdomain
date Fri Feb 16 11:24:10 2007 +0000 (2007-02-16)
parents 48c0f5489d44
children c5ff7671b9f2
line source
1 #include <linux/config.h>
2 #include <linux/mm.h>
3 #include <linux/module.h>
4 #include <linux/slab.h>
5 #include <linux/vmalloc.h>
6 #include <asm/uaccess.h>
7 #include <xen/driver_util.h>
9 static int f(pte_t *pte, struct page *pmd_page, unsigned long addr, void *data)
10 {
11 /* apply_to_page_range() does all the hard work. */
12 return 0;
13 }
15 struct vm_struct *alloc_vm_area(unsigned long size)
16 {
17 struct vm_struct *area;
19 area = get_vm_area(size, VM_IOREMAP);
20 if (area == NULL)
21 return NULL;
23 /*
24 * This ensures that page tables are constructed for this region
25 * of kernel virtual address space and mapped into init_mm.
26 */
27 if (apply_to_page_range(&init_mm, (unsigned long)area->addr,
28 area->size, f, NULL)) {
29 free_vm_area(area);
30 return NULL;
31 }
33 /* Map page directories into every address space. */
34 vmalloc_sync_all();
36 return area;
37 }
38 EXPORT_SYMBOL_GPL(alloc_vm_area);
40 void free_vm_area(struct vm_struct *area)
41 {
42 struct vm_struct *ret;
43 ret = remove_vm_area(area->addr);
44 BUG_ON(ret != area);
45 kfree(area);
46 }
47 EXPORT_SYMBOL_GPL(free_vm_area);