aboutsummaryrefslogtreecommitdiffstats
path: root/arch/x86
diff options
context:
space:
mode:
authorAndreas Herrmann <andreas.herrmann3@amd.com>2008-06-20 16:05:37 -0400
committerIngo Molnar <mingo@elte.hu>2008-06-24 07:05:55 -0400
commitf6887264deba4cd991f0ca006918dcff4c939021 (patch)
tree5becb05dfc2b328b0e8f90594f7a86cf0da69d52 /arch/x86
parent3e9c83b309fd7cbf1d9b801d0d5877c040e30420 (diff)
x86: pat.c consolidate list_add handling in reserve_memtype
Signed-off-by: Andreas Herrmann <andreas.herrmann3@amd.com> Cc: Venkatesh Pallipadi <venkatesh.pallipadi@intel.com> Cc: Suresh B Siddha <suresh.b.siddha@intel.com> Signed-off-by: Ingo Molnar <mingo@elte.hu>
Diffstat (limited to 'arch/x86')
-rw-r--r--arch/x86/mm/pat.c21
1 files changed, 8 insertions, 13 deletions
diff --git a/arch/x86/mm/pat.c b/arch/x86/mm/pat.c
index 1118288f8fe2..49dcd9652ec8 100644
--- a/arch/x86/mm/pat.c
+++ b/arch/x86/mm/pat.c
@@ -198,6 +198,7 @@ int reserve_memtype(u64 start, u64 end, unsigned long req_type,
198{ 198{
199 struct memtype *new, *entry; 199 struct memtype *new, *entry;
200 unsigned long actual_type; 200 unsigned long actual_type;
201 struct list_head *where;
201 int err = 0; 202 int err = 0;
202 203
203 BUG_ON(start >= end); /* end is exclusive */ 204 BUG_ON(start >= end); /* end is exclusive */
@@ -251,13 +252,12 @@ int reserve_memtype(u64 start, u64 end, unsigned long req_type,
251 spin_lock(&memtype_lock); 252 spin_lock(&memtype_lock);
252 253
253 /* Search for existing mapping that overlaps the current range */ 254 /* Search for existing mapping that overlaps the current range */
255 where = NULL;
254 list_for_each_entry(entry, &memtype_list, nd) { 256 list_for_each_entry(entry, &memtype_list, nd) {
255 struct memtype *saved_ptr; 257 struct memtype *saved_ptr;
256 258
257 if (entry->start >= end) { 259 if (entry->start >= end) {
258 dprintk("New Entry\n"); 260 where = entry->nd.prev;
259 list_add(&new->nd, entry->nd.prev);
260 new = NULL;
261 break; 261 break;
262 } 262 }
263 263
@@ -295,9 +295,7 @@ int reserve_memtype(u64 start, u64 end, unsigned long req_type,
295 295
296 dprintk("Overlap at 0x%Lx-0x%Lx\n", 296 dprintk("Overlap at 0x%Lx-0x%Lx\n",
297 saved_ptr->start, saved_ptr->end); 297 saved_ptr->start, saved_ptr->end);
298 /* No conflict. Go ahead and add this new entry */ 298 where = saved_ptr->nd.prev;
299 list_add(&new->nd, saved_ptr->nd.prev);
300 new = NULL;
301 break; 299 break;
302 } 300 }
303 301
@@ -335,9 +333,7 @@ int reserve_memtype(u64 start, u64 end, unsigned long req_type,
335 333
336 dprintk("Overlap at 0x%Lx-0x%Lx\n", 334 dprintk("Overlap at 0x%Lx-0x%Lx\n",
337 saved_ptr->start, saved_ptr->end); 335 saved_ptr->start, saved_ptr->end);
338 /* No conflict. Go ahead and add this new entry */ 336 where = &saved_ptr->nd;
339 list_add(&new->nd, &saved_ptr->nd);
340 new = NULL;
341 break; 337 break;
342 } 338 }
343 } 339 }
@@ -354,11 +350,10 @@ int reserve_memtype(u64 start, u64 end, unsigned long req_type,
354 return err; 350 return err;
355 } 351 }
356 352
357 if (new) { 353 if (where)
358 /* No conflict. Not yet added to the list. Add to the tail */ 354 list_add(&new->nd, where);
355 else
359 list_add_tail(&new->nd, &memtype_list); 356 list_add_tail(&new->nd, &memtype_list);
360 dprintk("New Entry\n");
361 }
362 357
363 spin_unlock(&memtype_lock); 358 spin_unlock(&memtype_lock);
364 359