mirror of
https://github.com/tbsdtv/linux_media.git
synced 2025-07-23 04:33:26 +02:00
lib: Add a generic cmdline parse function parse_option_str
There should be a generic function to parse params like a=b,c Adding parse_option_str in lib/cmdline.c which will return true if there's specified option set in the params. Also updated efi=old_map parsing code to use the new function Signed-off-by: Dave Young <dyoung@redhat.com> Signed-off-by: Matt Fleming <matt.fleming@intel.com>
This commit is contained in:
@@ -160,3 +160,32 @@ unsigned long long memparse(const char *ptr, char **retptr)
|
||||
return ret;
|
||||
}
|
||||
EXPORT_SYMBOL(memparse);
|
||||
|
||||
/**
|
||||
* parse_option_str - Parse a string and check an option is set or not
|
||||
* @str: String to be parsed
|
||||
* @option: option name
|
||||
*
|
||||
* This function parses a string containing a comma-separated list of
|
||||
* strings like a=b,c.
|
||||
*
|
||||
* Return true if there's such option in the string, or return false.
|
||||
*/
|
||||
bool parse_option_str(const char *str, const char *option)
|
||||
{
|
||||
while (*str) {
|
||||
if (!strncmp(str, option, strlen(option))) {
|
||||
str += strlen(option);
|
||||
if (!*str || *str == ',')
|
||||
return true;
|
||||
}
|
||||
|
||||
while (*str && *str != ',')
|
||||
str++;
|
||||
|
||||
if (*str == ',')
|
||||
str++;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
Reference in New Issue
Block a user