Received: by 2002:ac0:a594:0:0:0:0:0 with SMTP id m20-v6csp2966892imm; Thu, 17 May 2018 00:44:04 -0700 (PDT) X-Google-Smtp-Source: AB8JxZraGtVgXc03gsPI+0r6NPSB/lbb3tybl978Si9E0FMQk980d9QWexRiTZdyNrDuEswKBlXx X-Received: by 2002:a62:e50d:: with SMTP id n13-v6mr4169272pff.125.1526543044018; Thu, 17 May 2018 00:44:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1526543043; cv=none; d=google.com; s=arc-20160816; b=lByjDyuf/MlbTNacQ8HHRZzkm5HJ3RYv6cNHGz+HO6eSPI1/W8VBcyY05EKEuKVyfw Nb9ppKqqNymWZ8hWifbQs79hhckEyJfe87x7jDF5V+fQJgdsUEtQu4cJhGkHnlVl/5qw 2cUerM9DZKkFhU9NoiIVEOI1JQCq/Ppw1+L+vpM8WxVUoufdfzKe4CIbzdekfnRvlAg+ 9sh/AQAACLogXwQCjTiJ9zi0RnxHmQASKhsUJT6MyDl2qyr9kRgx9mICnmCTdU0ES82l MOQvBf7/AYuJjmjD9nPk/1N+5WSa2Qn2ifuBEQAOC7Fk0ZbsnlCRiabUNoegjI0mIV/a PJ1g== 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=xf3Rz9C5YN4GoIVVku2l54v4hP6y42Hv973Xpt2TH/Y=; b=fG4l9v77ZJvU1FuFT41+yhskZEBYqKN+WeuX4BZuuyxJ6v8XOB1e+eIpHB//r38T9C k99ZDo+PrwQ85wUv6zETgBVhbTUvgta9g61FvHmJL0uNR2qy6gyuol2zx0g1b4RBHP9E +50AdXU0+mu3iJmYze7StueuEvAFw3jzjg8KR6bWse/tSCBaOJC47jcYDbvFdMi/sYn4 ScdFffH0xFqOidGVxKN6gJyQU5++GbJjv5AtiyEEsqLhGdgNf3GUAhMWO67oEl2gP2wN hZp7X0sl/sDYcYR9FvO5dueP2lH5GxjqoiZXZ0bfK9kgyHHL8o0QRcE5SAh78e7O9yZz 5A9g== 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 t1-v6si3031374pgc.6.2018.05.17.00.43.49; Thu, 17 May 2018 00:44:03 -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 S1752565AbeEQHnY (ORCPT + 99 others); Thu, 17 May 2018 03:43:24 -0400 Received: from alexa-out.qualcomm.com ([129.46.98.28]:59609 "EHLO alexa-out.qualcomm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752455AbeEQHnQ (ORCPT ); Thu, 17 May 2018 03:43:16 -0400 X-IronPort-AV: E=Sophos;i="5.49,409,1520924400"; d="scan'208";a="17713698" Received: from ironmsg02-sd.qualcomm.com ([10.53.140.142]) by alexa-out.qualcomm.com with ESMTP; 17 May 2018 00:43:16 -0700 Received: from westreach.qualcomm.com ([10.228.196.125]) by ironmsg02-sd.qualcomm.com with ESMTP; 17 May 2018 00:43:14 -0700 Received: by westreach.qualcomm.com (Postfix, from userid 467151) id B6D091F31; Thu, 17 May 2018 03:43:12 -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 , Bjorn Helgaas Subject: [PATCH v17 6/9] PCI/portdrv: Add generic pcie_port_find_device() Date: Thu, 17 May 2018 03:43:08 -0400 Message-Id: <1526542991-5291-7-git-send-email-poza@codeaurora.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1526542991-5291-1-git-send-email-poza@codeaurora.org> References: <1526542991-5291-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 Add generic pcie_port_find_device() routine. Signed-off-by: Oza Pawandeep Signed-off-by: Bjorn Helgaas 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 e5bbf08..a5b3b3a 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 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_device_remove - unregister PCI Express port service devices * @dev: PCI Express port the service devices to unregister are associated with * -- 2.7.4