Received: by 10.192.165.148 with SMTP id m20csp1424989imm; Wed, 2 May 2018 22:06:36 -0700 (PDT) X-Google-Smtp-Source: AB8JxZrDir8HOwNKO7+prnyqDn5cWBbvrdju/zCWUzonZy3hrNSdtgFrdN2eEDkHQcSw1zSEH2DX X-Received: by 2002:a17:902:1c7:: with SMTP id b65-v6mr22545145plb.298.1525323996174; Wed, 02 May 2018 22:06:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1525323996; cv=none; d=google.com; s=arc-20160816; b=m0d4Y6XUNUdt4k6o1KSolwDG8zisOxwzUvXn0iTrQqirufF1hwu2HwIottK4zRNMuT NIn2zm3sVvr/kEuZ35t4xHsnEDfwOFHoZSuWZ5fUQre5rwDjOCi/yWFQ3toZ0NZXuN9c QKnWX2h0paam01EsI6bYD/htGZxWHScpPFShFVjz02cGg+ks+Hty3sN6vPmOSM3c7yQm L6EOjBkIHR6Xy/EuayawPLjv1DrUMankLSgoAAD2FJsX+/9JR1uIR4ASzNTWeeBA0MK2 WJ/CB9i5SdXPt7F2fnGt5hFrjxLBQfDgtsH+sLJFoqcTEXCnJlGuoDSu6co1D6B2htQ+ gvpg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:arc-authentication-results; bh=jVnavRtPW7QLrHDqBj1mvSLisgWy38a8+qEoZq4aJMc=; b=Z87ZLstVyYDt2l1BmNUHhMcmOcwffw2YB0Sm3EKKwb3DVXrgEWCEYCVarDXayR38yJ +gNZEv0T094WWIVBv6Aob2AnxHcgPrNg8gGyEch+ebIEBiH4whJUN95rgmdS5vwlRX7v U+inAEOMHLH8B1XvoiND8k85A9d/SmyvotQL7qdQBYy1EOOW7Qy5qRZTsY/XoJ2/qu80 rnb/P9XnZUm0Uzta8miUgaMWPN+ku/9l1tOvGDRpMzeRp5WVVbKZAQWJdaFR9hSrPFt1 DPyoPU0ipWmZVPibNCmJyoPrPr2Y9vsWvEqFaSNwpuspJ1BTnGl0Rs972Cik4j9V0tLf 9w1A== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id d22si3626651pfn.84.2018.05.02.22.06.21; Wed, 02 May 2018 22:06:36 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752250AbeECFFu (ORCPT + 99 others); Thu, 3 May 2018 01:05:50 -0400 Received: from wolverine01.qualcomm.com ([199.106.114.254]:5679 "EHLO wolverine01.qualcomm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751869AbeECFEF (ORCPT ); Thu, 3 May 2018 01:04:05 -0400 X-IronPort-AV: E=Sophos;i="5.49,356,1520924400"; d="scan'208";a="338643507" Received: from unknown (HELO ironmsg-SD-alpha.qualcomm.com) ([10.53.140.30]) by wolverine01.qualcomm.com with ESMTP; 02 May 2018 22:04:04 -0700 X-IronPort-AV: E=McAfee;i="5900,7806,8881"; a="182707667" Received: from westreach.qualcomm.com ([10.228.196.125]) by ironmsg-SD-alpha.qualcomm.com with ESMTP; 02 May 2018 22:04:03 -0700 Received: by westreach.qualcomm.com (Postfix, from userid 467151) id 07D031F2B; Thu, 3 May 2018 01:04:02 -0400 (EDT) From: Oza Pawandeep To: Bjorn Helgaas , Philippe Ombredanne , Thomas Gleixner , Greg Kroah-Hartman , Kate Stewart , linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org, Dongdong Liu , Keith Busch , Wei Zhang , Sinan Kaya , Timur Tabi Cc: Oza Pawandeep Subject: [PATCH v15 7/9] PCI/PORTDRV: Implement generic find device Date: Thu, 3 May 2018 01:03:56 -0400 Message-Id: <1525323838-1735-8-git-send-email-poza@codeaurora.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1525323838-1735-1-git-send-email-poza@codeaurora.org> References: <1525323838-1735-1-git-send-email-poza@codeaurora.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This patch implements generic pcie_port_find_device() routine. Signed-off-by: Oza Pawandeep Reviewed-by: Keith Busch diff --git a/drivers/pci/pcie/portdrv.h b/drivers/pci/pcie/portdrv.h index ba6c963..896608a 100644 --- a/drivers/pci/pcie/portdrv.h +++ b/drivers/pci/pcie/portdrv.h @@ -114,4 +114,6 @@ static inline void pcie_pme_interrupt_enable(struct pci_dev *dev, bool en) {} struct pcie_port_service_driver *pcie_port_find_service(struct pci_dev *dev, u32 service); +struct device *pcie_port_find_device(struct pci_dev *dev, + u32 service); #endif /* _PORTDRV_H_ */ diff --git a/drivers/pci/pcie/portdrv_core.c b/drivers/pci/pcie/portdrv_core.c index d843055..c6147c4 100644 --- a/drivers/pci/pcie/portdrv_core.c +++ b/drivers/pci/pcie/portdrv_core.c @@ -20,6 +20,7 @@ #include "portdrv.h" struct portdrv_service_data { struct pcie_port_service_driver *drv; + struct device *dev; u32 service; }; @@ -415,6 +416,7 @@ static int find_service_iter(struct device *device, void *data) service_driver = to_service_driver(device->driver); if (service_driver->service == service) { pdrvs->drv = service_driver; + pdrvs->dev = device; return 1; } } @@ -443,6 +445,27 @@ struct pcie_port_service_driver *pcie_port_find_service(struct pci_dev *dev, } /** + * pcie_port_find_device - find the struct device + * @dev: PCI Express port the service devices associated with + * @service: For the service to find + * + * Find PCI Express port service driver associated with given service + */ +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_device_remove - unregister PCI Express port service devices * @dev: PCI Express port the service devices to unregister are associated with * -- 2.7.4