Received: by 2002:a25:7ec1:0:0:0:0:0 with SMTP id z184csp768705ybc; Sat, 16 Nov 2019 08:21:27 -0800 (PST) X-Google-Smtp-Source: APXvYqwbXezDyxOXl2kE2SawT3MNijB4nhw/oP9znjbzdwwZxH1STgEDSiV+8kk33XvWXRkTF0Ip X-Received: by 2002:a5d:4b05:: with SMTP id v5mr2958043wrq.210.1573921287214; Sat, 16 Nov 2019 08:21:27 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1573921287; cv=none; d=google.com; s=arc-20160816; b=uQL36En+ZrdFNnaykU37GcsAe5QSnCz/sc2rbOPp9hv7ZrE2fNvDl8ITgqGBUkRRai DPRRvwePcFHG3xTLDmNVNCiy0A/GJ0zJgmXo3D03XDm53MMnqDHRJqu2b+oZPbWIh3n8 dzGj1POatN9qf/IX/3FIdc77nD/IsMwXAIOJIUQGIV6w+269m6eChLveflgVN6ZSslAo /HIjwkn9Rly3CS9KEAaClA31H/LBEYyKMhJjam5G5AgVnqgxPyBz5QEkiAJDOKNAN9O+ L+p3LiyOV0iIHid/aPcXX39yDdStAUyCnzZcsuTQnZVWqEccUJJezBfMj57W/VlBMRpt taWA== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=B65trDle3WqqvgNE2Ilipw7WMDSroYtm7tfStBg8fTk=; b=jhGc4MErCUeC48fTeHxPHYMHHbkfCTDfImtXu/Ppf0YOotrhaW4bvGVYcusNEZdfS4 ZtDJUtcfEoyQB2cPX7yvUGnxqnJCmvT+J8nH4rcbmRTyyFaNVvuwv7ZbcOKklhHJNeJ3 Z1npFJM/9Ctv7w5EY8oAmZ7u04Q3U34jXC//RLJsHC6tTf6v4oPMIE/duoawT+nrOxXr LiWhnpzcSLe12+0nisg6CHoc4lztGLDubhBtOevVfHOW2R54tCg1NPNzkji8G0aNY/SA 3wyrApprHHv8GW9sqdraRfP/XoMW4j7ZPYiEDdGqDnYibHs1JG9wEZfY7XtoBt7otr3i 1Jkw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=z5Htd2sv; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id c26si9264349edc.416.2019.11.16.08.21.02; Sat, 16 Nov 2019 08:21:27 -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=z5Htd2sv; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728517AbfKPQQr (ORCPT + 99 others); Sat, 16 Nov 2019 11:16:47 -0500 Received: from mail.kernel.org ([198.145.29.99]:53628 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729570AbfKPPq6 (ORCPT ); Sat, 16 Nov 2019 10:46:58 -0500 Received: from sasha-vm.mshome.net (unknown [50.234.116.4]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 94BB4208C0; Sat, 16 Nov 2019 15:46:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1573919217; bh=iKpvKUeKnN0Hf7ggvou7pK3D070MmYPc8kd9SuILrDk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=z5Htd2svfswmAqUT0izcc56IgIYbPuh8GRDy4626eHQM2pJRDKjgOdDU8nwEjHUVs FFqOT94vYsIoXw0audSmg7E2f5LeyuAEoyFK7qyAvcnlBg6yKLWxQguyQPG7EzZoAF xtAVtgNyQF2HuEl1J1ZM1ZmukVCI06aNBB0RV0PI= From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Frank Rowand , Alan Tull , Sasha Levin , devicetree@vger.kernel.org Subject: [PATCH AUTOSEL 4.19 223/237] of: unittest: allow base devicetree to have symbol metadata Date: Sat, 16 Nov 2019 10:40:58 -0500 Message-Id: <20191116154113.7417-223-sashal@kernel.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20191116154113.7417-1-sashal@kernel.org> References: <20191116154113.7417-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore 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 bac4b4bbc33de..e8997cdb228cb 100644 --- a/drivers/of/unittest.c +++ b/drivers/of/unittest.c @@ -1067,20 +1067,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); + } } /** @@ -1089,18 +1113,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; @@ -1121,8 +1150,6 @@ static int attach_node_and_children(struct device_node *np) attach_node_and_children(child); child = next; } - - return 0; } /** -- 2.20.1