Received: by 2002:a25:7ec1:0:0:0:0:0 with SMTP id z184csp5985857ybc; Wed, 27 Nov 2019 12:56:34 -0800 (PST) X-Google-Smtp-Source: APXvYqxrlG7LC9gdADgk1x+i6oEG4sdnQ0QU1M/92Xq0j+Ys8DbBok+Ur5Gu8TR2I1BErTpzr8nc X-Received: by 2002:a17:906:19d0:: with SMTP id h16mr49283976ejd.301.1574888194476; Wed, 27 Nov 2019 12:56:34 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1574888194; cv=none; d=google.com; s=arc-20160816; b=colkmuZJeMrdAQzhT/pfFj/7Nsaqlrwn6RV0LeBre0e8epfvJsuKTrfTk2nxGmO1cl pUsmHYnVhc/6mWaOIJ0/GKjwY6YSk9OccgG03/YoduHd10LjxZQfz3L6Lgwrqd3RsjDL kX50JatTNrWPymMjgqV7m9R+l7iqRMo627AmYQs9wZTeLHMrNY3kMWIK7YP10msDVmq/ gsLd6xafmjRQXZS//GbBfR/YEEcp7k4kOZNGa7omss7OjmRJ2i1NXh6oF3/2xTmAW+km sPk/KvBpD2zaEY1TscW+0P0o5JqIIu4gRV2JOBKxN2zujmy0gWzpHfe3Nbr5JAHghPYU XJ5Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=PuzNzNVrHMZ8UPZV0KQVj6Brp1PrL6gp6DToeTXd3UA=; b=m6XxhGHrtMvIXK7XnwfDLb8N7QSpO05KJ59kuC2qbYdy0v/mViHaEKOTSneJdp58YA XeP7AVkAh+tM8AOqYG5PQwf6vNagnqvKbCmONbHiBKba4feKcq0j2a09SD+kBdPJTLUo UKULhZDjco2eB0JJ6vu1qrvbSUKTKYR2t5WsFDEUQqiD4D3oRgaWL9IiCc9lvKsaLcxK vtwxZGpddGv0g46DAkrsSAMIm6RvMEht3OyYuj1bZwjk7H3Hcf1rBrtERdTh/bhbEkIO HC1uuVG5Y2M8WooFLEGf1728blWc2EtHNPGOwi334z1QfaxcLcF6QHv8zguMfvMw6Cao mqjg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=rx1C5b5d; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id o28si12003085edc.353.2019.11.27.12.56.10; Wed, 27 Nov 2019 12:56:34 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=rx1C5b5d; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730588AbfK0UwV (ORCPT + 99 others); Wed, 27 Nov 2019 15:52:21 -0500 Received: from mail.kernel.org ([198.145.29.99]:39702 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730593AbfK0UwR (ORCPT ); Wed, 27 Nov 2019 15:52:17 -0500 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 7595C21871; Wed, 27 Nov 2019 20:52:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1574887937; bh=CsVoL3NyfiNt7Eogn47IcWHjO7uZLP+evt4RF0CnHnQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=rx1C5b5dHPIteHO+Y25GbBSd9/aAF+fAifglcIH2F346/30hAlTKK/he/028a6NHU 8waXTVdKP/SR30h+n2MIrEcpMCzMP1i4Rw4d/f7BqhfwFLBrJB0JvwZSuWDVtlbXqb eRaWKeuR6GCX/uaCq9vVfHwtrLTV/tWKUVpyhTtI= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Alan Tull , Frank Rowand , Sasha Levin Subject: [PATCH 4.14 153/211] of: unittest: allow base devicetree to have symbol metadata Date: Wed, 27 Nov 2019 21:31:26 +0100 Message-Id: <20191127203108.463074072@linuxfoundation.org> X-Mailer: git-send-email 2.24.0 In-Reply-To: <20191127203049.431810767@linuxfoundation.org> References: <20191127203049.431810767@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Frank Rowand [ Upstream commit 5babefb7f7ab1f23861336d511cc666fa45ede82 ] 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 Signed-off-by: Sasha Levin --- 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 87650d42682fc..9d204649c963c 100644 --- a/drivers/of/unittest.c +++ b/drivers/of/unittest.c @@ -910,20 +910,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); + } } /** @@ -932,18 +956,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; @@ -964,8 +993,6 @@ static int attach_node_and_children(struct device_node *np) attach_node_and_children(child); child = next; } - - return 0; } /** -- 2.20.1