Received: by 2002:ac0:a594:0:0:0:0:0 with SMTP id m20-v6csp609833imm; Fri, 11 May 2018 03:44:08 -0700 (PDT) X-Google-Smtp-Source: AB8JxZqZ1o6BD/ldbS9zHfm6mCgort/sDpoMq8SwEklSd2Bn/wM9NSZ++qIFUjg4WQnvIVQBX5zc X-Received: by 2002:a17:902:f44:: with SMTP id 62-v6mr5023955ply.318.1526035448707; Fri, 11 May 2018 03:44:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1526035448; cv=none; d=google.com; s=arc-20160816; b=yYIGF7RSG0u20Rl3AIVhABszppYwgIz+TtF/6ypfSv6atbGgZgdaYXmXcTWuWFZpoy UWXPQYcKI9oBXNYvpA0E7MHuN2BgOK0wvgKFBel4E1+bNdK5/Uh6HEvheXheLzOMmtOB U4dvtciYkfuFl0gE2Jp1dMLxOh6/hPM94JFUTPcf+F4ZySWyq82XCS5POCrtKQAjaYy3 cyNDdG3BVj5d9ZLfyTh3F8bPcoDpZcJaoG+ZO96T2jr9hOICYX8z4PiBkbSHI53WnGFM 1UaLdTl8hUwmLQYMYNl2PH7cBD+i8vyemZciMm21YSvX6JHTPt3vKu1h7FbdCsW9ccUz Basg== 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=Uamu9nTixlFw/nVi39a2NIxDgFepUNEIpAxUJNxh8H4=; b=jJG+cu7NEGyu+SyGE6uS5NWoNfluqd9U47efj/I0tVpNe2q1mZGF3MwRDZ2QnNCJge 7sXu2FRRLtKqUSpjj96foMG11D78IrhhUv8GoUjA18L4Ty5aNKNJWimfgfQlyryIrGGI DwsYfvVgSJ6+kVGMZ2TiEs6kMZ1PeVR4y338Y8c8xX0zawZKrO1gb+6VtOCM+Z/U82Bo 6UspRDqJEWkFUhr0dPAgiGa11zBFTdaSLVuTo+hcypZ3c90x6wvCnh2J6NftZHcU+0Px KAhgU24gSdhiI438/Coh995EZdiRzX0lOgRK/0K9bgCLhafu6TD5kEtSm0dJEWvkY/tw E7Ug== 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 s3-v6si2693078plp.241.2018.05.11.03.43.53; Fri, 11 May 2018 03:44:08 -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 S1753049AbeEKKnk (ORCPT + 99 others); Fri, 11 May 2018 06:43:40 -0400 Received: from alexa-out.qualcomm.com ([129.46.98.28]:33617 "EHLO alexa-out.qualcomm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752862AbeEKKne (ORCPT ); Fri, 11 May 2018 06:43:34 -0400 X-IronPort-AV: E=Sophos;i="5.49,388,1520924400"; d="scan'208";a="17306051" Received: from ironmsg04-sd.qualcomm.com ([10.53.140.144]) by alexa-out.qualcomm.com with ESMTP; 11 May 2018 03:43:33 -0700 X-IronPort-AV: E=McAfee;i="5900,7806,8889"; a="82987134" Received: from westreach.qualcomm.com ([10.228.196.125]) by ironmsg04-sd.qualcomm.com with ESMTP; 11 May 2018 03:43:32 -0700 Received: by westreach.qualcomm.com (Postfix, from userid 467151) id B18191F2D; Fri, 11 May 2018 06:43:30 -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 v16 7/9] PCI/PORTDRV: Implement generic find device Date: Fri, 11 May 2018 06:43:26 -0400 Message-Id: <1526035408-31328-8-git-send-email-poza@codeaurora.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1526035408-31328-1-git-send-email-poza@codeaurora.org> References: <1526035408-31328-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..bc2c337 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