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 33A43C19F2A for ; Sat, 30 Jul 2022 21:53:49 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 083DE842A3; Sat, 30 Jul 2022 23:53:18 +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="mgTUmvTd"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 9FCE4841EA; Sat, 30 Jul 2022 23:53:13 +0200 (CEST) Received: from mail-ot1-x32e.google.com (mail-ot1-x32e.google.com [IPv6:2607:f8b0:4864:20::32e]) (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 83E09841D5 for ; Sat, 30 Jul 2022 23:53:09 +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-ot1-x32e.google.com with SMTP id br15-20020a056830390f00b0061c9d73b8bdso5658398otb.6 for ; Sat, 30 Jul 2022 14:53:09 -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; bh=vTFmnTByBhOSWvUHtae5LCNo6zRCt8QaFBGn7RjbL80=; b=mgTUmvTdasLg0nkFxlRgYy1sUf/6pUsElAZHQMQDHNehRSaXeDgt+PIxLxDPNPDVye 7a2oQrxk8xBKtCM9f+/rJCVsguLs/GGYIePvbATlBSX/hULhbSqWavcA4LzqybqqyvyR 8Ox3MtQAaPnyy2wZjo5WOgrRfd8C9iJnzxCAo= 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; bh=vTFmnTByBhOSWvUHtae5LCNo6zRCt8QaFBGn7RjbL80=; b=l5Eoyrqz9alLN6ipnCZOWagAMJCKExjlhZI6LoL9DA/gU1YxEPPNV55ws04ndJgvUO 6s1ptefmdmcc2Ok4s070SZ21toa0A4TO7KJ9DukOej8bEtAbC/9st1o+QgWvLZPSp/4Q fuHR0hyJ2hnKGVXC5UoRbwWfbJj+GGMrLaVAkmLUdqppZHXIemASWrvlkFzM1aLQ7GyQ FT638+Jk/BDiLVmWYBiZr0m4T3I/q3QhZ2m7dcQvuNYfYddE/kUJToruxPbTUC9iz8dC qPk+/4DtBZVcohyJ/DxQhbVy6TqxQs4JZsoEaeufuDfCXaJlweu9Kpn2RLJi/3TttTVo 6+XQ== X-Gm-Message-State: AJIora+jCaGcH162zP5jzu8iHiD21vw9BiwxbansY9e9sIIZZM2TjNzS KwohKqMwQdeEQ1vv3+SFC2dU5lxG0+XckQMr X-Google-Smtp-Source: AGRyM1sImRL93BsvvfMg3eaCViFPMRciErscKY3JaR7z6OA8JZhquN2wjSVrMzGp9ReHE+nksH1xNA== X-Received: by 2002:a05:6830:6419:b0:61c:5648:122f with SMTP id cj25-20020a056830641900b0061c5648122fmr3810875otb.324.1659217986377; Sat, 30 Jul 2022 14:53:06 -0700 (PDT) Received: from sjg1.lan (c-67-190-102-125.hsd1.co.comcast.net. [67.190.102.125]) by smtp.gmail.com with ESMTPSA id 19-20020a544193000000b0032f75714af1sm1699656oiy.18.2022.07.30.14.53.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 30 Jul 2022 14:53:04 -0700 (PDT) From: Simon Glass To: U-Boot Mailing List Cc: Tom Rini , Bin Meng , Simon Glass , Marek Vasut , Pavel Herrmann Subject: [PATCH v2 04/35] dm: core: Split out the declaration of ofnode Date: Sat, 30 Jul 2022 15:52:06 -0600 Message-Id: <20220730215237.818368-3-sjg@chromium.org> X-Mailer: git-send-email 2.37.1.455.g008518b4e5-goog In-Reply-To: <20220730215237.818368-1-sjg@chromium.org> References: <20220730215237.818368-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 --- (no changes since v1) 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.1.455.g008518b4e5-goog