All of lore.kernel.org
 help / color / mirror / Atom feed
From: Kevin Cernekee <cernekee@gmail.com>
To: Ralf Baechle <ralf@linux-mips.org>,
	David Daney <ddaney@caviumnetworks.com>
Cc: linux-mips@linux-mips.org, linux-kernel@vger.kernel.org
Subject: [PATCH 3/4] MIPS: Clean up protection_map[] initialization
Date: Sat, 16 Apr 2011 09:44:31 -0700	[thread overview]
Message-ID: <305a554e4aa54669dfff53283de096eb@localhost> (raw)
In-Reply-To: <7aa38c32b7748a95e814e5bb0583f967@localhost>

Fix long lines, factor out cut&paste flags, and add comments to explain
the pgprot flags used.

Signed-off-by: Kevin Cernekee <cernekee@gmail.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

  parent reply	other threads:[~2011-04-16 16:52 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-04-16 16:44 [PATCH 1/4] MIPS: Replace _PAGE_READ with _PAGE_NO_READ Kevin Cernekee
2011-04-16 16:44 ` [PATCH 2/4] MIPS: Add dummy _PAGE_NO_EXEC field for R3000 and 64BIT_PHYS_ADDR cases Kevin Cernekee
2011-05-12 14:12   ` Ralf Baechle
2011-04-16 16:44 ` Kevin Cernekee [this message]
2011-05-12 14:12   ` [PATCH 3/4] MIPS: Clean up protection_map[] initialization Ralf Baechle
2011-04-16 16:44 ` [PATCH 4/4] MIPS: Remove unused PAGE_* definitions Kevin Cernekee
2011-05-12 14:12   ` Ralf Baechle
2011-04-18 17:32 ` [PATCH 1/4] MIPS: Replace _PAGE_READ with _PAGE_NO_READ David Daney
2011-04-18 18:24   ` Kevin Cernekee
2011-04-18 18:52     ` David Daney
2011-05-12 14:12 ` Ralf Baechle
2011-05-13 15:07 ` Ralf Baechle
2011-05-13 15:46   ` Kevin Cernekee
2011-05-13 15:56     ` Ralf Baechle
2011-05-13 16:55       ` Kevin Cernekee
2011-05-13 17:36         ` Jayachandran C.
2011-05-13 17:51           ` Kevin Cernekee
2011-05-13 18:45             ` Jayachandran C.
2011-05-13 18:57               ` David Daney
2011-05-13 22:00                 ` Arnaud Patard
2011-05-13 22:06               ` Kevin Cernekee
2011-05-14  5:13                 ` Jayachandran C.
2011-05-14  6:02                   ` Kevin Cernekee
2011-05-16 12:57                     ` Jayachandran C.
2011-05-13 17:17       ` David Daney

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=305a554e4aa54669dfff53283de096eb@localhost \
    --to=cernekee@gmail.com \
    --cc=ddaney@caviumnetworks.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mips@linux-mips.org \
    --cc=ralf@linux-mips.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.