1/*
2 *  linux/drivers/video/fb_cmdline.c
3 *
4 *  Copyright (C) 2014 Intel Corp
5 *  Copyright (C) 1994 Martin Schaller
6 *
7 *	2001 - Documented with DocBook
8 *	- Brad Douglas <brad@neruo.com>
9 *
10 * This file is subject to the terms and conditions of the GNU General Public
11 * License.  See the file COPYING in the main directory of this archive
12 * for more details.
13 *
14 * Authors:
15 *    Daniel Vetter <daniel.vetter@ffwll.ch>
16 */
17
18#include <linux/export.h>
19#include <linux/fb.h>
20#include <linux/string.h>
21
22#include <video/cmdline.h>
23
24/**
25 * fb_get_options - get kernel boot parameters
26 * @name:   framebuffer name as it would appear in
27 *          the boot parameter line
28 *          (video=<name>:<options>)
29 * @option: the option will be stored here
30 *
31 * The caller owns the string returned in @option and is
32 * responsible for releasing the memory.
33 *
34 * NOTE: Needed to maintain backwards compatibility
35 */
36int fb_get_options(const char *name, char **option)
37{
38	const char *options = NULL;
39	bool is_of = false;
40	bool enabled;
41
42	if (name)
43		is_of = strncmp(name, "offb", 4);
44
45	enabled = __video_get_options(name, &options, is_of);
46
47	if (options) {
48		if (!strncmp(options, "off", 3))
49			enabled = false;
50	}
51
52	if (option) {
53		if (options)
54			*option = kstrdup(options, GFP_KERNEL);
55		else
56			*option = NULL;
57	}
58
59	return enabled ? 0 : 1; // 0 on success, 1 otherwise
60}
61EXPORT_SYMBOL(fb_get_options);
62