uml: physmem code tidying
authorJeff Dike <jdike@addtoit.com>
Tue, 16 Oct 2007 08:26:47 +0000 (01:26 -0700)
committerLinus Torvalds <torvalds@woody.linux-foundation.org>
Tue, 16 Oct 2007 16:43:05 +0000 (09:43 -0700)
Tidying of the UML physical memory system.  These are mostly style fixes,
however the includes were cleaned as well.  This uncovered a need for
mem_user.h to be included in mode_kern_skas.h.

Signed-off-by: Jeff Dike <jdike@linux.intel.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
arch/um/include/skas/mode_kern_skas.h
arch/um/kernel/physmem.c

index 8ee6285dfacc50c4c1650779c6dc25428ee00ad2..c29485109a9a77ae6dbba463c4d32a94e3e88fbc 100644 (file)
@@ -1,5 +1,5 @@
 /*
 /*
- * Copyright (C) 2002 Jeff Dike (jdike@karaya.com)
+ * Copyright (C) 2002 - 2007 Jeff Dike (jdike@{linux.intel,addtoit}.com)
  * Licensed under the GPL
  */
 
  * Licensed under the GPL
  */
 
@@ -9,6 +9,7 @@
 #include "linux/sched.h"
 #include "asm/page.h"
 #include "asm/ptrace.h"
 #include "linux/sched.h"
 #include "asm/page.h"
 #include "asm/ptrace.h"
+#include "mem_user.h"
 
 extern void flush_thread_skas(void);
 extern void switch_to_skas(void *prev, void *next);
 
 extern void flush_thread_skas(void);
 extern void switch_to_skas(void *prev, void *next);
index 8aeac4d9351168e30ba8fc978caf679fce47077d..fb695e48fad70631e0328a65037583c819d0af5e 100644 (file)
@@ -1,25 +1,17 @@
 /*
 /*
- * Copyright (C) 2000 - 2003 Jeff Dike (jdike@addtoit.com)
+ * Copyright (C) 2000 - 2007 Jeff Dike (jdike@{addtoit,linux.intel}.com)
  * Licensed under the GPL
  */
 
  * Licensed under the GPL
  */
 
-#include "linux/mm.h"
-#include "linux/rbtree.h"
-#include "linux/slab.h"
-#include "linux/vmalloc.h"
 #include "linux/bootmem.h"
 #include "linux/bootmem.h"
-#include "linux/module.h"
+#include "linux/mm.h"
 #include "linux/pfn.h"
 #include "linux/pfn.h"
-#include "asm/types.h"
-#include "asm/pgtable.h"
-#include "kern_util.h"
+#include "asm/page.h"
 #include "as-layout.h"
 #include "as-layout.h"
+#include "init.h"
+#include "kern.h"
 #include "mode_kern.h"
 #include "mode_kern.h"
-#include "mem.h"
-#include "mem_user.h"
 #include "os.h"
 #include "os.h"
-#include "kern.h"
-#include "init.h"
 
 static int physmem_fd = -1;
 
 
 static int physmem_fd = -1;
 
@@ -49,10 +41,10 @@ int __init init_maps(unsigned long physmem, unsigned long iomem,
        total_len = phys_len + iomem_len + highmem_len;
 
        map = alloc_bootmem_low_pages(total_len);
        total_len = phys_len + iomem_len + highmem_len;
 
        map = alloc_bootmem_low_pages(total_len);
-       if(map == NULL)
+       if (map == NULL)
                return -ENOMEM;
 
                return -ENOMEM;
 
-       for(i = 0; i < total_pages; i++){
+       for (i = 0; i < total_pages; i++) {
                p = &map[i];
                memset(p, 0, sizeof(struct page));
                SetPageReserved(p);
                p = &map[i];
                memset(p, 0, sizeof(struct page));
                SetPageReserved(p);
@@ -68,7 +60,7 @@ static unsigned long kmem_top = 0;
 
 unsigned long get_kmem_end(void)
 {
 
 unsigned long get_kmem_end(void)
 {
-       if(kmem_top == 0)
+       if (kmem_top == 0)
                kmem_top = CHOOSE_MODE(kmem_end_tt, kmem_end_skas);
        return kmem_top;
 }
                kmem_top = CHOOSE_MODE(kmem_end_tt, kmem_end_skas);
        return kmem_top;
 }
@@ -81,8 +73,8 @@ void map_memory(unsigned long virt, unsigned long phys, unsigned long len,
 
        fd = phys_mapping(phys, &offset);
        err = os_map_memory((void *) virt, fd, offset, len, r, w, x);
 
        fd = phys_mapping(phys, &offset);
        err = os_map_memory((void *) virt, fd, offset, len, r, w, x);
-       if(err) {
-               if(err == -ENOMEM)
+       if (err) {
+               if (err == -ENOMEM)
                        printk("try increasing the host's "
                               "/proc/sys/vm/max_map_count to <physical "
                               "memory size>/4096\n");
                        printk("try increasing the host's "
                               "/proc/sys/vm/max_map_count to <physical "
                               "memory size>/4096\n");
@@ -106,7 +98,7 @@ void __init setup_physmem(unsigned long start, unsigned long reserve_end,
        offset = uml_reserved - uml_physmem;
        err = os_map_memory((void *) uml_reserved, physmem_fd, offset,
                            len - offset, 1, 1, 1);
        offset = uml_reserved - uml_physmem;
        err = os_map_memory((void *) uml_reserved, physmem_fd, offset,
                            len - offset, 1, 1, 1);
-       if(err < 0){
+       if (err < 0) {
                os_print_error(err, "Mapping memory");
                exit(1);
        }
                os_print_error(err, "Mapping memory");
                exit(1);
        }
@@ -126,16 +118,16 @@ int phys_mapping(unsigned long phys, __u64 *offset_out)
 {
        int fd = -1;
 
 {
        int fd = -1;
 
-       if(phys < physmem_size){
+       if (phys < physmem_size) {
                fd = physmem_fd;
                *offset_out = phys;
        }
                fd = physmem_fd;
                *offset_out = phys;
        }
-       else if(phys < __pa(end_iomem)){
+       else if (phys < __pa(end_iomem)) {
                struct iomem_region *region = iomem_regions;
 
                struct iomem_region *region = iomem_regions;
 
-               while(region != NULL){
-                       if((phys >= region->phys) &&
-                          (phys < region->phys + region->size)){
+               while (region != NULL) {
+                       if ((phys >= region->phys) &&
+                           (phys < region->phys + region->size)) {
                                fd = region->fd;
                                *offset_out = phys - region->phys;
                                break;
                                fd = region->fd;
                                *offset_out = phys - region->phys;
                                break;
@@ -143,7 +135,7 @@ int phys_mapping(unsigned long phys, __u64 *offset_out)
                        region = region->next;
                }
        }
                        region = region->next;
                }
        }
-       else if(phys < __pa(end_iomem) + highmem){
+       else if (phys < __pa(end_iomem) + highmem) {
                fd = physmem_fd;
                *offset_out = phys - iomem_size;
        }
                fd = physmem_fd;
                *offset_out = phys - iomem_size;
        }
@@ -188,8 +180,8 @@ unsigned long find_iomem(char *driver, unsigned long *len_out)
 {
        struct iomem_region *region = iomem_regions;
 
 {
        struct iomem_region *region = iomem_regions;
 
-       while(region != NULL){
-               if(!strcmp(region->driver, driver)){
+       while (region != NULL) {
+               if (!strcmp(region->driver, driver)) {
                        *len_out = region->size;
                        return region->virt;
                }
                        *len_out = region->size;
                        return region->virt;
                }
@@ -206,10 +198,10 @@ int setup_iomem(void)
        unsigned long iomem_start = high_physmem + PAGE_SIZE;
        int err;
 
        unsigned long iomem_start = high_physmem + PAGE_SIZE;
        int err;
 
-       while(region != NULL){
+       while (region != NULL) {
                err = os_map_memory((void *) iomem_start, region->fd, 0,
                                    region->size, 1, 1, 0);
                err = os_map_memory((void *) iomem_start, region->fd, 0,
                                    region->size, 1, 1, 0);
-               if(err)
+               if (err)
                        printk("Mapping iomem region for driver '%s' failed, "
                               "errno = %d\n", region->driver, -err);
                else {
                        printk("Mapping iomem region for driver '%s' failed, "
                               "errno = %d\n", region->driver, -err);
                else {