Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp1282735imm; Fri, 8 Jun 2018 13:14:34 -0700 (PDT) X-Google-Smtp-Source: ADUXVKIpymtkzSSWg4ZwY/ZZlH0J3yfGi0CubYetIwQ+dEJ3Msm5aOICbtvAnm/a6WScuPiox/qV X-Received: by 2002:a65:4005:: with SMTP id f5-v6mr6271027pgp.302.1528488874110; Fri, 08 Jun 2018 13:14:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528488874; cv=none; d=google.com; s=arc-20160816; b=i3se781t611NER63w7M6HSIYfjRcEZdDMJbTZwOuUeeMo/frLhGqg4PPRrTwTLZqqd EbhkwuvUISh1mJwO5ULPCMJgfXLCJBpKI0Sl58/dRzvG8IKNOhAVtAFgcLZtgH3uqUoB I90NfArBsXAawjxoDtPMfdE55PEm2vHi2qZU8HzhfBZp8J4vbyQLTySDUQ4xT4C6TUFF XKZW8j9H12Uouq8AlKnSdBysWs5SiW4sAXa5qAel4ByZsd/WFJoyNpllUzmKDgWNp4Dt 0md4EhiY/ECX9OWooGlNFn0nmmv2+179dmZNXA+eexaIMsqcKxvW7s14PAFBY0F0oA8/ hzvQ== 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=4R/4lYG6OTVFJ073E4/sotTKwGazpl8F0Y+YPlvcmNg=; b=BRnP46cR2MShrwbW39OVJYBCCap/LVuxjWAUXqXikP+uTRj5MJaV0pvfRJlUz62+OI 5gIYXARGE0WD08gkiNZPfXf2hShlEy8g5riGbPs/0TDWkkK5ZtvdkeUrF+2wZ6mQWQSD UtN9CnPr8HKj5Q4q4LIax1gjIpQi5cnlHKC3jObGio0hf7F3O99+qLQ5iOmWBziTuSng h0E/O++06WXT7UHrz1XnrD3UvjELA3ZwOem1eu+PHJA/mK3ihjf2wxlD+Wkuqxz231ZF f5bfGDtRUqvLUqxxW5RM9wP1x57SPZ/XHK0CPP7DqLCp15Z0BSM1JNLsbjsDjXZI21mF 1anA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=TLVlI2EK; 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.14.19; Fri, 08 Jun 2018 13:14:34 -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=TLVlI2EK; 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 S1753148AbeFHUMg (ORCPT + 99 others); Fri, 8 Jun 2018 16:12:36 -0400 Received: from mail.kernel.org ([198.145.29.99]:51546 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753115AbeFHUMd (ORCPT ); Fri, 8 Jun 2018 16:12:33 -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 A4883206B7; Fri, 8 Jun 2018 20:12:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1528488752; bh=/79RUPsUPmX/JEhrn52CHxbCa+WggclOBN9rJRnnvYk=; h=Subject:From:To:Cc:Date:In-Reply-To:References:From; b=TLVlI2EK3raVbEvBEaNPdUgcG0g1uHWhMQdUKIOHKqimdIP0Phl+QxepUSeKB0UH2 rAuxIJSFv80ATraHJ+jQ9astAySFeSuirk9DkALlTzcxJ0vaP/bMlRVbDy2GuzXzqx L9AKVDMBVBoMlHO3khX6hCRVYx+oeleN1nmJdsuY= Subject: [PATCH v1 5/9] PCI/portdrv: Squash lookup interfaces 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:31 -0500 Message-ID: <152848875188.14051.2166609505666979991.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 lookup interfaces into portdrv_pci.c. No functional change intended. Signed-off-by: Bjorn Helgaas --- drivers/pci/pcie/portdrv_core.c | 69 --------------------------------------- drivers/pci/pcie/portdrv_pci.c | 68 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 68 insertions(+), 69 deletions(-) diff --git a/drivers/pci/pcie/portdrv_core.c b/drivers/pci/pcie/portdrv_core.c index 2ef046af08d2..77b1c1ea8885 100644 --- a/drivers/pci/pcie/portdrv_core.c +++ b/drivers/pci/pcie/portdrv_core.c @@ -19,75 +19,6 @@ #include "../pci.h" #include "portdrv.h" -struct portdrv_service_data { - struct pcie_port_service_driver *drv; - struct device *dev; - u32 service; -}; - -static int find_service_iter(struct device *device, void *data) -{ - struct pcie_port_service_driver *service_driver; - struct portdrv_service_data *pdrvs; - u32 service; - - pdrvs = (struct portdrv_service_data *) data; - service = pdrvs->service; - - if (device->bus == &pcie_port_bus_type && device->driver) { - service_driver = to_service_driver(device->driver); - if (service_driver->service == service) { - pdrvs->drv = service_driver; - pdrvs->dev = device; - return 1; - } - } - - return 0; -} - -/** - * pcie_port_find_service - find the service driver - * @dev: PCI Express port the service is associated with - * @service: Service to find - * - * Find PCI Express port service driver associated with given service - */ -struct pcie_port_service_driver *pcie_port_find_service(struct pci_dev *dev, - u32 service) -{ - struct pcie_port_service_driver *drv; - struct portdrv_service_data pdrvs; - - pdrvs.drv = NULL; - pdrvs.service = service; - device_for_each_child(&dev->dev, &pdrvs, find_service_iter); - - drv = pdrvs.drv; - return drv; -} - -/** - * pcie_port_find_device - find the struct device - * @dev: PCI Express port the service is associated with - * @service: For the service to find - * - * Find the struct device associated with given service on a pci_dev - */ -struct device *pcie_port_find_device(struct pci_dev *dev, - u32 service) -{ - struct device *device; - struct portdrv_service_data pdrvs; - - pdrvs.dev = NULL; - pdrvs.service = service; - device_for_each_child(&dev->dev, &pdrvs, find_service_iter); - - device = pdrvs.dev; - return device; -} - /** * pcie_port_probe_service - probe driver for given PCI Express port service * @dev: PCI Express port service device to probe against diff --git a/drivers/pci/pcie/portdrv_pci.c b/drivers/pci/pcie/portdrv_pci.c index ab5e3a63981b..b019af97f14e 100644 --- a/drivers/pci/pcie/portdrv_pci.c +++ b/drivers/pci/pcie/portdrv_pci.c @@ -42,6 +42,74 @@ __setup("pcie_ports=", pcie_port_setup); /* global data */ +struct portdrv_service_data { + struct pcie_port_service_driver *drv; + struct device *dev; + u32 service; +}; + +static int find_service_iter(struct device *device, void *data) +{ + struct pcie_port_service_driver *service_driver; + struct portdrv_service_data *pdrvs; + u32 service; + + pdrvs = (struct portdrv_service_data *) data; + service = pdrvs->service; + + if (device->bus == &pcie_port_bus_type && device->driver) { + service_driver = to_service_driver(device->driver); + if (service_driver->service == service) { + pdrvs->drv = service_driver; + pdrvs->dev = device; + return 1; + } + } + + return 0; +} + +/** + * pcie_port_find_service - find the service driver + * @dev: PCI Express port the service is associated with + * @service: Service to find + * + * Find PCI Express port service driver associated with given service + */ +struct pcie_port_service_driver *pcie_port_find_service(struct pci_dev *dev, + u32 service) +{ + struct pcie_port_service_driver *drv; + struct portdrv_service_data pdrvs; + + pdrvs.drv = NULL; + pdrvs.service = service; + device_for_each_child(&dev->dev, &pdrvs, find_service_iter); + + drv = pdrvs.drv; + return drv; +} + +/** + * pcie_port_find_device - find the struct device + * @dev: PCI Express port the service is associated with + * @service: For the service to find + * + * Find the struct device associated with given service on a pci_dev + */ +struct device *pcie_port_find_device(struct pci_dev *dev, u32 service) +{ + struct device *device; + struct portdrv_service_data pdrvs; + + pdrvs.dev = NULL; + pdrvs.service = service; + device_for_each_child(&dev->dev, &pdrvs, find_service_iter); + + device = pdrvs.dev; + return device; +} + static int pcie_portdrv_restore_config(struct pci_dev *dev) { int retval;