From patchwork Thu Jul 22 19:10:51 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Grant Likely X-Patchwork-Id: 59628 X-Patchwork-Delegate: grant.likely@secretlab.ca Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from bilbo.ozlabs.org (localhost [127.0.0.1]) by ozlabs.org (Postfix) with ESMTP id BDEEA100A92 for ; Fri, 23 Jul 2010 05:11:22 +1000 (EST) Received: by ozlabs.org (Postfix) id 94CDC1007D2; Fri, 23 Jul 2010 05:11:14 +1000 (EST) Delivered-To: linuxppc-dev@ozlabs.org Received: from mail-gy0-f170.google.com (mail-gy0-f170.google.com [209.85.160.170]) by ozlabs.org (Postfix) with ESMTP id C761D1007D1 for ; Fri, 23 Jul 2010 05:11:13 +1000 (EST) Received: by gyh4 with SMTP id 4so981319gyh.15 for ; Thu, 22 Jul 2010 12:11:11 -0700 (PDT) Received: by 10.100.165.19 with SMTP id n19mr2760048ane.48.1279825871308; Thu, 22 Jul 2010 12:11:11 -0700 (PDT) MIME-Version: 1.0 Received: by 10.231.164.170 with HTTP; Thu, 22 Jul 2010 12:10:51 -0700 (PDT) In-Reply-To: References: <1279756992-29543-1-git-send-email-dbaryshkov@gmail.com> <1279756992-29543-2-git-send-email-dbaryshkov@gmail.com> <566EC982-1CDA-4806-8EC0-8C9F36448F83@kernel.crashing.org> From: Grant Likely Date: Thu, 22 Jul 2010 13:10:51 -0600 X-Google-Sender-Auth: IRcBZxK_dZHxwLHCGhZaOtzh-E0 Message-ID: Subject: Re: [PATCH 2/2] mpc85xx_edac: change to use new definitions for PCI EDAC regspace To: Dmitry Eremin-Solenikov Cc: linuxppc-dev@ozlabs.org, Doug Thompson , bluesmoke-devel@lists.sourceforge.net X-BeenThere: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: linuxppc-dev-bounces+patchwork-incoming=ozlabs.org@lists.ozlabs.org Errors-To: linuxppc-dev-bounces+patchwork-incoming=ozlabs.org@lists.ozlabs.org On Thu, Jul 22, 2010 at 10:48 AM, Dmitry Eremin-Solenikov wrote: > Hello, > > On Thu, Jul 22, 2010 at 7:38 PM, Kumar Gala wrote: >> >> On Jul 21, 2010, at 7:03 PM, Dmitry Eremin-Solenikov wrote: >> >>> Currently (as mpc8540-pci) devices are not created on of_platform bus, >>> mpc85xx_edac can't probe to them. Follow the change to dts trees to bind >>> not to the main mpc8540-pci node but to special mpc85xx-pci-error nodes, >>> present on soc bus. >>> >>> Signed-off-by: Dmitry Eremin-Solenikov >>> --- >>> drivers/edac/mpc85xx_edac.c |   18 +++++++++--------- >>> 1 files changed, 9 insertions(+), 9 deletions(-) >> >> Nak. >> >> We already have a node in the dts for the PCI controller.  Lets update the platform code to add the pci controller to the of_platform_bus_probe list. > > I've had that idea. However it's really look strange to me to call > of_platform_bus_probe() on the bus node, for which we (IMO) explicitly > won't like for > child devices (PCI devices) to be added to of_platform bus. Would it > be suitable to just call of_platform_device_create for it (Or do i > miss someth BTW: While I'm at it, should I change all mpc8540-pci/-pcix device > names to include respective SoC name? It is good practice to include both the specific name, and the name of the device it is backwards compatible to. g. From d84af195dbcd99ce172bf639538231141176d402 Mon Sep 17 00:00:00 2001 From: Grant Likely Date: Thu, 22 Jul 2010 13:01:11 -0600 Subject: [PATCH] of/device: Register children with a compatible value in of_platform_bus_probe() Currently, of_platform_bus_probe() completely skips nodes which do not explicitly match the 'matches' table passed in. Or, if the root node matches, then it registers all the children unconditionally. However, there are situations, such as registering devices from the root node, when it is desirable to register child nodes, but only if they actually represent devices. For example, the root node may contain both a local bus and a PCI device, but it also contains the chosen, aliases and cpus nodes which don't represent real devices. This patch changes of_platform_bus_probe() to register all nodes at the top level if they either match the matches table (the current behaviour), or if they have a 'compatible' value (indicating it represents a device). --- drivers/of/platform.c | 31 ++++++++++++++++++++++++++----- 1 files changed, 26 insertions(+), 5 deletions(-) diff --git a/drivers/of/platform.c b/drivers/of/platform.c index f3f1ec8..2ead562 100644 --- a/drivers/of/platform.c +++ b/drivers/of/platform.c @@ -709,16 +709,37 @@ int of_platform_bus_probe(struct device_node *root, rc = of_platform_bus_create(root, matches, &dev->dev); goto bail; } + + /* Register each child node if either: + * a) it has a 'compatible' value indicating they are a device, or + * b) it is specified by the 'matches' table (by name or device_type) + * If a node is specified in the matches table, then all its children + * also get registered. + */ for_each_child_of_node(root, child) { - if (!of_match_node(matches, child)) + void *compat = of_get_property(child, "compatible", NULL); + struct of_device_id *match = of_match_node(matches, child); + + /* Skip if node neither matches nor has a compatible property */ + if (!compat && !match) continue; - pr_debug(" match: %s\n", child->full_name); + pr_debug(" register device: %s\n", child->full_name); + + /* Passed the first test, register node as a platform device */ dev = of_platform_device_create(child, NULL, parent); - if (dev == NULL) + if (!dev) { rc = -ENOMEM; - else - rc = of_platform_bus_create(child, matches, &dev->dev); + of_node_put(child); + break; + } + + /* Only register child nodes if specified by matches table */ + if (!match) + continue; + + pr_debug(" register children of: %s\n", child->full_name); + rc = of_platform_bus_create(child, matches, &dev->dev); if (rc) { of_node_put(child); break; -- 1.7.0.4