Commit 58a9b5d2 authored by Heiner Kallweit's avatar Heiner Kallweit Committed by David S. Miller

bnxt: Search VPD with pci_vpd_find_ro_info_keyword()

Use pci_vpd_find_ro_info_keyword() to search for keywords in VPD to
simplify the code.
Signed-off-by: default avatarHeiner Kallweit <hkallweit1@gmail.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent ebcdc8eb
...@@ -13174,8 +13174,8 @@ static int bnxt_init_mac_addr(struct bnxt *bp) ...@@ -13174,8 +13174,8 @@ static int bnxt_init_mac_addr(struct bnxt *bp)
static void bnxt_vpd_read_info(struct bnxt *bp) static void bnxt_vpd_read_info(struct bnxt *bp)
{ {
struct pci_dev *pdev = bp->pdev; struct pci_dev *pdev = bp->pdev;
int i, len, pos, ro_size, size; unsigned int vpd_size, kw_len;
unsigned int vpd_size; int pos, size;
u8 *vpd_data; u8 *vpd_data;
vpd_data = pci_vpd_alloc(pdev, &vpd_size); vpd_data = pci_vpd_alloc(pdev, &vpd_size);
...@@ -13184,42 +13184,22 @@ static void bnxt_vpd_read_info(struct bnxt *bp) ...@@ -13184,42 +13184,22 @@ static void bnxt_vpd_read_info(struct bnxt *bp)
return; return;
} }
i = pci_vpd_find_tag(vpd_data, vpd_size, PCI_VPD_LRDT_RO_DATA); pos = pci_vpd_find_ro_info_keyword(vpd_data, vpd_size,
if (i < 0) { PCI_VPD_RO_KEYWORD_PARTNO, &kw_len);
netdev_err(bp->dev, "VPD READ-Only not found\n");
goto exit;
}
ro_size = pci_vpd_lrdt_size(&vpd_data[i]);
i += PCI_VPD_LRDT_TAG_SIZE;
if (i + ro_size > vpd_size)
goto exit;
pos = pci_vpd_find_info_keyword(vpd_data, i, ro_size,
PCI_VPD_RO_KEYWORD_PARTNO);
if (pos < 0) if (pos < 0)
goto read_sn; goto read_sn;
len = pci_vpd_info_field_size(&vpd_data[pos]); size = min_t(int, kw_len, BNXT_VPD_FLD_LEN - 1);
pos += PCI_VPD_INFO_FLD_HDR_SIZE;
if (len + pos > vpd_size)
goto read_sn;
size = min(len, BNXT_VPD_FLD_LEN - 1);
memcpy(bp->board_partno, &vpd_data[pos], size); memcpy(bp->board_partno, &vpd_data[pos], size);
read_sn: read_sn:
pos = pci_vpd_find_info_keyword(vpd_data, i, ro_size, pos = pci_vpd_find_ro_info_keyword(vpd_data, vpd_size,
PCI_VPD_RO_KEYWORD_SERIALNO); PCI_VPD_RO_KEYWORD_SERIALNO,
&kw_len);
if (pos < 0) if (pos < 0)
goto exit; goto exit;
len = pci_vpd_info_field_size(&vpd_data[pos]); size = min_t(int, kw_len, BNXT_VPD_FLD_LEN - 1);
pos += PCI_VPD_INFO_FLD_HDR_SIZE;
if (len + pos > vpd_size)
goto exit;
size = min(len, BNXT_VPD_FLD_LEN - 1);
memcpy(bp->board_serialno, &vpd_data[pos], size); memcpy(bp->board_serialno, &vpd_data[pos], size);
exit: exit:
kfree(vpd_data); kfree(vpd_data);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment