diff options
-rw-r--r-- | arch/x86/platform/efi/efi.c | 22 | ||||
-rw-r--r-- | include/linux/kernel.h | 1 | ||||
-rw-r--r-- | lib/cmdline.c | 29 |
3 files changed, 32 insertions, 20 deletions
diff --git a/arch/x86/platform/efi/efi.c b/arch/x86/platform/efi/efi.c index c90d3cd2728c..c73a7df5d37f 100644 --- a/arch/x86/platform/efi/efi.c +++ b/arch/x86/platform/efi/efi.c | |||
@@ -932,26 +932,8 @@ u64 efi_mem_attributes(unsigned long phys_addr) | |||
932 | 932 | ||
933 | static int __init parse_efi_cmdline(char *str) | 933 | static int __init parse_efi_cmdline(char *str) |
934 | { | 934 | { |
935 | if (*str == '=') | 935 | if (parse_option_str(str, "old_map")) |
936 | str++; | 936 | set_bit(EFI_OLD_MEMMAP, &efi.flags); |
937 | |||
938 | while (*str) { | ||
939 | if (!strncmp(str, "old_map", 7)) { | ||
940 | set_bit(EFI_OLD_MEMMAP, &efi.flags); | ||
941 | str += strlen("old_map"); | ||
942 | } | ||
943 | |||
944 | /* | ||
945 | * Skip any options we don't understand. Presumably | ||
946 | * they apply to the EFI boot stub. | ||
947 | */ | ||
948 | while (*str && *str != ',') | ||
949 | str++; | ||
950 | |||
951 | /* If we hit a delimiter, skip it */ | ||
952 | if (*str == ',') | ||
953 | str++; | ||
954 | } | ||
955 | 937 | ||
956 | return 0; | 938 | return 0; |
957 | } | 939 | } |
diff --git a/include/linux/kernel.h b/include/linux/kernel.h index 95624bed87ef..f66427ef0628 100644 --- a/include/linux/kernel.h +++ b/include/linux/kernel.h | |||
@@ -407,6 +407,7 @@ int vsscanf(const char *, const char *, va_list); | |||
407 | extern int get_option(char **str, int *pint); | 407 | extern int get_option(char **str, int *pint); |
408 | extern char *get_options(const char *str, int nints, int *ints); | 408 | extern char *get_options(const char *str, int nints, int *ints); |
409 | extern unsigned long long memparse(const char *ptr, char **retptr); | 409 | extern unsigned long long memparse(const char *ptr, char **retptr); |
410 | extern bool parse_option_str(const char *str, const char *option); | ||
410 | 411 | ||
411 | extern int core_kernel_text(unsigned long addr); | 412 | extern int core_kernel_text(unsigned long addr); |
412 | extern int core_kernel_data(unsigned long addr); | 413 | extern int core_kernel_data(unsigned long addr); |
diff --git a/lib/cmdline.c b/lib/cmdline.c index 76a712e6e20e..8f13cf73c2ec 100644 --- a/lib/cmdline.c +++ b/lib/cmdline.c | |||
@@ -160,3 +160,32 @@ unsigned long long memparse(const char *ptr, char **retptr) | |||
160 | return ret; | 160 | return ret; |
161 | } | 161 | } |
162 | EXPORT_SYMBOL(memparse); | 162 | EXPORT_SYMBOL(memparse); |
163 | |||
164 | /** | ||
165 | * parse_option_str - Parse a string and check an option is set or not | ||
166 | * @str: String to be parsed | ||
167 | * @option: option name | ||
168 | * | ||
169 | * This function parses a string containing a comma-separated list of | ||
170 | * strings like a=b,c. | ||
171 | * | ||
172 | * Return true if there's such option in the string, or return false. | ||
173 | */ | ||
174 | bool parse_option_str(const char *str, const char *option) | ||
175 | { | ||
176 | while (*str) { | ||
177 | if (!strncmp(str, option, strlen(option))) { | ||
178 | str += strlen(option); | ||
179 | if (!*str || *str == ',') | ||
180 | return true; | ||
181 | } | ||
182 | |||
183 | while (*str && *str != ',') | ||
184 | str++; | ||
185 | |||
186 | if (*str == ',') | ||
187 | str++; | ||
188 | } | ||
189 | |||
190 | return false; | ||
191 | } | ||