From: Thomas Gleixner <tglx@linutronix.de>
To: Marco Stornelli <marco.stornelli@gmail.com>
Cc: Linux Kernel <linux-kernel@vger.kernel.org>,
x86@kernel.org, Tim Bird <tim.bird@am.sony.com>,
andi@firstfloor.org
Subject: Re: [PATCH] archs: add ioremap_change_write_prot
Date: Tue, 26 Oct 2010 18:24:07 +0200 (CEST) [thread overview]
Message-ID: <alpine.LFD.2.00.1010261818300.3115@localhost6.localdomain6> (raw)
In-Reply-To: <4CC3F13B.4030107@gmail.com>
On Sun, 24 Oct 2010, Marco Stornelli wrote:
> From: Marco Stornelli <marco.stornelli@gmail.com>
>
> This patch adds a new function called ioremap_change_write_prot.
> Goal of this patch is to create a general function for all archs to be
> able to change a write protection of a memory mapped area. x86
> has already got a similar framework, so this function is only
> a wrapper. Next target will be arm and powerpc. This function
> will be used by Pramfs (see its latest review).
Sorry for the delay. I'm traveling.
> Signed-off-by: Marco Stornelli <marco.stornelli@gmail.com>
> ---
>
> diff -Nurp linux-2.6.36-orig/arch/x86/mm/ioremap.c linux-2.6.36/arch/x86/mm/ioremap.c
> --- linux-2.6.36-orig/arch/x86/mm/ioremap.c 2010-09-13 01:07:37.000000000 +0200
> +++ linux-2.6.36/arch/x86/mm/ioremap.c 2010-10-24 10:03:36.000000000 +0200
> @@ -50,6 +50,27 @@ int ioremap_change_attr(unsigned long va
> return err;
> }
> +int ioremap_change_write_prot(unsigned long vaddr, unsigned long size,
> + unsigned int rw)
> +{
> + unsigned long nrpages = size >> PAGE_SHIFT;
> + int ret;
> +
> + /* Page aligned */
> + vaddr &= PAGE_MASK;
> +
> + if (size & (PAGE_SIZE - 1))
> + nrpages++;
> +
> + if (rw)
> + ret = set_memory_rw(vaddr, nrpages);
> + else
> + ret = set_memory_ro(vaddr, nrpages);
> +
> + return ret;
> +}
> +EXPORT_SYMBOL(ioremap_change_write_prot);
Why inventing a new interface if we have one already ?
set_memory_* which has a few more variants than ro/rw
Also this is not related to ioremap, these are functions which works on
almost anything when there are other restrictions in place.
So implementing set_memory_ro(), set_memory_rw() for those archs which
you need it for makes more sense than creating a misnomed and
misplaced wrapper.
Thanks,
tglx
next prev parent reply other threads:[~2010-10-26 16:24 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-10-24 8:41 Marco Stornelli
2010-10-26 10:56 ` Marco Stornelli
2010-10-26 13:14 ` Andi Kleen
2010-10-26 16:24 ` Thomas Gleixner [this message]
2010-10-27 6:55 ` Marco Stornelli
2010-10-27 7:59 ` Andi Kleen
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=alpine.LFD.2.00.1010261818300.3115@localhost6.localdomain6 \
--to=tglx@linutronix.de \
--cc=andi@firstfloor.org \
--cc=linux-kernel@vger.kernel.org \
--cc=marco.stornelli@gmail.com \
--cc=tim.bird@am.sony.com \
--cc=x86@kernel.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®