aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/mtd/mtdchar.c
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2010-08-10 14:49:21 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2010-08-10 14:49:21 -0400
commite8a89cebdbaab14caaa26debdb4ffd493b8831af (patch)
treee0843f082628408ce259c72db36da54dff603987 /drivers/mtd/mtdchar.c
parent8196867c74890ccdf40a2b5e3e173597fbc4f9ac (diff)
parent6ae0185fe201eae0548dace2a84acb5050fc8606 (diff)
Merge git://git.infradead.org/mtd-2.6
* git://git.infradead.org/mtd-2.6: (79 commits) mtd: Remove obsolete <mtd/compatmac.h> include mtd: Update copyright notices jffs2: Update copyright notices mtd-physmap: add support users can assign the probe type in board files mtd: remove redwood map driver mxc_nand: Add v3 (i.MX51) Support mxc_nand: support 8bit ecc mxc_nand: fix correct_data function mxc_nand: add V1_V2 namespace to registers mxc_nand: factor out a check_int function mxc_nand: make some internally used functions overwriteable mxc_nand: rework get_dev_status mxc_nand: remove 0xe00 offset from registers mtd: denali: Add multi connected NAND support mtd: denali: Remove set_ecc_config function mtd: denali: Remove unuseful code in get_xx_nand_para functions mtd: denali: Remove device_info_tag structure mtd: m25p80: add support for the Winbond W25Q32 SPI flash chip mtd: m25p80: add support for the Intel/Numonyx {16,32,64}0S33B SPI flash chips mtd: m25p80: add support for the EON EN25P{32, 64} SPI flash chips ... Fix up trivial conflicts in drivers/mtd/maps/{Kconfig,redwood.c} due to redwood driver removal.
Diffstat (limited to 'drivers/mtd/mtdchar.c')
-rw-r--r--drivers/mtd/mtdchar.c59
1 files changed, 56 insertions, 3 deletions
diff --git a/drivers/mtd/mtdchar.c b/drivers/mtd/mtdchar.c
index 91c8013cf0d9..a825002123c8 100644
--- a/drivers/mtd/mtdchar.c
+++ b/drivers/mtd/mtdchar.c
@@ -1,5 +1,19 @@
1/* 1/*
2 * Character-device access to raw MTD devices. 2 * Copyright © 1999-2010 David Woodhouse <dwmw2@infradead.org>
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
3 * 17 *
4 */ 18 */
5 19
@@ -18,7 +32,7 @@
18#include <linux/mount.h> 32#include <linux/mount.h>
19 33
20#include <linux/mtd/mtd.h> 34#include <linux/mtd/mtd.h>
21#include <linux/mtd/compatmac.h> 35#include <linux/mtd/map.h>
22 36
23#include <asm/uaccess.h> 37#include <asm/uaccess.h>
24 38
@@ -675,6 +689,20 @@ static int mtd_ioctl(struct file *file, u_int cmd, u_long arg)
675 break; 689 break;
676 } 690 }
677 691
692 case MEMISLOCKED:
693 {
694 struct erase_info_user einfo;
695
696 if (copy_from_user(&einfo, argp, sizeof(einfo)))
697 return -EFAULT;
698
699 if (!mtd->is_locked)
700 ret = -EOPNOTSUPP;
701 else
702 ret = mtd->is_locked(mtd, einfo.start, einfo.length);
703 break;
704 }
705
678 /* Legacy interface */ 706 /* Legacy interface */
679 case MEMGETOOBSEL: 707 case MEMGETOOBSEL:
680 { 708 {
@@ -950,9 +978,34 @@ static int mtd_mmap(struct file *file, struct vm_area_struct *vma)
950#ifdef CONFIG_MMU 978#ifdef CONFIG_MMU
951 struct mtd_file_info *mfi = file->private_data; 979 struct mtd_file_info *mfi = file->private_data;
952 struct mtd_info *mtd = mfi->mtd; 980 struct mtd_info *mtd = mfi->mtd;
981 struct map_info *map = mtd->priv;
982 unsigned long start;
983 unsigned long off;
984 u32 len;
985
986 if (mtd->type == MTD_RAM || mtd->type == MTD_ROM) {
987 off = vma->vm_pgoff << PAGE_SHIFT;
988 start = map->phys;
989 len = PAGE_ALIGN((start & ~PAGE_MASK) + map->size);
990 start &= PAGE_MASK;
991 if ((vma->vm_end - vma->vm_start + off) > len)
992 return -EINVAL;
993
994 off += start;
995 vma->vm_pgoff = off >> PAGE_SHIFT;
996 vma->vm_flags |= VM_IO | VM_RESERVED;
997
998#ifdef pgprot_noncached
999 if (file->f_flags & O_DSYNC || off >= __pa(high_memory))
1000 vma->vm_page_prot = pgprot_noncached(vma->vm_page_prot);
1001#endif
1002 if (io_remap_pfn_range(vma, vma->vm_start, off >> PAGE_SHIFT,
1003 vma->vm_end - vma->vm_start,
1004 vma->vm_page_prot))
1005 return -EAGAIN;
953 1006
954 if (mtd->type == MTD_RAM || mtd->type == MTD_ROM)
955 return 0; 1007 return 0;
1008 }
956 return -ENOSYS; 1009 return -ENOSYS;
957#else 1010#else
958 return vma->vm_flags & VM_SHARED ? 0 : -ENOSYS; 1011 return vma->vm_flags & VM_SHARED ? 0 : -ENOSYS;