[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <625fc13d0609051800w5d4b114cp5e2517ca683708ee@mail.gmail.com>
Date: Tue, 5 Sep 2006 20:00:06 -0500
From: "Josh Boyer" <jwboyer@...il.com>
To: "David Howells" <dhowells@...hat.com>
Cc: dwmw2@...radead.org, linux-mtd@...ts.infradead.org,
linux-kernel@...r.kernel.org
Subject: Re: [PATCH] Make MTD chardev mmap available under some circumstances
On 9/5/06, David Howells <dhowells@...hat.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@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists