[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <305a554e4aa54669dfff53283de096eb@localhost>
Date: Sat, 16 Apr 2011 09:44:31 -0700
From: Kevin Cernekee <cernekee@...il.com>
To: Ralf Baechle <ralf@...ux-mips.org>,
David Daney <ddaney@...iumnetworks.com>
Cc: linux-mips@...ux-mips.org, linux-kernel@...r.kernel.org
Subject: [PATCH 3/4] MIPS: Clean up protection_map[] initialization
Fix long lines, factor out cut&paste flags, and add comments to explain
the pgprot flags used.
Signed-off-by: Kevin Cernekee <cernekee@...il.com>
---
arch/mips/mm/cache.c | 42 +++++++++++++++++++++++++-----------------
1 files changed, 25 insertions(+), 17 deletions(-)
diff --git a/arch/mips/mm/cache.c b/arch/mips/mm/cache.c
index 7c251e6..edb003f 100644
--- a/arch/mips/mm/cache.c
+++ b/arch/mips/mm/cache.c
@@ -137,23 +137,31 @@ EXPORT_SYMBOL(_page_cachable_default);
static inline void setup_protection_map(void)
{
- protection_map[0] = __pgprot(_page_cachable_default | _PAGE_PRESENT | _PAGE_NO_EXEC | _PAGE_NO_READ);
- protection_map[1] = __pgprot(_page_cachable_default | _PAGE_PRESENT | _PAGE_NO_EXEC);
- protection_map[2] = __pgprot(_page_cachable_default | _PAGE_PRESENT | _PAGE_NO_EXEC | _PAGE_NO_READ);
- protection_map[3] = __pgprot(_page_cachable_default | _PAGE_PRESENT | _PAGE_NO_EXEC);
- protection_map[4] = __pgprot(_page_cachable_default | _PAGE_PRESENT | _PAGE_NO_READ);
- protection_map[5] = __pgprot(_page_cachable_default | _PAGE_PRESENT);
- protection_map[6] = __pgprot(_page_cachable_default | _PAGE_PRESENT | _PAGE_NO_READ);
- protection_map[7] = __pgprot(_page_cachable_default | _PAGE_PRESENT);
-
- protection_map[8] = __pgprot(_page_cachable_default | _PAGE_PRESENT | _PAGE_NO_EXEC | _PAGE_NO_READ);
- protection_map[9] = __pgprot(_page_cachable_default | _PAGE_PRESENT | _PAGE_NO_EXEC);
- protection_map[10] = __pgprot(_page_cachable_default | _PAGE_PRESENT | _PAGE_NO_EXEC | _PAGE_WRITE | _PAGE_NO_READ);
- protection_map[11] = __pgprot(_page_cachable_default | _PAGE_PRESENT | _PAGE_NO_EXEC | _PAGE_WRITE);
- protection_map[12] = __pgprot(_page_cachable_default | _PAGE_PRESENT | _PAGE_NO_READ);
- protection_map[13] = __pgprot(_page_cachable_default | _PAGE_PRESENT);
- protection_map[14] = __pgprot(_page_cachable_default | _PAGE_PRESENT | _PAGE_WRITE | _PAGE_NO_READ);
- protection_map[15] = __pgprot(_page_cachable_default | _PAGE_PRESENT | _PAGE_WRITE);
+ int i;
+ const unsigned long prot[] = {
+ /* private mappings (clear the dirty bit until written) */
+ [0] = _PAGE_NO_EXEC | _PAGE_NO_READ, /* --- */
+ [1] = _PAGE_NO_EXEC, /* r-- */
+ [2] = _PAGE_NO_EXEC | _PAGE_NO_READ, /* -w- */
+ [3] = _PAGE_NO_EXEC, /* rw- */
+ [4] = _PAGE_NO_READ, /* --x */
+ [5] = 0, /* r-x */
+ [6] = _PAGE_NO_READ, /* -wx */
+ [7] = 0, /* rwx */
+ /* shared mappings */
+ [8] = _PAGE_NO_EXEC | _PAGE_NO_READ, /* --- */
+ [9] = _PAGE_NO_EXEC, /* r-- */
+ [10] = _PAGE_NO_EXEC | _PAGE_WRITE | _PAGE_NO_READ, /* -w- */
+ [11] = _PAGE_NO_EXEC | _PAGE_WRITE, /* rw- */
+ [12] = _PAGE_NO_READ, /* --x */
+ [13] = 0, /* r-x */
+ [14] = _PAGE_WRITE | _PAGE_NO_READ, /* -wx */
+ [15] = _PAGE_WRITE, /* rwx */
+ };
+
+ for (i = 0; i < ARRAY_SIZE(protection_map); i++)
+ protection_map[i] = __pgprot(_page_cachable_default |
+ _PAGE_PRESENT | prot[i]);
}
void __cpuinit cpu_cache_init(void)
--
1.7.4.3
--
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