From: Rob Herring Date: Tue, 3 Oct 2017 16:07:55 +0000 (-0500) Subject: of/fdt: skip unflattening of disabled nodes X-Git-Url: http://git.lede-project.org./?a=commitdiff_plain;h=77ea8a68c54ede3fd60dadb6a49b597f6eb5aee7;p=openwrt%2Fstaging%2Fblogic.git of/fdt: skip unflattening of disabled nodes For static DT usecases, we don't need the disabled nodes and can skip unflattening. This saves a significant amount of RAM in memory constrained cases. In one example on STM32F469, the RAM usage goes from 118K to 26K. There are a few cases in the kernel that modify the status property dynamically. These all are changes from enabled to disabled, depend on OF_DYNAMIC or are not FDT based (PDT based). Tested-by: Nicolas Pitre Reviewed-by: Frank Rowand Signed-off-by: Rob Herring --- diff --git a/drivers/of/fdt.c b/drivers/of/fdt.c index f8c39705418b..2d515b85a198 100644 --- a/drivers/of/fdt.c +++ b/drivers/of/fdt.c @@ -396,6 +396,10 @@ static int unflatten_dt_nodes(const void *blob, if (WARN_ON_ONCE(depth >= FDT_MAX_DEPTH)) continue; + if (!IS_ENABLED(CONFIG_OF_KOBJ) && + !of_fdt_device_is_available(blob, offset)) + continue; + if (!populate_node(blob, offset, &mem, nps[depth], &nps[depth+1], dryrun)) return mem - base;