From patchwork Mon Aug 20 09:09:58 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jens Wiklander X-Patchwork-Id: 144551 Delivered-To: patches@linaro.org Received: by 2002:a2e:9754:0:0:0:0:0 with SMTP id f20-v6csp3721998ljj; Mon, 20 Aug 2018 02:10:12 -0700 (PDT) X-Received: by 2002:a2e:2e02:: with SMTP id u2-v6mr32082498lju.77.1534756212043; Mon, 20 Aug 2018 02:10:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1534756212; cv=none; d=google.com; s=arc-20160816; b=AUfEM/BKLRYXSLdZVdZqq8Pcsp8Y79FXc6Bz7iDxS2Oe09iRniDjNtdadkEWuQSXYz JBB1ewnjrD7hwKReAsPlwEUpoV5xTt6ReSOC4+Jb5JnnjxLU6ALccFCcnZyNVp0/azWp piNacLqnNApW9uZaJStEtfHxaAAcPXOuLceog2M9gxgb9B2vJkdNh/iuQzPeI+EcdwRB 2Rao/XDsVhYKAkcL3wfOxNESyAqS3IN/s8s8VrApxlq28DadlnEkNL0rUnWEvmuSht56 x7Vj54+CzTd1mPtrk8eU1dI0afeD8ZyBnc4wym5mq2CeTCQKj6p5yC8g0YiafKhcbtNb ifjg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature:arc-authentication-results; bh=WB0r/QnU5Maqf0pqVTMNOqHxmR20pieSek+3MYJad+w=; b=kgvGHeM7aIYlt/na3zqdQNSNGpxI2GxcLjej2xIi5KUQWveGrgwXzLapfXJIIO+Lin C2OWuUDdhqt7XS60iYS0BqflqwdCZskCtLv+0gNFVMq54BCxxzpv5C+GRChW4Wqbmb6Z kynJ/wy+SPCZJ+arrrDFrUSRSyYy4kZjcskAUX4ZVwyc0Jo48KWvWvfEeEIkcO/uaYe+ 3OiHbIoQ+srOOsCrZ9jIVWIySxVvTwbSaqVj5YuIfVDMKVrrb0Wxnzeh28Qe2dyeNjQB IUM0ob5moND5dupcggeZjXax9lY4Pt7Qk5ypAg0SKRnKRbQVU23prxGG1+yHdI170VQa 4mEg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=dBSvcoPI; spf=pass (google.com: domain of jens.wiklander@linaro.org designates 209.85.220.65 as permitted sender) smtp.mailfrom=jens.wiklander@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from mail-sor-f65.google.com (mail-sor-f65.google.com. [209.85.220.65]) by mx.google.com with SMTPS id g80-v6sor1602558ljf.80.2018.08.20.02.10.11 for (Google Transport Security); Mon, 20 Aug 2018 02:10:12 -0700 (PDT) Received-SPF: pass (google.com: domain of jens.wiklander@linaro.org designates 209.85.220.65 as permitted sender) client-ip=209.85.220.65; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=dBSvcoPI; spf=pass (google.com: domain of jens.wiklander@linaro.org designates 209.85.220.65 as permitted sender) smtp.mailfrom=jens.wiklander@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=WB0r/QnU5Maqf0pqVTMNOqHxmR20pieSek+3MYJad+w=; b=dBSvcoPIiAVEo9Rdpn7YuwABz9p1qZI8aNwj4pMyXKOPTlMzsguOtMkRroqaV+gFni SA4nH4ahFNqtvnOTNmq6NsnB3uBe5sRLudClAwr1HN0J+m5bO8ZGkuLIwGemNPA72pLA 7jSDangUWKE23dp435btpHvKiDy7GeVG0qT5E= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=WB0r/QnU5Maqf0pqVTMNOqHxmR20pieSek+3MYJad+w=; b=Xvh10kvao0nHW4Bt6vrNhh+7cwWUUMjMSI/tTIr3EXT0x9Hkbr81WON6P7Bp1VK3p1 QS6NJsbU74/IomoVUmdvxEbNS4AraFFd+s5uKUzjLMeNSlsai/IaM5qdM6X8B4sPAenh 4P1glaFCh7l7rIntm3dCD74GhBFQgo2URKV8dmuxRHqwke3j0cO8o8zp+vwzyR9IStyL dq0kvIZgixyd9a3GnjdVhx/4aJoK4lfAgJItiodhRWCHAZuMKPXR2BikTFboCOD9X9Pt 0/BDe2gnDE1nUfKRbttzkvZxkzJe62rMzKDofZyfcJsmd3EP2HmBniNTVSWMr+ORvwyA xtkA== X-Gm-Message-State: AOUpUlGDSjegVb0/n8i5yPHDGZBMpaZmx1FrSwwwi79L7ZT3lxYeWz+y TSSqgJOmH4EKIGkdl7fidsOK2IdG X-Google-Smtp-Source: AA+uWPzpqI6ci7GJQ06tWm1SrhuVaIraoHat2Aavupj0xC3faosgeE4QZdQoZlu74OEePs4qN1zMiw== X-Received: by 2002:a2e:590e:: with SMTP id n14-v6mr29878018ljb.128.1534756211657; Mon, 20 Aug 2018 02:10:11 -0700 (PDT) Return-Path: Received: from jax.urgonet (h-84-105.A175.priv.bahnhof.se. [79.136.84.105]) by smtp.gmail.com with ESMTPSA id i2-v6sm1041025lfa.78.2018.08.20.02.10.10 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 20 Aug 2018 02:10:10 -0700 (PDT) From: Jens Wiklander To: u-boot@lists.denx.de Cc: Simon Glass , Jens Wiklander Subject: [PATCH v2 1/3] ofnode: add ofnode_by_prop_value() Date: Mon, 20 Aug 2018 11:09:58 +0200 Message-Id: <20180820091000.3241-2-jens.wiklander@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180820091000.3241-1-jens.wiklander@linaro.org> References: <20180820091000.3241-1-jens.wiklander@linaro.org> Adds ofnode_by_prop_value() to search for nodes with a given property and value, an ofnode version of fdt_node_offset_by_prop_value(). Signed-off-by: Jens Wiklander --- drivers/core/of_access.c | 27 +++++++++++++++++++++++++++ drivers/core/ofnode.c | 14 ++++++++++++++ include/dm/of_access.h | 16 ++++++++++++++++ include/dm/ofnode.h | 14 ++++++++++++++ 4 files changed, 71 insertions(+) -- 2.17.1 Reviewed-by: Simon Glass diff --git a/drivers/core/of_access.c b/drivers/core/of_access.c index 0729dfcdb3b8..14c020a687b7 100644 --- a/drivers/core/of_access.c +++ b/drivers/core/of_access.c @@ -376,6 +376,33 @@ struct device_node *of_find_compatible_node(struct device_node *from, return np; } +static int of_device_has_prop_value(const struct device_node *device, + const char *propname, const void *propval, + int proplen) +{ + struct property *prop = of_find_property(device, propname, NULL); + + if (!prop || !prop->value || prop->length != proplen) + return 0; + return !memcmp(prop->value, propval, proplen); +} + +struct device_node *of_find_node_by_prop_value(struct device_node *from, + const char *propname, + const void *propval, int proplen) +{ + struct device_node *np; + + for_each_of_allnodes_from(from, np) { + if (of_device_has_prop_value(np, propname, propval, proplen) && + of_node_get(np)) + break; + } + of_node_put(from); + + return np; +} + struct device_node *of_find_node_by_phandle(phandle handle) { struct device_node *np; diff --git a/drivers/core/ofnode.c b/drivers/core/ofnode.c index 0cfb0fbabb00..a7e192772324 100644 --- a/drivers/core/ofnode.c +++ b/drivers/core/ofnode.c @@ -777,3 +777,17 @@ ofnode ofnode_by_compatible(ofnode from, const char *compat) gd->fdt_blob, ofnode_to_offset(from), compat)); } } + +ofnode ofnode_by_prop_value(ofnode from, const char *propname, + const void *propval, int proplen) +{ + if (of_live_active()) { + return np_to_ofnode(of_find_node_by_prop_value( + (struct device_node *)ofnode_to_np(from), propname, + propval, proplen)); + } else { + return offset_to_ofnode(fdt_node_offset_by_prop_value( + gd->fdt_blob, ofnode_to_offset(from), + propname, propval, proplen)); + } +} diff --git a/include/dm/of_access.h b/include/dm/of_access.h index dd1abb8e97b4..5ed1a0cdb427 100644 --- a/include/dm/of_access.h +++ b/include/dm/of_access.h @@ -193,6 +193,22 @@ static inline struct device_node *of_find_node_by_path(const char *path) struct device_node *of_find_compatible_node(struct device_node *from, const char *type, const char *compatible); +/** + * of_find_node_by_prop_value() - find a node with a given property value + * + * Find a node based on a property value. + * @from: Node to start searching from or NULL. the node you pass will not be + * searched, only the next one will; typically, you pass what the previous + * call returned. + * @propname: property name to check + * @propval: property value to search for + * @proplen: length of the value in propval + * @return node pointer or NULL if not found + */ +struct device_node *of_find_node_by_prop_value(struct device_node *from, + const char *propname, + const void *propval, + int proplen); /** * of_find_node_by_phandle() - Find a node given a phandle * diff --git a/include/dm/ofnode.h b/include/dm/ofnode.h index ab36b74c4ca4..c06d77849c73 100644 --- a/include/dm/ofnode.h +++ b/include/dm/ofnode.h @@ -702,6 +702,20 @@ int ofnode_read_resource_byname(ofnode node, const char *name, */ ofnode ofnode_by_compatible(ofnode from, const char *compat); +/** + * ofnode_by_prop_value() - Find the next node with given property value + * + * Find the next node after @from that has a @propname with a value + * @propval and a length @proplen. + * + * @from: ofnode to start from (use ofnode_null() to start at the + * beginning) @propname: property name to check @propval: property value to + * search for @proplen: length of the value in propval @return ofnode + * found, or ofnode_null() if none + */ +ofnode ofnode_by_prop_value(ofnode from, const char *propname, + const void *propval, int proplen); + /** * ofnode_for_each_subnode() - iterate over all subnodes of a parent * From patchwork Mon Aug 20 09:09:59 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jens Wiklander X-Patchwork-Id: 144552 Delivered-To: patches@linaro.org Received: by 2002:a2e:9754:0:0:0:0:0 with SMTP id f20-v6csp3722013ljj; Mon, 20 Aug 2018 02:10:13 -0700 (PDT) X-Received: by 2002:a19:d105:: with SMTP id i5-v6mr8132220lfg.31.1534756213338; Mon, 20 Aug 2018 02:10:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1534756213; cv=none; d=google.com; s=arc-20160816; b=fDVhFki809aH7CUtjejOgfrZwtfeuLDCPDp1bidIOH5aunpKhHn8qyzA1XI0rPDcgD AI1zhNj2CHIXqSJJN6lqIMsr+ImWJcGEolwYdObfewNOWZZGmFw1KYXDmKiGBKZN8eb4 ELxpSt6YTI5cAnUGv7DEBELif+0BZiyzQfT3kIrCVojRlg3fNEilm2WnAYPIydCzQQYc UwuKBoEBI/22uCRZaJcrIZNP0IFxuhlHff9PsvzvrP9mcMMvaY3FkEFd+4+uQu9vHqC0 l0Zm/4yUeTAUVlkBDEu9xC5aoc+yerkyyOFU9YhlDaoIVXzKNSM0teaFdbRDuZ60yPV5 tGig== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature:arc-authentication-results; bh=2bzMZmfsRh7F6NXhmL1mEgS9uNys0knxo3Bgi/cT4+g=; b=EBGLpatcxbGHYrIhbI2wLsPR2VmhoN/13ZN9gHiRnjmICcbQIzBibiFCwIqnxw3ahK ggldOeyjpVs6GFtlm9rzpOcrVeoJxYN8l9mIgYwe4PdItXMqiESVPP48dfoYGLnajKbC Q74tbnHwJXessn9e4t997CEDNcJGBAenfV03cnNc8WhjfuV2poKg1nL/UaiaUBq+8+UH LRURkg9CU91V48O0E14Nu4bhPxi+AloI5QYoC+kz9AwIZi2M1VFsHu+HV0TRE7D46Tv8 Qhj9aGv5cAz9d0+HOOPKAR7dr3liOrcv7+AECCF2+qvttDBfb3fqhMAEY+Vjk33OuVNr dnmw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=cgqGAA1x; spf=pass (google.com: domain of jens.wiklander@linaro.org designates 209.85.220.41 as permitted sender) smtp.mailfrom=jens.wiklander@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from mail-sor-f41.google.com (mail-sor-f41.google.com. [209.85.220.41]) by mx.google.com with SMTPS id m77-v6sor1545130lje.107.2018.08.20.02.10.13 for (Google Transport Security); Mon, 20 Aug 2018 02:10:13 -0700 (PDT) Received-SPF: pass (google.com: domain of jens.wiklander@linaro.org designates 209.85.220.41 as permitted sender) client-ip=209.85.220.41; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=cgqGAA1x; spf=pass (google.com: domain of jens.wiklander@linaro.org designates 209.85.220.41 as permitted sender) smtp.mailfrom=jens.wiklander@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=2bzMZmfsRh7F6NXhmL1mEgS9uNys0knxo3Bgi/cT4+g=; b=cgqGAA1xWt4pNKueXh8sgnyqG6K6a+ux/dHoSEklH2a8OcHuOpXLsAw+v6APcLaiec Q4R3Qi+mjOVTZkYZaLq7jMdoFtuK9T8Sj28rbHm2msz2kjmbLTJWTxreYFywSnFIgBjR 7DFunuXUzCWbOuUlcfSJwJglZsME+dKazkTYs= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=2bzMZmfsRh7F6NXhmL1mEgS9uNys0knxo3Bgi/cT4+g=; b=SDhRAPc4+0GqWh0g1DdjLNq+IUJFz/twxEXekTo6AnOBQtAMIaFHbrKFQc6+DwHQOX fN2bg6Izaeh3fXb0hgYXOPFX6dY6DajIyU2h1o6Qw6zlXAHdrXibpMC+K6uF8DczUsjr jbasTj9ZXhXv6EB/Zoc1bWpZ6wbHsAvWI/WG1l3zqE02AxaojxFA1rbNz8psyMU/hYIy 9RpfQvSNHryk3J+T1E39X5tT9sup2hkVsJgUEdQIa6NkNPjqAwCciKTavj1n0K4s0bBg tUtI+UMsJxV/47srJDAQ1kUUQ7i6zkn74lLEiVNNUMVIPuVfdUlhu31NEyqb/BZi0ct9 449Q== X-Gm-Message-State: AOUpUlErd0sSuFAgn16S1o9lM3PQYFRGW7MG30m6sEJjvqNPsFL/qmFI 6cNMafl1JX8Av5NtQKqvJj5tUu/gBBX8xw== X-Google-Smtp-Source: AA+uWPxX534TmAc1BmcK4Qzss276Cr4GdHxK+63vxc954e0XHkWnj10TLNbvRuVIZwAH8sRShRYpqw== X-Received: by 2002:a2e:4d9d:: with SMTP id c29-v6mr29504467ljd.132.1534756213155; Mon, 20 Aug 2018 02:10:13 -0700 (PDT) Return-Path: Received: from jax.urgonet (h-84-105.A175.priv.bahnhof.se. [79.136.84.105]) by smtp.gmail.com with ESMTPSA id i2-v6sm1041025lfa.78.2018.08.20.02.10.11 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 20 Aug 2018 02:10:12 -0700 (PDT) From: Jens Wiklander To: u-boot@lists.denx.de Cc: Simon Glass , Jens Wiklander Subject: [PATCH v2 2/3] fdt: fdtdec_setup_memory_banksize() use livetree Date: Mon, 20 Aug 2018 11:09:59 +0200 Message-Id: <20180820091000.3241-3-jens.wiklander@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180820091000.3241-1-jens.wiklander@linaro.org> References: <20180820091000.3241-1-jens.wiklander@linaro.org> Converts fdtdec_setup_memory_banksize() to use ofnode functions instead. Reviewed-by: Simon Glass Signed-off-by: Jens Wiklander --- lib/fdtdec.c | 46 +++++++++++++++++++++------------------------- 1 file changed, 21 insertions(+), 25 deletions(-) -- 2.17.1 diff --git a/lib/fdtdec.c b/lib/fdtdec.c index a208589c48ae..fef2f88f9d10 100644 --- a/lib/fdtdec.c +++ b/lib/fdtdec.c @@ -16,6 +16,7 @@ #include #include #include +#include #include DECLARE_GLOBAL_DATA_PTR; @@ -1182,43 +1183,34 @@ int fdtdec_setup_mem_size_base(void) #if defined(CONFIG_NR_DRAM_BANKS) -static int get_next_memory_node(const void *blob, int startoffset) +static ofnode get_next_memory_node(ofnode mem) { - int mem = -1; - do { - mem = fdt_node_offset_by_prop_value(gd->fdt_blob, mem, - "device_type", "memory", 7); - } while (!fdtdec_get_is_enabled(blob, mem)); + mem = ofnode_by_prop_value(mem, "device_type", "memory", 7); + } while (ofnode_valid(mem) && !ofnode_is_available(mem)); return mem; } int fdtdec_setup_memory_banksize(void) { - int bank, ret, mem, reg = 0; - struct fdt_resource res; + int bank, reg = 0; + struct resource res; + ofnode mem; - mem = get_next_memory_node(gd->fdt_blob, -1); - if (mem < 0) { - debug("%s: Missing /memory node\n", __func__); - return -EINVAL; - } + mem = get_next_memory_node(ofnode_null()); + if (!ofnode_valid(mem)) + goto missing_node; for (bank = 0; bank < CONFIG_NR_DRAM_BANKS; bank++) { - ret = fdt_get_resource(gd->fdt_blob, mem, "reg", reg++, &res); - if (ret == -FDT_ERR_NOTFOUND) { + while (ofnode_read_resource(mem, reg++, &res)) { reg = 0; - mem = get_next_memory_node(gd->fdt_blob, mem); - if (mem == -FDT_ERR_NOTFOUND) - break; - - ret = fdt_get_resource(gd->fdt_blob, mem, "reg", reg++, &res); - if (ret == -FDT_ERR_NOTFOUND) - break; - } - if (ret != 0) { - return -EINVAL; + mem = get_next_memory_node(mem); + if (!ofnode_valid(mem)) { + if (bank) + return 0; + goto missing_node; + } } gd->bd->bi_dram[bank].start = (phys_addr_t)res.start; @@ -1232,6 +1224,10 @@ int fdtdec_setup_memory_banksize(void) } return 0; + +missing_node: + debug("%s: Missing /memory node\n", __func__); + return -EINVAL; } #endif From patchwork Mon Aug 20 09:10:00 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jens Wiklander X-Patchwork-Id: 144553 Delivered-To: patches@linaro.org Received: by 2002:a2e:9754:0:0:0:0:0 with SMTP id f20-v6csp3722037ljj; Mon, 20 Aug 2018 02:10:14 -0700 (PDT) X-Received: by 2002:a19:a053:: with SMTP id j80-v6mr13354463lfe.115.1534756214600; Mon, 20 Aug 2018 02:10:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1534756214; cv=none; d=google.com; s=arc-20160816; b=F76Xmaam0hFfR01uU7/6WGj4tcALOusZaEY7BP+k7c755d+UVRxpzuuZjmlkqaQz0d jJACwG+MxqqgUD/AT0j1LBIeRNpPi8ynSCCr526k4/DsUMk3HKmimJo6RnUnuxLm4/9x HXgxNOMjgsXQ/V3TtZ1n4BywULhcjI1B4rvVuPxbP29vNf+VC5a9NBEcXg4xHo+WvaNW lyFvv2ANz/CroOGjq6hxEAp+ltGkjbJt9yBsYDql+cCIxlW8G9lNVgjISjgZ10G+OV5R FJygLeZMjZ6LMh2jIPzcAlMMOsQqqEZSXv/QFYe/rVGljPSBz1mSX8nPUmH09VqYxI85 tGKA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature:arc-authentication-results; bh=EOLNa8mCsKuzKP4cTXAhkiicPXdmoJck1D3okfiW3SI=; b=bjnzKbPUX1UfXCrgH7Jn/8JCkw9HhDtlhhWNU6ILOW4FTvUfGdifbWoMYBJ4PthrCl Sg4QJEnCAyrZaQbGL3P0ffvXqwUXdy2du9hEvM/MUHAlR+W1WODgV8zI6jnAIAh6IMDi 9lJChcKUH6m35Qx3on/SHDZnhrqSy6R+d6OqlWEoEK0cIFB9K5pRvXKXWdaJETObT2oJ udjQcsNy8vwai1Usl9kQvcFIwz/sd+/GQn2uwGTjSSHqskjs4jOl51FgBpKs4LsaknVc 2NW8OSaoOkeDElA7uWu21oJtIlSeoZND340CSMTzRjaBZwqT1YIK1/+Xc1Zknz0T1HBq cB4Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=cfs2vHaH; spf=pass (google.com: domain of jens.wiklander@linaro.org designates 209.85.220.41 as permitted sender) smtp.mailfrom=jens.wiklander@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from mail-sor-f41.google.com (mail-sor-f41.google.com. [209.85.220.41]) by mx.google.com with SMTPS id u16-v6sor1585830ljk.102.2018.08.20.02.10.14 for (Google Transport Security); Mon, 20 Aug 2018 02:10:14 -0700 (PDT) Received-SPF: pass (google.com: domain of jens.wiklander@linaro.org designates 209.85.220.41 as permitted sender) client-ip=209.85.220.41; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=cfs2vHaH; spf=pass (google.com: domain of jens.wiklander@linaro.org designates 209.85.220.41 as permitted sender) smtp.mailfrom=jens.wiklander@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=EOLNa8mCsKuzKP4cTXAhkiicPXdmoJck1D3okfiW3SI=; b=cfs2vHaHr2wQ4OaXEXN0sB7h4kstcNn3aU1NZTwXhCVm7TH3gjRTi+djXt78FiyFAz SEcu7u43zOrTiN8Fz7xM0LfDaz4ksEa6WACjfUeqGYWQB3O18a98nFDwwduAjRTV0A6m eTHd7cCKS3FycFk4zUC16g6o48wjAVJJ83X70= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=EOLNa8mCsKuzKP4cTXAhkiicPXdmoJck1D3okfiW3SI=; b=avG7lrrm3VntSTJCetPF1BKkb/yk7gztoGcPT7q7aqvIeoSV9jLZbnDFo7JyjIrsUD 1BnesivwkRkFzhKyBiq3IkjPupzVI2h9ys1K7Msr63T+A/cTX3OitfbrQuD9i4ECG3p1 qTrUvE82yLUj4tQboKjcdHT/m/w8mYeqaIpZ3ogtPqI04pp/q5AtBzqdVicq5ruLv9j9 QJpf0tiauKpm9oiX5xDa4rOySgyrG0f5jh+ryaRcx5nC+EX8Ab1pZbdL7b711X63Pfdb Nehvm0shpK1FXY/tOGR7rVyZkQDRgwTv1e7PwfZGtX1qltp5nK4fBa2LaDUGCPXHHVBy YU/Q== X-Gm-Message-State: AOUpUlFnZtkkJGTmKpfpfWrT371eyZbP818uZ3sNarXcns5HaCTKSjZC ppDI1tqd9T+U7v92r2nzWtYKVzy8TqvF8A== X-Google-Smtp-Source: AA+uWPymiUhhpSIC7he5fjSVdIMRP9CHLLaCh3GwXKZ5MFbf2puVLTJPD9bfxPVEqs+e2zXsEB6/Ww== X-Received: by 2002:a2e:9bc9:: with SMTP id w9-v6mr25225692ljj.33.1534756214444; Mon, 20 Aug 2018 02:10:14 -0700 (PDT) Return-Path: Received: from jax.urgonet (h-84-105.A175.priv.bahnhof.se. [79.136.84.105]) by smtp.gmail.com with ESMTPSA id i2-v6sm1041025lfa.78.2018.08.20.02.10.13 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 20 Aug 2018 02:10:13 -0700 (PDT) From: Jens Wiklander To: u-boot@lists.denx.de Cc: Simon Glass , Jens Wiklander Subject: [PATCH v2 3/3] test: ofnode: test ofnode_by_prop_value() Date: Mon, 20 Aug 2018 11:10:00 +0200 Message-Id: <20180820091000.3241-4-jens.wiklander@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180820091000.3241-1-jens.wiklander@linaro.org> References: <20180820091000.3241-1-jens.wiklander@linaro.org> Test ofnode_by_prop_value() Signed-off-by: Jens Wiklander --- test/dm/ofnode.c | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) -- 2.17.1 Reviewed-by: Simon Glass diff --git a/test/dm/ofnode.c b/test/dm/ofnode.c index 8db1f9857f7d..907d1ddbdb6f 100644 --- a/test/dm/ofnode.c +++ b/test/dm/ofnode.c @@ -15,3 +15,30 @@ static int dm_test_ofnode_compatible(struct unit_test_state *uts) return 0; } DM_TEST(dm_test_ofnode_compatible, DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT); + +static int dm_test_ofnode_by_prop_value(struct unit_test_state *uts) +{ + const char propname[] = "compatible"; + const char propval[] = "denx,u-boot-fdt-test"; + const char *str; + ofnode node = ofnode_null(); + + /* Find first matching node, there should be at least one */ + node = ofnode_by_prop_value(node, propname, propval, sizeof(propval)); + ut_assert(ofnode_valid(node)); + str = ofnode_read_string(node, propname); + ut_assert(str && !strcmp(str, propval)); + + /* Find the rest of the matching nodes */ + while (true) { + node = ofnode_by_prop_value(node, propname, propval, + sizeof(propval)); + if (!ofnode_valid(node)) + break; + str = ofnode_read_string(node, propname); + ut_assert(str && !strcmp(str, propval)); + } + + return 0; +} +DM_TEST(dm_test_ofnode_by_prop_value, DM_TESTF_SCAN_FDT);