aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorBjorn Helgaas <bjorn.helgaas@hp.com>2006-03-26 04:37:05 -0500
committerLinus Torvalds <torvalds@g5.osdl.org>2006-03-26 11:56:54 -0500
commit136939a2b5aa4302281215745ccd567e1df2e8d4 (patch)
tree384841deada5b0ceb44c255e0474866bbc8d3354 /drivers
parent3ed3bce846abc7ef460104b461cac793e41afe5e (diff)
[PATCH] EFI, /dev/mem: simplify efi_mem_attribute_range()
Pass the size, not a pointer to the size, to efi_mem_attribute_range(). This function validates memory regions for the /dev/mem read/write/mmap paths. The pointer allows arches to reduce the size of the range, but I think that's unnecessary complexity. Simplifying it will let me use efi_mem_attribute_range() to improve the ia64 ioremap() implementation. Signed-off-by: Bjorn Helgaas <bjorn.helgaas@hp.com> Cc: Matt Domsch <Matt_Domsch@dell.com> Cc: "Tolentino, Matthew E" <matthew.e.tolentino@intel.com> Cc: "Brown, Len" <len.brown@intel.com> Cc: Andi Kleen <ak@muc.de> Acked-by: "Luck, Tony" <tony.luck@intel.com> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/char/mem.c18
1 files changed, 6 insertions, 12 deletions
diff --git a/drivers/char/mem.c b/drivers/char/mem.c
index 26d0116b48d4..5245ba1649ed 100644
--- a/drivers/char/mem.c
+++ b/drivers/char/mem.c
@@ -88,21 +88,15 @@ static inline int uncached_access(struct file *file, unsigned long addr)
88} 88}
89 89
90#ifndef ARCH_HAS_VALID_PHYS_ADDR_RANGE 90#ifndef ARCH_HAS_VALID_PHYS_ADDR_RANGE
91static inline int valid_phys_addr_range(unsigned long addr, size_t *count) 91static inline int valid_phys_addr_range(unsigned long addr, size_t count)
92{ 92{
93 unsigned long end_mem; 93 if (addr + count > __pa(high_memory))
94
95 end_mem = __pa(high_memory);
96 if (addr >= end_mem)
97 return 0; 94 return 0;
98 95
99 if (*count > end_mem - addr)
100 *count = end_mem - addr;
101
102 return 1; 96 return 1;
103} 97}
104 98
105static inline int valid_mmap_phys_addr_range(unsigned long addr, size_t *size) 99static inline int valid_mmap_phys_addr_range(unsigned long addr, size_t size)
106{ 100{
107 return 1; 101 return 1;
108} 102}
@@ -119,7 +113,7 @@ static ssize_t read_mem(struct file * file, char __user * buf,
119 ssize_t read, sz; 113 ssize_t read, sz;
120 char *ptr; 114 char *ptr;
121 115
122 if (!valid_phys_addr_range(p, &count)) 116 if (!valid_phys_addr_range(p, count))
123 return -EFAULT; 117 return -EFAULT;
124 read = 0; 118 read = 0;
125#ifdef __ARCH_HAS_NO_PAGE_ZERO_MAPPED 119#ifdef __ARCH_HAS_NO_PAGE_ZERO_MAPPED
@@ -177,7 +171,7 @@ static ssize_t write_mem(struct file * file, const char __user * buf,
177 unsigned long copied; 171 unsigned long copied;
178 void *ptr; 172 void *ptr;
179 173
180 if (!valid_phys_addr_range(p, &count)) 174 if (!valid_phys_addr_range(p, count))
181 return -EFAULT; 175 return -EFAULT;
182 176
183 written = 0; 177 written = 0;
@@ -249,7 +243,7 @@ static int mmap_mem(struct file * file, struct vm_area_struct * vma)
249{ 243{
250 size_t size = vma->vm_end - vma->vm_start; 244 size_t size = vma->vm_end - vma->vm_start;
251 245
252 if (!valid_mmap_phys_addr_range(vma->vm_pgoff << PAGE_SHIFT, &size)) 246 if (!valid_mmap_phys_addr_range(vma->vm_pgoff << PAGE_SHIFT, size))
253 return -EINVAL; 247 return -EINVAL;
254 248
255 vma->vm_page_prot = phys_mem_access_prot(file, vma->vm_pgoff, 249 vma->vm_page_prot = phys_mem_access_prot(file, vma->vm_pgoff,