diff options
| author | Jordan Borgner <mail@jordan-borgner.de> | 2018-11-02 10:56:22 -0400 |
|---|---|---|
| committer | Ingo Molnar <mingo@kernel.org> | 2018-11-06 15:05:01 -0500 |
| commit | e8eeb3c8aab044ee8faf5e0389db8518629a9324 (patch) | |
| tree | 3a971ce6498b82dedd90fb20fef3904297653504 | |
| parent | 163c8d54a997153ee1a1e07fcac087492ad85b37 (diff) | |
x86/boot: Simplify the detect_memory*() control flow
The return values of these functions are not used - so simplify the functions.
No change in functionality.
[ mingo: Simplified the changelog. ]
Suggested: Ingo Molnar <mingo@kernel.org>
Signed-off-by: Jordan Borgner <mail@jordan-borgner.de>
Cc: Borislav Petkov <bp@alien8.de>
Cc: H. Peter Anvin <hpa@zytor.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Link: http://lkml.kernel.org/r/20181102145622.zjx2t3mdu3rv6sgy@JordanDesktop
Signed-off-by: Ingo Molnar <mingo@kernel.org>
| -rw-r--r-- | arch/x86/boot/boot.h | 2 | ||||
| -rw-r--r-- | arch/x86/boot/memory.c | 31 |
2 files changed, 11 insertions, 22 deletions
diff --git a/arch/x86/boot/boot.h b/arch/x86/boot/boot.h index ef5a9cc66fb8..32a09eb5c101 100644 --- a/arch/x86/boot/boot.h +++ b/arch/x86/boot/boot.h | |||
| @@ -309,7 +309,7 @@ void query_edd(void); | |||
| 309 | void __attribute__((noreturn)) die(void); | 309 | void __attribute__((noreturn)) die(void); |
| 310 | 310 | ||
| 311 | /* memory.c */ | 311 | /* memory.c */ |
| 312 | int detect_memory(void); | 312 | void detect_memory(void); |
| 313 | 313 | ||
| 314 | /* pm.c */ | 314 | /* pm.c */ |
| 315 | void __attribute__((noreturn)) go_to_protected_mode(void); | 315 | void __attribute__((noreturn)) go_to_protected_mode(void); |
diff --git a/arch/x86/boot/memory.c b/arch/x86/boot/memory.c index 7df2b28207be..f06c147b5140 100644 --- a/arch/x86/boot/memory.c +++ b/arch/x86/boot/memory.c | |||
| @@ -17,7 +17,7 @@ | |||
| 17 | 17 | ||
| 18 | #define SMAP 0x534d4150 /* ASCII "SMAP" */ | 18 | #define SMAP 0x534d4150 /* ASCII "SMAP" */ |
| 19 | 19 | ||
| 20 | static int detect_memory_e820(void) | 20 | static void detect_memory_e820(void) |
| 21 | { | 21 | { |
| 22 | int count = 0; | 22 | int count = 0; |
| 23 | struct biosregs ireg, oreg; | 23 | struct biosregs ireg, oreg; |
| @@ -68,10 +68,10 @@ static int detect_memory_e820(void) | |||
| 68 | count++; | 68 | count++; |
| 69 | } while (ireg.ebx && count < ARRAY_SIZE(boot_params.e820_table)); | 69 | } while (ireg.ebx && count < ARRAY_SIZE(boot_params.e820_table)); |
| 70 | 70 | ||
| 71 | return boot_params.e820_entries = count; | 71 | boot_params.e820_entries = count; |
| 72 | } | 72 | } |
| 73 | 73 | ||
| 74 | static int detect_memory_e801(void) | 74 | static void detect_memory_e801(void) |
| 75 | { | 75 | { |
| 76 | struct biosregs ireg, oreg; | 76 | struct biosregs ireg, oreg; |
| 77 | 77 | ||
| @@ -80,7 +80,7 @@ static int detect_memory_e801(void) | |||
| 80 | intcall(0x15, &ireg, &oreg); | 80 | intcall(0x15, &ireg, &oreg); |
| 81 | 81 | ||
| 82 | if (oreg.eflags & X86_EFLAGS_CF) | 82 | if (oreg.eflags & X86_EFLAGS_CF) |
| 83 | return -1; | 83 | return; |
| 84 | 84 | ||
| 85 | /* Do we really need to do this? */ | 85 | /* Do we really need to do this? */ |
| 86 | if (oreg.cx || oreg.dx) { | 86 | if (oreg.cx || oreg.dx) { |
| @@ -89,7 +89,7 @@ static int detect_memory_e801(void) | |||
| 89 | } | 89 | } |
| 90 | 90 | ||
| 91 | if (oreg.ax > 15*1024) { | 91 | if (oreg.ax > 15*1024) { |
| 92 | return -1; /* Bogus! */ | 92 | return; /* Bogus! */ |
| 93 | } else if (oreg.ax == 15*1024) { | 93 | } else if (oreg.ax == 15*1024) { |
| 94 | boot_params.alt_mem_k = (oreg.bx << 6) + oreg.ax; | 94 | boot_params.alt_mem_k = (oreg.bx << 6) + oreg.ax; |
| 95 | } else { | 95 | } else { |
| @@ -102,11 +102,9 @@ static int detect_memory_e801(void) | |||
| 102 | */ | 102 | */ |
| 103 | boot_params.alt_mem_k = oreg.ax; | 103 | boot_params.alt_mem_k = oreg.ax; |
| 104 | } | 104 | } |
| 105 | |||
| 106 | return 0; | ||
| 107 | } | 105 | } |
| 108 | 106 | ||
| 109 | static int detect_memory_88(void) | 107 | static void detect_memory_88(void) |
| 110 | { | 108 | { |
| 111 | struct biosregs ireg, oreg; | 109 | struct biosregs ireg, oreg; |
| 112 | 110 | ||
| @@ -115,22 +113,13 @@ static int detect_memory_88(void) | |||
| 115 | intcall(0x15, &ireg, &oreg); | 113 | intcall(0x15, &ireg, &oreg); |
| 116 | 114 | ||
| 117 | boot_params.screen_info.ext_mem_k = oreg.ax; | 115 | boot_params.screen_info.ext_mem_k = oreg.ax; |
| 118 | |||
| 119 | return -(oreg.eflags & X86_EFLAGS_CF); /* 0 or -1 */ | ||
| 120 | } | 116 | } |
| 121 | 117 | ||
| 122 | int detect_memory(void) | 118 | void detect_memory(void) |
| 123 | { | 119 | { |
| 124 | int err = -1; | 120 | detect_memory_e820(); |
| 125 | |||
| 126 | if (detect_memory_e820() > 0) | ||
| 127 | err = 0; | ||
| 128 | |||
| 129 | if (!detect_memory_e801()) | ||
| 130 | err = 0; | ||
| 131 | 121 | ||
| 132 | if (!detect_memory_88()) | 122 | detect_memory_e801(); |
| 133 | err = 0; | ||
| 134 | 123 | ||
| 135 | return err; | 124 | detect_memory_88(); |
| 136 | } | 125 | } |
