Blob Blame History Raw
From: Heiner Kallweit <hkallweit1@gmail.com>
Date: Thu, 26 Aug 2021 20:55:43 +0200
Subject: PCI/VPD: Add pci_vpd_find_id_string()
Patch-mainline: v5.15-rc1
Git-commit: acfbb1b8a494d7bfd316dfb363a820e6df637e8d
References: jsc#PED-1506

Add a pci_vpd_find_id_string() API function to retrieve the ID string from
VPD.

This way callers don't need pci_vpd_lrdt_size() any longer, and it can be
made private to the VPD core.

Link: https://lore.kernel.org/r/c5225bf6-8d29-970d-e271-0d7b52252630@gmail.com
Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Acked-by: Thomas Bogendoerfer <tbogendoerfer@suse.de>
---
 drivers/pci/vpd.c   |    6 ++++++
 include/linux/pci.h |   10 ++++++++++
 2 files changed, 16 insertions(+)

--- a/drivers/pci/vpd.c
+++ b/drivers/pci/vpd.c
@@ -320,6 +320,12 @@ static int pci_vpd_find_tag(const u8 *bu
 	return -ENOENT;
 }
 
+int pci_vpd_find_id_string(const u8 *buf, unsigned int len, unsigned int *size)
+{
+	return pci_vpd_find_tag(buf, len, PCI_VPD_LRDT_ID_STRING, size);
+}
+EXPORT_SYMBOL_GPL(pci_vpd_find_id_string);
+
 static int pci_vpd_find_info_keyword(const u8 *buf, unsigned int off,
 			      unsigned int len, const char *kw)
 {
--- a/include/linux/pci.h
+++ b/include/linux/pci.h
@@ -2360,6 +2360,16 @@ static inline u8 pci_vpd_info_field_size
 void *pci_vpd_alloc(struct pci_dev *dev, unsigned int *size);
 
 /**
+ * pci_vpd_find_id_string - Locate id string in VPD
+ * @buf: Pointer to buffered VPD data
+ * @len: The length of the buffer area in which to search
+ * @size: Pointer to field where length of id string is returned
+ *
+ * Returns the index of the id string or -ENOENT if not found.
+ */
+int pci_vpd_find_id_string(const u8 *buf, unsigned int len, unsigned int *size);
+
+/**
  * pci_vpd_find_ro_info_keyword - Locate info field keyword in VPD RO section
  * @buf: Pointer to buffered VPD data
  * @len: The length of the buffer area in which to search