From patchwork Wed Mar 5 11:48:54 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Liviu Dudau X-Patchwork-Id: 25761 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-oa0-f72.google.com (mail-oa0-f72.google.com [209.85.219.72]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 5410C203C3 for ; Wed, 5 Mar 2014 11:51:31 +0000 (UTC) Received: by mail-oa0-f72.google.com with SMTP id g12sf3278318oah.11 for ; Wed, 05 Mar 2014 03:51:30 -0800 (PST) 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=e3+m10eQzcVSR1q98WRl4WNtXBAmgeZd96ISZwvuoNw=; b=YjnMCWthHEW+yOBXe/Wyi9pn1xRV8bZZfnrBnRLpv3K47YwrI8UEwb2MQnO5jknDGe VKDvL989/6RDgceeDIckQfI0kRWejMOwu42Xna9JwFCk6ZBUlG9OhUh+DTy7zmOtP1pb h8RL450OIEiCHSmjSArNTUEB6v50+LY56AArwuz22+M+574o48NrLqWorrnIHdN4l6s7 evu6ZpYE6BLkPqyseDqShUfnQJEJ7avRN1heDL1giUBZcGO2PC7Bu6hQtKbw7Po3gHp6 M8JKABWOvXQyjrXvZLzX4exnRvl2FxD1qnvTEpzalXC89/zXkiQJr/uCo+Os//OHZEAG MJJA== X-Gm-Message-State: ALoCoQnHQXLhpMjMCqMUDbiG+KO0ehRERAzRSGliwbeBR1BiZJZ01Z5qNJOeno+Ywq3JDYI1Gi5R X-Received: by 10.182.186.105 with SMTP id fj9mr2283640obc.5.1394020290877; Wed, 05 Mar 2014 03:51:30 -0800 (PST) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.106.165 with SMTP id e34ls260579qgf.29.gmail; Wed, 05 Mar 2014 03:51:30 -0800 (PST) X-Received: by 10.220.147.16 with SMTP id j16mr1175229vcv.28.1394020290664; Wed, 05 Mar 2014 03:51:30 -0800 (PST) Received: from mail-ve0-f172.google.com (mail-ve0-f172.google.com [209.85.128.172]) by mx.google.com with ESMTPS id xn5si621075vdc.3.2014.03.05.03.51.30 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 05 Mar 2014 03:51:30 -0800 (PST) Received-SPF: neutral (google.com: 209.85.128.172 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) client-ip=209.85.128.172; Received: by mail-ve0-f172.google.com with SMTP id jx11so907496veb.17 for ; Wed, 05 Mar 2014 03:51:30 -0800 (PST) X-Received: by 10.58.161.205 with SMTP id xu13mr112649veb.4.1394020290558; Wed, 05 Mar 2014 03:51:30 -0800 (PST) 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.220.78.9 with SMTP id i9csp12497vck; Wed, 5 Mar 2014 03:51:30 -0800 (PST) X-Received: by 10.66.228.201 with SMTP id sk9mr6277473pac.134.1394020289550; Wed, 05 Mar 2014 03:51:29 -0800 (PST) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id zj6si2245675pac.88.2014.03.05.03.51.28; Wed, 05 Mar 2014 03:51:28 -0800 (PST) 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; Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756377AbaCELvT (ORCPT + 26 others); Wed, 5 Mar 2014 06:51:19 -0500 Received: from fw-tnat.cambridge.arm.com ([217.140.96.21]:51633 "EHLO cam-smtp0.cambridge.arm.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1752502AbaCELts (ORCPT ); Wed, 5 Mar 2014 06:49:48 -0500 Received: from e106497-lin.cambridge.arm.com (e106497-lin.cambridge.arm.com [10.1.195.170]) by cam-smtp0.cambridge.arm.com (8.13.8/8.13.8) with ESMTP id s25BmvbB028509; Wed, 5 Mar 2014 11:48:58 GMT From: Liviu Dudau To: linux-pci , Bjorn Helgaas , Catalin Marinas , Will Deacon , linaro-kernel Cc: Benjamin Herrenschmidt , LKML , "devicetree@vger.kernel.org" , LAKML , Tanmay Inamdar , Arnd Bergmann Subject: [PATCH v6 3/6] pci: Create pci_host_bridge before its associated bus in pci_create_root_bus. Date: Wed, 5 Mar 2014 11:48:54 +0000 Message-Id: <1394020137-1830-4-git-send-email-Liviu.Dudau@arm.com> X-Mailer: git-send-email 1.9.0 In-Reply-To: <1394020137-1830-1-git-send-email-Liviu.Dudau@arm.com> References: <1394020137-1830-1-git-send-email-Liviu.Dudau@arm.com> 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: liviu.dudau@arm.com X-Original-Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.128.172 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) 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: , Before commit 7b5436635800 the pci_host_bridge was created before the root bus. As that commit has added a needless dependency on the bus for pci_alloc_host_bridge() the creation order has been changed for no good reason. Revert the order of creation as we are going to depend on the pci_host_bridge structure to retrieve the domain number of the root bus. Signed-off-by: Liviu Dudau Tested-by: Tanmay Inamdar Acked-by: Grant Likely --- drivers/pci/probe.c | 36 ++++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c index 6e34498..fd11c12 100644 --- a/drivers/pci/probe.c +++ b/drivers/pci/probe.c @@ -505,7 +505,7 @@ static void pci_release_host_bridge_dev(struct device *dev) kfree(bridge); } -static struct pci_host_bridge *pci_alloc_host_bridge(struct pci_bus *b) +static struct pci_host_bridge *pci_alloc_host_bridge(void) { struct pci_host_bridge *bridge; @@ -514,7 +514,6 @@ static struct pci_host_bridge *pci_alloc_host_bridge(struct pci_bus *b) return NULL; INIT_LIST_HEAD(&bridge->windows); - bridge->bus = b; return bridge; } @@ -1727,9 +1726,19 @@ struct pci_bus *pci_create_root_bus(struct device *parent, int bus, char bus_addr[64]; char *fmt; + bridge = pci_alloc_host_bridge(); + if (!bridge) + return NULL; + + bridge->dev.parent = parent; + bridge->dev.release = pci_release_host_bridge_dev; + error = pcibios_root_bridge_prepare(bridge); + if (error) + goto err_out; + b = pci_alloc_bus(); if (!b) - return NULL; + goto err_out; b->sysdata = sysdata; b->ops = ops; @@ -1738,26 +1747,15 @@ struct pci_bus *pci_create_root_bus(struct device *parent, int bus, if (b2) { /* If we already got to this bus through a different bridge, ignore it */ dev_dbg(&b2->dev, "bus already known\n"); - goto err_out; + goto err_bus_out; } - bridge = pci_alloc_host_bridge(b); - if (!bridge) - goto err_out; - - bridge->dev.parent = parent; - bridge->dev.release = pci_release_host_bridge_dev; + bridge->bus = b; dev_set_name(&bridge->dev, "pci%04x:%02x", pci_domain_nr(b), bus); - error = pcibios_root_bridge_prepare(bridge); - if (error) { - kfree(bridge); - goto err_out; - } - error = device_register(&bridge->dev); if (error) { put_device(&bridge->dev); - goto err_out; + goto err_bus_out; } b->bridge = get_device(&bridge->dev); device_enable_async_suspend(b->bridge); @@ -1814,8 +1812,10 @@ struct pci_bus *pci_create_root_bus(struct device *parent, int bus, class_dev_reg_err: put_device(&bridge->dev); device_unregister(&bridge->dev); -err_out: +err_bus_out: kfree(b); +err_out: + kfree(bridge); return NULL; }