mirror of
https://github.com/torvalds/linux
synced 2024-10-19 09:49:29 +00:00
PCI/VPD: Include post-processing in pci_vpd_find_tag()
Move pci_vpd_find_tag() post-processing from pci_vpd_find_ro_info_keyword() to pci_vpd_find_tag(). This simplifies function pci_vpd_find_id_string() that will be added in a subsequent patch. Link: https://lore.kernel.org/r/fb15393f-d3b2-e140-2643-570d3abd7382@gmail.com Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com> Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
This commit is contained in:
parent
59b83b29bb
commit
46a347835c
|
@ -296,16 +296,25 @@ void *pci_vpd_alloc(struct pci_dev *dev, unsigned int *size)
|
||||||
}
|
}
|
||||||
EXPORT_SYMBOL_GPL(pci_vpd_alloc);
|
EXPORT_SYMBOL_GPL(pci_vpd_alloc);
|
||||||
|
|
||||||
static int pci_vpd_find_tag(const u8 *buf, unsigned int len, u8 rdt)
|
static int pci_vpd_find_tag(const u8 *buf, unsigned int len, u8 rdt, unsigned int *size)
|
||||||
{
|
{
|
||||||
int i = 0;
|
int i = 0;
|
||||||
|
|
||||||
/* look for LRDT tags only, end tag is the only SRDT tag */
|
/* look for LRDT tags only, end tag is the only SRDT tag */
|
||||||
while (i + PCI_VPD_LRDT_TAG_SIZE <= len && buf[i] & PCI_VPD_LRDT) {
|
while (i + PCI_VPD_LRDT_TAG_SIZE <= len && buf[i] & PCI_VPD_LRDT) {
|
||||||
if (buf[i] == rdt)
|
unsigned int lrdt_len = pci_vpd_lrdt_size(buf + i);
|
||||||
return i;
|
u8 tag = buf[i];
|
||||||
|
|
||||||
i += PCI_VPD_LRDT_TAG_SIZE + pci_vpd_lrdt_size(buf + i);
|
i += PCI_VPD_LRDT_TAG_SIZE;
|
||||||
|
if (tag == rdt) {
|
||||||
|
if (i + lrdt_len > len)
|
||||||
|
lrdt_len = len - i;
|
||||||
|
if (size)
|
||||||
|
*size = lrdt_len;
|
||||||
|
return i;
|
||||||
|
}
|
||||||
|
|
||||||
|
i += lrdt_len;
|
||||||
}
|
}
|
||||||
|
|
||||||
return -ENOENT;
|
return -ENOENT;
|
||||||
|
@ -384,16 +393,10 @@ int pci_vpd_find_ro_info_keyword(const void *buf, unsigned int len,
|
||||||
int ro_start, infokw_start;
|
int ro_start, infokw_start;
|
||||||
unsigned int ro_len, infokw_size;
|
unsigned int ro_len, infokw_size;
|
||||||
|
|
||||||
ro_start = pci_vpd_find_tag(buf, len, PCI_VPD_LRDT_RO_DATA);
|
ro_start = pci_vpd_find_tag(buf, len, PCI_VPD_LRDT_RO_DATA, &ro_len);
|
||||||
if (ro_start < 0)
|
if (ro_start < 0)
|
||||||
return ro_start;
|
return ro_start;
|
||||||
|
|
||||||
ro_len = pci_vpd_lrdt_size(buf + ro_start);
|
|
||||||
ro_start += PCI_VPD_LRDT_TAG_SIZE;
|
|
||||||
|
|
||||||
if (ro_start + ro_len > len)
|
|
||||||
ro_len = len - ro_start;
|
|
||||||
|
|
||||||
infokw_start = pci_vpd_find_info_keyword(buf, ro_start, ro_len, kw);
|
infokw_start = pci_vpd_find_info_keyword(buf, ro_start, ro_len, kw);
|
||||||
if (infokw_start < 0)
|
if (infokw_start < 0)
|
||||||
return infokw_start;
|
return infokw_start;
|
||||||
|
|
Loading…
Reference in a new issue