lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <20191128125406.10417-1-info@metux.net>
Date:   Thu, 28 Nov 2019 13:54:01 +0100
From:   "Enrico Weigelt, metux IT consult" <info@...ux.net>
To:     linux-kernel@...r.kernel.org
Cc:     tim@...tersideup.com, james.morse@....com, rrichter@...vell.com,
        jdelvare@...e.com, linux@...ck-us.net, miquel.raynal@...tlin.com,
        richard@....at, vigneshr@...com, linux-crypto@...r.kernel.org,
        linux-edac@...r.kernel.org, linux-hwmon@...r.kernel.org,
        linux-mtd@...ts.infradead.org, linux-pci@...r.kernel.org
Subject: [PATCH 1/6] include: linux: pci.h: introduce pci_get_device_by_id()

From: Enrico Weigelt <info@...ux.net>

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 <info@...ux.net>
---
 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);
-- 
2.11.0

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ