// SPDX-License-Identifier: GPL-2.0-only /* * * Misc librarized functions for cmdline poking. */ #include <linux/kernel.h> #include <linux/string.h> #include <linux/ctype.h> #include <asm/setup.h> #include <asm/cmdline.h> #include <asm/bug.h> static inline int myisspace(u8 c) { … } /* * Find a boolean option (like quiet,noapic,nosmp....) * * @cmdline: the cmdline string * @max_cmdline_size: the maximum size of cmdline * @option: option string to look for * * Returns the position of that @option (starts counting with 1) * or 0 on not found. @option will only be found if it is found * as an entire word in @cmdline. For instance, if @option="car" * then a cmdline which contains "cart" will not match. */ static int __cmdline_find_option_bool(const char *cmdline, int max_cmdline_size, const char *option) { … } /* * Find a non-boolean option (i.e. option=argument). In accordance with * standard Linux practice, if this option is repeated, this returns the * last instance on the command line. * * @cmdline: the cmdline string * @max_cmdline_size: the maximum size of cmdline * @option: option string to look for * @buffer: memory buffer to return the option argument * @bufsize: size of the supplied memory buffer * * Returns the length of the argument (regardless of if it was * truncated to fit in the buffer), or -1 on not found. */ static int __cmdline_find_option(const char *cmdline, int max_cmdline_size, const char *option, char *buffer, int bufsize) { … } int cmdline_find_option_bool(const char *cmdline, const char *option) { … } int cmdline_find_option(const char *cmdline, const char *option, char *buffer, int bufsize) { … }