From patchwork Thu Nov 28 12:54:01 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Enrico Weigelt, metux IT consult" X-Patchwork-Id: 11265971 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id CDF01921 for ; Thu, 28 Nov 2019 12:58:56 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id AE40C21781 for ; Thu, 28 Nov 2019 12:58:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726582AbfK1M64 (ORCPT ); Thu, 28 Nov 2019 07:58:56 -0500 Received: from mout.kundenserver.de ([212.227.126.134]:54199 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726252AbfK1M64 (ORCPT ); Thu, 28 Nov 2019 07:58:56 -0500 Received: from orion.localdomain ([95.117.37.214]) by mrelayeu.kundenserver.de (mreue011 [212.227.15.167]) with ESMTPSA (Nemesis) id 1MUY9w-1iRTdx29gW-00QSQQ; Thu, 28 Nov 2019 13:54:33 +0100 From: "Enrico Weigelt, metux IT consult" To: linux-kernel@vger.kernel.org Cc: tim@buttersideup.com, james.morse@arm.com, rrichter@marvell.com, jdelvare@suse.com, linux@roeck-us.net, miquel.raynal@bootlin.com, richard@nod.at, vigneshr@ti.com, linux-crypto@vger.kernel.org, linux-edac@vger.kernel.org, linux-hwmon@vger.kernel.org, linux-mtd@lists.infradead.org, linux-pci@vger.kernel.org Subject: [PATCH 1/6] include: linux: pci.h: introduce pci_get_device_by_id() Date: Thu, 28 Nov 2019 13:54:01 +0100 Message-Id: <20191128125406.10417-1-info@metux.net> X-Mailer: git-send-email 2.11.0 X-Provags-ID: V03:K1:38OkZkxKYjduW4lFWkkXpmNgmHkotIPpFTk3wHRoh85U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GIaHd2hXzWKKrAYXxWLNoAfpPpxkBab7RONNYNsZ/y1Ty +vl6YAdeoGR8p0KxwDZg== Sender: linux-hwmon-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-hwmon@vger.kernel.org From: Enrico Weigelt Introduce a little helper for getting pci device via struct pci_device_id, helpful for reducing a little bit of boilerplate. Signed-off-by: Enrico Weigelt, metux IT consult --- include/linux/pci.h | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/include/linux/pci.h b/include/linux/pci.h index eb9f371aa77c..f6650b13724a 100644 --- a/include/linux/pci.h +++ b/include/linux/pci.h @@ -1050,6 +1050,21 @@ struct pci_bus *pci_find_next_bus(const struct pci_bus *from); struct pci_dev *pci_get_device(unsigned int vendor, unsigned int device, struct pci_dev *from); + +/** + * pci_get_device_by_id() - get pci dev by struct pci_device_id + * @id: pci_device_id struct + * + * Retrieve PCI device by struct pci_device_id struct + * + * @return: pointer to struct pci_dev if sucessful, NULL otherwise + */ +static inline struct pci_dev *pci_get_device_by_id( + const struct pci_device_id *id) +{ + return pci_get_device(id->vendor, id->device, NULL); +} + struct pci_dev *pci_get_subsys(unsigned int vendor, unsigned int device, unsigned int ss_vendor, unsigned int ss_device, struct pci_dev *from);