video/fbdev: Always built-in video= cmdline parsing
authorDaniel Vetter <daniel.vetter@ffwll.ch>
Wed, 6 Aug 2014 09:36:38 +0000 (11:36 +0200)
committerDaniel Vetter <daniel.vetter@ffwll.ch>
Wed, 6 Aug 2014 12:50:02 +0000 (14:50 +0200)
In drm/i915 we want to get at the video= cmdline modes even when we
don't have fbdev support enabled, so that users can always override
the kernel's initial mode selection.

But that gives us a direct depency upon the parsing code in the fbdev
subsystem. Since it's so little code just extract these 2 functions
and always build them in.

Whiel at it fix the checkpatch fail in this code.

v2: Also move fb_mode_option. Spotted by the kbuild.

v3: Review from Geert:
- Keep the old copyright notice from fb_mem.c, although I have no
idea what exactly applies.
- Only compile this when needed.

Cc: Geert Uytterhoeven <geert@linux-m68k.org>
Cc: Plagniol-Villard <plagnioj@jcrosoft.com>
Cc: Tomi Valkeinen <tomi.valkeinen@ti.com>
Cc: linux-fbdev@vger.kernel.org
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
--

I prefer if we can merge this through drm-next since we'll use it
there in follow-up patches.
-Daniel

drivers/video/fbdev/Kconfig
drivers/video/fbdev/core/Makefile
drivers/video/fbdev/core/fb_cmdline.c [new file with mode: 0644]
drivers/video/fbdev/core/fbmem.c
drivers/video/fbdev/core/modedb.c

index 59c98bfd5a8a68299aa87cc356b054af7a47558e..f1458c95a688781c1e2b2492e5dd228afd3a69a6 100644 (file)
@@ -4,6 +4,7 @@
 
 menuconfig FB
        tristate "Support for frame buffer devices"
+       select FB_CMDLINE
        ---help---
          The frame buffer device provides an abstraction for the graphics
          hardware. It represents the frame buffer of some video hardware and
@@ -52,6 +53,9 @@ config FIRMWARE_EDID
         combination with certain motherboards and monitors are known to
         suffer from this problem.
 
+config FB_CMDLINE
+       bool
+
 config FB_DDC
        tristate
        depends on FB
index fa306538dac29ae6bfab136546949377e968782b..67f28e20a89256c0b11a23d9a81bf8defa98c1e5 100644 (file)
@@ -1,4 +1,5 @@
 obj-y                             += fb_notify.o
+obj-$(CONFIG_FB_CMDLINE)          += fb_cmdline.o
 obj-$(CONFIG_FB)                  += fb.o
 fb-y                              := fbmem.o fbmon.o fbcmap.o fbsysfs.o \
                                      modedb.o fbcvt.o
diff --git a/drivers/video/fbdev/core/fb_cmdline.c b/drivers/video/fbdev/core/fb_cmdline.c
new file mode 100644 (file)
index 0000000..39509cc
--- /dev/null
@@ -0,0 +1,110 @@
+/*
+ *  linux/drivers/video/fb_cmdline.c
+ *
+ *  Copyright (C) 2014 Intel Corp
+ *  Copyright (C) 1994 Martin Schaller
+ *
+ *     2001 - Documented with DocBook
+ *     - Brad Douglas <brad@neruo.com>
+ *
+ * This file is subject to the terms and conditions of the GNU General Public
+ * License.  See the file COPYING in the main directory of this archive
+ * for more details.
+ *
+ * Authors:
+ *    Vetter <danie.vetter@ffwll.ch>
+ */
+#include <linux/init.h>
+#include <linux/fb.h>
+
+static char *video_options[FB_MAX] __read_mostly;
+static int ofonly __read_mostly;
+
+const char *fb_mode_option;
+EXPORT_SYMBOL_GPL(fb_mode_option);
+
+/**
+ * fb_get_options - get kernel boot parameters
+ * @name:   framebuffer name as it would appear in
+ *          the boot parameter line
+ *          (video=<name>:<options>)
+ * @option: the option will be stored here
+ *
+ * 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;
+
+       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);
+
+/**
+ *     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.
+ *
+ *     Returns zero.
+ *
+ */
+static int __init video_setup(char *options)
+{
+       int i, global = 0;
+
+       if (!options || !*options)
+               global = 1;
+
+       if (!global && !strncmp(options, "ofonly", 6)) {
+               ofonly = 1;
+               global = 1;
+       }
+
+       if (!global && !strchr(options, ':')) {
+               fb_mode_option = options;
+               global = 1;
+       }
+
+       if (!global) {
+               for (i = 0; i < FB_MAX; i++) {
+                       if (video_options[i] == NULL) {
+                               video_options[i] = options;
+                               break;
+                       }
+               }
+       }
+
+       return 1;
+}
+__setup("video=", video_setup);
index b5e85f6c1c26a8576a74a6205a3857ebbeffe9bf..0705d8883edecc785a72f4ef256b9894e4d0e950 100644 (file)
@@ -1908,96 +1908,4 @@ int fb_new_modelist(struct fb_info *info)
        return err;
 }
 
-static char *video_options[FB_MAX] __read_mostly;
-static int ofonly __read_mostly;
-
-/**
- * fb_get_options - get kernel boot parameters
- * @name:   framebuffer name as it would appear in
- *          the boot parameter line
- *          (video=<name>:<options>)
- * @option: the option will be stored here
- *
- * 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;
-
-       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);
-
-#ifndef MODULE
-/**
- *     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.
- *
- *     Returns zero.
- *
- */
-static int __init video_setup(char *options)
-{
-       int i, global = 0;
-
-       if (!options || !*options)
-               global = 1;
-
-       if (!global && !strncmp(options, "ofonly", 6)) {
-               ofonly = 1;
-               global = 1;
-       }
-
-       if (!global && !strchr(options, ':')) {
-               fb_mode_option = options;
-               global = 1;
-       }
-
-       if (!global) {
-               for (i = 0; i < FB_MAX; i++) {
-                       if (video_options[i] == NULL) {
-                               video_options[i] = options;
-                               break;
-                       }
-
-               }
-       }
-
-       return 1;
-}
-__setup("video=", video_setup);
-#endif
-
 MODULE_LICENSE("GPL");
index a9a907c440d73ee89f2acc8fd20d7aa905230b43..388f7971494b1bea4b0fe1e6ab0e6a607f0baa66 100644 (file)
@@ -29,9 +29,6 @@
 #define DPRINTK(fmt, args...)
 #endif
 
-const char *fb_mode_option;
-EXPORT_SYMBOL_GPL(fb_mode_option);
-
 /*
  *  Standard video mode definitions (taken from XFree86)
  */
This page took 0.0297 seconds and 5 git commands to generate.