From patchwork Tue Feb 9 14:30:47 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thierry Reding X-Patchwork-Id: 8262291 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.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id C6BF39F1C1 for ; Tue, 9 Feb 2016 14:30:55 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id D7ADF20272 for ; Tue, 9 Feb 2016 14:30:54 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id E46652026C for ; Tue, 9 Feb 2016 14:30:53 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932333AbcBIOaw (ORCPT ); Tue, 9 Feb 2016 09:30:52 -0500 Received: from mail-wm0-f47.google.com ([74.125.82.47]:37946 "EHLO mail-wm0-f47.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932162AbcBIOav (ORCPT ); Tue, 9 Feb 2016 09:30:51 -0500 Received: by mail-wm0-f47.google.com with SMTP id p63so25580769wmp.1; Tue, 09 Feb 2016 06:30:50 -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=g6T/YYF3yKVdsfYj3iXQHUB6Pt6ba8y/gzm+B7ag5Jo=; b=CXYjpz/7uk91GFLNulZfWbDzLrJBlKCafpZtGQez3Y1OA2mm3Jf7biOTIkIcxGoLCS /rHk3Uy7+TKr1sdWBeWFc1LtgxTjDlcnuE129mnOBzwfM74N4IlUwScisFprEKB8AuV+ hC/AYGpTPuXIn9+a47Bba+YNWJ95Anb1eL/2lXOaSf1zIYYB8RjxzO97wFuQWEb13ysg pvLlYGPBkqT78jFSIO1uNNtlkdrJi/P7yJd0DctBSDsK1hPolF/KwWWvyteHXZqK8XYk KjkMJqOg2j/pb13+vPosUc5UYRAnNJOkjG5Bn03fSqeTWvEJHNUagOl8F5N+/9oU16HU bEmw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=g6T/YYF3yKVdsfYj3iXQHUB6Pt6ba8y/gzm+B7ag5Jo=; b=ADoGh5qVygaJeiUjTi6wO7hc+eRZxpdDF7tMyd8rQy9fOyIV0gbc1b12L/2mUy4Frr pQEDmXKl88BlEEunBCTMvrk/Q5CbYEY3ItVXLDu6TNV0en6lb7MwD7uN0GBCCwT6NGvq oouIYABRSbAgSch8aZ6hcLL6tujk5SMOMrHN5xOaK3D0VesThBIK4t6ALy+2bFg9PO5x GSyBW4rOcUIFb56izTVywSIDZ7pB3pwBi5DWljjSms2Ic71tSybUBS8QKcC8zMVm/Du6 ThlQvkIP2pUR7cSuR4G7fnK01Hc+KqvLbeoKcrPgUXlxDYtNFSdRtrI97CqIi8tyk2g2 D5jQ== X-Gm-Message-State: AG10YOQZgTlepDErIqhc428Um2WlNCpXRXNxFcs4oIsYubEXxC8oZZSChqXohDmJ+xGi1g== X-Received: by 10.28.109.150 with SMTP id b22mr5634460wmi.27.1455028250340; Tue, 09 Feb 2016 06:30:50 -0800 (PST) Received: from localhost (port-17172.pppoe.wtnet.de. [46.59.128.173]) by smtp.gmail.com with ESMTPSA id t195sm17980532wme.13.2016.02.09.06.30.49 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 09 Feb 2016 06:30:49 -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 v2 1/2] PCI: Add pci_ops.{add,remove}_bus() callbacks Date: Tue, 9 Feb 2016 15:30:47 +0100 Message-Id: <1455028248-1950-1-git-send-email-thierry.reding@gmail.com> X-Mailer: git-send-email 2.7.1 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.1 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=unavailable 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 These callbacks will be called on every newly created bus and when a bus is being removed, respectively. This can be used by drivers to implement driver-specific initialization and teardown of the bus, in addition to the architecture-specifics implemented by the pcibios_add_bus() and the pcibios_remove_bus() functions. Signed-off-by: Thierry Reding --- Changes in v2: - add pci_ops.remove_bus() callback - always call pcibios_add_bus() drivers/pci/probe.c | 6 ++++++ drivers/pci/remove.c | 4 ++++ include/linux/pci.h | 2 ++ 3 files changed, 12 insertions(+) diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c index 6d7ab9bb0d5a..3ea4de1c6926 100644 --- a/drivers/pci/probe.c +++ b/drivers/pci/probe.c @@ -758,6 +758,12 @@ add_dev: pcibios_add_bus(child); + if (child->ops->add_bus) { + ret = child->ops->add_bus(child); + if (WARN_ON(ret < 0)) + dev_err(&child->dev, "failed to add bus: %d\n", ret); + } + /* Create legacy_io and legacy_mem files for this bus */ pci_create_legacy_files(child); diff --git a/drivers/pci/remove.c b/drivers/pci/remove.c index 8a280e9c2ad1..d35c7fcde3af 100644 --- a/drivers/pci/remove.c +++ b/drivers/pci/remove.c @@ -54,6 +54,10 @@ void pci_remove_bus(struct pci_bus *bus) pci_bus_release_busn_res(bus); up_write(&pci_bus_sem); pci_remove_legacy_files(bus); + + if (bus->ops->remove_bus) + bus->ops->remove_bus(bus); + pcibios_remove_bus(bus); device_unregister(&bus->dev); } diff --git a/include/linux/pci.h b/include/linux/pci.h index 27df4a6585da..0f7ef14c4d10 100644 --- a/include/linux/pci.h +++ b/include/linux/pci.h @@ -578,6 +578,8 @@ 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 (*remove_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);