From 9938424f0c4d208883cbf32083ec2bfcc220f85b Mon Sep 17 00:00:00 2001 From: Richard Cochran Date: Mon, 14 Jun 2010 18:10:33 +0200 Subject: mtd: add an ioctl to query the lock status of a flash sector This patchs adds a way for user space programs to find out whether a flash sector is locked. An optional driver method in the mtd_info struct provides the information. Signed-off-by: Richard Cochran Signed-off-by: Artem Bityutskiy Signed-off-by: David Woodhouse --- drivers/mtd/mtdchar.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'drivers/mtd/mtdchar.c') diff --git a/drivers/mtd/mtdchar.c b/drivers/mtd/mtdchar.c index 8b223c0343ee..a8e69dd2b2e4 100644 --- a/drivers/mtd/mtdchar.c +++ b/drivers/mtd/mtdchar.c @@ -676,6 +676,20 @@ static int mtd_ioctl(struct inode *inode, struct file *file, break; } + case MEMISLOCKED: + { + struct erase_info_user einfo; + + if (copy_from_user(&einfo, argp, sizeof(einfo))) + return -EFAULT; + + if (!mtd->is_locked) + ret = -EOPNOTSUPP; + else + ret = mtd->is_locked(mtd, einfo.start, einfo.length); + break; + } + /* Legacy interface */ case MEMGETOOBSEL: { -- cgit v1.2.1 From dd02b67d5e9e7896891fa27eb5db65f55a290998 Mon Sep 17 00:00:00 2001 From: Anatolij Gustschin Date: Tue, 15 Jun 2010 09:30:15 +0200 Subject: mtd: mtdchar: fix mmap for MTD RAM/ROM char devices For no-mmu systems mmap() on RAM/ROM devices already works but for systems with mmu it probably was not tested and doesn't work. This patch allows using mmap() on MTD RAM/ROM devices on systems with MMU. It has been tested on mpc5121e based platform with MR0A16A MRAM device attached over LocalBus. Signed-off-by: Anatolij Gustschin Acked-by: Mike Frysinger Signed-off-by: David Woodhouse --- drivers/mtd/mtdchar.c | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) (limited to 'drivers/mtd/mtdchar.c') diff --git a/drivers/mtd/mtdchar.c b/drivers/mtd/mtdchar.c index a8e69dd2b2e4..c27e65e3e291 100644 --- a/drivers/mtd/mtdchar.c +++ b/drivers/mtd/mtdchar.c @@ -18,6 +18,7 @@ #include #include +#include #include #include @@ -955,9 +956,34 @@ static int mtd_mmap(struct file *file, struct vm_area_struct *vma) #ifdef CONFIG_MMU struct mtd_file_info *mfi = file->private_data; struct mtd_info *mtd = mfi->mtd; + struct map_info *map = mtd->priv; + unsigned long start; + unsigned long off; + u32 len; + + if (mtd->type == MTD_RAM || mtd->type == MTD_ROM) { + off = vma->vm_pgoff << PAGE_SHIFT; + start = map->phys; + len = PAGE_ALIGN((start & ~PAGE_MASK) + map->size); + start &= PAGE_MASK; + if ((vma->vm_end - vma->vm_start + off) > len) + return -EINVAL; + + off += start; + vma->vm_pgoff = off >> PAGE_SHIFT; + vma->vm_flags |= VM_IO | VM_RESERVED; + +#ifdef pgprot_noncached + if (file->f_flags & O_DSYNC || off >= __pa(high_memory)) + vma->vm_page_prot = pgprot_noncached(vma->vm_page_prot); +#endif + if (io_remap_pfn_range(vma, vma->vm_start, off >> PAGE_SHIFT, + vma->vm_end - vma->vm_start, + vma->vm_page_prot)) + return -EAGAIN; - if (mtd->type == MTD_RAM || mtd->type == MTD_ROM) return 0; + } return -ENOSYS; #else return vma->vm_flags & VM_SHARED ? 0 : -ENOSYS; -- cgit v1.2.1 From a1452a3771c4eb85bd779790b040efdc36f4274e Mon Sep 17 00:00:00 2001 From: David Woodhouse Date: Sun, 8 Aug 2010 20:58:20 +0100 Subject: mtd: Update copyright notices Signed-off-by: David Woodhouse --- drivers/mtd/mtdchar.c | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) (limited to 'drivers/mtd/mtdchar.c') diff --git a/drivers/mtd/mtdchar.c b/drivers/mtd/mtdchar.c index c27e65e3e291..f6d76f1adca0 100644 --- a/drivers/mtd/mtdchar.c +++ b/drivers/mtd/mtdchar.c @@ -1,5 +1,19 @@ /* - * Character-device access to raw MTD devices. + * Copyright © 1999-2010 David Woodhouse + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA * */ -- cgit v1.2.1 From 6ae0185fe201eae0548dace2a84acb5050fc8606 Mon Sep 17 00:00:00 2001 From: David Woodhouse Date: Sun, 8 Aug 2010 21:19:42 +0100 Subject: mtd: Remove obsolete include Signed-off-by: David Woodhouse --- drivers/mtd/mtdchar.c | 1 - 1 file changed, 1 deletion(-) (limited to 'drivers/mtd/mtdchar.c') diff --git a/drivers/mtd/mtdchar.c b/drivers/mtd/mtdchar.c index f6d76f1adca0..638827a25b77 100644 --- a/drivers/mtd/mtdchar.c +++ b/drivers/mtd/mtdchar.c @@ -33,7 +33,6 @@ #include #include -#include #include -- cgit v1.2.1