From patchwork Sun Sep 2 21:52:17 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yinghai Lu X-Patchwork-Id: 1397411 Return-Path: X-Original-To: patchwork-linux-acpi@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork1.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork1.kernel.org (Postfix) with ESMTP id DB6BD4025E for ; Sun, 2 Sep 2012 21:54:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755396Ab2IBVxy (ORCPT ); Sun, 2 Sep 2012 17:53:54 -0400 Received: from rcsinet15.oracle.com ([148.87.113.117]:23552 "EHLO rcsinet15.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755882Ab2IBVwn (ORCPT ); Sun, 2 Sep 2012 17:52:43 -0400 Received: from ucsinet21.oracle.com (ucsinet21.oracle.com [156.151.31.93]) by rcsinet15.oracle.com (Sentrion-MTA-4.2.2/Sentrion-MTA-4.2.2) with ESMTP id q82LqXOV028802 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Sun, 2 Sep 2012 21:52:34 GMT Received: from acsmt356.oracle.com (acsmt356.oracle.com [141.146.40.156]) by ucsinet21.oracle.com (8.14.4+Sun/8.14.4) with ESMTP id q82LqWlK011066 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Sun, 2 Sep 2012 21:52:33 GMT Received: from abhmt105.oracle.com (abhmt105.oracle.com [141.146.116.57]) by acsmt356.oracle.com (8.12.11.20060308/8.12.11) with ESMTP id q82LqWAT000376; Sun, 2 Sep 2012 16:52:32 -0500 Received: from linux-siqj.site (/75.55.221.75) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Sun, 02 Sep 2012 14:52:32 -0700 From: Yinghai Lu To: Bjorn Helgaas , Taku Izumi , Jiang Liu , x86 Cc: Andrew Morton , Linus Torvalds , Greg Kroah-Hartman , linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org, linux-acpi@vger.kernel.org, Yinghai Lu Subject: [PATCH part3 07/11] PCI: Add pci_bus_add_single_device() Date: Sun, 2 Sep 2012 14:52:17 -0700 Message-Id: <1346622741-30799-8-git-send-email-yinghai@kernel.org> X-Mailer: git-send-email 1.7.7 In-Reply-To: <1346622741-30799-1-git-send-email-yinghai@kernel.org> References: <1346622741-30799-1-git-send-email-yinghai@kernel.org> X-Source-IP: ucsinet21.oracle.com [156.151.31.93] Sender: linux-acpi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org Will use it to pci_bus_bridge_scan_resize() to make bridge will have pci_bus directory created correctly. Signed-off-by: Yinghai Lu --- drivers/pci/bus.c | 39 +++++++++++++++++++++++++++++++++++++++ include/linux/pci.h | 1 + 2 files changed, 40 insertions(+), 0 deletions(-) diff --git a/drivers/pci/bus.c b/drivers/pci/bus.c index 2882d01..950b786 100644 --- a/drivers/pci/bus.c +++ b/drivers/pci/bus.c @@ -259,6 +259,45 @@ void pci_bus_add_devices(const struct pci_bus *bus) } } +void pci_bus_add_single_device(struct pci_dev *dev) +{ + struct pci_bus *child; + int retval; + + /* Skip already-added devices */ + if (!dev->is_added) { + retval = pci_bus_add_device(dev); + if (retval) + dev_err(&dev->dev, "Error adding device, continuing\n"); + } + + BUG_ON(!dev->is_added); + + child = dev->subordinate; + /* + * If there is an unattached subordinate bus, attach + * it and then scan for unattached PCI devices. + */ + if (child) { + if (list_empty(&child->node)) { + down_write(&pci_bus_sem); + list_add_tail(&child->node, &dev->bus->children); + up_write(&pci_bus_sem); + } + pci_bus_add_devices(child); + + /* + * register the bus with sysfs as the parent is now + * properly registered. + */ + if (!child->is_added) { + retval = pci_bus_add_child(child); + if (retval) + dev_err(&dev->dev, "Error adding bus, continuing\n"); + } + } +} + void pci_enable_bridges(struct pci_bus *bus) { struct pci_dev *dev; diff --git a/include/linux/pci.h b/include/linux/pci.h index f994e93..4446448 100644 --- a/include/linux/pci.h +++ b/include/linux/pci.h @@ -700,6 +700,7 @@ void pcibios_bus_to_resource(struct pci_dev *dev, struct resource *res, void pcibios_scan_specific_bus(int busn); extern struct pci_bus *pci_find_bus(int domain, int busnr); void pci_bus_add_devices(const struct pci_bus *bus); +void pci_bus_add_single_device(struct pci_dev *dev); struct pci_bus *pci_scan_bus_parented(struct device *parent, int bus, struct pci_ops *ops, void *sysdata); struct pci_bus *pci_scan_bus(int bus, struct pci_ops *ops, void *sysdata);