Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 8CB9BECAAA1 for ; Wed, 31 Aug 2022 03:09:42 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id B8C05849D8; Wed, 31 Aug 2022 05:09:34 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.b="dHK8fhyp"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 270DE849AC; Wed, 31 Aug 2022 05:09:33 +0200 (CEST) Received: from mail-oa1-x34.google.com (mail-oa1-x34.google.com [IPv6:2001:4860:4864:20::34]) (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 55E6D849D1 for ; Wed, 31 Aug 2022 05:09:07 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=sjg@chromium.org Received: by mail-oa1-x34.google.com with SMTP id 586e51a60fabf-11f34610d4aso10542354fac.9 for ; Tue, 30 Aug 2022 20:09:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date; bh=TNM9G3lJTJGaHNTTlE6hjr5rG8dqWVrRN5UP5qg4xmc=; b=dHK8fhypv01sIPsBqQQhQHkNNN6hcR4fEcz247gG8LQ67j4k1xgUChULUAeIJsaoKd ZE7KktCEPq+w1bsdAFfE7xdyemFhzslb7p8sT9v1cCCxqQWhqdp8qYrZmpjpIR51/G51 SQNI1bX7RWhU5kWo2djHkmhC5WQcHJPpAe4rE= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date; bh=TNM9G3lJTJGaHNTTlE6hjr5rG8dqWVrRN5UP5qg4xmc=; b=xjJ8x1b6YE101oY0aYJtWdq/YwxfMPNa411Iyf5S9lYdrbePqLlo0uoa9d8R4cEY4G jp4td9bkvHNkBpeo+wnB9AbdsWjtdp1Ln7/w/yDEoJsvA6CrOKnE6v1RQOfe3vtEK8Et l381sOyIzypmTZ7wu926a8vpIorZnfJmQKKa4hRFG8CHQB8xH6UL/TvPY3rRwrlmgnYl g2VEEIPMzZkjBMD3gwCSqY51AXrwpR8H99PN81KjYCr8GTiRPBOBrO4+NyVc390D7Yx8 OzUmA45aY/v0hXmZcrWPOMWxpNSzQTntei7rsTCTGRbemId3S2U39Svk/uiPDs1J9drQ patg== X-Gm-Message-State: ACgBeo2c/nXbKaTTJtMNhepKaQw/lvhRPgRQ0BLQeeNkp6vMbUMBF3T/ anf3s4E5vEQe+Ga2bl9kPWFvjrqUcbJEhQ== X-Google-Smtp-Source: AA6agR71B95ZR0rBWjo0v0oqnY+c+03fBYQHGeGXPh5MoeSrZsTrvVg0eqtwv31zP/FI9ePZJeZBwg== X-Received: by 2002:a05:6870:608e:b0:104:887d:4c64 with SMTP id t14-20020a056870608e00b00104887d4c64mr531037oae.173.1661915345725; Tue, 30 Aug 2022 20:09:05 -0700 (PDT) Received: from sjg1.roam.corp.google.com (c-67-190-102-125.hsd1.co.comcast.net. [67.190.102.125]) by smtp.gmail.com with ESMTPSA id fp39-20020a05687065a700b00116d5103487sm9282605oab.31.2022.08.30.20.09.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 30 Aug 2022 20:09:05 -0700 (PDT) From: Simon Glass To: U-Boot Mailing List Cc: Michal Simek , =?UTF-8?q?Marek=20Beh=C3=BAn?= , Kishon Vijay Abraham I , Tom Rini , Simon Glass , Marek Vasut , Pavel Herrmann Subject: [PATCH 06/21] dm: core: Pass a root node to of_find_node_by_phandle() Date: Tue, 30 Aug 2022 21:08:02 -0600 Message-Id: <20220831030817.27804-7-sjg@chromium.org> X-Mailer: git-send-email 2.37.2.672.g94769d06f0-goog In-Reply-To: <20220831030817.27804-1-sjg@chromium.org> References: <20220831030817.27804-1-sjg@chromium.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 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.103.6 at phobos.denx.de X-Virus-Status: Clean This function currently assumes that the control FDT is used. Update it to allow a root node to be passed, so it can work with any tree. Also add a comment to ofnode_get_by_phandle() so that its purpose is clear. Signed-off-by: Simon Glass --- drivers/core/of_access.c | 7 ++++--- drivers/core/ofnode.c | 2 +- include/dm/of_access.h | 4 +++- include/dm/ofnode.h | 2 ++ 4 files changed, 10 insertions(+), 5 deletions(-) diff --git a/drivers/core/of_access.c b/drivers/core/of_access.c index a52f5a6b18b..ee09bbb7550 100644 --- a/drivers/core/of_access.c +++ b/drivers/core/of_access.c @@ -445,14 +445,15 @@ struct device_node *of_find_node_by_prop_value(struct device_node *from, return np; } -struct device_node *of_find_node_by_phandle(phandle handle) +struct device_node *of_find_node_by_phandle(struct device_node *root, + phandle handle) { struct device_node *np; if (!handle) return NULL; - for_each_of_allnodes(np) + for_each_of_allnodes_from(root, np) if (np->phandle == handle) break; (void)of_node_get(np); @@ -659,7 +660,7 @@ static int __of_parse_phandle_with_args(const struct device_node *np, * below. */ if (cells_name || cur_index == index) { - node = of_find_node_by_phandle(phandle); + node = of_find_node_by_phandle(NULL, phandle); if (!node) { debug("%s: could not find phandle\n", np->full_name); diff --git a/drivers/core/ofnode.c b/drivers/core/ofnode.c index 45ea84e9fb8..bf8eaf6d09a 100644 --- a/drivers/core/ofnode.c +++ b/drivers/core/ofnode.c @@ -329,7 +329,7 @@ ofnode ofnode_get_by_phandle(uint phandle) ofnode node; if (of_live_active()) - node = np_to_ofnode(of_find_node_by_phandle(phandle)); + node = np_to_ofnode(of_find_node_by_phandle(NULL, phandle)); else node.of_offset = fdt_node_offset_by_phandle(gd->fdt_blob, phandle); diff --git a/include/dm/of_access.h b/include/dm/of_access.h index 5b7821d0a1b..c0ac91a416a 100644 --- a/include/dm/of_access.h +++ b/include/dm/of_access.h @@ -258,11 +258,13 @@ struct device_node *of_find_node_by_prop_value(struct device_node *from, /** * of_find_node_by_phandle() - Find a node given a phandle * + * @root: root node to start from (NULL for default device tree) * @handle: phandle of the node to find * * Return: node pointer, or NULL if not found */ -struct device_node *of_find_node_by_phandle(phandle handle); +struct device_node *of_find_node_by_phandle(struct device_node *root, + phandle handle); /** * of_read_u32() - Find and read a 32-bit integer from a property diff --git a/include/dm/ofnode.h b/include/dm/ofnode.h index 7ce1e4c6d91..018ee70c2ff 100644 --- a/include/dm/ofnode.h +++ b/include/dm/ofnode.h @@ -461,6 +461,8 @@ int ofnode_get_path(ofnode node, char *buf, int buflen); /** * ofnode_get_by_phandle() - get ofnode from phandle * + * This uses the default (control) device tree + * * @phandle: phandle to look up * Return: ofnode reference to the phandle */ -- 2.37.2.672.g94769d06f0-goog