Received: by 10.223.185.116 with SMTP id b49csp3265559wrg; Sun, 25 Feb 2018 18:25:49 -0800 (PST) X-Google-Smtp-Source: AG47ELuWpsjSQdiALlOKITqVjONocBMw5SqseAPjMimcDLyQoR3JfzBurSPp8OQ2bvXve6CfLrQC X-Received: by 10.99.183.68 with SMTP id w4mr4089764pgt.113.1519611949317; Sun, 25 Feb 2018 18:25:49 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519611949; cv=none; d=google.com; s=arc-20160816; b=YDVPBOK7wryoT4Viu8Bk7SErXmFl9GehvITgFKlS0NwbGj/SsjP3JxqpwuTBodwfzL CcUpv/fJ+LBGmIIRd1L4yGmD8wX3F87Zis9IQcDQDJ6H+oDiykBIRVI6pvghXO4H0Kl9 GnuOV1VQpp2wm31va7Jb3ESOp1gZCnat3NIVM8dRPjoxt921wAjss3yzZtP0Zo4ydZp8 N6ZjEeGIuVfvEiYLecRr09EUUqGhAQINbGgBAAwccAkSqAye0Iiv9AXW1WY4mKLKsc8S Xiy5k6KJuX/TEsq6b/is1X16wjWfynJit+o6OLE9Tl1e6DzeCBRSAhsCnNV5idBc6vLX 8kSg== 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=kEKUtdzzG8rxQ7bzdA6IRftNdWhq6PW56oS2poWDuFw=; b=RvO8GqqLaaOyK+qBplMwW70u/V1MXmOjhe0cgMYsQlXHw2WjiZxTDTFeaf/pAmd9Q9 fEKD2bl/u9GPnr9W7dZMx2/MQwPpIa53mGXS1ROQgJ4f3Xtk2rbHOf+a7hRpOlUxQ9/y dowI4AB9WJGgbf4A9RUU/DHOqF/DnG2/T3Bsy2KykdH9EAaRHsRLa5/65jFXMaAPY/ee eNFRW3qCkQzLkBt+qH7NxnJ4IhBYqkG/jaREic8PG2m1OB703lG7DoIdTAZGvNKTG4BD rQc+sTa3DJAGkLPI628fm+1wYtkRDE1emSnVcsdFVE/+HrivvUiMAV1G2OldkHVVmC50 t5Hg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=d30dm9hp; 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 m21si4913616pgn.405.2018.02.25.18.25.35; Sun, 25 Feb 2018 18:25:49 -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=d30dm9hp; 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 S1752104AbeBZCXj (ORCPT + 99 others); Sun, 25 Feb 2018 21:23:39 -0500 Received: from mail-pg0-f68.google.com ([74.125.83.68]:34443 "EHLO mail-pg0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752018AbeBZCX0 (ORCPT ); Sun, 25 Feb 2018 21:23:26 -0500 Received: by mail-pg0-f68.google.com with SMTP id m19so5637928pgn.1; Sun, 25 Feb 2018 18:23:26 -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=kEKUtdzzG8rxQ7bzdA6IRftNdWhq6PW56oS2poWDuFw=; b=d30dm9hpCr2idW9gxSNl6xDWNHtRtaX7Sgf4FhevPGAAvJFNqX9opxtxbafyobohCU WJqxkF33wA/anhLUTSzekiOYdwluxe+rz2Kj4WxsiT9yE4LYrTA2kpliZy076N/1IZUw Txjf3/WPRGJWeB/+mbTM1pDvgEDpbg94leeVnFdXNEaTYPhEogdnNKYiH4Jndme4pvko R53BKI71xgUZGUGaGHdLIGbw0Ztr0JmFuSr9rzJK0/qZz4fuSFG81j4xV/rPfR/txhvs TgLDpWzpshcrMY3CFm1u8EYBc0blsKHQ+YRS/t2H/zqDsvHSW7aN6TLN74NlHeTrUoc+ 56+A== 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=kEKUtdzzG8rxQ7bzdA6IRftNdWhq6PW56oS2poWDuFw=; b=nhsUaGTo4TIreo/LvgNINj8JsuP2vjwDR0Uakswqo4kiDyXqSt4h9OdA3QZsOJ7V0a DX2RUM2g4TE7t45eNogmVaHfvh4bHiFActKoJv1SUEqksab9dBzivN2HSi93OaTWXrl9 2l1M3MeHIZj2vSOt9Mz8zx5gn6XGg9D+MDmVzgQ09qCcnTe0FNnW3IFnTlF1KfzfbmRP 3oN/+JJjs8Xec6twQEoHt+gI5ktTdWMlNjoEyw+lE0ByJbdZvx0POnm6vLF5hYjgdYKI aIsZyS0/zUDFBJjWWDYUrSSq2lSKYF6YRangZq7AW9NIq9PXR2Fr1F04sQgbL7pHIPtX FXGA== X-Gm-Message-State: APf1xPCuE+xRRSavKW7BR1/yQ++q2du8GUBoRX9tsDIHXtJza4zVHIJD oLDwvfp5/fCiGEbtAXsiyL8= X-Received: by 10.101.97.139 with SMTP id c11mr7398263pgv.447.1519611806080; Sun, 25 Feb 2018 18:23:26 -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 b6sm17690617pfm.160.2018.02.25.18.23.25 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sun, 25 Feb 2018 18:23:25 -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 2/6] of: remove kbasename(of->full_name) from overlay related code Date: Sun, 25 Feb 2018 18:22:26 -0800 Message-Id: <1519611750-22355-3-git-send-email-frowand.list@gmail.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1519611750-22355-1-git-send-email-frowand.list@gmail.com> References: <1519611750-22355-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. The overlay node creation code was not modified to reflect this change. Fix the node names generate 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 --- drivers/of/dynamic.c | 21 ++++++++++----------- drivers/of/of_private.h | 3 ++- drivers/of/overlay.c | 8 ++------ drivers/of/resolver.c | 5 +---- drivers/of/unittest.c | 6 +++--- 5 files changed, 18 insertions(+), 25 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..b9df55e0a656 100644 --- a/drivers/of/overlay.c +++ b/drivers/of/overlay.c @@ -323,19 +323,15 @@ static int add_changeset_property(struct overlay_changeset *ovcs, static int add_changeset_node(struct overlay_changeset *ovcs, struct device_node *target_node, struct device_node *node) { - const char *node_kbasename; struct device_node *tchild; int ret = 0; - node_kbasename = kbasename(node->full_name); - for_each_child_of_node(target_node, tchild) - if (!of_node_cmp(node_kbasename, kbasename(tchild->full_name))) + if (!of_node_cmp(node->full_name, tchild->full_name)) break; if (!tchild) { - tchild = __of_node_dup(node, "%pOF/%s", - target_node, node_kbasename); + tchild = __of_node_dup(node, node->full_name); if (!tchild) return -ENOMEM; diff --git a/drivers/of/resolver.c b/drivers/of/resolver.c index 740d19bde601..0e0969f58216 100644 --- a/drivers/of/resolver.c +++ b/drivers/of/resolver.c @@ -137,10 +137,7 @@ static int update_usages_of_a_phandle_reference(struct device_node *overlay, static int node_name_cmp(const struct device_node *dn1, const struct device_node *dn2) { - const char *n1 = kbasename(dn1->full_name); - const char *n2 = kbasename(dn2->full_name); - - return of_node_cmp(n1, n2); + return of_node_cmp(dn1->full_name, dn2->full_name); } /* 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