Received: by 10.223.185.116 with SMTP id b49csp4253137wrg; Mon, 26 Feb 2018 14:07:11 -0800 (PST) X-Google-Smtp-Source: AH8x224qxYpdz2b9rDP3bcfR/wjabpxkZxpJJiwTZS7y8ryusXNhzYYsOv7FUpTEACS8K2ALqzYJ X-Received: by 10.98.98.194 with SMTP id w185mr12062645pfb.9.1519682831010; Mon, 26 Feb 2018 14:07:11 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519682830; cv=none; d=google.com; s=arc-20160816; b=IrZGHDrezZhvskcmXiAMEvNYpUvbUYh1EGcbflIGdN/OIOD7RRrtBB2LG3DYwL/a89 6SvTbZw1lPMB9Yg18V0KM3uabU03g1auAwvGd8jTCkdjILxAHI0dkuAaUBrGsY6m+G+o p4RwpP7Nxjh0oW+lPY5pYzjqLEzVv1vWYWep2dGQi267zcKSnyw1a0FQ7nYnCCsAqCzp FfVU+VLzyUGEc1rWYpFJTgM5brLH5UphAENutY4BxPk3q2Tcq9JJFOM6ucDolZFPVZjI 4KqHDxxtwcs3lMLjTmYbO3EFIAbh8lke88XER1oh2USC+bfQ5FRtrR6bfcf/tMb0uqsa orfA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=vQpWBMSGDM+QqJNQ1hEw/ZibUF4s3z2n6PXwkVgCAWs=; b=yrdhyWpzdmQeyWl4+TGGuVszk1SyoLdlKutaoJkqYq32iHXmAVenJ2WZggCdi+yyMl fleFvbDqFSdZIdmaAuI8/3A9ixiYoJNdjmS2HJvlJ58mAtX47pU+UgIg55OUkXmKb/fB oIvRkfVBX+XXus5PoIKpqA42JjYo3aF2wFWx+OQ3z8ZWDnC+sbLnmzfzoSlnX2CIIgHZ gSl+noiF9UF8AlSUdD4zSaWsRmhefsWjYT7jMiUWd5a38xZpT9bsuBMC+juA0mpAGn1z qUkCtFFE0BPuCW76oNeDZOkiVsanuDOPjA/tEvO7DK5/mf8+E/Q0uS48bt/iREk7SM5/ iMmA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=r0WtkRnN; 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=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id k66si7369313pfa.415.2018.02.26.14.06.54; Mon, 26 Feb 2018 14:07:10 -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=@gmail.com header.s=20161025 header.b=r0WtkRnN; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752057AbeBZWFK (ORCPT + 99 others); Mon, 26 Feb 2018 17:05:10 -0500 Received: from mail-pg0-f67.google.com ([74.125.83.67]:43228 "EHLO mail-pg0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751570AbeBZWCL (ORCPT ); Mon, 26 Feb 2018 17:02:11 -0500 Received: by mail-pg0-f67.google.com with SMTP id e9so2388620pgs.10; Mon, 26 Feb 2018 14:02:11 -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=vQpWBMSGDM+QqJNQ1hEw/ZibUF4s3z2n6PXwkVgCAWs=; b=r0WtkRnN9HWFOJ+0aCqmXqFbXM79I661zkRSyKaoMAX/JGx6i/2DDO9L8Qvz0Zu5jC DkHddGNKTLpqwPieTcfApg2Q+G58L4Ltqf74jintxT0JffnTI16BPfDSY5g4lwJZ56dU pe6snIVX5mE9hdxVohNnqN+OYTF/zgVto4Ye6essjmR0eGYUjRQDgUowXf/UrmutXXPS SwuP3OmAV/iTklM4X3dx+5osmELEDhynhw1ZD/R2sLsneddK8jY6xLLpv92zLHoJT6OO RCDyj4rem0Y8yz/oXl5ifkZnN2J12D9U36Ob3TAC+FcwWOOW8KWgJfPYH1h9z4sxatmU 129Q== 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=vQpWBMSGDM+QqJNQ1hEw/ZibUF4s3z2n6PXwkVgCAWs=; b=Ljzrp4lPKD0FaL04/kHg9hvogpfQJoefYC6fxqQUEHtJ3i+waWAyFSHklhJPeZVRD1 /kzEXnW1iKcn7Fc8EfXGQzL92TL9vGflSH+fBn1yS1UIMzXUZCfJilSQVXNIVvpATTPa aHDhtXyQ4RV0odqaWJtQ396HW08ABnbEJ8CpljTDrvx/TJvd6L14cPP8xKeY3G2UNjlo X0Mx3EriiouuTF7anjvYkqFL1UMjlan53nR5E/GS+abi0YO0QzuUi/Be5yGBeN6sCSl8 6kNVasthDXONBD03Cgum7Brbc+HwJRd7f5Nw423gVuu6Wfs2//9v0zH+Vwai/+C2oweX cp1g== X-Gm-Message-State: APf1xPCu39ozIm3X+qz8QLFuMP+Q6odb9Kg7LZ/8VV3GEZMSmDyAll1f 0FrmJevZk3kDfNqees4qv+k= X-Received: by 10.101.93.17 with SMTP id e17mr9572451pgr.281.1519682530732; Mon, 26 Feb 2018 14:02:10 -0800 (PST) Received: from localhost.localdomain (c-73-93-215-6.hsd1.ca.comcast.net. [73.93.215.6]) by smtp.gmail.com with ESMTPSA id c184sm2259513pfc.0.2018.02.26.14.02.09 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 26 Feb 2018 14:02:10 -0800 (PST) From: frowand.list@gmail.com To: Rob Herring , pantelis.antoniou@konsulko.com, Pantelis Antoniou Cc: devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, geert@linux-m68k.org Subject: [PATCH v2 2/2] of: overlay: do not include path in full_name of added nodes Date: Mon, 26 Feb 2018 14:01:23 -0800 Message-Id: <1519682483-19828-3-git-send-email-frowand.list@gmail.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1519682483-19828-1-git-send-email-frowand.list@gmail.com> References: <1519682483-19828-1-git-send-email-frowand.list@gmail.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Frank Rowand Struct device_node full_name no longer includes the full path name when the devicetree is created from a flattened device tree (FDT). The overlay node creation code was not modified to reflect this change. Fix the node full_name generated by overlay code to contain only the basename. Unittests call an overlay internal function to create new nodes. Fix up these calls to provide basename only instead of the full path. Fixes: a7e4cfb0a7ca ("of/fdt: only store the device node basename in full_name") Signed-off-by: Frank Rowand --- changes since version 1: - update patch one-line description and full description - no longer remove kbasename from resolver.c - add_changeset_node(): add back kbasename() when comparing nodes in the livetree against nodes in the overlay - add_changeset_node(): add header comments to document assumptions and behavior, and to explain why kbasename() is used drivers/of/dynamic.c | 21 ++++++++++----------- drivers/of/of_private.h | 3 ++- drivers/of/overlay.c | 18 +++++++++++++++--- drivers/of/unittest.c | 6 +++--- 4 files changed, 30 insertions(+), 18 deletions(-) diff --git a/drivers/of/dynamic.c b/drivers/of/dynamic.c index 7bb33d22b4e2..f4f8ed9b5454 100644 --- a/drivers/of/dynamic.c +++ b/drivers/of/dynamic.c @@ -383,25 +383,24 @@ struct property *__of_prop_dup(const struct property *prop, gfp_t allocflags) /** * __of_node_dup() - Duplicate or create an empty device node dynamically. - * @fmt: Format string (plus vargs) for new full name of the device node + * @np: if not NULL, contains properties to be duplicated in new node + * @full_name: string value to be duplicated into new node's full_name field * - * Create an device tree node, either by duplicating an empty node or by allocating - * an empty one suitable for further modification. The node data are - * dynamically allocated and all the node flags have the OF_DYNAMIC & - * OF_DETACHED bits set. Returns the newly allocated node or NULL on out of - * memory error. + * Create a device tree node, optionally duplicating the properties of + * another node. The node data are dynamically allocated and all the node + * flags have the OF_DYNAMIC & OF_DETACHED bits set. + * + * Returns the newly allocated node or NULL on out of memory error. */ -struct device_node *__of_node_dup(const struct device_node *np, const char *fmt, ...) +struct device_node *__of_node_dup(const struct device_node *np, + const char *full_name) { - va_list vargs; struct device_node *node; node = kzalloc(sizeof(*node), GFP_KERNEL); if (!node) return NULL; - va_start(vargs, fmt); - node->full_name = kvasprintf(GFP_KERNEL, fmt, vargs); - va_end(vargs); + node->full_name = kstrdup(full_name, GFP_KERNEL); if (!node->full_name) { kfree(node); return NULL; diff --git a/drivers/of/of_private.h b/drivers/of/of_private.h index 0c609e7d0334..26bb31beb03e 100644 --- a/drivers/of/of_private.h +++ b/drivers/of/of_private.h @@ -104,7 +104,8 @@ extern void *__unflatten_device_tree(const void *blob, * own the devtree lock or work on detached trees only. */ struct property *__of_prop_dup(const struct property *prop, gfp_t allocflags); -__printf(2, 3) struct device_node *__of_node_dup(const struct device_node *np, const char *fmt, ...); +struct device_node *__of_node_dup(const struct device_node *np, + const char *full_name); struct device_node *__of_find_node_by_path(struct device_node *parent, const char *path); diff --git a/drivers/of/overlay.c b/drivers/of/overlay.c index 3397d7642958..c39df1c663be 100644 --- a/drivers/of/overlay.c +++ b/drivers/of/overlay.c @@ -307,7 +307,20 @@ static int add_changeset_property(struct overlay_changeset *ovcs, * If @node has child nodes, add the children recursively via * build_changeset_next_level(). * - * NOTE: Multiple mods of created nodes not supported. + * NOTE_1: A live devicetree created from a flattened device tree (FDT) will + * not contain the full path in node->full_name. Thus an overlay + * created from an FDT also will not contain the full path in + * node->full_name. However, a live devicetree created from Open + * Firmware may have the full path in node->full_name. + * + * add_changeset_node() follows the FDT convention and does not include + * the full path in node->full_name. Even though it expects the overlay + * to not contain the full path, it uses kbasename() to remove the + * full path should it exist. It also uses kbasename() in comparisons + * to nodes in the live devicetree so that it can apply an overlay to + * a live devicetree created from Open Firmware. + * + * NOTE_2: Multiple mods of created nodes not supported. * If more than one fragment contains a node that does not already exist * in the live tree, then for each fragment of_changeset_attach_node() * will add a changeset entry to add the node. When the changeset is @@ -334,8 +347,7 @@ static int add_changeset_node(struct overlay_changeset *ovcs, break; if (!tchild) { - tchild = __of_node_dup(node, "%pOF/%s", - target_node, node_kbasename); + tchild = __of_node_dup(node, node_kbasename); if (!tchild) return -ENOMEM; diff --git a/drivers/of/unittest.c b/drivers/of/unittest.c index 490bbee0cf87..acf233c34ef7 100644 --- a/drivers/of/unittest.c +++ b/drivers/of/unittest.c @@ -571,13 +571,13 @@ static void __init of_unittest_changeset(void) struct device_node *n1, *n2, *n21, *nchangeset, *nremove, *parent, *np; struct of_changeset chgset; - n1 = __of_node_dup(NULL, "/testcase-data/changeset/n1"); + n1 = __of_node_dup(NULL, "n1"); unittest(n1, "testcase setup failure\n"); - n2 = __of_node_dup(NULL, "/testcase-data/changeset/n2"); + n2 = __of_node_dup(NULL, "n2"); unittest(n2, "testcase setup failure\n"); - n21 = __of_node_dup(NULL, "%s/%s", "/testcase-data/changeset/n2", "n21"); + n21 = __of_node_dup(NULL, "n21"); unittest(n21, "testcase setup failure %p\n", n21); nchangeset = of_find_node_by_path("/testcase-data/changeset"); -- Frank Rowand