From patchwork Tue Feb 26 15:25:41 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiang Liu X-Patchwork-Id: 2186091 Return-Path: X-Original-To: patchwork-linux-acpi@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork2.kernel.org (Postfix) with ESMTP id 2BADCDF215 for ; Tue, 26 Feb 2013 15:34:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1759681Ab3BZPak (ORCPT ); Tue, 26 Feb 2013 10:30:40 -0500 Received: from mail-pb0-f48.google.com ([209.85.160.48]:52247 "EHLO mail-pb0-f48.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1759664Ab3BZPah (ORCPT ); Tue, 26 Feb 2013 10:30:37 -0500 Received: by mail-pb0-f48.google.com with SMTP id wy12so2410084pbc.7 for ; Tue, 26 Feb 2013 07:30:37 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=x-received:from:to:cc:subject:date:message-id:x-mailer:in-reply-to :references; bh=+sh1v9JBQcwp8C+8JhotngpS4J4GJZTTImei+WUKTY4=; b=d/L/KyrmMckRTvoATHwFw4OsgJg+4rtizgDhL8wPYLU18K8ga7JON4eHbnGkadUJml PqErZhF9mzdoaPZvWJeGCCKvbsAuobzUS5sGgO9DB49bRMe6LzQFf5hugQLKgW9I6gEd Knwl/zporDb9M2eNRYafB0oT8gDnvsBGt5NrRLzojlr/quUXu2hcZkXCpP+sUPBhtcBM 1uWWbEmH/qCq2uzkospvy874eUE5yu45ObGvt7XviYMKosL4t7w8YiAYR8+qhngEQlW9 PZTPvq4RJP67HzG8bVxz3s/ItwmdjfsXtd4j/woHv0oGIuZUZf46xlL1yRmApqaSA9Z6 O9Jw== X-Received: by 10.66.159.201 with SMTP id xe9mr2249517pab.110.1361892637123; Tue, 26 Feb 2013 07:30:37 -0800 (PST) Received: from localhost.localdomain ([114.250.77.63]) by mx.google.com with ESMTPS id gg7sm1229055pbc.45.2013.02.26.07.30.28 (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 26 Feb 2013 07:30:36 -0800 (PST) From: Jiang Liu To: Bjorn Helgaas , "Rafael J . Wysocki" Cc: Jiang Liu , Yinghai Lu , Yijing Wang , Jiang Liu , linux-kernel@vger.kernel.org, linux-pci@vger.kernel.org, Greg Kroah-Hartman , ACPI Devel Maling List , Toshi Kani , Myron Stowe , "Rafael J. Wysocki" Subject: [PATCH v8 01/13] PCI: do not check is_added flag in pci_remove_bus() Date: Tue, 26 Feb 2013 23:25:41 +0800 Message-Id: <1361892353-14786-2-git-send-email-jiang.liu@huawei.com> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1361892353-14786-1-git-send-email-jiang.liu@huawei.com> References: <1361892353-14786-1-git-send-email-jiang.liu@huawei.com> Sender: linux-acpi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org The is_added flag in struct pci_bus is always set after invoking device_register() and pci_create_legacy_files(). The related code paths are: 1) pci_create_root_bus() and pci_add_new_bus() bus = pci_alloc_bus() device_register(&bus->dev) pci_create_legacy_file(bus) 2.a) pci_scan_child_bus(bus) set is_added flag for PCI root buses 2.b) pci_bus_add_devices(bus) set is_added flag for normal PCI buses So pci_remove_bus() shouldn't use is_added flag to guard invoking of pci_remove_lagecy_files() and device_unregister(). One more step further, now bus->is_added is only used to guard invoking of pcibios_fixup_bus(), so cleaup the code. Signed-off-by: Jiang Liu Signed-off-by: Yijing Wang Cc: Yinghai Lu Cc: "Rafael J. Wysocki" Cc: Toshi Kani Cc: linux-pci@vger.kernel.org Cc: linux-kernel@vger.kernel.org --- drivers/pci/bus.c | 11 ++--------- drivers/pci/probe.c | 3 +-- drivers/pci/remove.c | 3 --- 3 files changed, 3 insertions(+), 14 deletions(-) diff --git a/drivers/pci/bus.c b/drivers/pci/bus.c index 8647dc6..bdc1e8b 100644 --- a/drivers/pci/bus.c +++ b/drivers/pci/bus.c @@ -206,16 +206,9 @@ void pci_bus_add_devices(const struct pci_bus *bus) list_for_each_entry(dev, &bus->devices, bus_list) { BUG_ON(!dev->is_added); - child = dev->subordinate; - - if (!child) - continue; - pci_bus_add_devices(child); - - if (child->is_added) - continue; - child->is_added = 1; + if (child) + pci_bus_add_devices(child); } } diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c index b494066..45c93b3 100644 --- a/drivers/pci/probe.c +++ b/drivers/pci/probe.c @@ -1627,8 +1627,7 @@ unsigned int pci_scan_child_bus(struct pci_bus *bus) if (!bus->is_added) { dev_dbg(&bus->dev, "fixups for bus\n"); pcibios_fixup_bus(bus); - if (pci_is_root_bus(bus)) - bus->is_added = 1; + bus->is_added = 1; } for (pass=0; pass < 2; pass++) diff --git a/drivers/pci/remove.c b/drivers/pci/remove.c index fc38c48..66967e5 100644 --- a/drivers/pci/remove.c +++ b/drivers/pci/remove.c @@ -48,9 +48,6 @@ void pci_remove_bus(struct pci_bus *bus) list_del(&bus->node); pci_bus_release_busn_res(bus); up_write(&pci_bus_sem); - if (!bus->is_added) - return; - pci_remove_legacy_files(bus); device_unregister(&bus->dev); }