From patchwork Wed Jul 23 23:44:22 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Grant Likely X-Patchwork-Id: 34183 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-yh0-f70.google.com (mail-yh0-f70.google.com [209.85.213.70]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id BA45920672 for ; Wed, 23 Jul 2014 23:45:41 +0000 (UTC) Received: by mail-yh0-f70.google.com with SMTP id b6sf6994075yha.5 for ; Wed, 23 Jul 2014 16:45:41 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:delivered-to:from:to:cc:subject :date:message-id:in-reply-to:references:sender:precedence:list-id :x-original-sender:x-original-authentication-results:mailing-list :list-post:list-help:list-archive:list-unsubscribe; bh=QouTAZcOFAiAIvlszMs7rTXVN6yWFLhNw1QYcWH7R90=; b=YJERGAlOo3seSBaig3JNY7Ka7RRMM2HcazBTaYAdAVZIghrzfraHKwBR2AIUfHxp8r 7v+pm9D+SpYR8U4jfdR1glxjCOgzIkcT8jb41rJt8PGAaAEN6aKrl/qSX16/W5X0npJd jQo0Nytdv4rAS2rG0l6/9aErGZI+9ju7aMKsYUdtDEVsKq2k1gBc0lu+TXetW91X7gDV T5HQwRki8g4gGVccvVSyL61uaUrxitfqdAejPTbmdawWIO/hs0fz0bnJLW5/Y8GnVRsB 1S3dBruDbOWxqA090+LOE5G1+XbsrCC4U/tuY9O6xSrlBQG6hUnj0zJa/TEAR0cWkWa1 wDlA== X-Gm-Message-State: ALoCoQkNHXj20S9qHAXO5JfY+a3eNssxNp7Iui3hJ5gla+SIFOr+Z0dcrY1neh8rfk9Uh+8WM3Ur X-Received: by 10.224.127.6 with SMTP id e6mr2339118qas.3.1406159141433; Wed, 23 Jul 2014 16:45:41 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.96.38 with SMTP id j35ls539861qge.89.gmail; Wed, 23 Jul 2014 16:45:41 -0700 (PDT) X-Received: by 10.220.250.203 with SMTP id mp11mr7282219vcb.2.1406159141334; Wed, 23 Jul 2014 16:45:41 -0700 (PDT) Received: from mail-vc0-f174.google.com (mail-vc0-f174.google.com [209.85.220.174]) by mx.google.com with ESMTPS id o11si3821612vdh.16.2014.07.23.16.45.41 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 23 Jul 2014 16:45:41 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.220.174 as permitted sender) client-ip=209.85.220.174; Received: by mail-vc0-f174.google.com with SMTP id la4so3533530vcb.5 for ; Wed, 23 Jul 2014 16:45:41 -0700 (PDT) X-Received: by 10.52.244.81 with SMTP id xe17mr6058971vdc.24.1406159141230; Wed, 23 Jul 2014 16:45:41 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.221.37.5 with SMTP id tc5csp320987vcb; Wed, 23 Jul 2014 16:45:40 -0700 (PDT) X-Received: by 10.68.68.131 with SMTP id w3mr3212873pbt.90.1406159140395; Wed, 23 Jul 2014 16:45:40 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id ki10si4066540pbd.62.2014.07.23.16.45.39 for ; Wed, 23 Jul 2014 16:45:40 -0700 (PDT) Received-SPF: none (google.com: linux-kernel-owner@vger.kernel.org does not designate permitted sender hosts) client-ip=209.132.180.67; Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1758644AbaGWXpi (ORCPT + 16 others); Wed, 23 Jul 2014 19:45:38 -0400 Received: from mail-pa0-f42.google.com ([209.85.220.42]:33485 "EHLO mail-pa0-f42.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1758610AbaGWXol (ORCPT ); Wed, 23 Jul 2014 19:44:41 -0400 Received: by mail-pa0-f42.google.com with SMTP id lf10so2659086pab.15 for ; Wed, 23 Jul 2014 16:44:41 -0700 (PDT) X-Received: by 10.68.69.7 with SMTP id a7mr5948801pbu.49.1406159081310; Wed, 23 Jul 2014 16:44:41 -0700 (PDT) Received: from trevor.secretlab.ca (S0106602ad082623c.cg.shawcable.net. [68.146.69.61]) by mx.google.com with ESMTPSA id gw8sm3563273pbc.28.2014.07.23.16.44.38 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 23 Jul 2014 16:44:40 -0700 (PDT) Received: by trevor.secretlab.ca (Postfix, from userid 1000) id E5677C43A1A; Wed, 23 Jul 2014 17:44:26 -0600 (MDT) From: Grant Likely To: linux-kernel@vger.kernel.org, Nathan Fontenot , Tyrel Datwyler , Pantelis Antoniou , devicetree@vger.kernel.org Cc: Grant Likely , Benjamin Herrenschmidt Subject: [PATCH 08/10] of: Move dynamic node fixups out of powerpc and into common code Date: Wed, 23 Jul 2014 17:44:22 -0600 Message-Id: <1406159064-21366-9-git-send-email-grant.likely@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1406159064-21366-1-git-send-email-grant.likely@linaro.org> References: <1406159064-21366-1-git-send-email-grant.likely@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: list List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: grant.likely@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.220.174 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , PowerPC does an odd thing with dynamic nodes. It uses a notifier to catch new node additions and set some of the values like name and type. This makes no sense since that same code can be put directly into of_attach_node(). Besides, all dynamic node users need this, not just powerpc. Fix this problem by moving the logic out of arch/powerpc and into drivers/of/dynamic.c. It is also important to remove this notifier because we want to move the firing of notifiers from before the tree is modified to after so that the receiver gets a consistent view of the tree, but that is incompatible with notifiers that modify the node. Signed-off-by: Grant Likely Cc: Nathan Fontenot Cc: Benjamin Herrenschmidt --- arch/powerpc/kernel/prom.c | 70 ---------------------------------------------- drivers/of/base.c | 4 +-- drivers/of/dynamic.c | 13 +++++++++ drivers/of/of_private.h | 2 ++ 4 files changed, 17 insertions(+), 72 deletions(-) diff --git a/arch/powerpc/kernel/prom.c b/arch/powerpc/kernel/prom.c index b694b0730971..9e8d8a880d6f 100644 --- a/arch/powerpc/kernel/prom.c +++ b/arch/powerpc/kernel/prom.c @@ -821,76 +821,6 @@ int cpu_to_chip_id(int cpu) } EXPORT_SYMBOL(cpu_to_chip_id); -#ifdef CONFIG_PPC_PSERIES -/* - * Fix up the uninitialized fields in a new device node: - * name, type and pci-specific fields - */ - -static int of_finish_dynamic_node(struct device_node *node) -{ - struct device_node *parent = of_get_parent(node); - int err = 0; - const phandle *ibm_phandle; - - node->name = of_get_property(node, "name", NULL); - node->type = of_get_property(node, "device_type", NULL); - - if (!node->name) - node->name = ""; - if (!node->type) - node->type = ""; - - if (!parent) { - err = -ENODEV; - goto out; - } - - /* We don't support that function on PowerMac, at least - * not yet - */ - if (machine_is(powermac)) - return -ENODEV; - - /* fix up new node's phandle field */ - if ((ibm_phandle = of_get_property(node, "ibm,phandle", NULL))) - node->phandle = *ibm_phandle; - -out: - of_node_put(parent); - return err; -} - -static int prom_reconfig_notifier(struct notifier_block *nb, - unsigned long action, void *node) -{ - int err; - - switch (action) { - case OF_RECONFIG_ATTACH_NODE: - err = of_finish_dynamic_node(node); - if (err < 0) - printk(KERN_ERR "finish_node returned %d\n", err); - break; - default: - err = 0; - break; - } - return notifier_from_errno(err); -} - -static struct notifier_block prom_reconfig_nb = { - .notifier_call = prom_reconfig_notifier, - .priority = 10, /* This one needs to run first */ -}; - -static int __init prom_reconfig_setup(void) -{ - return of_reconfig_notifier_register(&prom_reconfig_nb); -} -__initcall(prom_reconfig_setup); -#endif - bool arch_match_cpu_phys_id(int cpu, u64 phys_id) { return (int)phys_id == get_hard_smp_processor_id(cpu); diff --git a/drivers/of/base.c b/drivers/of/base.c index ad4929cbd876..ededf8e33145 100644 --- a/drivers/of/base.c +++ b/drivers/of/base.c @@ -266,8 +266,8 @@ EXPORT_SYMBOL(of_find_all_nodes); * Find a property with a given name for a given node * and return the value. */ -static const void *__of_get_property(const struct device_node *np, - const char *name, int *lenp) +const void *__of_get_property(const struct device_node *np, + const char *name, int *lenp) { struct property *pp = __of_find_property(np, name, lenp); diff --git a/drivers/of/dynamic.c b/drivers/of/dynamic.c index b96d83100987..7c020b9a3317 100644 --- a/drivers/of/dynamic.c +++ b/drivers/of/dynamic.c @@ -98,6 +98,19 @@ int of_property_notify(int action, struct device_node *np, 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(PPC_PSERIES) && !phandle) + phandle = __of_get_property(np, "ibm,phandle", &sz); + np->phandle = (phandle && (sz >= 4)) ? be32_to_cpup(phandle) : 0; + np->child = NULL; np->sibling = np->parent->child; np->allnext = np->parent->allnext; diff --git a/drivers/of/of_private.h b/drivers/of/of_private.h index 0d99ba8caeed..8129c0e58d70 100644 --- a/drivers/of/of_private.h +++ b/drivers/of/of_private.h @@ -63,6 +63,8 @@ static inline int of_property_notify(int action, struct device_node *np, struct property *__of_prop_dup(const struct property *prop, gfp_t allocflags); struct device_node *__of_node_alloc(const char *full_name, gfp_t allocflags); +extern const void *__of_get_property(const struct device_node *np, + const char *name, int *lenp); extern int __of_add_property(struct device_node *np, struct property *prop); extern int __of_add_property_sysfs(struct device_node *np, struct property *prop);