File tree Expand file tree Collapse file tree 2 files changed +24
-3
lines changed
tools/bootconfig/include/linux Expand file tree Collapse file tree 2 files changed +24
-3
lines changed Original file line number Diff line number Diff line change 66
77#define pr_fmt (fmt ) "bootconfig: " fmt
88
9+ #include <linux/bootconfig.h>
910#include <linux/bug.h>
1011#include <linux/ctype.h>
1112#include <linux/errno.h>
1213#include <linux/kernel.h>
14+ #include <linux/memblock.h>
1315#include <linux/printk.h>
14- #include <linux/bootconfig.h>
1516#include <linux/string.h>
1617
1718/*
2324 * node (for array).
2425 */
2526
26- static struct xbc_node xbc_nodes [ XBC_NODE_MAX ] __initdata ;
27+ static struct xbc_node * xbc_nodes __initdata ;
2728static int xbc_node_num __initdata ;
2829static char * xbc_data __initdata ;
2930static size_t xbc_data_size __initdata ;
@@ -719,7 +720,8 @@ void __init xbc_destroy_all(void)
719720 xbc_data = NULL ;
720721 xbc_data_size = 0 ;
721722 xbc_node_num = 0 ;
722- memset (xbc_nodes , 0 , sizeof (xbc_nodes ));
723+ memblock_free (__pa (xbc_nodes ), sizeof (struct xbc_node ) * XBC_NODE_MAX );
724+ xbc_nodes = NULL ;
723725}
724726
725727/**
@@ -748,6 +750,13 @@ int __init xbc_init(char *buf)
748750 return - ERANGE ;
749751 }
750752
753+ xbc_nodes = memblock_alloc (sizeof (struct xbc_node ) * XBC_NODE_MAX ,
754+ SMP_CACHE_BYTES );
755+ if (!xbc_nodes ) {
756+ pr_err ("Failed to allocate memory for bootconfig nodes.\n" );
757+ return - ENOMEM ;
758+ }
759+ memset (xbc_nodes , 0 , sizeof (struct xbc_node ) * XBC_NODE_MAX );
751760 xbc_data = buf ;
752761 xbc_data_size = ret + 1 ;
753762 last_parent = NULL ;
Original file line number Diff line number Diff line change 1+ /* SPDX-License-Identifier: GPL-2.0 */
2+ #ifndef _XBC_LINUX_MEMBLOCK_H
3+ #define _XBC_LINUX_MEMBLOCK_H
4+
5+ #include <stdlib.h>
6+
7+ #define __pa (addr ) (addr)
8+ #define SMP_CACHE_BYTES 0
9+ #define memblock_alloc (size , align ) malloc(size)
10+ #define memblock_free (paddr , size ) free(paddr)
11+
12+ #endif
You can’t perform that action at this time.
0 commit comments