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 B5EA2ECAAD8 for ; Wed, 31 Aug 2022 03:11:43 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id C1EFD849D8; Wed, 31 Aug 2022 05:10:35 +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="iROzaLsu"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id BDE5584A00; Wed, 31 Aug 2022 05:09:53 +0200 (CEST) Received: from mail-ot1-x32d.google.com (mail-ot1-x32d.google.com [IPv6:2607:f8b0:4864:20::32d]) (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 09BDC849D1 for ; Wed, 31 Aug 2022 05:09:51 +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-x32d.google.com with SMTP id t11-20020a05683014cb00b0063734a2a786so9419390otq.11 for ; Tue, 30 Aug 2022 20:09:50 -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=WptKVYvEe7lBrFyZTPT0vWCb10Cd8lW0CQnMAvv1M6U=; b=iROzaLsu/9mCz2vwQmtZbsFvqsQ5DnoYL6ssvgEumWRmWFgJqWHjhzgCKaVErZxRHy dxLqPjmGnb2LGovLtwV4dEFmEIDlD+6WIewMw4WqI/CV+X372SlwPtmZgTIejf7rcfUi zBqTGF0H8FNbhqb4cMIPgZ9aRpyWAiM1CxM7c= 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=WptKVYvEe7lBrFyZTPT0vWCb10Cd8lW0CQnMAvv1M6U=; b=2vWnMTgN6XMhg/J/eHxSsDkJRsiB6ymNiOH6c/UFl8256jHt1gZ3j1rWK8Lc+7Xm+R OEfltNov48p4/g7UBVJ2ymClAuUwLmpxmiiQjyHFZzxGN3c/4eFqXtMF+khw4yqK/q8s 8rS9ZVIyvEPhK80RJqlX/O/i+JuyxDzg/IkqUmQ3h+AWOqVL/qLfbR5TisLMa6b/+Ojn b4V51pTN/OvkaJNKO+F97mpJ2zZhh3JsN6V3RjwJdivCK7sMiP3cYWeUUpbGiPl+h9mF JDkFNX1iAIEtd57uwRxU9iAxo4e9ma0Cv4g/YO+o5Fp5QNGtAiq4WtApE3F9cmDXRsuQ JzCA== X-Gm-Message-State: ACgBeo2haOcyrHWRHXLafGnPIjRQH+ZrRGUKdZ68fKFOnJUw6WcumaDi 9+q0YFWrsjssDfPFZJTG/Z0lDmEumQHLoQ== X-Google-Smtp-Source: AA6agR6X4nOzfOLlFjZYIZhwevNw28m26JE5LUkX81ANqgnb9ERnG+KzNyUCj3t9dBufwb1wiOgDOg== X-Received: by 2002:a05:6830:6081:b0:61d:13e9:fabd with SMTP id by1-20020a056830608100b0061d13e9fabdmr9550551otb.286.1661915355242; Tue, 30 Aug 2022 20:09:15 -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.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 30 Aug 2022 20:09:15 -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 16/21] dm: core: Add ofnode functions to obtain an oftree Date: Tue, 30 Aug 2022 21:08:12 -0600 Message-Id: <20220831030817.27804-17-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 At present dm_test_ofnode_root() does this manually. Add some inline functions to handle it, so this code can be centralised. Signed-off-by: Simon Glass --- include/dm/ofnode.h | 31 +++++++++++++++++++++++++++++++ test/dm/ofnode.c | 4 ++-- 2 files changed, 33 insertions(+), 2 deletions(-) diff --git a/include/dm/ofnode.h b/include/dm/ofnode.h index e879feab002..d8d5082806e 100644 --- a/include/dm/ofnode.h +++ b/include/dm/ofnode.h @@ -238,6 +238,37 @@ static inline oftree oftree_default(void) return tree; } +/** + * oftree_from_np() - Returns an oftree from a node pointer + * + * @root: Root node of the tree + * Returns: reference to the given node + */ +static inline oftree oftree_from_np(struct device_node *root) +{ + oftree tree; + + tree.np = root; + + return tree; +} + +/** + * oftree_from_fdt() - Returns an oftree from a flat device tree pointer + * + * @fdt: Device tree to use + * + * Returns: reference to the given node + */ +static inline oftree oftree_from_fdt(void *fdt) +{ + oftree tree; + + tree.fdt = fdt; + + return tree; +} + /** * ofnode_name_eq() - Check if the node name is equivalent to a given name * ignoring the unit address diff --git a/test/dm/ofnode.c b/test/dm/ofnode.c index a36fd104048..7f195a725a0 100644 --- a/test/dm/ofnode.c +++ b/test/dm/ofnode.c @@ -518,9 +518,9 @@ static int dm_test_ofnode_root(struct unit_test_state *uts) ut_assertok(make_ofnode_fdt(uts, fdt, sizeof(fdt))); if (of_live_active()) { ut_assertok(unflatten_device_tree(fdt, &root)); - tree.np = root; + tree = oftree_from_np(root); } else { - tree.fdt = fdt; + tree = oftree_from_fdt(fdt); } /* Make sure they don't work on this new tree */ -- 2.37.2.672.g94769d06f0-goog