Received: by 2002:ac0:a582:0:0:0:0:0 with SMTP id m2-v6csp3322077imm; Sun, 14 Oct 2018 17:27:25 -0700 (PDT) X-Google-Smtp-Source: ACcGV60vZ8XnkQHB1pWQG7JBTbhDvsp1UKvRaQ4gh2ki5WU6xrrd7Pow9ihon3tYadKcYExequ2R X-Received: by 2002:a17:902:9347:: with SMTP id g7-v6mr14887798plp.90.1539563245082; Sun, 14 Oct 2018 17:27:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1539563245; cv=none; d=google.com; s=arc-20160816; b=bhC3jHeXh1Y1VccXrhhf8Lf+bAB9mPpJ7rwWnJkNY2PFRVaD2io2Prz+qGmaxpYGWX 1G/3xW2l7Nhky+6ILmGsk03AWCoHMUWFQ+OpciMNHqhEkX/9P+6LF/crC4o5d+UfBqRD SRGALzuXn8F2AruUfHruvsUGQpoYI/6u5BEUeStXuM795n7RdAP6Ws33aR5nJ6fOe2yf ET2MDMvYKgJxR+WzRLyk8kJiCGE/8NIpUowcXZF3Kc06TVLn5We0CLXQUcTSahuIucAK VC5Cd0OysbrAuNdxeWHX/tNc8DTUR/5zx8mA/oMAIpRSBAmJclIxRK76TB3CnG3hGgA2 /EHQ== 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=lcuTd93Zs0lVeU8vKhWhv5GEua+bMb9Vyzo19XuwRmc=; b=SstvbTLX3vcAY8lUp3Fgd5eZrI/UUZu/byIBFAli518TxEf92Lj23Z3Wb4BybGYGX3 x5Euy4KOzYMu71fYCh0zDqKYMnKVNsEbQn2mV9K1sYkUSBxW7W7SmXfh48EDBc2Oe7/n MuLEKAWW5lb3C95pPSDIi/Ig6GyUl4RsxZPyUKbwiUdNp36ipMyvGmRq3PUN+kKC02VD g0xdkGm2ayCEdqzsHYQNhm7VZ0b1VKt3s7E77bSRM4MEs2AF+VQKK79tCtC/gc1m7Hwp Ea8vHVCt08QOtD+fms0yO3h2wjQTeDyczwz4fRT8MzLkLAsIPAmTsAkS/mX0ZAS6BWKR buMQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=Bh5+o4A0; 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 o68-v6si5075208pfb.203.2018.10.14.17.27.06; Sun, 14 Oct 2018 17:27:25 -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=Bh5+o4A0; 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 S1726970AbeJOIJJ (ORCPT + 99 others); Mon, 15 Oct 2018 04:09:09 -0400 Received: from mail-pl1-f196.google.com ([209.85.214.196]:43487 "EHLO mail-pl1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726920AbeJOIJH (ORCPT ); Mon, 15 Oct 2018 04:09:07 -0400 Received: by mail-pl1-f196.google.com with SMTP id 30-v6so8384198plb.10; Sun, 14 Oct 2018 17:26:19 -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=lcuTd93Zs0lVeU8vKhWhv5GEua+bMb9Vyzo19XuwRmc=; b=Bh5+o4A0M2N6QlVmdomIjWhFrf4xvr1abWLG9NqdVLB+bcy3AGcqSRkPGCzn3wYY8s YtrjktZUaz3bFyJ5EdvmqqSTA/TOp5SXaQgEs+SYh432/4j9sAzcMDoeQxgMmmy6e7vG hJivODcbGojVwlm/x3puKgANs5bB0KO7x38C8+NlPRvJjUdKCNssiEL67egRZJ7rN0l4 JCCMqHpGmaiDkKA+/L4GVpLbDQ8y2pmK/ScEiWklxud0Mt8dqEwb2+zXF9WC+Ne9CQe0 gdN7+8B07io3RvzaWnpkK0p5iYXxmhXtHLZ1UQX/6p+V/jNl+hUThrSR0Fiikasmxpl3 bABA== 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=lcuTd93Zs0lVeU8vKhWhv5GEua+bMb9Vyzo19XuwRmc=; b=dSvDql5zlUInRsaKmLcR2+KRzZz9sPLMo1gnViUEInGFS4hQSIWl4b81Mj4Oiv8jQF FCwZ+2PPVSDgW+fJ9vcVHSQOL9vpn0oq9fa85PNFmFfaQ6/jf73mDHXf01+cG/8ICwzu 3xio9dD0JHQPSFRmh0aIyGxmYAZGrmn9SWEgVlO34HfsVdwhe+de4A7cZO0Bs5FKO9pQ mNRJWW6WxU9F0yH4KnQpXs2x1sr82pxxAdcXp0W9aRDWbcZNN046zGHZNO4S0raMuM6R GAYYUYeLOyJ7OS8AG+T+UW6CAKetlUXTloxpaSg1ca/J5PLo13DbZ3+meE4cx5eAw8Ck jpLg== X-Gm-Message-State: ABuFfoh82QiJ6hXKGOpUQUL56Bi2z9+hXLSmQ9WE2bk1bKRloBhJkkT+ QwA5cVbrFjMACDBbZ3pKsn4= X-Received: by 2002:a17:902:6848:: with SMTP id f8-v6mr15031222pln.27.1539563178699; Sun, 14 Oct 2018 17:26:18 -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 j14-v6sm11387110pgh.52.2018.10.14.17.26.17 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sun, 14 Oct 2018 17:26:18 -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 v3 15/18] of: overlay: set node fields from properties when add new overlay node Date: Sun, 14 Oct 2018 17:24:27 -0700 Message-Id: <1539563070-12969-16-git-send-email-frowand.list@gmail.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1539563070-12969-1-git-send-email-frowand.list@gmail.com> References: <1539563070-12969-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 5f7c99b9de0d..5b740114dbdc 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 908bcc62019b..f5c3330567b6 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); @@ -406,9 +411,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); @@ -422,6 +428,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