Skip to contentSkip to conversation

x86, setup: code clean of e820_reserve_setup_data()

PATCH In review Wei Yang 3 participants 5 messages Jun 4, 2015 – Jun 7, 2015 x86

lore
Share & tools
lore

Wei Yang

author
#0 lore raw

PATCH 1/1 x86, setup: code clean of e820_reserve_setup_data()

pa_data and found are highly related, so there is no need to set a found flag.

This patch removes the found and just return when pa_data is NULL.

---
 arch/x86/kernel/setup.c |    7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)
arch/x86/kernel/setup.c +3 -4
index 0a2421c..b95e653 100644
@@ -461,19 +461,18 @@ static void __init e820_reserve_setup_data(void)
 {
 	struct setup_data *data;
 	u64 pa_data;
-	int found = 0;
 
 	pa_data = boot_params.hdr.setup_data;
+	if (!pa_data)
+		return;
+
 	while (pa_data) {
 		data = early_memremap(pa_data, sizeof(*data));
 		e820_update_range(pa_data, sizeof(*data)+data->len,
 			 E820_RAM, E820_RESERVED_KERN);
-		found = 1;
 		pa_data = data->next;
 		early_iounmap(data, sizeof(*data));
 	}
-	if (!found)
-		return;
 
 	sanitize_e820_map(e820.map, ARRAY_SIZE(e820.map), &e820.nr_map);
 	memcpy(&e820_saved, &e820, sizeof(struct e820map));
Signature · 1 line
1.7.9.5
#1 lore raw
Quoted 27 lines · Wei Yang

pa_data and found are highly related, so there is no need to set a found flag.

This patch removes the found and just return when pa_data is NULL.

---
 arch/x86/kernel/setup.c |    7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)
arch/x86/kernel/setup.c +3 -1
index 0a2421c..b95e653 100644
@@ -461,19 +461,18 @@ static void __init e820_reserve_setup_data(void)
 {
 	struct setup_data *data;
 	u64 pa_data;
-	int found = 0;
 
 	pa_data = boot_params.hdr.setup_data;
+	if (!pa_data)
+		return;
+
 	while (pa_data) {
 		data = early_memremap(pa_data, sizeof(*data));
 		e820_update_range(pa_data, sizeof(*data)+data->len,

arch/x86/kernel/setup.c static void __init e820_reserve_setup_data(void) · line 478

Quoted 10 lines
arch/x86/kernel/setup.c +0 -3
 			 E820_RAM, E820_RESERVED_KERN);
-		found = 1;
 		pa_data = data->next;
 		early_iounmap(data, sizeof(*data));
 	}
-	if (!found)
-		return;
 
 	sanitize_e820_map(e820.map, ARRAY_SIZE(e820.map), &e820.nr_map);
 	memcpy(&e820_saved, &e820, sizeof(struct e820map));

This patch does not apply to Linus's latest tree.

Thanks,

Ingo

author
#3 lore raw

PATCH 1/1 x86, setup: code clean of e820_reserve_setup_data()

In reply to Wei Yang

pa_data and found are highly related, so there is no need to set a found flag.

This patch removes the found and just return when pa_data is NULL.

---
 arch/x86/kernel/setup.c |    7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)
arch/x86/kernel/setup.c +3 -4
index d74ac33..c3992c3 100644
@@ -461,19 +461,18 @@ static void __init e820_reserve_setup_data(void)
 {
 	struct setup_data *data;
 	u64 pa_data;
-	int found = 0;
 
 	pa_data = boot_params.hdr.setup_data;
+	if (!pa_data)
+		return;
+
 	while (pa_data) {
 		data = early_memremap(pa_data, sizeof(*data));
 		e820_update_range(pa_data, sizeof(*data)+data->len,
 			 E820_RAM, E820_RESERVED_KERN);
-		found = 1;
 		pa_data = data->next;
 		early_memunmap(data, sizeof(*data));
 	}
-	if (!found)
-		return;
 
 	sanitize_e820_map(e820.map, ARRAY_SIZE(e820.map), &e820.nr_map);
 	memcpy(&e820_saved, &e820, sizeof(struct e820map));
Signature · 1 line
1.7.9.5
author
#2 lore raw
In reply to Ingo Molnar
Quoted 38 lines · Ingo Molnar
Quoted 35 lines · Wei Yang

pa_data and found are highly related, so there is no need to set a found flag.

This patch removes the found and just return when pa_data is NULL.

---
 arch/x86/kernel/setup.c |    7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)
arch/x86/kernel/setup.c +3 -4
index 0a2421c..b95e653 100644
@@ -461,19 +461,18 @@ static void __init e820_reserve_setup_data(void)
 {
 	struct setup_data *data;
 	u64 pa_data;
-	int found = 0;
 
 	pa_data = boot_params.hdr.setup_data;
+	if (!pa_data)
+		return;
+
 	while (pa_data) {
 		data = early_memremap(pa_data, sizeof(*data));
 		e820_update_range(pa_data, sizeof(*data)+data->len,
 			 E820_RAM, E820_RESERVED_KERN);
-		found = 1;
 		pa_data = data->next;
 		early_iounmap(data, sizeof(*data));
 	}
-	if (!found)
-		return;
 
Quoted 4 lines

arch/x86/kernel/setup.c static void __init e820_reserve_setup_data(void) · line 478

Quoted 2 lines
arch/x86/kernel/setup.c +0 -0
 	sanitize_e820_map(e820.map, ARRAY_SIZE(e820.map), &e820.nr_map);
 	memcpy(&e820_saved, &e820, sizeof(struct e820map));

This patch does not apply to Linus's latest tree.

Thanks Ingo.

Rebased on top of v4.1-rc6.

Quoted 4 lines

Thanks,

Ingo

Signature · 2 lines
Richard Yang
Help you, Help me
#4 lore raw

[tip:x86/boot] x86/boot/setup: Clean up the e820_reserve_setup_data() code

In reply to Wei Yang
x86/boot/setup: Clean up the e820_reserve_setup_data() code
Commit-ID:  f2af7d25b4aa5b01203cc76e7530ea7fd18864a0
Gitweb:     http://git.kernel.org/tip/f2af7d25b4aa5b01203cc76e7530ea7fd18864a0
Author:     Wei Yang <[email protected]>
AuthorDate: Thu, 4 Jun 2015 14:18:49 +0800
Committer:  Ingo Molnar <[email protected]>
CommitDate: Fri, 5 Jun 2015 13:53:22 +0200

x86/boot/setup: Clean up the e820_reserve_setup_data() code

Deobfuscate the 'found' logic, it can be replaced with a simple:

	if (!pa_data)
		return;

and 'found' can be eliminated.

Cc Andrew Morton <[email protected]>
Cc Borislav Petkov <[email protected]>
Cc H. Peter Anvin <[email protected]>
Cc Linus Torvalds <[email protected]>
Cc Peter Zijlstra <[email protected]>
Cc Thomas Gleixner <[email protected]>
Cc Yinghai Lu <[email protected]>
---
 arch/x86/kernel/setup.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)
arch/x86/kernel/setup.c +3 -4
index d74ac33..c3992c3 100644
@@ -461,19 +461,18 @@ static void __init e820_reserve_setup_data(void)
 {
 	struct setup_data *data;
 	u64 pa_data;
-	int found = 0;
 
 	pa_data = boot_params.hdr.setup_data;
+	if (!pa_data)
+		return;
+
 	while (pa_data) {
 		data = early_memremap(pa_data, sizeof(*data));
 		e820_update_range(pa_data, sizeof(*data)+data->len,
 			 E820_RAM, E820_RESERVED_KERN);
-		found = 1;
 		pa_data = data->next;
 		early_memunmap(data, sizeof(*data));
 	}
-	if (!found)
-		return;
 
 	sanitize_e820_map(e820.map, ARRAY_SIZE(e820.map), &e820.nr_map);
 	memcpy(&e820_saved, &e820, sizeof(struct e820map));