From patchwork Fri Mar 14 15:34:29 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Liviu Dudau X-Patchwork-Id: 26265 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-qa0-f72.google.com (mail-qa0-f72.google.com [209.85.216.72]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id EF88C202DD for ; Fri, 14 Mar 2014 15:37:59 +0000 (UTC) Received: by mail-qa0-f72.google.com with SMTP id f11sf5296161qae.7 for ; Fri, 14 Mar 2014 08:37:59 -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=tAxq9SP7NmmjEiUmi8xEPjiD2ccVnTfkSrFAO4ndBXM=; b=IySHybnG55ERy3Dj29+gB4TWRHPIUwJfGD1nr8dpIY6Rz29umBUP7QimHnUkKsRa1p ibyQQhAmnNvtfw6MBvFDe0qiOYmIBaEL79yy5Nap3ThpyHwfHztp+jzefimFanTkHcXe pqfqyNYFxPIvBNjvBm/cvMK5kNP3iTIsR4/R35EQW8hc4eddR5culZImrcUQ7YeBMpMO iV7GZqLxrHInpF+yKTLLD8wdTBJLiTK8Djw1V8UWnXWaSOKYH8HIHkmTaBpoY0TkW7d5 lspCrY5s7gMIMmmyhvQRQPAPbUPaldvGyoW2RgAInnXF9cPShsMKNx6E7Bbdur4n/96v aKwA== X-Gm-Message-State: ALoCoQlziGICKkE0j8Q5UjAIUB+EjDxc7aHuzEyQbHPxr30CnpDczYa+S1BkcHhmW36JSyLzMktA X-Received: by 10.236.144.102 with SMTP id m66mr3212032yhj.50.1394811479685; Fri, 14 Mar 2014 08:37:59 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.27.117 with SMTP id 108ls811762qgw.77.gmail; Fri, 14 Mar 2014 08:37:59 -0700 (PDT) X-Received: by 10.220.81.194 with SMTP id y2mr995728vck.29.1394811479559; Fri, 14 Mar 2014 08:37:59 -0700 (PDT) Received: from mail-vc0-f173.google.com (mail-vc0-f173.google.com [209.85.220.173]) by mx.google.com with ESMTPS id k2si2218142vcj.30.2014.03.14.08.37.59 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 14 Mar 2014 08:37:59 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.220.173 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) client-ip=209.85.220.173; Received: by mail-vc0-f173.google.com with SMTP id il7so2954421vcb.32 for ; Fri, 14 Mar 2014 08:37:59 -0700 (PDT) X-Received: by 10.52.15.132 with SMTP id x4mr1292842vdc.31.1394811479448; Fri, 14 Mar 2014 08:37:59 -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.220.78.9 with SMTP id i9csp27992vck; Fri, 14 Mar 2014 08:37:58 -0700 (PDT) X-Received: by 10.66.252.135 with SMTP id zs7mr9944605pac.13.1394811478463; Fri, 14 Mar 2014 08:37:58 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id yp10si4075602pab.339.2014.03.14.08.37.28; Fri, 14 Mar 2014 08:37:28 -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; Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755869AbaCNPg7 (ORCPT + 26 others); Fri, 14 Mar 2014 11:36:59 -0400 Received: from fw-tnat.cambridge.arm.com ([217.140.96.21]:50990 "EHLO cam-smtp0.cambridge.arm.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1755492AbaCNPfO (ORCPT ); Fri, 14 Mar 2014 11:35:14 -0400 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 s2EFYWIB004053; Fri, 14 Mar 2014 15:34:32 GMT From: Liviu Dudau To: linux-pci , Bjorn Helgaas , Catalin Marinas , Will Deacon , Benjamin Herrenschmidt , linaro-kernel , Arnd Bergmann Cc: LKML , "devicetree@vger.kernel.org" , LAKML , Tanmay Inamdar , Grant Likely Subject: [PATCH v7 3/6] pci: Create pci_host_bridge before its associated bus in pci_create_root_bus. Date: Fri, 14 Mar 2014 15:34:29 +0000 Message-Id: <1394811272-1547-4-git-send-email-Liviu.Dudau@arm.com> X-Mailer: git-send-email 1.9.0 In-Reply-To: <1394811272-1547-1-git-send-email-Liviu.Dudau@arm.com> References: <1394811272-1547-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.220.173 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 Acked-by: Grant Likely Tested-by: Tanmay Inamdar --- 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; }