Received: by 2002:ac0:a582:0:0:0:0:0 with SMTP id m2-v6csp4640384imm; Mon, 15 Oct 2018 19:40:43 -0700 (PDT) X-Google-Smtp-Source: ACcGV61I7YLqG5IsEdcxpWDCGbkaxRSGzH9P3cZhPh+O2P9CNLZzbtKcvX6TSO94kn63cPJEZDL9 X-Received: by 2002:a63:f64f:: with SMTP id u15-v6mr18667828pgj.258.1539657643857; Mon, 15 Oct 2018 19:40:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1539657643; cv=none; d=google.com; s=arc-20160816; b=jrzqlavgP8V1O0M6GL72x+2q61AE1BsAaOkxwS08TiG54VEfA8fUcw1Kc2HrZzO65V VbHnD6FzaEHqlcOdDgmmVpWisinoS6UTvaRV7DlsChpFcUhTxQnEulX+URjrzRR8Icqt xpNouxte36JzqJOis8Gyi3EZBu6rZoaZlBcBzE6UVzF+XQaWwLz0Jv7GOUOlFY8nb0io FFwU7zAa3e8+tZLnk9x3JBsZyJp8ydmn/Lk86ocR82Myl9ODndrRkdiiqnXfdhnWtbfp Q8gviLQVhxcxD7cQmaOFXLuTAeq5ZL1rIxVFUkz6yTEjnOTktF1DRTWVqGQhylk5rnga 2WWw== 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; bh=ZU22ELPXEDk7hK8IMh4HSxAwkt1z8zH1FWohOQL9WT8=; b=a0UQEudEBpljazftt8bdRNLGPC5MzZNkIm2K/Ky5V3WpaVZJreGFmRwmknCd1r713z mhAvdnPLJFpi2XKfuJ6hXwIhsImJAtI6mBjyT3Xik/RAgGxD7/Hq/AAgY2wVHNFxlKQ1 dsIPRJui7BsQzXjW2jU//oiSEnEb2xsBscDX5IDInKAQ4vd2Z4rspjNYE3gIJ7vtko1c bTMVDQcnNDbWNO6GW+eQLO//J9sjxbOFgPY7PeXjq3JrwwAf9KONrS5g8gQbUwMw4ozI 87kW/EVbTeu9bfAvaH3Yn4h6k+bEkmqallTO7/zzqUay2jLN1C+fYs8PM+YGIeqb4+LX 9aOA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=E4lp5Dcj; 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 w8-v6si12010776pgj.584.2018.10.15.19.40.28; Mon, 15 Oct 2018 19:40:43 -0700 (PDT) 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=E4lp5Dcj; 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 S1727258AbeJPK1e (ORCPT + 99 others); Tue, 16 Oct 2018 06:27:34 -0400 Received: from mail-pl1-f194.google.com ([209.85.214.194]:36640 "EHLO mail-pl1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727169AbeJPK1e (ORCPT ); Tue, 16 Oct 2018 06:27:34 -0400 Received: by mail-pl1-f194.google.com with SMTP id y11-v6so10214303plt.3; Mon, 15 Oct 2018 19:39:30 -0700 (PDT) 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=ZU22ELPXEDk7hK8IMh4HSxAwkt1z8zH1FWohOQL9WT8=; b=E4lp5DcjD9TdbUkMm/MOty7cd2JHe+RP9yKnZrAmFkK7BgbHkOc6i0FCKUcgSHMnZ3 t7kGJXDjz3r0fuPc+vFbi/sV5Awv2L9BqxIQ1l6Cxz7Fic6WrqIROmKD3Gm3ePgwc8am 3NLpf94tkCelwlm8ufry8WT7mp4eC2HpH9rIEQDTM5brLfbhtKXhnaCYaRzjzcxycRlr eho7y7PFAiXP/cYe0AcYItt6puCLjdaT5URoHWnlNWBkZb36Tgo9uoD2HiSuf4LyWawO bDdKSKiikjekopHkkCuR8K20XUs4x7up7Zm9YWOE+OOgBUpzOytLc6WULS0ilgqi7H91 fjvA== 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=ZU22ELPXEDk7hK8IMh4HSxAwkt1z8zH1FWohOQL9WT8=; b=PQTJji8zLf8Vpnyi7d3phOOv8FzEy7HWkVzQrRlQTGri7ASGY3bbbxiEucWpTHcDWj ax8PXAG+y9lLm/iNjM9A5Aaqh7bjl8c3XgDCxep35BauM0xICQDvsB6nTpZTxrFjLYk3 jHM3KmBYET684+GT0PbMGEmLaDSGMDZ0zjVRQe08aEJWMQ/9/A7hSR6NuFoWO0kG1QC/ szPTAZo9R6LcU/gD60wd4fWKiRw2D8Jlhb5avWxt53PLk/WkuVDqnJ3m9NAIiVrHkzl/ X1GTNBY5l1lSprCLKDeDs00ey++kyuoJ2L36UpTR5BHzS9a+yXrxhgyHyd6r7IAdLLKP r6MQ== X-Gm-Message-State: ABuFfoj/adTL3VBMlRcU/YECEWLZRqHL3WnO9xY2lqxpHyuKY7Fc08Di /fjniJeZMIugBCPo4FRs8WY= X-Received: by 2002:a17:902:b907:: with SMTP id bf7-v6mr19886883plb.127.1539657570008; Mon, 15 Oct 2018 19:39:30 -0700 (PDT) Received: from localhost.localdomain (c-24-6-192-50.hsd1.ca.comcast.net. [24.6.192.50]) by smtp.gmail.com with ESMTPSA id u79-v6sm18620287pfd.117.2018.10.15.19.39.28 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 15 Oct 2018 19:39:29 -0700 (PDT) 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 v4 15/18] of: overlay: set node fields from properties when add new overlay node Date: Mon, 15 Oct 2018 19:37:35 -0700 Message-Id: <1539657458-24401-16-git-send-email-frowand.list@gmail.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1539657458-24401-1-git-send-email-frowand.list@gmail.com> References: <1539657458-24401-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 Overlay nodes added by add_changeset_node() do not have the node fields name, phandle, and type set. The node passed to __of_attach_node() when the add node changeset entry is processed does not contain any properties. The node's properties are located in add property changeset entries that will be processed after the add node changeset is applied. Set the node's fields in the node contained in the add node changeset entry and do not set them to incorrect values in add_changeset_node(). A visible symptom that is fixed by this patch is the names of nodes added by overlays that have an entry in /sys/bus/platform/drivers/*/ will contain the unit-address but the node-name will be , for example, "fc4ab000.". After applying the patch the name, in this example, for node restart@fc4ab000 is "fc4ab000.restart". Signed-off-by: Frank Rowand --- drivers/of/dynamic.c | 27 ++++++++++++++++++--------- drivers/of/overlay.c | 29 ++++++++++++++++++++++++----- 2 files changed, 42 insertions(+), 14 deletions(-) diff --git a/drivers/of/dynamic.c b/drivers/of/dynamic.c index a94f727ec3da..a9f5d5fb3f25 100644 --- a/drivers/of/dynamic.c +++ b/drivers/of/dynamic.c @@ -205,15 +205,24 @@ static void __of_attach_node(struct device_node *np) const __be32 *phandle; int sz; - np->name = __of_get_property(np, "name", NULL) ? : ""; - np->type = __of_get_property(np, "device_type", NULL) ? : ""; - - phandle = __of_get_property(np, "phandle", &sz); - if (!phandle) - phandle = __of_get_property(np, "linux,phandle", &sz); - if (IS_ENABLED(CONFIG_PPC_PSERIES) && !phandle) - phandle = __of_get_property(np, "ibm,phandle", &sz); - np->phandle = (phandle && (sz >= 4)) ? be32_to_cpup(phandle) : 0; + if (!of_node_check_flag(np, OF_OVERLAY)) { + np->name = __of_get_property(np, "name", NULL); + np->type = __of_get_property(np, "device_type", NULL); + if (!np->name) + np->name = ""; + if (!np->type) + np->type = ""; + + phandle = __of_get_property(np, "phandle", &sz); + if (!phandle) + phandle = __of_get_property(np, "linux,phandle", &sz); + if (IS_ENABLED(CONFIG_PPC_PSERIES) && !phandle) + phandle = __of_get_property(np, "ibm,phandle", &sz); + if (phandle && (sz >= 4)) + np->phandle = be32_to_cpup(phandle); + else + np->phandle = 0; + } np->child = NULL; np->sibling = np->parent->child; diff --git a/drivers/of/overlay.c b/drivers/of/overlay.c index 01afd22566ed..d011177e5aaa 100644 --- a/drivers/of/overlay.c +++ b/drivers/of/overlay.c @@ -307,10 +307,11 @@ static int add_changeset_property(struct overlay_changeset *ovcs, int ret = 0; bool check_for_non_overlay_node = false; - if (!of_prop_cmp(overlay_prop->name, "name") || - !of_prop_cmp(overlay_prop->name, "phandle") || - !of_prop_cmp(overlay_prop->name, "linux,phandle")) - return 0; + if (target->in_livetree) + if (!of_prop_cmp(overlay_prop->name, "name") || + !of_prop_cmp(overlay_prop->name, "phandle") || + !of_prop_cmp(overlay_prop->name, "linux,phandle")) + return 0; if (target->in_livetree) prop = of_find_property(target->np, overlay_prop->name, NULL); @@ -331,6 +332,10 @@ static int add_changeset_property(struct overlay_changeset *ovcs, if (!prop) { check_for_non_overlay_node = true; + if (!target->in_livetree) { + new_prop->next = target->np->deadprops; + target->np->deadprops = new_prop; + } ret = of_changeset_add_property(&ovcs->cset, target->np, new_prop); @@ -410,9 +415,10 @@ static int add_changeset_node(struct overlay_changeset *ovcs, struct target *target, struct device_node *node) { const char *node_kbasename; + const __be32 *phandle; struct device_node *tchild; struct target target_child; - int ret = 0; + int ret = 0, size; node_kbasename = kbasename(node->full_name); @@ -426,6 +432,19 @@ static int add_changeset_node(struct overlay_changeset *ovcs, return -ENOMEM; tchild->parent = target->np; + tchild->name = __of_get_property(node, "name", NULL); + tchild->type = __of_get_property(node, "device_type", NULL); + + if (!tchild->name) + tchild->name = ""; + if (!tchild->type) + tchild->type = ""; + + /* ignore obsolete "linux,phandle" */ + phandle = __of_get_property(node, "phandle", &size); + if (phandle && (size == 4)) + tchild->phandle = be32_to_cpup(phandle); + of_node_set_flag(tchild, OF_OVERLAY); ret = of_changeset_attach_node(&ovcs->cset, tchild); -- Frank Rowand