[PATCH 3/7] x86: pat.c more trivial changes

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
From: Andreas Herrmann
Date: Friday, June 20, 2008 - 1:03 pm

- add BUG statement to catch invalid start and end parameters
 - No need to track the actual type in both req_type and actual_type --
   keep req_type unchanged.
 - removed (IMHO) superfluous comments

Signed-off-by: Andreas Herrmann <andreas.herrmann3@amd.com>
---
 arch/x86/mm/pat.c |   21 ++++++++-------------
 1 files changed, 8 insertions(+), 13 deletions(-)

diff --git a/arch/x86/mm/pat.c b/arch/x86/mm/pat.c
index a6507bf..c996a36 100644
--- a/arch/x86/mm/pat.c
+++ b/arch/x86/mm/pat.c
@@ -200,7 +200,8 @@ int reserve_memtype(u64 start, u64 end, unsigned long req_type,
 	unsigned long actual_type;
 	int err = 0;
 
-	/* Only track when pat_enabled */
+ 	BUG_ON(start >= end); /* end is exclusive */
+
 	if (!pat_enabled) {
 		/* This is identical to page table setting without PAT */
 		if (new_type) {
@@ -228,17 +229,13 @@ int reserve_memtype(u64 start, u64 end, unsigned long req_type,
 		 */
 		u8 mtrr_type = mtrr_type_lookup(start, end);
 
-		if (mtrr_type == MTRR_TYPE_WRBACK) {
-			req_type = _PAGE_CACHE_WB;
+		if (mtrr_type == MTRR_TYPE_WRBACK)
 			actual_type = _PAGE_CACHE_WB;
-		} else {
-			req_type = _PAGE_CACHE_UC_MINUS;
+		else
 			actual_type = _PAGE_CACHE_UC_MINUS;
-		}
-	} else {
-		req_type &= _PAGE_CACHE_MASK;
-		actual_type = pat_x_mtrr_type(start, end, req_type);
-	}
+	} else
+		actual_type = pat_x_mtrr_type(start, end,
+					      req_type & _PAGE_CACHE_MASK);
 
 	new  = kmalloc(sizeof(struct memtype), GFP_KERNEL);
 	if (!new)
@@ -406,10 +403,8 @@ int free_memtype(u64 start, u64 end)
 	struct memtype *entry;
 	int err = -EINVAL;
 
-	/* Only track when pat_enabled */
-	if (!pat_enabled) {
+	if (!pat_enabled)
 		return 0;
-	}
 
 	/* Low ISA region is always mapped WB. No need to track */
 	if (is_ISA_range(start, end - 1))
-- 
1.5.5.4



--
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
[PATCH 0/7] x86: pat.c: reserve_memtype strip down, Andreas Herrmann, (Fri Jun 20, 12:55 pm)
[PATCH 1/7] x86: introduce macro to check whether an addre ..., Andreas Herrmann, (Fri Jun 20, 12:58 pm)
Re: [PATCH 2/7] x86: pat.c choose more crisp variable names, Andreas Herrmann, (Fri Jun 20, 1:01 pm)
[PATCH 3/7] x86: pat.c more trivial changes, Andreas Herrmann, (Fri Jun 20, 1:03 pm)
Re: [PATCH 0/7] x86: pat.c: reserve_memtype strip down, Ingo Molnar, (Tue Jun 24, 4:08 am)
RE: [PATCH 0/7] x86: pat.c: reserve_memtype strip down, Pallipadi, Venkatesh, (Tue Jun 24, 2:59 pm)