From patchwork Mon Nov 17 10:21:35 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: wangyijing X-Patchwork-Id: 40891 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-wi0-f200.google.com (mail-wi0-f200.google.com [209.85.212.200]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 89EE024035 for ; Mon, 17 Nov 2014 09:43:51 +0000 (UTC) Received: by mail-wi0-f200.google.com with SMTP id ex7sf3007050wid.11 for ; Mon, 17 Nov 2014 01:43:50 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:delivered-to:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:sender:precedence:list-id :x-original-sender:x-original-authentication-results:mailing-list :list-post:list-help:list-archive:list-unsubscribe:content-type; bh=sLD+2G397P1vr0xZ2IAoVeFi40Zq331gEliH8h86ATU=; b=heqkK+76r0m1lkbwq9u0u2N/52caBsfMXFzNVAhGpCJkyBMvb6Ptt0+yqaSicotNfV 7enJiz2KQ3Di/iOREyWk8G7pd3sBI2xun4MR8NKLi4UMtOaFRBLRCsbLX1kXs4fXJp4Q LxXecn9ErIyVtUsZrjguf8FNEUvR3+wEgAA3f65uiCHkgNainBcjQ+KORiToyGyWWrBy 737KGOrt8YmK5Cjj4TPCht9vtV7zgvRoKMnwOHmVINXMGTUHCxFGy/Z6DPcTl3hAXm84 4JQtfQ0kpjkMrCNA5ff9aF9/vZ8X0nUas68HWpRAiGbr/b7bGt9u6mwHg1IeZjaX50jN stpQ== X-Gm-Message-State: ALoCoQkgjfzN7JwRpxtX693l57hOJtUUU/P6ujXXUZabx6tyWH+wB8VuiEoN5moOxo7RUp1YDyuP X-Received: by 10.112.147.131 with SMTP id tk3mr7445826lbb.2.1416217430815; Mon, 17 Nov 2014 01:43:50 -0800 (PST) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.7.232 with SMTP id m8ls433211laa.45.gmail; Mon, 17 Nov 2014 01:43:50 -0800 (PST) X-Received: by 10.152.116.80 with SMTP id ju16mr25976554lab.13.1416217430608; Mon, 17 Nov 2014 01:43:50 -0800 (PST) Received: from mail-la0-f54.google.com (mail-la0-f54.google.com. [209.85.215.54]) by mx.google.com with ESMTPS id j1si47553059lam.100.2014.11.17.01.43.50 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 17 Nov 2014 01:43:50 -0800 (PST) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.54 as permitted sender) client-ip=209.85.215.54; Received: by mail-la0-f54.google.com with SMTP id gf13so5934508lab.41 for ; Mon, 17 Nov 2014 01:43:50 -0800 (PST) X-Received: by 10.112.14.69 with SMTP id n5mr26066494lbc.34.1416217430527; Mon, 17 Nov 2014 01:43:50 -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.112.184.201 with SMTP id ew9csp1127394lbc; Mon, 17 Nov 2014 01:43:49 -0800 (PST) X-Received: by 10.70.33.195 with SMTP id t3mr2602768pdi.135.1416217428909; Mon, 17 Nov 2014 01:43:48 -0800 (PST) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id ro9si34800041pab.72.2014.11.17.01.43.48 for ; Mon, 17 Nov 2014 01:43:48 -0800 (PST) Received-SPF: none (google.com: linux-kernel-owner@vger.kernel.org does not designate permitted sender hosts) client-ip=209.132.180.67; Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752550AbaKQJnq (ORCPT + 26 others); Mon, 17 Nov 2014 04:43:46 -0500 Received: from szxga01-in.huawei.com ([119.145.14.64]:43137 "EHLO szxga01-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751679AbaKQJkw (ORCPT ); Mon, 17 Nov 2014 04:40:52 -0500 Received: from 172.24.2.119 (EHLO szxeml462-hub.china.huawei.com) ([172.24.2.119]) by szxrg01-dlp.huawei.com (MOS 4.3.7-GA FastPath queued) with ESMTP id CEO10123; Mon, 17 Nov 2014 17:40:42 +0800 (CST) Received: from localhost.localdomain (10.175.100.166) by szxeml462-hub.china.huawei.com (10.82.67.205) with Microsoft SMTP Server id 14.3.158.1; Mon, 17 Nov 2014 17:40:28 +0800 From: Yijing Wang To: Bjorn Helgaas CC: , , Xinwei Hu , Wuyun , , Russell King , , Thomas Gleixner , Benjamin Herrenschmidt , , Tony Luck , , Thierry Reding , Liviu Dudau , , Yijing Wang , Yijing Wang Subject: [RFC PATCH 01/16] PCI: Enhance pci_scan_root_bus() to support default IO/MEM resources Date: Mon, 17 Nov 2014 18:21:35 +0800 Message-ID: <1416219710-26088-2-git-send-email-wangyijing@huawei.com> X-Mailer: git-send-email 1.7.1 In-Reply-To: <1416219710-26088-1-git-send-email-wangyijing@huawei.com> References: <1416219710-26088-1-git-send-email-wangyijing@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.175.100.166] X-CFilter-Loop: Reflected 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: wangyijing@huawei.com X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.54 as permitted sender) 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: , From: Yijing Wang Pci_scan_root_bus(), pci_scan_bus() and pci_scan_bus_parented() are very similar. But the latter two use the default io/mem resources. Enhance pci_scan_root_bus() to support default io/mem resources, then we could use pci_scan_root_bus() instead of them, and clean them up. Signed-off-by: Yijing Wang --- drivers/pci/probe.c | 20 ++++++++++++++------ 1 files changed, 14 insertions(+), 6 deletions(-) diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c index 5ed9930..fc99e88 100644 --- a/drivers/pci/probe.c +++ b/drivers/pci/probe.c @@ -2069,15 +2069,23 @@ struct pci_bus *pci_scan_root_bus(struct device *parent, int bus, struct pci_host_bridge_window *window; bool found = false; struct pci_bus *b; + LIST_HEAD(default_res); int max; - list_for_each_entry(window, resources, list) - if (window->res->flags & IORESOURCE_BUS) { - found = true; - break; - } + if (!resources) { + pci_add_resource(&default_res, &ioport_resource); + pci_add_resource(&default_res, &iomem_resource); + pci_add_resource(&default_res, &busn_resource); + } else { + list_for_each_entry(window, resources, list) + if (window->res->flags & IORESOURCE_BUS) { + found = true; + break; + } + } - b = pci_create_root_bus(parent, bus, ops, sysdata, resources); + b = pci_create_root_bus(parent, bus, ops, sysdata, + resources ? resources : &default_res); if (!b) return NULL;