From: Ian Pratt This patch adds ARCH_HAS_DEV_MEM, enabling per-architecture implementations of /dev/mem and thus avoids a number of messy #ifdef's. Although the mmap case can be solved easily be simply using io_remap_page_range instead of remap_pfn_range on all architecutres, we need to support read/write of /dev/mem in order for dmidecode etc to work. These changes are more messy, and we believe warrant making /dev/mem arch specific, which also cleans up uncached_access too. Signed-off-by: Ian Pratt Signed-off-by: Andrew Morton --- 25-akpm/drivers/char/mem.c | 11 ++++++++--- 1 files changed, 8 insertions(+), 3 deletions(-) diff -puN drivers/char/mem.c~xen-vmm-4-has_arch_dev_mem drivers/char/mem.c --- 25/drivers/char/mem.c~xen-vmm-4-has_arch_dev_mem 2005-02-28 18:04:43.000000000 -0800 +++ 25-akpm/drivers/char/mem.c 2005-02-28 18:07:50.000000000 -0800 @@ -111,6 +111,7 @@ static inline int valid_phys_addr_range( } #endif +#ifndef ARCH_HAS_DEV_MEM /* * This funcion reads the *physical* memory. The f_pos points directly to the * memory location. @@ -231,8 +232,9 @@ static ssize_t write_mem(struct file * f *ppos += written; return written; } +#endif /* ARCH_HAS_DEV_MEM */ -static int mmap_mem(struct file * file, struct vm_area_struct * vma) +static int mmap_kmem(struct file *file, struct vm_area_struct *vma) { #ifdef pgprot_noncached unsigned long offset = vma->vm_pgoff << PAGE_SHIFT; @@ -399,7 +401,6 @@ do_write_kmem(void *p, unsigned long rea return written; } - /* * This function writes to the *virtual* memory as seen by the kernel. */ @@ -690,7 +691,7 @@ static int open_port(struct inode * inod return capable(CAP_SYS_RAWIO) ? 0 : -EPERM; } -#define mmap_kmem mmap_mem +#define mmap_mem mmap_kmem #define zero_lseek null_lseek #define full_lseek null_lseek #define write_zero write_null @@ -698,6 +699,7 @@ static int open_port(struct inode * inod #define open_mem open_port #define open_kmem open_mem +#ifndef ARCH_HAS_DEV_MEM static struct file_operations mem_fops = { .llseek = memory_lseek, .read = read_mem, @@ -705,6 +707,9 @@ static struct file_operations mem_fops = .mmap = mmap_mem, .open = open_mem, }; +#else +extern struct file_operations mem_fops; +#endif static struct file_operations kmem_fops = { .llseek = memory_lseek, _