generic: 4.4: refresh patches
[openwrt.git] / target / linux / ixp4xx / patches-3.18 / 162-wg302v1_mem_fixup.patch
1 --- a/arch/arm/mach-ixp4xx/wg302v1-setup.c
2 +++ b/arch/arm/mach-ixp4xx/wg302v1-setup.c
3 @@ -117,6 +117,35 @@ static struct platform_device *wg302v1_d
4         &wg302v1_eth[0],
5  };
6  
7 +static char wg302v1_mem_fixup[] __initdata = " mem=32M";
8 +
9 +static void __init wg302v1_fixup(struct tag *tags, char **cmdline,
10 +                                struct meminfo *mi)
11 +{
12 +       struct tag *t = tags;
13 +       char *p = *cmdline;
14 +       size_t fixlen, cmdlen;
15 +
16 +       /* Find the end of the tags table, taking note of any cmdline tag. */
17 +       for (; t->hdr.size; t = tag_next(t)) {
18 +               if (t->hdr.tag == ATAG_CMDLINE) {
19 +                       p = t->u.cmdline.cmdline;
20 +               }
21 +       }
22 +
23 +       fixlen = strlen(wg302v1_mem_fixup);
24 +       cmdlen = strlen(p);
25 +       if (fixlen + cmdlen >= COMMAND_LINE_SIZE)
26 +               return;
27 +
28 +       /* append the fixup to the cmdline */
29 +       memmove(p + cmdlen, wg302v1_mem_fixup, fixlen + 1);
30 +
31 +       /* Adjust the size of the atag if there was one */
32 +       if (t->hdr.size)
33 +               t->hdr.size += fixlen;
34 +}
35 +
36  static void __init wg302v1_init(void)
37  {
38         ixp4xx_sys_init();