* [PATCH] mtdchar: allow mmap() on MTD RAM/ROM char devices
@ 2010-04-16 15:41 Anatolij Gustschin
2010-04-28 13:25 ` Artem Bityutskiy
0 siblings, 1 reply; 6+ messages in thread
From: Anatolij Gustschin @ 2010-04-16 15:41 UTC (permalink / raw)
To: linux-mtd
Cc: Artem Bityutskiy, Anatolij Gustschin, David Woodhouse, Detlev Zundel
Signed-off-by: Anatolij Gustschin <agust@denx.de>
---
drivers/mtd/mtdchar.c | 29 ++++++++++++++++++++++++++++-
1 files changed, 28 insertions(+), 1 deletions(-)
diff --git a/drivers/mtd/mtdchar.c b/drivers/mtd/mtdchar.c
index c355491..416f6eb 100644
--- a/drivers/mtd/mtdchar.c
+++ b/drivers/mtd/mtdchar.c
@@ -17,6 +17,7 @@
#include <linux/compat.h>
#include <linux/mtd/mtd.h>
+#include <linux/mtd/map.h>
#include <linux/mtd/compatmac.h>
#include <asm/uaccess.h>
@@ -925,9 +926,35 @@ 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) {
+ if (vma->vm_pgoff > (~0UL >> PAGE_SHIFT))
+ return -EINVAL;
+ 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;
+ vma->vm_page_prot =
+ phys_mem_access_prot(file, off >> PAGE_SHIFT,
+ vma->vm_end - vma->vm_start,
+ vma->vm_page_prot);
+ 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;
--
1.6.3.3
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH] mtdchar: allow mmap() on MTD RAM/ROM char devices
2010-04-16 15:41 [PATCH] mtdchar: allow mmap() on MTD RAM/ROM char devices Anatolij Gustschin
@ 2010-04-28 13:25 ` Artem Bityutskiy
2010-04-28 13:31 ` Artem Bityutskiy
0 siblings, 1 reply; 6+ messages in thread
From: Artem Bityutskiy @ 2010-04-28 13:25 UTC (permalink / raw)
To: Anatolij Gustschin; +Cc: David Woodhouse, linux-mtd, Detlev Zundel
On Fri, 2010-04-16 at 17:41 +0200, Anatolij Gustschin wrote:
> Signed-off-by: Anatolij Gustschin <agust@denx.de>
> ---
> drivers/mtd/mtdchar.c | 29 ++++++++++++++++++++++++++++-
> 1 files changed, 28 insertions(+), 1 deletions(-)
>
Taken this to l2-mtd-2.6.git / dunno
--
Best Regards,
Artem Bityutskiy (Артём Битюцкий)
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] mtdchar: allow mmap() on MTD RAM/ROM char devices
2010-04-28 13:25 ` Artem Bityutskiy
@ 2010-04-28 13:31 ` Artem Bityutskiy
2010-04-28 16:20 ` [PATCH v2] " Anatolij Gustschin
0 siblings, 1 reply; 6+ messages in thread
From: Artem Bityutskiy @ 2010-04-28 13:31 UTC (permalink / raw)
To: Anatolij Gustschin; +Cc: linux-mtd, David Woodhouse, Detlev Zundel
On Wed, 2010-04-28 at 16:25 +0300, Artem Bityutskiy wrote:
> On Fri, 2010-04-16 at 17:41 +0200, Anatolij Gustschin wrote:
> > Signed-off-by: Anatolij Gustschin <agust@denx.de>
> > ---
> > drivers/mtd/mtdchar.c | 29 ++++++++++++++++++++++++++++-
> > 1 files changed, 28 insertions(+), 1 deletions(-)
> >
>
> Taken this to l2-mtd-2.6.git / dunno
Removed, because it breaks compilation on my x86_64:
[dedekind@sauron l2-mtd-2.6]\$ make -j8
CHK include/linux/version.h
CHK include/generated/utsrelease.h
CALL scripts/checksyscalls.sh
CHK include/generated/compile.h
CC [M] drivers/mtd/mtdchar.o
CHK include/linux/version.h
make[2]: `scripts/unifdef' is up to date.
Building modules, stage 2.
Kernel: arch/x86/boot/bzImage is ready (#3)
MODPOST 1635 modules
ERROR: "phys_mem_access_prot" [drivers/mtd/mtdchar.ko] undefined!
WARNING: modpost: Found 11 section mismatch(es).
To see full details build your kernel with:
'make CONFIG_DEBUG_SECTION_MISMATCH=y'
make[1]: *** [__modpost] Error 1
make: *** [modules] Error 2
[dedekind@sauron l2-mtd-2.6]\$ git
--
Best Regards,
Artem Bityutskiy (Артём Битюцкий)
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH v2] mtdchar: allow mmap() on MTD RAM/ROM char devices
2010-04-28 13:31 ` Artem Bityutskiy
@ 2010-04-28 16:20 ` Anatolij Gustschin
2010-04-29 14:13 ` Anatolij Gustschin
0 siblings, 1 reply; 6+ messages in thread
From: Anatolij Gustschin @ 2010-04-28 16:20 UTC (permalink / raw)
To: linux-mtd; +Cc: Anatolij Gustschin
Signed-off-by: Anatolij Gustschin <agust@denx.de>
---
v1 -> v2:
- Fixed compilation breakage on x86_64 while compiling
as module, since on x86_64 phys_mem_access_prot() is
not exported. Sorry for the breakage.
drivers/mtd/mtdchar.c | 30 +++++++++++++++++++++++++++++-
1 files changed, 29 insertions(+), 1 deletions(-)
diff --git a/drivers/mtd/mtdchar.c b/drivers/mtd/mtdchar.c
index c355491..db755a4 100644
--- a/drivers/mtd/mtdchar.c
+++ b/drivers/mtd/mtdchar.c
@@ -17,6 +17,7 @@
#include <linux/compat.h>
#include <linux/mtd/mtd.h>
+#include <linux/mtd/map.h>
#include <linux/mtd/compatmac.h>
#include <asm/uaccess.h>
@@ -925,9 +926,36 @@ 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) {
+ if (vma->vm_pgoff > (~0UL >> PAGE_SHIFT))
+ return -EINVAL;
+ 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;
--
1.6.3.3
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH v2] mtdchar: allow mmap() on MTD RAM/ROM char devices
2010-04-28 16:20 ` [PATCH v2] " Anatolij Gustschin
@ 2010-04-29 14:13 ` Anatolij Gustschin
2010-05-04 13:45 ` Artem Bityutskiy
0 siblings, 1 reply; 6+ messages in thread
From: Anatolij Gustschin @ 2010-04-29 14:13 UTC (permalink / raw)
To: Artem Bityutskiy; +Cc: linux-mtd
Hi Artem,
On Wed, 28 Apr 2010 18:20:40 +0200
Anatolij Gustschin <agust@denx.de> wrote:
> Signed-off-by: Anatolij Gustschin <agust@denx.de>
> ---
> v1 -> v2:
> - Fixed compilation breakage on x86_64 while compiling
> as module, since on x86_64 phys_mem_access_prot() is
> not exported. Sorry for the breakage.
>
> drivers/mtd/mtdchar.c | 30 +++++++++++++++++++++++++++++-
> 1 files changed, 29 insertions(+), 1 deletions(-)
Is this patch ok now?
Thanks,
Anatolij
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH v2] mtdchar: allow mmap() on MTD RAM/ROM char devices
2010-04-29 14:13 ` Anatolij Gustschin
@ 2010-05-04 13:45 ` Artem Bityutskiy
0 siblings, 0 replies; 6+ messages in thread
From: Artem Bityutskiy @ 2010-05-04 13:45 UTC (permalink / raw)
To: Anatolij Gustschin; +Cc: linux-mtd
On Thu, 2010-04-29 at 16:13 +0200, Anatolij Gustschin wrote:
> Hi Artem,
>
> On Wed, 28 Apr 2010 18:20:40 +0200
> Anatolij Gustschin <agust@denx.de> wrote:
>
> > Signed-off-by: Anatolij Gustschin <agust@denx.de>
> > ---
> > v1 -> v2:
> > - Fixed compilation breakage on x86_64 while compiling
> > as module, since on x86_64 phys_mem_access_prot() is
> > not exported. Sorry for the breakage.
> >
> > drivers/mtd/mtdchar.c | 30 +++++++++++++++++++++++++++++-
> > 1 files changed, 29 insertions(+), 1 deletions(-)
>
> Is this patch ok now?
Not sure, I did not really review it, but it compiles now and I've
pushed it to my l2-mtd-2.6 / dunno tree.
--
Best Regards,
Artem Bityutskiy (Артём Битюцкий)
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2010-05-04 13:52 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-04-16 15:41 [PATCH] mtdchar: allow mmap() on MTD RAM/ROM char devices Anatolij Gustschin
2010-04-28 13:25 ` Artem Bityutskiy
2010-04-28 13:31 ` Artem Bityutskiy
2010-04-28 16:20 ` [PATCH v2] " Anatolij Gustschin
2010-04-29 14:13 ` Anatolij Gustschin
2010-05-04 13:45 ` Artem Bityutskiy
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.