summaryrefslogtreecommitdiff
path: root/drivers/video/fbdev/core/fb_cmdline.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/video/fbdev/core/fb_cmdline.c')
-rw-r--r--drivers/video/fbdev/core/fb_cmdline.c94
1 files changed, 24 insertions, 70 deletions
diff --git a/drivers/video/fbdev/core/fb_cmdline.c b/drivers/video/fbdev/core/fb_cmdline.c
index 3b5bd666b952..4d1634c492ec 100644
--- a/drivers/video/fbdev/core/fb_cmdline.c
+++ b/drivers/video/fbdev/core/fb_cmdline.c
@@ -12,16 +12,14 @@
* for more details.
*
* Authors:
- * Vetter <danie.vetter@ffwll.ch>
+ * Daniel Vetter <daniel.vetter@ffwll.ch>
*/
-#include <linux/init.h>
-#include <linux/fb.h>
-static char *video_options[FB_MAX] __read_mostly;
-static int ofonly __read_mostly;
+#include <linux/export.h>
+#include <linux/fb.h>
+#include <linux/string.h>
-const char *fb_mode_option;
-EXPORT_SYMBOL_GPL(fb_mode_option);
+#include <video/cmdline.h>
/**
* fb_get_options - get kernel boot parameters
@@ -30,78 +28,34 @@ EXPORT_SYMBOL_GPL(fb_mode_option);
* (video=<name>:<options>)
* @option: the option will be stored here
*
+ * The caller owns the string returned in @option and is
+ * responsible for releasing the memory.
+ *
* NOTE: Needed to maintain backwards compatibility
*/
int fb_get_options(const char *name, char **option)
{
- char *opt, *options = NULL;
- int retval = 0;
- int name_len = strlen(name), i;
-
- if (name_len && ofonly && strncmp(name, "offb", 4))
- retval = 1;
+ const char *options = NULL;
+ bool is_of = false;
+ bool enabled;
- if (name_len && !retval) {
- for (i = 0; i < FB_MAX; i++) {
- if (video_options[i] == NULL)
- continue;
- if (!video_options[i][0])
- continue;
- opt = video_options[i];
- if (!strncmp(name, opt, name_len) &&
- opt[name_len] == ':')
- options = opt + name_len + 1;
- }
- }
- /* No match, pass global option */
- if (!options && option && fb_mode_option)
- options = kstrdup(fb_mode_option, GFP_KERNEL);
- if (options && !strncmp(options, "off", 3))
- retval = 1;
-
- if (option)
- *option = options;
-
- return retval;
-}
-EXPORT_SYMBOL(fb_get_options);
+ if (name)
+ is_of = strncmp(name, "offb", 4);
-/**
- * video_setup - process command line options
- * @options: string of options
- *
- * Process command line options for frame buffer subsystem.
- *
- * NOTE: This function is a __setup and __init function.
- * It only stores the options. Drivers have to call
- * fb_get_options() as necessary.
- */
-static int __init video_setup(char *options)
-{
- if (!options || !*options)
- goto out;
+ enabled = __video_get_options(name, &options, is_of);
- if (!strncmp(options, "ofonly", 6)) {
- ofonly = 1;
- goto out;
+ if (options) {
+ if (!strncmp(options, "off", 3))
+ enabled = false;
}
- if (strchr(options, ':')) {
- /* named */
- int i;
-
- for (i = 0; i < FB_MAX; i++) {
- if (video_options[i] == NULL) {
- video_options[i] = options;
- break;
- }
- }
- } else {
- /* global */
- fb_mode_option = options;
+ if (option) {
+ if (options)
+ *option = kstrdup(options, GFP_KERNEL);
+ else
+ *option = NULL;
}
-out:
- return 1;
+ return enabled ? 0 : 1; // 0 on success, 1 otherwise
}
-__setup("video=", video_setup);
+EXPORT_SYMBOL(fb_get_options);