Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp1283872imm; Fri, 8 Jun 2018 13:15:43 -0700 (PDT) X-Google-Smtp-Source: ADUXVKKYSVDaz+1A3Fc4xep8bdfuegA9RFb5xkOyMGvJgS4PDAe46ePYQqaoCQnvHoJjCygxr9cu X-Received: by 2002:a63:6f42:: with SMTP id k63-v6mr6485586pgc.135.1528488943398; Fri, 08 Jun 2018 13:15:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528488943; cv=none; d=google.com; s=arc-20160816; b=DhfPSEm/nLLk87CBIqpfb3Xy/Qf17jxYJ6zPUCJpQwqzXwbtBy8kre3hlCjnfktn3F AKA7CuXZYHp/e6ro6DUlbB8qMdU80DhsVL/XlM1UZ63VPf4fsjCFdBGQ6eTImr4/RJP4 qUf3qSLWC6ecc+Cdv9f4wwVNLf1qjbPWp0fDXOlNYl/jvKTodDrNsdY8X+hafZqHm+o1 rKdkF2QeMJfYisd4oPgE35IJcb6VeMLH+DwQiNjf2OatqFxTHGMvgNZgN7nrUJCLivSo v9OREVFumlu59goKPa6fSC6J7c0N9wY/0VBKWWm907WddArQLRabRB+7pMr4N6MENnr2 59Qw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:cc:to:from :subject:dkim-signature:arc-authentication-results; bh=iazsL1RpohJha8rLhvfYAMBsJuoN63/M5YPM05Oy1Vw=; b=Ot81WQQv1S+Z/KDK4Zbi8k5/kOxaHSURBZGl749Tq6YJW+W2N4ARQXdyaHzS5ypbCy HUA0yWqmo+boPVYZ0KUHs5Ko7Gqtbz4VoyF5Q3WuWWkbFMoskrQcuorniGKgENZBsEA0 kaQTPTxnEuzdZyHZra7QLts+qrly+LKQozK/haonnnQtp+3b4Cs5Eygf79r9GnZt3qj+ +WWj4lJc6dx44dW776meF3qNI1hlOLNXTAPcjWiolKnKOzu7QL1N04xNuaOFQddC8b+I qaSLpaCY9jKO7pU83R/734oFNWDVtjXPLuSx+DT8f2ipq1Efmm8SuO9YWiiKBbx3K4ap kZPw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=vsBaa9ef; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 34-v6si55599316plc.346.2018.06.08.13.15.29; Fri, 08 Jun 2018 13:15:43 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=vsBaa9ef; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753201AbeFHUNe (ORCPT + 99 others); Fri, 8 Jun 2018 16:13:34 -0400 Received: from mail.kernel.org ([198.145.29.99]:51602 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753158AbeFHUMj (ORCPT ); Fri, 8 Jun 2018 16:12:39 -0400 Received: from localhost (unknown [150.199.191.185]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id C9E49206B7; Fri, 8 Jun 2018 20:12:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1528488759; bh=FU76aCB8NThfMkDgnH7FynfH5m2DHp4yzvI59Ets6zI=; h=Subject:From:To:Cc:Date:In-Reply-To:References:From; b=vsBaa9ef/gHoc2emZnL2ZemMaQOeOQtqAbzeSo+vW7E+owlQ7ScvTabp/XU01ZfOF gfCaKIsgjYaYd2ag+5z1vxxRHal4GOo0KL+VkZ1yYxk1ugMWHDSzf5LOva5E7WxRhR k97B1idr1jjAErgVlNCjgwrEwMGu/WBxI7JwH8f4= Subject: [PATCH v1 6/9] PCI/portdrv: Squash service driver registration into portdrv_pci.c From: Bjorn Helgaas To: linux-pci@vger.kernel.org Cc: Oza Pawandeep , linux-kernel@vger.kernel.org Date: Fri, 08 Jun 2018 15:12:38 -0500 Message-ID: <152848875803.14051.11862886995562549992.stgit@bhelgaas-glaptop.roam.corp.google.com> In-Reply-To: <152848853199.14051.12670957565366345798.stgit@bhelgaas-glaptop.roam.corp.google.com> References: <152848853199.14051.12670957565366345798.stgit@bhelgaas-glaptop.roam.corp.google.com> User-Agent: StGit/0.18 MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Bjorn Helgaas Squash service driver registration into portdrv_pci.c. No functional change intended. Signed-off-by: Bjorn Helgaas --- drivers/pci/pcie/Makefile | 2 - drivers/pci/pcie/portdrv_core.c | 116 --------------------------------------- drivers/pci/pcie/portdrv_pci.c | 96 ++++++++++++++++++++++++++++++++ 3 files changed, 97 insertions(+), 117 deletions(-) delete mode 100644 drivers/pci/pcie/portdrv_core.c diff --git a/drivers/pci/pcie/Makefile b/drivers/pci/pcie/Makefile index 03f4e0b3a140..aad431790b1d 100644 --- a/drivers/pci/pcie/Makefile +++ b/drivers/pci/pcie/Makefile @@ -2,7 +2,7 @@ # # Makefile for PCI Express features and port driver -pcieportdrv-y := portdrv_core.o portdrv_pci.o err.o +pcieportdrv-y := portdrv_pci.o err.o obj-$(CONFIG_PCIEPORTBUS) += pcieportdrv.o diff --git a/drivers/pci/pcie/portdrv_core.c b/drivers/pci/pcie/portdrv_core.c deleted file mode 100644 index 77b1c1ea8885..000000000000 --- a/drivers/pci/pcie/portdrv_core.c +++ /dev/null @@ -1,116 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0 -/* - * Purpose: PCI Express Port Bus Driver's Core Functions - * - * Copyright (C) 2004 Intel - * Copyright (C) Tom Long Nguyen (tom.l.nguyen@intel.com) - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "../pci.h" -#include "portdrv.h" - -/** - * pcie_port_probe_service - probe driver for given PCI Express port service - * @dev: PCI Express port service device to probe against - * - * If PCI Express port service driver is registered with - * pcie_port_service_register(), this function will be called by the driver core - * whenever match is found between the driver and a port service device. - */ -static int pcie_port_probe_service(struct device *dev) -{ - struct pcie_device *pciedev; - struct pcie_port_service_driver *driver; - int status; - - if (!dev || !dev->driver) - return -ENODEV; - - driver = to_service_driver(dev->driver); - if (!driver || !driver->probe) - return -ENODEV; - - pciedev = to_pcie_device(dev); - status = driver->probe(pciedev); - if (status) - return status; - - get_device(dev); - return 0; -} - -/** - * pcie_port_remove_service - detach driver from given PCI Express port service - * @dev: PCI Express port service device to handle - * - * If PCI Express port service driver is registered with - * pcie_port_service_register(), this function will be called by the driver core - * when device_unregister() is called for the port service device associated - * with the driver. - */ -static int pcie_port_remove_service(struct device *dev) -{ - struct pcie_device *pciedev; - struct pcie_port_service_driver *driver; - - if (!dev || !dev->driver) - return 0; - - pciedev = to_pcie_device(dev); - driver = to_service_driver(dev->driver); - if (driver && driver->remove) { - driver->remove(pciedev); - put_device(dev); - } - return 0; -} - -/** - * pcie_port_shutdown_service - shut down given PCI Express port service - * @dev: PCI Express port service device to handle - * - * If PCI Express port service driver is registered with - * pcie_port_service_register(), this function will be called by the driver core - * when device_shutdown() is called for the port service device associated - * with the driver. - */ -static void pcie_port_shutdown_service(struct device *dev) {} - -/** - * pcie_port_service_register - register PCI Express port service driver - * @new: PCI Express port service driver to register - */ -int pcie_port_service_register(struct pcie_port_service_driver *new) -{ - if (pcie_ports_disabled) - return -ENODEV; - - new->driver.name = new->name; - new->driver.bus = &pcie_port_bus_type; - new->driver.probe = pcie_port_probe_service; - new->driver.remove = pcie_port_remove_service; - new->driver.shutdown = pcie_port_shutdown_service; - - return driver_register(&new->driver); -} -EXPORT_SYMBOL(pcie_port_service_register); - -/** - * pcie_port_service_unregister - unregister PCI Express port service driver - * @drv: PCI Express port service driver to unregister - */ -void pcie_port_service_unregister(struct pcie_port_service_driver *drv) -{ - driver_unregister(&drv->driver); -} -EXPORT_SYMBOL(pcie_port_service_unregister); diff --git a/drivers/pci/pcie/portdrv_pci.c b/drivers/pci/pcie/portdrv_pci.c index b019af97f14e..1375e91c268f 100644 --- a/drivers/pci/pcie/portdrv_pci.c +++ b/drivers/pci/pcie/portdrv_pci.c @@ -110,6 +110,102 @@ struct device *pcie_port_find_device(struct pci_dev *dev, u32 service) return device; } +/** + * pcie_port_probe_service - probe driver for given PCI Express port service + * @dev: PCI Express port service device to probe against + * + * If PCI Express port service driver is registered with + * pcie_port_service_register(), this function will be called by the driver core + * whenever match is found between the driver and a port service device. + */ +static int pcie_port_probe_service(struct device *dev) +{ + struct pcie_device *pciedev; + struct pcie_port_service_driver *driver; + int status; + + if (!dev || !dev->driver) + return -ENODEV; + + driver = to_service_driver(dev->driver); + if (!driver || !driver->probe) + return -ENODEV; + + pciedev = to_pcie_device(dev); + status = driver->probe(pciedev); + if (status) + return status; + + get_device(dev); + return 0; +} + +/** + * pcie_port_remove_service - detach driver from given PCI Express port service + * @dev: PCI Express port service device to handle + * + * If PCI Express port service driver is registered with + * pcie_port_service_register(), this function will be called by the driver core + * when device_unregister() is called for the port service device associated + * with the driver. + */ +static int pcie_port_remove_service(struct device *dev) +{ + struct pcie_device *pciedev; + struct pcie_port_service_driver *driver; + + if (!dev || !dev->driver) + return 0; + + pciedev = to_pcie_device(dev); + driver = to_service_driver(dev->driver); + if (driver && driver->remove) { + driver->remove(pciedev); + put_device(dev); + } + return 0; +} + +/** + * pcie_port_shutdown_service - shut down given PCI Express port service + * @dev: PCI Express port service device to handle + * + * If PCI Express port service driver is registered with + * pcie_port_service_register(), this function will be called by the driver core + * when device_shutdown() is called for the port service device associated + * with the driver. + */ +static void pcie_port_shutdown_service(struct device *dev) {} + +/** + * pcie_port_service_register - register PCI Express port service driver + * @new: PCI Express port service driver to register + */ +int pcie_port_service_register(struct pcie_port_service_driver *new) +{ + if (pcie_ports_disabled) + return -ENODEV; + + new->driver.name = new->name; + new->driver.bus = &pcie_port_bus_type; + new->driver.probe = pcie_port_probe_service; + new->driver.remove = pcie_port_remove_service; + new->driver.shutdown = pcie_port_shutdown_service; + + return driver_register(&new->driver); +} +EXPORT_SYMBOL(pcie_port_service_register); + +/** + * pcie_port_service_unregister - unregister PCI Express port service driver + * @drv: PCI Express port service driver to unregister + */ +void pcie_port_service_unregister(struct pcie_port_service_driver *drv) +{ + driver_unregister(&drv->driver); +} +EXPORT_SYMBOL(pcie_port_service_unregister); + static int pcie_portdrv_restore_config(struct pci_dev *dev) { int retval;