From patchwork Fri Nov 9 06:06:03 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Frank Rowand X-Patchwork-Id: 10675321 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 0808F14D6 for ; Fri, 9 Nov 2018 06:08:22 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id EAA182E7F5 for ; Fri, 9 Nov 2018 06:08:21 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id DD5C22E80C; Fri, 9 Nov 2018 06:08:21 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 65B3A2E7F5 for ; Fri, 9 Nov 2018 06:08:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728184AbeKIPrE (ORCPT ); Fri, 9 Nov 2018 10:47:04 -0500 Received: from mail-pl1-f193.google.com ([209.85.214.193]:41697 "EHLO mail-pl1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728158AbeKIPrD (ORCPT ); Fri, 9 Nov 2018 10:47:03 -0500 Received: by mail-pl1-f193.google.com with SMTP id p16-v6so445792plr.8; Thu, 08 Nov 2018 22:08:02 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=B33kF9iV0Uu4RxMZKXEawnQNU8qd2/woHNjsUwzS9rE=; b=s0wH8YomeWLrPb03gdpSrV8FvNg+cry98nME9qdxQmtbwOeGmOq0GmEX8IbGOxkJvv oZd96a5pZLvLvIF78gGHg2Xig3uLwfgMSwRFMoy7/p8rF4cQtTUj2A/N4REYk1cYRgKD e2WUgV1RWVU7Mw5onOqqHfJJzubT5HOIMZ1VrIFK0xP6ZlZb+9Tp598x2zOERaW2P9UP SlArPRpKTIKONZ2BFUkPPwwhnuDmd4MsWh4T0Jkg324fUjflYp2uCV7Q3WPf258/L/jq ggd6I3LlYjUaD/1M4mT++5i1gyfKAyPf8wrO42Wxwb2uAss0UlTvxhY13j/P0OBhJ2+a mhxw== 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=B33kF9iV0Uu4RxMZKXEawnQNU8qd2/woHNjsUwzS9rE=; b=nRr9bSFucy4seN8nAUbHypLUWKWiKZa5cb4H+hwnlUH0X7qxhqnpo0wg5xuJYS5Gu4 EnvDNpgYWokrULohSICq5LE+GRX7jw3crAiadjq1H4YokI4CEqKQTd/iwuAikF7t2RC8 kUDhQsR3coZByVxT+3GeJeO9TKjjXdcv8lIgsmGqbr+1rlM43TYG6WNIlF3VKw2f8Rx0 71/or2L0oA/9B4pSOGnjAlPYd2riXC+abiRZnBhl0ptZD76tqrtLHKbErZFtBR9GBEbJ 8o5M+WfMXVqQx5MH/Eks1pVgVRUUXUUGQviIywam7FkGDw70K8GVWcGKodOF8RQk2lZA Ip2Q== X-Gm-Message-State: AGRZ1gKfIpMpoVnEzTDwWoOB5yJnPUAvfWYs0NnOUVEq3E561r8HvcZv tqUEww4UAqZlxI15GhNqD9E= X-Google-Smtp-Source: AJdET5ezU26q3qtFV5XI8uVFXwC43rVlxWbKko340mCXDyN6CqYYMNG3rUhPWdsBExyKgyvIP0cg8A== X-Received: by 2002:a17:902:163:: with SMTP id 90-v6mr7711103plb.87.1541743682489; Thu, 08 Nov 2018 22:08:02 -0800 (PST) Received: from localhost.localdomain (c-24-6-192-50.hsd1.ca.comcast.net. [24.6.192.50]) by smtp.gmail.com with ESMTPSA id c70-v6sm6620722pfg.97.2018.11.08.22.08.01 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 08 Nov 2018 22:08:01 -0800 (PST) From: frowand.list@gmail.com To: Rob Herring , Pantelis Antoniou , Michael Ellerman , Benjamin Herrenschmidt , Paul Mackerras , Alan Tull , Moritz Fischer Cc: linux-kernel@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, devicetree@vger.kernel.org, linux-fpga@vger.kernel.org Subject: [PATCH v7 15/17] of: unittest: allow base devicetree to have symbol metadata Date: Thu, 8 Nov 2018 22:06:03 -0800 Message-Id: <1541743565-23163-16-git-send-email-frowand.list@gmail.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1541743565-23163-1-git-send-email-frowand.list@gmail.com> References: <1541743565-23163-1-git-send-email-frowand.list@gmail.com> Sender: linux-fpga-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fpga@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Frank Rowand The overlay metadata nodes in the FDT created from testcases.dts are not handled properly. The __fixups__ and __local_fixups__ node were added to the live devicetree, but should not be. Only the first property in the /__symbols__ node was added to the live devicetree if the live devicetree already contained a /__symbols node. All of the node's properties must be added. Tested-by: Alan Tull Signed-off-by: Frank Rowand --- drivers/of/unittest.c | 43 +++++++++++++++++++++++++++++++++++-------- 1 file changed, 35 insertions(+), 8 deletions(-) diff --git a/drivers/of/unittest.c b/drivers/of/unittest.c index 14838b21ec6a..d625a91a7f60 100644 --- a/drivers/of/unittest.c +++ b/drivers/of/unittest.c @@ -1071,20 +1071,44 @@ static void __init of_unittest_platform_populate(void) * of np into dup node (present in live tree) and * updates parent of children of np to dup. * - * @np: node already present in live tree + * @np: node whose properties are being added to the live tree * @dup: node present in live tree to be updated */ static void update_node_properties(struct device_node *np, struct device_node *dup) { struct property *prop; + struct property *save_next; struct device_node *child; - - for_each_property_of_node(np, prop) - of_add_property(dup, prop); + int ret; for_each_child_of_node(np, child) child->parent = dup; + + /* + * "unittest internal error: unable to add testdata property" + * + * If this message reports a property in node '/__symbols__' then + * the respective unittest overlay contains a label that has the + * same name as a label in the live devicetree. The label will + * be in the live devicetree only if the devicetree source was + * compiled with the '-@' option. If you encounter this error, + * please consider renaming __all__ of the labels in the unittest + * overlay dts files with an odd prefix that is unlikely to be + * used in a real devicetree. + */ + + /* + * open code for_each_property_of_node() because of_add_property() + * sets prop->next to NULL + */ + for (prop = np->properties; prop != NULL; prop = save_next) { + save_next = prop->next; + ret = of_add_property(dup, prop); + if (ret) + pr_err("unittest internal error: unable to add testdata property %pOF/%s", + np, prop->name); + } } /** @@ -1093,18 +1117,23 @@ static void update_node_properties(struct device_node *np, * * @np: Node to attach to live tree */ -static int attach_node_and_children(struct device_node *np) +static void attach_node_and_children(struct device_node *np) { struct device_node *next, *dup, *child; unsigned long flags; const char *full_name; full_name = kasprintf(GFP_KERNEL, "%pOF", np); + + if (!strcmp(full_name, "/__local_fixups__") || + !strcmp(full_name, "/__fixups__")) + return; + dup = of_find_node_by_path(full_name); kfree(full_name); if (dup) { update_node_properties(np, dup); - return 0; + return; } child = np->child; @@ -1125,8 +1154,6 @@ static int attach_node_and_children(struct device_node *np) attach_node_and_children(child); child = next; } - - return 0; } /**