lkml.org 
[lkml]   [2006]   [Sep]   [5]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH] Make MTD chardev mmap available under some circumstances
On 9/5/06, David Howells <dhowells@redhat.com> wrote:
>
> Make it possible to mmap MTD chardevs directly or by copy on a NOMMU system.

Why would you want to do this? I'm just curious.


> +/*
> + * Allow NOMMU mmap() to directly map the device (if not NULL)
> + * - return the address to which the offset maps
> + * - return -ENOSYS to indicate refusal to do the mapping

Where do you actually do the -ENOSYS part? I think that comment
belongs to the actual mtd_get_unmapped_area call in mtdchar.c, no?

> +/*
> + * try to determine where a shared mapping can be made
> + * - only supported for NOMMU at the moment (MMU can't doesn't copy private
> + * mappings)
> + */
> +#ifndef CONFIG_MMU
> +static unsigned long mtd_get_unmapped_area(struct file *file,
> + unsigned long addr,
> + unsigned long len,
> + unsigned long pgoff,
> + unsigned long flags)
> +{
> + struct mtd_file_info *mfi = file->private_data;
> + struct mtd_info *mtd = mfi->mtd;
> +
> + if (mtd->get_unmapped_area) {
> + unsigned long offset;
> +
> + if (addr != 0)
> + return (unsigned long) -EINVAL;
> +
> + if (len > mtd->size || pgoff >= (mtd->size >> PAGE_SHIFT))
> + return (unsigned long) -EINVAL;
> +
> + offset = pgoff << PAGE_SHIFT;
> + if (offset > mtd->size - len)
> + return (unsigned long) -EINVAL;
> +
> + return mtd->get_unmapped_area(mtd, len, offset, flags);
> + }
> +
> + /* can't map directly */
> + return (unsigned long) -ENOSYS;
> +}
> +#endif

Could we do something like:

#else
#define mtd_get_unmapped_area (NULL);

which would prevent the ugly ifdef in the mtd_fops structure?

> static struct file_operations mtd_fops = {
> .owner = THIS_MODULE,
> .llseek = mtd_lseek,
> @@ -771,6 +864,10 @@ static struct file_operations mtd_fops =
> .ioctl = mtd_ioctl,
> .open = mtd_open,
> .release = mtd_close,
> + .mmap = mtd_mmap,
> +#ifndef CONFIG_MMU
> + .get_unmapped_area = mtd_get_unmapped_area,
> +#endif

See above.


josh
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/

\
 
 \ /
  Last update: 2006-09-06 03:03    [W:0.029 / U:6.824 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site