From patchwork Wed Aug 21 23:39:22 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bjorn Helgaas X-Patchwork-Id: 2847955 X-Patchwork-Delegate: bhelgaas@google.com Return-Path: X-Original-To: patchwork-linux-pci@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 0A5F89F271 for ; Wed, 21 Aug 2013 23:39:28 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 008F0205C8 for ; Wed, 21 Aug 2013 23:39:27 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id EA2D4205C3 for ; Wed, 21 Aug 2013 23:39:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752589Ab3HUXjZ (ORCPT ); Wed, 21 Aug 2013 19:39:25 -0400 Received: from mail-oa0-f51.google.com ([209.85.219.51]:57095 "EHLO mail-oa0-f51.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752369Ab3HUXjY (ORCPT ); Wed, 21 Aug 2013 19:39:24 -0400 Received: by mail-oa0-f51.google.com with SMTP id h1so2143925oag.24 for ; Wed, 21 Aug 2013 16:39:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=subject:to:from:cc:date:message-id:in-reply-to:references :user-agent:mime-version:content-type:content-transfer-encoding; bh=z8dkXcfK7Qg9qlJL7k/N2dHPjVngaSzIYERRJf5pVAw=; b=IyEXN7ORmt5TEV7S+w5ldXPFuLp5mHfGB/FAudqi/m8+DomjsjN+1uHDK2YBdQANkO I8uzz92WEkBjGShYMqbfJiu1IzcvYvfKqYfo9VPTbpUhbN+v5+91oIh38gzwE2b9qSUH vitz0RqM99RjWBRb8kmL8T1061Q7RAEK23Fl2h6lopFv6aNQ0usC3N5epm33z/d06Z63 rhDOAXYqzn0oBL2iv1ocSJzkSeFO2wHWJmuqo5Fw+8aB5OblD7xGml6nJzHG7ZArC2C3 Q9+qzXii0REDfT1CAdCp+V/j27+jeCUlyNRUG+yi+QdrlzRAtESTOs1AywTU3jkpWWqY LcHg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-gm-message-state:subject:to:from:cc:date:message-id:in-reply-to :references:user-agent:mime-version:content-type :content-transfer-encoding; bh=z8dkXcfK7Qg9qlJL7k/N2dHPjVngaSzIYERRJf5pVAw=; b=fN4QX4ntMb3rEUOIhcQJDYztDWIfF+1YftCm7YyhmptQsw0WLy1CkCDPpTYhI3QyJN Wd7liF0OKSCRFxAdNAMHzlHJFsaqpOK0LM0OjU/7Deda3mrN40RJz8YjruMh9N56AJMB DdY017pQ9qESZcCKn1HkXGmVVtc0LDUFbxWv2usOeplRyg5GHxATiW9/r+Ci6mTxVIfv hpqMZazOAhUomUadZQRtOiwZHY+CzpL9QrFpIxhPm5UdMdv6qrTBLATOGASiK0lvEudi br8DxFqG2C0xMz6rjv/a7NGNYRU3o3Wu7Nv4gfFpiGOzzmvlwXnUMt2qwFDQfBVKi2TA HfXQ== X-Gm-Message-State: ALoCoQmjbHT25udB+Lk8P+yIbGXAzyw5mpVaXaAZaz3a+yCHC3gsQ8IDchF7J5ivsDh9Dvd6yshjUneIsnUAm/jKjy/A5ft8PSnwBvcSp382JIVK978JW6lVBtIJpxYhEiJfyHhb7CLcExT/SIlW5o9IVG+WxJeDKJcOlFxj6Dh4HXXvN9hZKvQm10w+oZ9s2io6ceXVsNvb6fVQR0pAWaR4mMg4l3O5GA== X-Received: by 10.182.131.196 with SMTP id oo4mr10975415obb.50.1377128364341; Wed, 21 Aug 2013 16:39:24 -0700 (PDT) Received: from localhost ([172.29.122.86]) by mx.google.com with ESMTPSA id r3sm1342274oep.2.1969.12.31.16.00.00 (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Wed, 21 Aug 2013 16:39:23 -0700 (PDT) Subject: [PATCH v7 2/5] PCI: Simplify pcie_bus_configure_settings() interface To: Yijing Wang From: Bjorn Helgaas Cc: linux-pci@vger.kernel.org, Jon Mason , jiang.liu@huawei.com, Hanjun Guo Date: Wed, 21 Aug 2013 17:39:22 -0600 Message-ID: <20130821233922.2300.55535.stgit@bhelgaas-glaptop> In-Reply-To: <20130821233722.2300.81773.stgit@bhelgaas-glaptop> References: <20130821233722.2300.81773.stgit@bhelgaas-glaptop> User-Agent: StGit/0.16 MIME-Version: 1.0 Sender: linux-pci-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org X-Spam-Status: No, score=-9.6 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Based on a patch by Jon Mason (see URL below). All users of pcie_bus_configure_settings() pass arguments of the form "bus, bus->self->pcie_mpss". The "mpss" argument is redundant since we can easily look it up internally. In addition, all callers check "bus->self" for NULL, which we can also do internally. This patch simplifies the interface and the callers. No functional change. Reference: http://lkml.kernel.org/r/1317048850-30728-2-git-send-email-mason@myri.com Signed-off-by: Bjorn Helgaas --- arch/powerpc/kernel/pci-common.c | 8 ++------ arch/tile/kernel/pci_gx.c | 9 ++------- arch/x86/pci/acpi.c | 9 ++------- drivers/pci/hotplug/pcihp_slot.c | 5 ++--- drivers/pci/probe.c | 7 +++++-- include/linux/pci.h | 2 +- 6 files changed, 14 insertions(+), 26 deletions(-) -- To unsubscribe from this list: send the line "unsubscribe linux-pci" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/arch/powerpc/kernel/pci-common.c b/arch/powerpc/kernel/pci-common.c index f46914a..d35ec34 100644 --- a/arch/powerpc/kernel/pci-common.c +++ b/arch/powerpc/kernel/pci-common.c @@ -1672,12 +1672,8 @@ void pcibios_scan_phb(struct pci_controller *hose) /* Configure PCI Express settings */ if (bus && !pci_has_flag(PCI_PROBE_ONLY)) { struct pci_bus *child; - list_for_each_entry(child, &bus->children, node) { - struct pci_dev *self = child->self; - if (!self) - continue; - pcie_bus_configure_settings(child, self->pcie_mpss); - } + list_for_each_entry(child, &bus->children, node) + pcie_bus_configure_settings(child); } } diff --git a/arch/tile/kernel/pci_gx.c b/arch/tile/kernel/pci_gx.c index 1142563..6640e7b 100644 --- a/arch/tile/kernel/pci_gx.c +++ b/arch/tile/kernel/pci_gx.c @@ -508,13 +508,8 @@ static void fixup_read_and_payload_sizes(struct pci_controller *controller) rc_dev_cap.word); /* Configure PCI Express MPS setting. */ - list_for_each_entry(child, &root_bus->children, node) { - struct pci_dev *self = child->self; - if (!self) - continue; - - pcie_bus_configure_settings(child, self->pcie_mpss); - } + list_for_each_entry(child, &root_bus->children, node) + pcie_bus_configure_settings(child); /* * Set the mac_config register in trio based on the MPS/MRS of the link. diff --git a/arch/x86/pci/acpi.c b/arch/x86/pci/acpi.c index d641897..b30e937 100644 --- a/arch/x86/pci/acpi.c +++ b/arch/x86/pci/acpi.c @@ -568,13 +568,8 @@ struct pci_bus *pci_acpi_scan_root(struct acpi_pci_root *root) */ if (bus) { struct pci_bus *child; - list_for_each_entry(child, &bus->children, node) { - struct pci_dev *self = child->self; - if (!self) - continue; - - pcie_bus_configure_settings(child, self->pcie_mpss); - } + list_for_each_entry(child, &bus->children, node) + pcie_bus_configure_settings(child); } if (bus && node != -1) { diff --git a/drivers/pci/hotplug/pcihp_slot.c b/drivers/pci/hotplug/pcihp_slot.c index fec2d5b..16f9203 100644 --- a/drivers/pci/hotplug/pcihp_slot.c +++ b/drivers/pci/hotplug/pcihp_slot.c @@ -160,9 +160,8 @@ void pci_configure_slot(struct pci_dev *dev) (dev->class >> 8) == PCI_CLASS_BRIDGE_PCI))) return; - if (dev->bus && dev->bus->self) - pcie_bus_configure_settings(dev->bus, - dev->bus->self->pcie_mpss); + if (dev->bus) + pcie_bus_configure_settings(dev->bus); memset(&hpp, 0, sizeof(hpp)); ret = pci_get_hp_params(dev, &hpp); diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c index 9a33430..ecae7f2 100644 --- a/drivers/pci/probe.c +++ b/drivers/pci/probe.c @@ -1607,10 +1607,13 @@ static int pcie_bus_configure_set(struct pci_dev *dev, void *data) * parents then children fashion. If this changes, then this code will not * work as designed. */ -void pcie_bus_configure_settings(struct pci_bus *bus, u8 mpss) +void pcie_bus_configure_settings(struct pci_bus *bus) { u8 smpss; + if (!bus->self) + return; + if (!pci_is_pcie(bus->self)) return; @@ -1625,7 +1628,7 @@ void pcie_bus_configure_settings(struct pci_bus *bus, u8 mpss) smpss = 0; if (pcie_bus_config == PCIE_BUS_SAFE) { - smpss = mpss; + smpss = bus->self->pcie_mpss; pcie_find_smpss(bus->self, &smpss); pci_walk_bus(bus, pcie_find_smpss, &smpss); diff --git a/include/linux/pci.h b/include/linux/pci.h index 0fd1f15..57062b7 100644 --- a/include/linux/pci.h +++ b/include/linux/pci.h @@ -675,7 +675,7 @@ struct pci_driver { /* these external functions are only available when PCI support is enabled */ #ifdef CONFIG_PCI -void pcie_bus_configure_settings(struct pci_bus *bus, u8 smpss); +void pcie_bus_configure_settings(struct pci_bus *bus); enum pcie_bus_config_types { PCIE_BUS_TUNE_OFF,