From patchwork Mon Nov 27 07:06:06 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 119657 Delivered-To: patch@linaro.org Received: by 10.140.22.164 with SMTP id 33csp1384496qgn; Sun, 26 Nov 2017 23:06:54 -0800 (PST) X-Google-Smtp-Source: AGs4zMZG7mMB6VxQnVgvxhUse0iVmDWZtiWxp7rxbN9WBjMiCeJX2OVM8WsXmbwo2rvQ6QNt8uCa X-Received: by 10.80.177.250 with SMTP id n55mr52796515edd.30.1511766414166; Sun, 26 Nov 2017 23:06:54 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1511766414; cv=none; d=google.com; s=arc-20160816; b=vTado5e76dbi352pjzbBuPniSIsNLjiiRGYA+0Lrc82BixJeZPt26JsHIUkBxYTSJN aadO9npPJVnCmXGBCmEM5xN/fQXegysyb3S22Nx4BjNuUKXE+JIuuAUDo6dlERWcV/+u CCfOKTC1folEPrxzDlZu88kO3IpTHB7+hsXlXFjjnSXx7qoqj2Ukk5LErGkUX8qkETCO piGPfdCenPog+zczdlJS0CKwOTGddHpA3FGes36rROEXVSO2Jfbzx7/XYHxkJb+M0Jv+ Gr1TzngZKUkM1sKNNdZ4kFzMLPwqMeEmMf35GgHuYWHyC1/eOctuiD/WW0hW+t1b7tdc nZ2Q== 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:references:in-reply-to:message-id:date :to:from:dkim-signature:dkim-filter:arc-authentication-results; bh=bAaCsWtdjkzaozxqDeQtY+FC3QrpR/R3DZr2rSZAryw=; b=N4l91vqrfntBZj1SHGQyK7sw4ge5aNY1qIoXl5YDNfxYVPsk+eJXjAC4u59/PH6yKf ckfCYXm+sBe3lTQZSSpZWKJpwUEDET2YwsVoCqD/dfpNpvR3ScnqIJcVDURaHH3w9wS6 iF/3CS9BzqO4sCe/r0rZeo6lcSvPpM9X6LPPFo03mNXKH2Tq/sKXraK4EkS2MCdcJVu/ 3WCXl5IE/lhFuPL9KmFjrIVMPVC22C/LQhRbFkxUJ2J0T0QFBptcgbk/6m97l33vHmOl 27HaonQiRCW+jfz9qdml033IwZXLCilj4pVyNfzEjzlrvNLxcI3ePRZik/ZLdGE5S9+b jIzg== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@nifty.com header.s=dec2015msa header.b=PcYLeTmo; 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 y45si1859884edc.82.2017.11.26.23.06.53; Sun, 26 Nov 2017 23:06:54 -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=PcYLeTmo; 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 6CBBFC21E5A; Mon, 27 Nov 2017 07:06:52 +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 2F4D1C21DB2; Mon, 27 Nov 2017 07:06:50 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 5F02BC21DB2; Mon, 27 Nov 2017 07:06:48 +0000 (UTC) Received: from conuserg-09.nifty.com (conuserg-09.nifty.com [210.131.2.76]) by lists.denx.de (Postfix) with ESMTPS id A0B4DC21D8C for ; Mon, 27 Nov 2017 07:06:46 +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 vAR76GXu021781; Mon, 27 Nov 2017 16:06:18 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conuserg-09.nifty.com vAR76GXu021781 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1511766378; bh=kopUNqhoJ1aK2FK4pgeX2yEw+ZOpURBXfguzI4spS3I=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=PcYLeTmoglHoURBDDYRBnOr9kh+OBGypeF2DYRGGwZSL5fOqCyDY//BjBKPndiywy rfLmrRN5nMlHq8JTnbL4MDF2X0ptJgCVlJY/mP6+2u7/cH1l7SC7VcqFvlMC4ZM5sQ gQkISN4qYLBHseSSHjWGsaLcMi3+UCSIPTd0i8vid8gHtOLwKr47LY7+rMvWozd1qJ 0a0Fl875LxAUVtfGO8sJc00jxFaaBzBe2SWvJWyKcrU2Wp9wriisKeDAkJK3jzz6FG 8n9z3W7DfMH0LWiye7ETyzdUfgFy4oVPsu/6XF/34vYmazbTMF/Ct0CkNKZLKuz0jh 5akhY66JvwKLA== X-Nifty-SrcIP: [153.142.97.92] From: Masahiro Yamada To: u-boot@lists.denx.de Date: Mon, 27 Nov 2017 16:06:06 +0900 Message-Id: <1511766367-20787-2-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> Subject: [U-Boot] [PATCH 1/2] libfdt: move fdt_find_regions() to fdt_region.c from 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" All the other fdt_*_region() functions are located in fdt_region.c, while only fdt_find_regions() was added to fdt_wip.c, strangely. Move it to the suitable place. Signed-off-by: Masahiro Yamada Reviewed-by: Simon Glass --- lib/libfdt/fdt_region.c | 129 ++++++++++++++++++++++++++++++++++++++++++++++++ lib/libfdt/fdt_wip.c | 129 ------------------------------------------------ 2 files changed, 129 insertions(+), 129 deletions(-) diff --git a/lib/libfdt/fdt_region.c b/lib/libfdt/fdt_region.c index 63099f1..5bfc4da 100644 --- a/lib/libfdt/fdt_region.c +++ b/lib/libfdt/fdt_region.c @@ -16,6 +16,135 @@ #include "libfdt_internal.h" +#define FDT_MAX_DEPTH 32 + +static int str_in_list(const char *str, char * const list[], int count) +{ + int i; + + for (i = 0; i < count; i++) + if (!strcmp(list[i], str)) + return 1; + + return 0; +} + +int fdt_find_regions(const void *fdt, char * const inc[], int inc_count, + char * const exc_prop[], int exc_prop_count, + struct fdt_region region[], int max_regions, + char *path, int path_len, int add_string_tab) +{ + int stack[FDT_MAX_DEPTH] = { 0 }; + char *end; + int nextoffset = 0; + uint32_t tag; + int count = 0; + int start = -1; + int depth = -1; + int want = 0; + int base = fdt_off_dt_struct(fdt); + + end = path; + *end = '\0'; + do { + const struct fdt_property *prop; + const char *name; + const char *str; + int include = 0; + int stop_at = 0; + int offset; + int len; + + offset = nextoffset; + tag = fdt_next_tag(fdt, offset, &nextoffset); + stop_at = nextoffset; + + switch (tag) { + case FDT_PROP: + include = want >= 2; + stop_at = offset; + prop = fdt_get_property_by_offset(fdt, offset, NULL); + str = fdt_string(fdt, fdt32_to_cpu(prop->nameoff)); + if (str_in_list(str, exc_prop, exc_prop_count)) + include = 0; + break; + + case FDT_NOP: + include = want >= 2; + stop_at = offset; + break; + + case FDT_BEGIN_NODE: + depth++; + if (depth == FDT_MAX_DEPTH) + return -FDT_ERR_BADSTRUCTURE; + name = fdt_get_name(fdt, offset, &len); + if (end - path + 2 + len >= path_len) + return -FDT_ERR_NOSPACE; + if (end != path + 1) + *end++ = '/'; + strcpy(end, name); + end += len; + stack[depth] = want; + if (want == 1) + stop_at = offset; + if (str_in_list(path, inc, inc_count)) + want = 2; + else if (want) + want--; + else + stop_at = offset; + include = want; + break; + + case FDT_END_NODE: + include = want; + want = stack[depth--]; + while (end > path && *--end != '/') + ; + *end = '\0'; + break; + + case FDT_END: + include = 1; + break; + } + + if (include && start == -1) { + /* Should we merge with previous? */ + if (count && count <= max_regions && + offset == region[count - 1].offset + + region[count - 1].size - base) + start = region[--count].offset - base; + else + start = offset; + } + + if (!include && start != -1) { + if (count < max_regions) { + region[count].offset = base + start; + region[count].size = stop_at - start; + } + count++; + start = -1; + } + } while (tag != FDT_END); + + if (nextoffset != fdt_size_dt_struct(fdt)) + return -FDT_ERR_BADLAYOUT; + + /* Add a region for the END tag and the string table */ + if (count < max_regions) { + region[count].offset = base + start; + region[count].size = nextoffset - start; + if (add_string_tab) + region[count].size += fdt_size_dt_strings(fdt); + } + count++; + + return count; +} + /** * fdt_add_region() - Add a new region to our list * @info: State information diff --git a/lib/libfdt/fdt_wip.c b/lib/libfdt/fdt_wip.c index 01adad0..7274c81 100644 --- a/lib/libfdt/fdt_wip.c +++ b/lib/libfdt/fdt_wip.c @@ -96,132 +96,3 @@ int fdt_nop_node(void *fdt, int nodeoffset) endoffset - nodeoffset); return 0; } - -#define FDT_MAX_DEPTH 32 - -static int str_in_list(const char *str, char * const list[], int count) -{ - int i; - - for (i = 0; i < count; i++) - if (!strcmp(list[i], str)) - return 1; - - return 0; -} - -int fdt_find_regions(const void *fdt, char * const inc[], int inc_count, - char * const exc_prop[], int exc_prop_count, - struct fdt_region region[], int max_regions, - char *path, int path_len, int add_string_tab) -{ - int stack[FDT_MAX_DEPTH] = { 0 }; - char *end; - int nextoffset = 0; - uint32_t tag; - int count = 0; - int start = -1; - int depth = -1; - int want = 0; - int base = fdt_off_dt_struct(fdt); - - end = path; - *end = '\0'; - do { - const struct fdt_property *prop; - const char *name; - const char *str; - int include = 0; - int stop_at = 0; - int offset; - int len; - - offset = nextoffset; - tag = fdt_next_tag(fdt, offset, &nextoffset); - stop_at = nextoffset; - - switch (tag) { - case FDT_PROP: - include = want >= 2; - stop_at = offset; - prop = fdt_get_property_by_offset(fdt, offset, NULL); - str = fdt_string(fdt, fdt32_to_cpu(prop->nameoff)); - if (str_in_list(str, exc_prop, exc_prop_count)) - include = 0; - break; - - case FDT_NOP: - include = want >= 2; - stop_at = offset; - break; - - case FDT_BEGIN_NODE: - depth++; - if (depth == FDT_MAX_DEPTH) - return -FDT_ERR_BADSTRUCTURE; - name = fdt_get_name(fdt, offset, &len); - if (end - path + 2 + len >= path_len) - return -FDT_ERR_NOSPACE; - if (end != path + 1) - *end++ = '/'; - strcpy(end, name); - end += len; - stack[depth] = want; - if (want == 1) - stop_at = offset; - if (str_in_list(path, inc, inc_count)) - want = 2; - else if (want) - want--; - else - stop_at = offset; - include = want; - break; - - case FDT_END_NODE: - include = want; - want = stack[depth--]; - while (end > path && *--end != '/') - ; - *end = '\0'; - break; - - case FDT_END: - include = 1; - break; - } - - if (include && start == -1) { - /* Should we merge with previous? */ - if (count && count <= max_regions && - offset == region[count - 1].offset + - region[count - 1].size - base) - start = region[--count].offset - base; - else - start = offset; - } - - if (!include && start != -1) { - if (count < max_regions) { - region[count].offset = base + start; - region[count].size = stop_at - start; - } - count++; - start = -1; - } - } while (tag != FDT_END); - - if (nextoffset != fdt_size_dt_struct(fdt)) - return -FDT_ERR_BADLAYOUT; - - /* Add a region for the END tag and the string table */ - if (count < max_regions) { - region[count].offset = base + start; - region[count].size = nextoffset - start; - if (add_string_tab) - region[count].size += fdt_size_dt_strings(fdt); - } - count++; - - return count; -} 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"