Received: by 10.192.165.148 with SMTP id m20csp3556398imm; Mon, 23 Apr 2018 08:29:02 -0700 (PDT) X-Google-Smtp-Source: AIpwx48fIpi8TSyiP6VN2V0uWze+Y/GI85mnlQgFQwtgaij9rRQ3TXXX7Zaeru/XDgYW7YNz1Ul9 X-Received: by 2002:a17:902:24c:: with SMTP id 70-v6mr21497361plc.384.1524497341957; Mon, 23 Apr 2018 08:29:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1524497341; cv=none; d=google.com; s=arc-20160816; b=nE10cfGdfD1aijJti9ddlmGi8kIFu66nmAGEE88UxbGdON8OymurgvVdgG0Ffu79yE GzqXlqFL1Pg1gTmBCGUu1mgQIVQqaZc1s5TiRGOlAk2CunPfZT0k1IS7skbQT2bvICUf /b1k6SAq8IfDC/rJ38e3DD8EsOi8v+XyZbfby6CQMNtIXR2ykehGPyMVUAA0Z9cj6uQv kgAZSGPebkZ266UVeppGDmJx544dhAr+e/ij7e1iO9KZOX3PW1s1nNPylRUZbOgTMzR1 dQUE+lFrFScZWY56hd8RPcOGtqS33UOEidC4LsG2XbXl23ilBM2NmATsL/DcW7vl4Ync Ytkg== 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=3QkSaovNbMONaTcYWGo1A2AwFcCFjbmse+KOm2UGAIk=; b=cZd8blitWQlBLxrCMTxCWo0tpCZZL2Wzg7dJ/PlI6YZn+Lb/UAYpNu0DDOlI4Ug9yE Rq2TjDkH+fjaPbVoEykTqTWV0UmF9Gcr/m4krYb4FpGUUb4QNV2/i9wOEdtt7nVYhZUC zhO6q+fkbjRVd6BWfSv6DH79E/0XM/6hKZLMNFgQfubRmhydkXbwiDLFd0HJD1HlqofJ C7kJojSK9d+UqDi132qHnP88DBDegv6LoWejf2fr3o8sumypIXoE+CIaU2Wc/nk6hZw5 aE1s81UWyoP8ur7qDUHeZzFzu1Y44eWpFZqxz0GtGa4t9HbWlZyHD8khWNRGLHoH3Ous V7zQ== 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 a4si9680481pgd.348.2018.04.23.08.28.47; Mon, 23 Apr 2018 08:29:01 -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 S932179AbeDWPZW (ORCPT + 99 others); Mon, 23 Apr 2018 11:25:22 -0400 Received: from wolverine02.qualcomm.com ([199.106.114.251]:8437 "EHLO wolverine02.qualcomm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755596AbeDWPXQ (ORCPT ); Mon, 23 Apr 2018 11:23:16 -0400 X-IronPort-AV: E=Sophos;i="5.49,318,1520924400"; d="scan'208";a="432990775" Received: from unknown (HELO ironmsg-SD-alpha.qualcomm.com) ([10.53.140.30]) by wolverine02.qualcomm.com with ESMTP; 23 Apr 2018 08:23:16 -0700 X-IronPort-AV: E=McAfee;i="5900,7806,8871"; a="173875856" Received: from westreach.qualcomm.com ([10.228.196.125]) by ironmsg-SD-alpha.qualcomm.com with ESMTP; 23 Apr 2018 08:23:15 -0700 Received: by westreach.qualcomm.com (Postfix, from userid 467151) id 6C1C31F09; Mon, 23 Apr 2018 11:23:14 -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 v14 4/9] PCI/PORTDRV: Implement generic find device Date: Mon, 23 Apr 2018 11:23:08 -0400 Message-Id: <1524496993-29799-5-git-send-email-poza@codeaurora.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1524496993-29799-1-git-send-email-poza@codeaurora.org> References: <1524496993-29799-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 diff --git a/drivers/pci/pcie/portdrv.h b/drivers/pci/pcie/portdrv.h index 419bdf3..06f4e11d 100644 --- a/drivers/pci/pcie/portdrv.h +++ b/drivers/pci/pcie/portdrv.h @@ -81,4 +81,6 @@ static inline void pcie_port_platform_notify(struct pci_dev *port, int *mask){} 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 94de1fa..dd13cc8 100644 --- a/drivers/pci/pcie/portdrv_core.c +++ b/drivers/pci/pcie/portdrv_core.c @@ -25,6 +25,7 @@ bool pciehp_msi_disabled; struct portdrv_service_data { struct pcie_port_service_driver *drv; + struct device *dev; u32 service; }; @@ -432,12 +433,14 @@ 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; } } return 0; } + /** * pcie_port_find_service - find the service driver * @dev: PCI Express port the service devices associated with @@ -460,6 +463,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