From patchwork Mon Nov 27 07:06:07 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 119658 Delivered-To: patch@linaro.org Received: by 10.140.22.164 with SMTP id 33csp1385182qgn; Sun, 26 Nov 2017 23:07:38 -0800 (PST) X-Google-Smtp-Source: AGs4zMbWWclHURJu7yS1WhxUm4mvxlF7hJuyeuUAdrDjntPXKEq/VsTu8mVmuRlEht2tXdUyVFdt X-Received: by 10.80.204.72 with SMTP id n8mr43633864edi.64.1511766458769; Sun, 26 Nov 2017 23:07:38 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1511766458; cv=none; d=google.com; s=arc-20160816; b=p8nT+v4sCvvErDXQihODhO+TeM8d0VF160cyUXPWcaDQAle+xI1X3saZMpyTY1JVzr ZOCXbt+l0lTy8RGlD9C3IYyJjEMjxXJDKYAyDohHacjixmf2fxTEpI6jU+O/gln9vq3z 76b9D3xLbiHhBJGqfcj0AQfvAZrUp6ZPzI6f7WjKqS1R2wdx6oRRojujaYGKiJr4bwuQ Q+acWkS0NDwITS5z3t0bRfiJtNg6rWE5FJUNgBwuUHe9W/GmFjrX/F79cHFrEJorGRRr GhMz7cpVFP13HCrh+Qu7DasxKqHtGvqmG6gfB7C1sy1zfabw4VLyoQCjnbj/jXQnIHm6 0qFA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:cc:references:in-reply-to:message-id :date:to:from:dkim-signature:dkim-filter:arc-authentication-results; bh=tYkIv+4GlrES7OniJ3qRZiratS7ogq9nGXAi2KzyVig=; b=a/wGMDMkUNpcXmxmOSiYE1q42olZ+cWm69d9FWKn4AvD85vnC2I0WZSrW8NRBDKNMA SCVpf4a5vj5RSn9rKKVvna7h+JqZjSe2Y1XZsOK2Ed1v3fL5YNO7uHuuZRzhgRT1DJiI Q6xXQMYWFUYU74Jsf25xhOZfssM4MgAX+ak+OHHMncNmr/309OPgiSM1ScQMHGUchn1v 0tDk+pc0QMB63+QkCtWmHBmSkBtqujRUcEbpK7HEFmRHjG9fDhqMYJHIuY+qKgY5goTf I5o/h82m7i6WeXG3BByf3MoFyAR4G3g1o9L/+iCePIx6m5BKaxU2psfvPZFs74NnRjch C/eg== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@nifty.com header.s=dec2015msa header.b=nB4JajK/; spf=pass (google.com: best guess record for domain of u-boot-bounces@lists.denx.de designates 81.169.180.215 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de Return-Path: Received: from lists.denx.de (dione.denx.de. [81.169.180.215]) by mx.google.com with ESMTP id z11si1509658edj.325.2017.11.26.23.07.38; Sun, 26 Nov 2017 23:07:38 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of u-boot-bounces@lists.denx.de designates 81.169.180.215 as permitted sender) client-ip=81.169.180.215; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@nifty.com header.s=dec2015msa header.b=nB4JajK/; spf=pass (google.com: best guess record for domain of u-boot-bounces@lists.denx.de designates 81.169.180.215 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de Received: by lists.denx.de (Postfix, from userid 105) id 53436C21E40; Mon, 27 Nov 2017 07:07:31 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on lists.denx.de X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=RCVD_IN_DNSWL_BLOCKED, T_DKIM_INVALID autolearn=unavailable autolearn_force=no version=3.4.0 Received: from lists.denx.de (localhost [IPv6:::1]) by lists.denx.de (Postfix) with ESMTP id D6BC5C21DF4; Mon, 27 Nov 2017 07:07:29 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 17E62C21E41; Mon, 27 Nov 2017 07:07:16 +0000 (UTC) Received: from conuserg-09.nifty.com (conuserg-09.nifty.com [210.131.2.76]) by lists.denx.de (Postfix) with ESMTPS id D30B6C21E72 for ; Mon, 27 Nov 2017 07:07:15 +0000 (UTC) Received: from pug.e01.socionext.com (p14092-ipngnfx01kyoto.kyoto.ocn.ne.jp [153.142.97.92]) (authenticated) by conuserg-09.nifty.com with ESMTP id vAR76GXv021781; Mon, 27 Nov 2017 16:06:18 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conuserg-09.nifty.com vAR76GXv021781 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1511766379; bh=jqJbwNgi/ArB9c+o3b6WWA9JbMZ0++bvfMEg8GqgvKg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=nB4JajK/S8gBbb7lv8jhfm/YUjLoXa2otliDPCIhkCOpiq+BEbfL6crev1cXtOBjZ 6qxn/NK118GEstbqS5Wp3L8mWO2OEgia77Wd6+TgXVXDWMZ8J0ytdzRlUYbaMnFzrt qohermPNGL09/j7XMKz9Etblv4HJgg1VlVJgpIcIE6R2/f9CFqjRBU6V3FnLUVDze0 QJY8UtqCSXPgA+n8ZUDBhqoOEhAYG4YgIlQQfFkiqXGhyUI6eEr/Owtp7bc8pEnQPq qaN/v55or23fZh+BYjbtgYUcECYuRt+v2+hSJ3ymsCS98dBBcQpDZmsI7flKD76seN HTc3XBYbtaFuA== X-Nifty-SrcIP: [153.142.97.92] From: Masahiro Yamada To: u-boot@lists.denx.de Date: Mon, 27 Nov 2017 16:06:07 +0900 Message-Id: <1511766367-20787-3-git-send-email-yamada.masahiro@socionext.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1511766367-20787-1-git-send-email-yamada.masahiro@socionext.com> References: <1511766367-20787-1-git-send-email-yamada.masahiro@socionext.com> Cc: Stefan Roese , "oliver@schinagl.nl" , Olliver Schinagl Subject: [U-Boot] [PATCH 2/2] libfdt: migrate fdt_wip.c to a wrapper of scripts/dtc/libfdt/fdt_wip.c X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.18 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" Now, lib/libfdt/fdt_wip.c is the same as scripts/dtc/libfdt/fdt_wip.c Change the former to a wrapper of the latter. Signed-off-by: Masahiro Yamada Reviewed-by: Simon Glass --- lib/libfdt/Makefile | 4 +- lib/libfdt/fdt_wip.c | 100 +------------------------------------------------ tools/Makefile | 4 +- tools/libfdt/fdt_wip.c | 2 + 4 files changed, 8 insertions(+), 102 deletions(-) create mode 100644 tools/libfdt/fdt_wip.c diff --git a/lib/libfdt/Makefile b/lib/libfdt/Makefile index 369bbf9..be42e94 100644 --- a/lib/libfdt/Makefile +++ b/lib/libfdt/Makefile @@ -8,6 +8,7 @@ # Use upstream code. obj-y += \ fdt.o \ + fdt_wip.o \ fdt_strerror.o \ fdt_sw.o \ fdt_empty_tree.o \ @@ -19,8 +20,7 @@ obj-$(CONFIG_OF_LIBFDT_OVERLAY) += fdt_overlay.o # TODO: split out the local modifiction. obj-y += \ fdt_ro.o \ - fdt_rw.o \ - fdt_wip.o \ + fdt_rw.o # U-Boot own file obj-y += fdt_region.o diff --git a/lib/libfdt/fdt_wip.c b/lib/libfdt/fdt_wip.c index 7274c81..6a771d0 100644 --- a/lib/libfdt/fdt_wip.c +++ b/lib/libfdt/fdt_wip.c @@ -1,98 +1,2 @@ -/* - * libfdt - Flat Device Tree manipulation - * Copyright (C) 2006 David Gibson, IBM Corporation. - * SPDX-License-Identifier: GPL-2.0+ BSD-2-Clause - */ -#include - -#ifndef USE_HOSTCC -#include -#include -#else -#include "fdt_host.h" -#endif - -#include "libfdt_internal.h" - -int fdt_setprop_inplace_namelen_partial(void *fdt, int nodeoffset, - const char *name, int namelen, - uint32_t idx, const void *val, - int len) -{ - void *propval; - int proplen; - - propval = fdt_getprop_namelen_w(fdt, nodeoffset, name, namelen, - &proplen); - if (!propval) - return proplen; - - if (proplen < (len + idx)) - return -FDT_ERR_NOSPACE; - - memcpy((char *)propval + idx, val, len); - return 0; -} - -int fdt_setprop_inplace(void *fdt, int nodeoffset, const char *name, - const void *val, int len) -{ - const void *propval; - int proplen; - - propval = fdt_getprop(fdt, nodeoffset, name, &proplen); - if (!propval) - return proplen; - - if (proplen != len) - return -FDT_ERR_NOSPACE; - - return fdt_setprop_inplace_namelen_partial(fdt, nodeoffset, name, - strlen(name), 0, - val, len); -} - -static void _fdt_nop_region(void *start, int len) -{ - fdt32_t *p; - - for (p = start; (char *)p < ((char *)start + len); p++) - *p = cpu_to_fdt32(FDT_NOP); -} - -int fdt_nop_property(void *fdt, int nodeoffset, const char *name) -{ - struct fdt_property *prop; - int len; - - prop = fdt_get_property_w(fdt, nodeoffset, name, &len); - if (!prop) - return len; - - _fdt_nop_region(prop, len + sizeof(*prop)); - - return 0; -} - -int _fdt_node_end_offset(void *fdt, int offset) -{ - int depth = 0; - - while ((offset >= 0) && (depth >= 0)) - offset = fdt_next_node(fdt, offset, &depth); - - return offset; -} - -int fdt_nop_node(void *fdt, int nodeoffset) -{ - int endoffset; - - endoffset = _fdt_node_end_offset(fdt, nodeoffset); - if (endoffset < 0) - return endoffset; - - _fdt_nop_region(fdt_offset_ptr_w(fdt, nodeoffset, 0), - endoffset - nodeoffset); - return 0; -} +#include +#include "../../scripts/dtc/libfdt/fdt_wip.c" diff --git a/tools/Makefile b/tools/Makefile index acbcd87..4d32fe5 100644 --- a/tools/Makefile +++ b/tools/Makefile @@ -61,11 +61,11 @@ FIT_SIG_OBJS-$(CONFIG_FIT_SIGNATURE) := common/image-sig.o # The following files are synced with upstream DTC. # Use synced versions from scripts/dtc/libfdt/. -LIBFDT_SRCS_SYNCED := fdt.c fdt_sw.c fdt_strerror.c fdt_empty_tree.c \ +LIBFDT_SRCS_SYNCED := fdt.c fdt_wip.c fdt_sw.c fdt_strerror.c fdt_empty_tree.c \ fdt_addresses.c fdt_overlay.c # The following files are locally modified for U-Boot (unfotunately). # Use U-Boot own versions from lib/libfdt/. -LIBFDT_SRCS_UNSYNCED := fdt_ro.c fdt_wip.c fdt_rw.c fdt_region.c +LIBFDT_SRCS_UNSYNCED := fdt_ro.c fdt_rw.c fdt_region.c LIBFDT_OBJS := $(addprefix libfdt/, $(patsubst %.c, %.o, $(LIBFDT_SRCS_SYNCED))) \ $(addprefix lib/libfdt/, $(patsubst %.c, %.o, $(LIBFDT_SRCS_UNSYNCED))) diff --git a/tools/libfdt/fdt_wip.c b/tools/libfdt/fdt_wip.c new file mode 100644 index 0000000..bad73ed --- /dev/null +++ b/tools/libfdt/fdt_wip.c @@ -0,0 +1,2 @@ +#include "fdt_host.h" +#include "../scripts/dtc/libfdt/fdt_wip.c"