From patchwork Fri Jun 8 09:42:06 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hongtao Jia X-Patchwork-Id: 163749 X-Patchwork-Delegate: galak@kernel.crashing.org Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from ozlabs.org (localhost [IPv6:::1]) by ozlabs.org (Postfix) with ESMTP id A012D100AE2 for ; Fri, 8 Jun 2012 20:06:25 +1000 (EST) Received: from va3outboundpool.messaging.microsoft.com (va3ehsobe006.messaging.microsoft.com [216.32.180.16]) (using TLSv1 with cipher AES128-SHA (128/128 bits)) (Client CN "mail.global.frontbridge.com", Issuer "Microsoft Secure Server Authority" (not verified)) by ozlabs.org (Postfix) with ESMTPS id 74577B7025 for ; Fri, 8 Jun 2012 20:00:45 +1000 (EST) Received: from mail170-va3-R.bigfish.com (10.7.14.241) by VA3EHSOBE004.bigfish.com (10.7.40.24) with Microsoft SMTP Server id 14.1.225.23; Fri, 8 Jun 2012 09:59:50 +0000 Received: from mail170-va3 (localhost [127.0.0.1]) by mail170-va3-R.bigfish.com (Postfix) with ESMTP id 79FE23E02CE; Fri, 8 Jun 2012 09:59:50 +0000 (UTC) X-Forefront-Antispam-Report: CIP:70.37.183.190; KIP:(null); UIP:(null); IPV:NLI; H:mail.freescale.net; RD:none; EFVD:NLI X-SpamScore: 0 X-BigFish: VS0(zzzz1202hzz8275bhz2dh2a8h668h839he5bhf0ah) Received: from mail170-va3 (localhost.localdomain [127.0.0.1]) by mail170-va3 (MessageSwitch) id 133914958932176_24852; Fri, 8 Jun 2012 09:59:49 +0000 (UTC) Received: from VA3EHSMHS012.bigfish.com (unknown [10.7.14.244]) by mail170-va3.bigfish.com (Postfix) with ESMTP id 0488E2A0049; Fri, 8 Jun 2012 09:59:49 +0000 (UTC) Received: from mail.freescale.net (70.37.183.190) by VA3EHSMHS012.bigfish.com (10.7.99.22) with Microsoft SMTP Server (TLS) id 14.1.225.23; Fri, 8 Jun 2012 09:59:48 +0000 Received: from az84smr01.freescale.net (10.64.34.197) by 039-SN1MMR1-002.039d.mgd.msft.net (10.84.1.15) with Microsoft SMTP Server (TLS) id 14.2.298.5; Fri, 8 Jun 2012 05:00:37 -0500 Received: from rock.am.freescale.net (rock.ap.freescale.net [10.193.20.106]) by az84smr01.freescale.net (8.14.3/8.14.0) with ESMTP id q58A02W5005252; Fri, 8 Jun 2012 03:00:34 -0700 From: Jia Hongtao To: , Subject: [PATCH V3 5/6] Avoid duplicate probe for of platform devices Date: Fri, 8 Jun 2012 17:42:06 +0800 Message-ID: <1339148527-16911-6-git-send-email-B38951@freescale.com> X-Mailer: git-send-email 1.7.5.1 In-Reply-To: <1339148527-16911-1-git-send-email-B38951@freescale.com> References: <1339148527-16911-1-git-send-email-B38951@freescale.com> MIME-Version: 1.0 X-OriginatorOrg: freescale.com Cc: R65777@freescale.com, b38951@freescale.com, B07421@freescale.com X-BeenThere: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.15rc1 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: linuxppc-dev-bounces+patchwork-incoming=ozlabs.org@lists.ozlabs.org Sender: "Linuxppc-dev" We changed the pcie controller driver to platform driver so that the PCI of platform devices need to be created earlier in the arch_initcall stage according to the original timing of calling fsl_add_bridge(). So we do PCI probing separately from other devices. But probing more than once could cause duplication warning. We add check if the devices have already probed before probing any devices to avoid duplication warning. Signed-off-by: Jia Hongtao Signed-off-by: Li Yang --- drivers/of/platform.c | 18 ++++++++++++------ 1 files changed, 12 insertions(+), 6 deletions(-) diff --git a/drivers/of/platform.c b/drivers/of/platform.c index a37330e..3aab01f 100644 --- a/drivers/of/platform.c +++ b/drivers/of/platform.c @@ -139,6 +139,18 @@ struct platform_device *of_device_alloc(struct device_node *np, if (!dev) return NULL; + dev->dev.of_node = of_node_get(np); + if (bus_id) + dev_set_name(&dev->dev, "%s", bus_id); + else + of_device_make_bus_id(&dev->dev); + + if (kset_find_obj(dev->dev.kobj.kset, kobject_name(&dev->dev.kobj))) { + kfree(dev); + of_node_put(np); + return NULL; + } + /* count the io and irq resources */ while (of_address_to_resource(np, num_reg, &temp_res) == 0) num_reg++; @@ -161,17 +173,11 @@ struct platform_device *of_device_alloc(struct device_node *np, WARN_ON(of_irq_to_resource_table(np, res, num_irq) != num_irq); } - dev->dev.of_node = of_node_get(np); #if defined(CONFIG_MICROBLAZE) dev->dev.dma_mask = &dev->archdata.dma_mask; #endif dev->dev.parent = parent; - if (bus_id) - dev_set_name(&dev->dev, "%s", bus_id); - else - of_device_make_bus_id(&dev->dev); - return dev; } EXPORT_SYMBOL(of_device_alloc);