mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "Josh Boyer" <jwboyer@gmail.com>
To: "David Howells" <dhowells@redhat.com>
Cc: dwmw2@infradead.org, linux-mtd@lists.infradead.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH] Make MTD chardev mmap available under some circumstances
Date: Tue, 5 Sep 2006 20:00:06 -0500	[thread overview]
Message-ID: <625fc13d0609051800w5d4b114cp5e2517ca683708ee@mail.gmail.com> (raw)
In-Reply-To: <24712.1157483886@warthog.cambridge.redhat.com>

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

      reply	other threads:[~2006-09-06  1:00 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-09-05 19:18 David Howells
2006-09-06  1:00 ` Josh Boyer [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=625fc13d0609051800w5d4b114cp5e2517ca683708ee@mail.gmail.com \
    --to=jwboyer@gmail.com \
    --cc=dhowells@redhat.com \
    --cc=dwmw2@infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mtd@lists.infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®