From patchwork Mon Nov 23 12:40:25 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thierry Reding X-Patchwork-Id: 7680861 X-Patchwork-Delegate: bhelgaas@google.com Return-Path: X-Original-To: patchwork-linux-pci@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 040C6BF90C for ; Mon, 23 Nov 2015 12:40:35 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 1BB8520710 for ; Mon, 23 Nov 2015 12:40:34 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 421CD206FA for ; Mon, 23 Nov 2015 12:40:33 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751845AbbKWMkc (ORCPT ); Mon, 23 Nov 2015 07:40:32 -0500 Received: from mail-pa0-f44.google.com ([209.85.220.44]:36213 "EHLO mail-pa0-f44.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751144AbbKWMkb (ORCPT ); Mon, 23 Nov 2015 07:40:31 -0500 Received: by pacdm15 with SMTP id dm15so190298244pac.3; Mon, 23 Nov 2015 04:40:30 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id; bh=mtYQq6hqwYXwDxGYZfCvks1Ml7+G/RrBr22MRXor4n4=; b=bkgDWc4jpJ/1iNr062S7aVJusOIAMvQL6XqYtFLnGGK0m964RxxZJRzAhpCzZqKYLN uiFNk9psEj8TIZ1t9M0vlNF4njapMpT44NlNteGY5h/hbGmBwmkMoTDQT+My/JxGZ6Kp XBS9TvX++Fwd/xhMKR70FKrzh/FEK7ks7kCbnA/Xix6QxG6SP88SmosWaI8yVN4XwE3D HJoJ8n5vTIZkj6oeKNXkHTQ8deW0Z+zVZNLII2fkQ8EubyIP7Y9PfO4mRw589YQ2QVDq 070enyyW2p99ZNDZvPyUqkn6mXFH0+XNzQAVPAuJT82CXTwE+LAFQe4mgsfYGnHBORSV 4QCg== X-Received: by 10.98.1.213 with SMTP id 204mr15744465pfb.128.1448282430788; Mon, 23 Nov 2015 04:40:30 -0800 (PST) Received: from localhost (port-18668.pppoe.wtnet.de. [46.59.134.139]) by smtp.gmail.com with ESMTPSA id tm4sm8713161pab.3.2015.11.23.04.40.28 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 23 Nov 2015 04:40:29 -0800 (PST) From: Thierry Reding To: Bjorn Helgaas Cc: Stephen Warren , Alexandre Courbot , linux-pci@vger.kernel.org, linux-tegra@vger.kernel.org Subject: [PATCH 1/2] PCI: Add pci_ops.add_bus() callback Date: Mon, 23 Nov 2015 13:40:25 +0100 Message-Id: <1448282426-2642-1-git-send-email-thierry.reding@gmail.com> X-Mailer: git-send-email 2.5.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=-7.4 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, 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 From: Thierry Reding This callback will be called on every newly created bus. Drivers can implement it to perform driver-specific initialization of the bus. Signed-off-by: Thierry Reding --- drivers/pci/probe.c | 8 +++++++- include/linux/pci.h | 1 + 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c index e735c728e3b3..fbed432f8915 100644 --- a/drivers/pci/probe.c +++ b/drivers/pci/probe.c @@ -754,7 +754,13 @@ add_dev: ret = device_register(&child->dev); WARN_ON(ret < 0); - pcibios_add_bus(child); + if (child->ops->add_bus) { + ret = child->ops->add_bus(child); + if (ret < 0) + dev_err(&child->dev, "failed to add bus: %d\n", ret); + } else { + pcibios_add_bus(child); + } /* Create legacy_io and legacy_mem files for this bus */ pci_create_legacy_files(child); diff --git a/include/linux/pci.h b/include/linux/pci.h index e828e7b4afec..70c1228d585f 100644 --- a/include/linux/pci.h +++ b/include/linux/pci.h @@ -569,6 +569,7 @@ static inline int pcibios_err_to_errno(int err) /* Low-level architecture-dependent routines */ struct pci_ops { + int (*add_bus)(struct pci_bus *bus); void __iomem *(*map_bus)(struct pci_bus *bus, unsigned int devfn, int where); int (*read)(struct pci_bus *bus, unsigned int devfn, int where, int size, u32 *val); int (*write)(struct pci_bus *bus, unsigned int devfn, int where, int size, u32 val);