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 E424FC433EF for ; Wed, 20 Jul 2022 17:00:44 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 46DD2840AE; Wed, 20 Jul 2022 19:00:25 +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="Xbz+uxZW"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 0322484053; Wed, 20 Jul 2022 19:00:22 +0200 (CEST) Received: from mail-wm1-x32f.google.com (mail-wm1-x32f.google.com [IPv6:2a00:1450:4864:20::32f]) (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 D40E58409E for ; Wed, 20 Jul 2022 19:00:13 +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-wm1-x32f.google.com with SMTP id f24-20020a1cc918000000b003a30178c022so1748019wmb.3 for ; Wed, 20 Jul 2022 10:00:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=bzqYunNH4AcVXmcMBv9tIy0WOTsK1t3XkKwWqxIO6Vw=; b=Xbz+uxZWwh5imkr07u5YnyY2snxX8qZstIYkjhyErOR8Lp48Hf5rC6UYZKb83Xt4Vv +94lZEtlX7FtYVbrQCcuiIl6crcvTpZGAz1lSohxx5QqbsGM52ZiP5yjIT1/OTgeNHWx EPN7fVPYcNGaQkmbDUsth/dGLlW0q7RERwEXE= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=bzqYunNH4AcVXmcMBv9tIy0WOTsK1t3XkKwWqxIO6Vw=; b=QWK7hMRlEdzd78bDJdnlACEIlfGaVwEZ9ktL9I3KJwo+QYu9hFxpxsCH6I5KswW3P4 fDlqfnUgGZZX5wDci+lpOfeY7hbOtqGOxbtkUsSKxRpW1PtVckZUluoMxdOekPKkZgoG FFBtIfY+mqHlKbBV6Yr/+vWg6BBtV605Q34OuHE6vY1TJKRU/zCXxhvEGd6kwrpRIuj/ Z9d7zHe64I+qii2K+/arcbUm/iQFxOHE/EWcM1ThZaN2nGHq0ZcJgXcXUVU7dH1ODxwg QMPP15QOmfOU9PU3G3T3SbHoLzmlwNsR/P4+KyKqDJytaxz6yHslk9DWrFA9R8Nt76zE vjmg== X-Gm-Message-State: AJIora/gALvPI+wVKxQ3NweD0ozoin8s2PMaGKZIx+dmLPv0SxnenIL6 kApM2wSjMhWg/1io3IAOgRG1y6w7jBNA4DE1 X-Google-Smtp-Source: AGRyM1sq7KIXAUDYe+3cXx9JOmDbB7NQWrbY/bL1kYG6Sj8c8KC+srp0sF8gGTIb73DMYa7PnyGWAA== X-Received: by 2002:a05:600c:a146:b0:3a3:1e79:4446 with SMTP id ib6-20020a05600ca14600b003a31e794446mr4892903wmb.158.1658336412652; Wed, 20 Jul 2022 10:00:12 -0700 (PDT) Received: from sjg1.roam.corp.google.com ([62.48.169.138]) by smtp.gmail.com with ESMTPSA id u16-20020a05600c00d000b003a31c4f6f74sm3690906wmm.32.2022.07.20.10.00.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 20 Jul 2022 10:00:12 -0700 (PDT) From: Simon Glass To: U-Boot Mailing List Cc: Tom Rini , Simon Glass , Marek Vasut , Pavel Herrmann Subject: [PATCH 03/19] dm: core: Split out the declaration of ofnode Date: Wed, 20 Jul 2022 10:59:31 -0600 Message-Id: <20220720165947.12728-4-sjg@chromium.org> X-Mailer: git-send-email 2.37.0.170.g444d1eabd0-goog In-Reply-To: <20220720165947.12728-1-sjg@chromium.org> References: <20220720165947.12728-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 is used by a lot of files, but ofnode.h needs to include a lot of header files. This can create dependency cycles, particularly with global_data.h which must include various declarations. Split the core delcarations into a separate file to fix this. Signed-off-by: Simon Glass --- include/dm/ofnode.h | 61 +--------------------------------- include/dm/ofnode_decl.h | 72 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 73 insertions(+), 60 deletions(-) create mode 100644 include/dm/ofnode_decl.h diff --git a/include/dm/ofnode.h b/include/dm/ofnode.h index bb60433124b..346b09c7d96 100644 --- a/include/dm/ofnode.h +++ b/include/dm/ofnode.h @@ -19,41 +19,7 @@ struct resource; -/** - * typedef union ofnode_union ofnode - reference to a device tree node - * - * This union can hold either a straightforward pointer to a struct device_node - * in the live device tree, or an offset within the flat device tree. In the - * latter case, the pointer value is just the integer offset within the flat DT. - * - * Thus we can reference nodes in both the live tree (once available) and the - * flat tree (until then). Functions are available to translate between an - * ofnode and either an offset or a `struct device_node *`. - * - * The reference can also hold a null offset, in which case the pointer value - * here is NULL. This corresponds to a struct device_node * value of - * NULL, or an offset of -1. - * - * There is no ambiguity as to whether ofnode holds an offset or a node - * pointer: when the live tree is active it holds a node pointer, otherwise it - * holds an offset. The value itself does not need to be unique and in theory - * the same value could point to a valid device node or a valid offset. We - * could arrange for a unique value to be used (e.g. by making the pointer - * point to an offset within the flat device tree in the case of an offset) but - * this increases code size slightly due to the subtraction. Since it offers no - * real benefit, the approach described here seems best. - * - * For now these points use constant types, since we don't allow writing - * the DT. - * - * @np: Pointer to device node, used for live tree - * @of_offset: Pointer into flat device tree, used for flat tree. Note that this - * is not a really a pointer to a node: it is an offset value. See above. - */ -typedef union ofnode_union { - const struct device_node *np; - long of_offset; -} ofnode; +#include struct ofnode_phandle_args { ofnode node; @@ -61,31 +27,6 @@ struct ofnode_phandle_args { uint32_t args[OF_MAX_PHANDLE_ARGS]; }; -/** - * struct ofprop - reference to a property of a device tree node - * - * This struct hold the reference on one property of one node, - * using struct ofnode and an offset within the flat device tree or either - * a pointer to a struct property in the live device tree. - * - * Thus we can reference arguments in both the live tree and the flat tree. - * - * The property reference can also hold a null reference. This corresponds to - * a struct property NULL pointer or an offset of -1. - * - * @node: Pointer to device node - * @offset: Pointer into flat device tree, used for flat tree. - * @prop: Pointer to property, used for live treee. - */ - -struct ofprop { - ofnode node; - union { - int offset; - const struct property *prop; - }; -}; - /** * ofnode_to_np() - convert an ofnode to a live DT node pointer * diff --git a/include/dm/ofnode_decl.h b/include/dm/ofnode_decl.h new file mode 100644 index 00000000000..7c9e43e4ad8 --- /dev/null +++ b/include/dm/ofnode_decl.h @@ -0,0 +1,72 @@ +/* SPDX-License-Identifier: GPL-2.0+ */ +/* + * Copyright 2022 Google LLC + * Written by Simon Glass + */ + +#ifndef _DM_OFNODE_DECL_H +#define _DM_OFNODE_DECL_H + +/** + * typedef union ofnode_union ofnode - reference to a device tree node + * + * This union can hold either a straightforward pointer to a struct device_node + * in the live device tree, or an offset within the flat device tree. In the + * latter case, the pointer value is just the integer offset within the flat DT. + * + * Thus we can reference nodes in both the live tree (once available) and the + * flat tree (until then). Functions are available to translate between an + * ofnode and either an offset or a `struct device_node *`. + * + * The reference can also hold a null offset, in which case the pointer value + * here is NULL. This corresponds to a struct device_node * value of + * NULL, or an offset of -1. + * + * There is no ambiguity as to whether ofnode holds an offset or a node + * pointer: when the live tree is active it holds a node pointer, otherwise it + * holds an offset. The value itself does not need to be unique and in theory + * the same value could point to a valid device node or a valid offset. We + * could arrange for a unique value to be used (e.g. by making the pointer + * point to an offset within the flat device tree in the case of an offset) but + * this increases code size slightly due to the subtraction. Since it offers no + * real benefit, the approach described here seems best. + * + * For now these points use constant types, since we don't allow writing + * the DT. + * + * @np: Pointer to device node, used for live tree + * @of_offset: Pointer into flat device tree, used for flat tree. Note that this + * is not a really a pointer to a node: it is an offset value. See above. + */ +typedef union ofnode_union { + const struct device_node *np; + long of_offset; +} ofnode; + +/** + * struct ofprop - reference to a property of a device tree node + * + * This struct hold the reference on one property of one node, + * using struct ofnode and an offset within the flat device tree or either + * a pointer to a struct property in the live device tree. + * + * Thus we can reference arguments in both the live tree and the flat tree. + * + * The property reference can also hold a null reference. This corresponds to + * a struct property NULL pointer or an offset of -1. + * + * @node: Pointer to device node + * @offset: Pointer into flat device tree, used for flat tree. + * @prop: Pointer to property, used for live treee. + */ + +struct ofprop { + ofnode node; + union { + int offset; + const struct property *prop; + }; +}; + +#endif + -- 2.37.0.170.g444d1eabd0-goog