From patchwork Mon Mar 30 03:56:23 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kever Yang X-Patchwork-Id: 1263717 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=85.214.62.61; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=rock-chips.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20161025 header.b=oMpJU7dQ; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 48rJZg1wY9z9sPF for ; Mon, 30 Mar 2020 14:57:47 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id C94A8818F8; Mon, 30 Mar 2020 05:57:03 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=rock-chips.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="oMpJU7dQ"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 84549818F4; Mon, 30 Mar 2020 05:56:53 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,SPF_HELO_NONE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-pg1-x544.google.com (mail-pg1-x544.google.com [IPv6:2607:f8b0:4864:20::544]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 306EA818BA for ; Mon, 30 Mar 2020 05:56:50 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=rock-chips.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=kever.yang@gmail.com Received: by mail-pg1-x544.google.com with SMTP id l14so930618pgb.1 for ; Sun, 29 Mar 2020 20:56:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=KQco2P4392Vj8r6T+ATXypljBq/N/OYteNG3CJXEQdo=; b=oMpJU7dQ8DIxm0LVdWaXjbA7QGj+c0EUV8nsN8+SNtyn6tShQo4DIfpPAdwfU8NjGh 9EanOLNvlYapI8dMu8ExRqzrjCYnYWKp8UBTew/qT3d2jNKh4E8cH5wglmtDXwZcncyw gWiqsJm3WvjlLzGHfU7x4gvJ70qmTjcNR4VWAwW5VJT1UB+ZxlDM6enKaqLyYPvecGGk XaF0eUBIC7fa+kNmuhtsGQj0BVbM074TV91vKGD1KAufWlqlG3RCSam7iKWn0RHv2W5N 7pep0USEGRoaJinZiWRKx21WPAPcxwzcuRvt1d9X2xTKbcZ6o3ySl1AtFeQIfyqi9Bbl yBmw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references; bh=KQco2P4392Vj8r6T+ATXypljBq/N/OYteNG3CJXEQdo=; b=LG69CYUvE19AriUYCcqkzw8hAoZyayNnYQibFQZoxaHyvmNJN4RtiYa/f3uf2FeRRr 9XY67q1AOCTbu89p4bTeeEPt/G1lY5VbO094A32qEUbJzHndhaosifK16FLHYADRn1LM ZhaB2y9Q7sLpxN+2vD8qKnLc7q09xlvk2bPvdU7pn9y1ygkK9MgLCi7l7rV6/wOlDh3I enXlA6Bn7aMcuVYJNBMBl8XR5kd3duvNJF77L4smoIp4ybzEABALepKU1vigaiLio5JG 0FVu/NL/gGWKT7h9jAOl/CerdpI5PVz6E+3wskZwe2oLcpPkHueNx8d8x+bZ87Fb3tJe +NDQ== X-Gm-Message-State: ANhLgQ1Dj24G2ZfQJV6imHgckgKlqLu//xaRdeM95suldy+yAD8Y+Lzn ev5qEz6rAsWKV7XVcmQcVrKBksCl X-Google-Smtp-Source: ADFU+vv3GxyUReOi5e4Sx0PrNtvVNiAVBmWAD4Ke/lWABpJtH/QMeFzwGIRHlUs3Gfs9K1TAZE9AbQ== X-Received: by 2002:a63:140f:: with SMTP id u15mr10616529pgl.277.1585540608590; Sun, 29 Mar 2020 20:56:48 -0700 (PDT) Received: from localhost.localdomain ([103.29.142.67]) by smtp.gmail.com with ESMTPSA id n100sm8902514pjc.38.2020.03.29.20.56.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 29 Mar 2020 20:56:48 -0700 (PDT) From: Kever Yang To: u-boot@lists.denx.de Cc: chenjh@rock-chips.com, rasmus.villemoes@prevas.dk, trini@konsulko.com, xypron.glpk@gmx.de, punit1.agrawal@toshiba.co.jp, Kever Yang , Simon Glass Subject: [PATCH v4 7/8] libfdt: Make fdtdec_get_child_count() available for HOST Date: Mon, 30 Mar 2020 11:56:23 +0800 Message-Id: <20200330035625.25164-7-kever.yang@rock-chips.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200330035625.25164-1-kever.yang@rock-chips.com> References: <20200330035625.25164-1-kever.yang@rock-chips.com> X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.30rc1 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.102.2 at phobos.denx.de X-Virus-Status: Clean The tool need to use fdtdec_get_child_count(), make it available for HOST_CC. Signed-off-by: Kever Yang Reviewed-by: Punit Agrawal Reviewed-by: Simon Glass --- Changes in v4: - add function comment for fdtdec_get_child_count() in fdt_support.h Changes in v3: None Changes in v2: None include/fdt_support.h | 9 +++++++++ lib/fdtdec.c | 11 ----------- lib/fdtdec_common.c | 11 +++++++++++ 3 files changed, 20 insertions(+), 11 deletions(-) diff --git a/include/fdt_support.h b/include/fdt_support.h index ba14acd7f6..2eff311fa4 100644 --- a/include/fdt_support.h +++ b/include/fdt_support.h @@ -343,6 +343,15 @@ int fdt_get_cells_len(const void *blob, char *nr_cells_name); #ifdef USE_HOSTCC int fdtdec_get_int(const void *blob, int node, const char *prop_name, int default_val); + +/* + * Count child nodes of one parent node. + * + * @param blob FDT blob + * @param node parent node + * @return number of child node; 0 if there is not child node + */ +int fdtdec_get_child_count(const void *blob, int node); #endif #ifdef CONFIG_FMAN_ENET int fdt_update_ethernet_dt(void *blob); diff --git a/lib/fdtdec.c b/lib/fdtdec.c index eb11fc898e..e13af283a1 100644 --- a/lib/fdtdec.c +++ b/lib/fdtdec.c @@ -810,17 +810,6 @@ int fdtdec_parse_phandle_with_args(const void *blob, int src_node, return rc; } -int fdtdec_get_child_count(const void *blob, int node) -{ - int subnode; - int num = 0; - - fdt_for_each_subnode(subnode, blob, node) - num++; - - return num; -} - int fdtdec_get_byte_array(const void *blob, int node, const char *prop_name, u8 *array, int count) { diff --git a/lib/fdtdec_common.c b/lib/fdtdec_common.c index 088e9e9063..5775992ef3 100644 --- a/lib/fdtdec_common.c +++ b/lib/fdtdec_common.c @@ -53,3 +53,14 @@ unsigned int fdtdec_get_uint(const void *blob, int node, const char *prop_name, debug("(not found)\n"); return default_val; } + +int fdtdec_get_child_count(const void *blob, int node) +{ + int subnode; + int num = 0; + + fdt_for_each_subnode(subnode, blob, node) + num++; + + return num; +}