brcm2708: update linux 4.4 patches to latest version
[openwrt/openwrt.git] / target / linux / brcm2708 / patches-4.4 / 0051-fdt-Add-support-for-the-CONFIG_CMDLINE_EXTEND-option.patch
1 From a251bf4a37d8fd468bc3ff853bcebe8ee452a31e Mon Sep 17 00:00:00 2001
2 From: Phil Elwell <phil@raspberrypi.org>
3 Date: Fri, 5 Dec 2014 17:26:26 +0000
4 Subject: [PATCH 051/170] fdt: Add support for the CONFIG_CMDLINE_EXTEND option
5
6 ---
7 drivers/of/fdt.c | 29 ++++++++++++++++++++++++-----
8 1 file changed, 24 insertions(+), 5 deletions(-)
9
10 --- a/drivers/of/fdt.c
11 +++ b/drivers/of/fdt.c
12 @@ -954,22 +954,38 @@ int __init early_init_dt_scan_chosen(uns
13
14 /* Retrieve command line */
15 p = of_get_flat_dt_prop(node, "bootargs", &l);
16 - if (p != NULL && l > 0)
17 - strlcpy(data, p, min((int)l, COMMAND_LINE_SIZE));
18 - p = of_get_flat_dt_prop(node, "bootargs-append", &l);
19 - if (p != NULL && l > 0)
20 - strlcat(data, p, min_t(int, strlen(data) + (int)l, COMMAND_LINE_SIZE));
21
22 /*
23 * CONFIG_CMDLINE is meant to be a default in case nothing else
24 * managed to set the command line, unless CONFIG_CMDLINE_FORCE
25 * is set in which case we override whatever was found earlier.
26 + *
27 + * However, it can be useful to be able to treat the default as
28 + * a starting point to be extended using CONFIG_CMDLINE_EXTEND.
29 */
30 + ((char *)data)[0] = '\0';
31 +
32 #ifdef CONFIG_CMDLINE
33 -#ifndef CONFIG_CMDLINE_FORCE
34 - if (!((char *)data)[0])
35 + strlcpy(data, CONFIG_CMDLINE, COMMAND_LINE_SIZE);
36 +
37 + if (p != NULL && l > 0) {
38 +#if defined(CONFIG_CMDLINE_EXTEND)
39 + int len = strlen(data);
40 + if (len > 0) {
41 + strlcat(data, " ", COMMAND_LINE_SIZE);
42 + len++;
43 + }
44 + strlcpy((char *)data + len, p, min((int)l, COMMAND_LINE_SIZE - len));
45 +#elif defined(CONFIG_CMDLINE_FORCE)
46 + pr_warning("Ignoring bootargs property (using the default kernel command line)\n");
47 +#else
48 + /* Neither extend nor force - just override */
49 + strlcpy(data, p, min((int)l, COMMAND_LINE_SIZE));
50 #endif
51 - strlcpy(data, CONFIG_CMDLINE, COMMAND_LINE_SIZE);
52 + }
53 +#else /* CONFIG_CMDLINE */
54 + if (p != NULL && l > 0)
55 + strlcpy(data, p, min((int)l, COMMAND_LINE_SIZE));
56 #endif /* CONFIG_CMDLINE */
57
58 pr_debug("Command line is: %s\n", (char*)data);