Skip to content

Commit

Permalink
Revert "bnxt: Search VPD with pci_vpd_find_ro_info_keyword()"
Browse files Browse the repository at this point in the history
This reverts commit 58a9b5d.

Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
David S. Miller committed Aug 23, 2021
1 parent df6deaf commit 54c0bcc
Showing 1 changed file with 29 additions and 9 deletions.
38 changes: 29 additions & 9 deletions drivers/net/ethernet/broadcom/bnxt/bnxt.c
Original file line number Diff line number Diff line change
Expand Up @@ -13174,8 +13174,8 @@ static int bnxt_init_mac_addr(struct bnxt *bp)
static void bnxt_vpd_read_info(struct bnxt *bp)
{
struct pci_dev *pdev = bp->pdev;
unsigned int vpd_size, kw_len;
int pos, size;
int i, len, pos, ro_size, size;
unsigned int vpd_size;
u8 *vpd_data;

vpd_data = pci_vpd_alloc(pdev, &vpd_size);
Expand All @@ -13184,22 +13184,42 @@ static void bnxt_vpd_read_info(struct bnxt *bp)
return;
}

pos = pci_vpd_find_ro_info_keyword(vpd_data, vpd_size,
PCI_VPD_RO_KEYWORD_PARTNO, &kw_len);
i = pci_vpd_find_tag(vpd_data, vpd_size, PCI_VPD_LRDT_RO_DATA);
if (i < 0) {
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)
goto read_sn;

size = min_t(int, kw_len, BNXT_VPD_FLD_LEN - 1);
len = pci_vpd_info_field_size(&vpd_data[pos]);
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);

read_sn:
pos = pci_vpd_find_ro_info_keyword(vpd_data, vpd_size,
PCI_VPD_RO_KEYWORD_SERIALNO,
&kw_len);
pos = pci_vpd_find_info_keyword(vpd_data, i, ro_size,
PCI_VPD_RO_KEYWORD_SERIALNO);
if (pos < 0)
goto exit;

size = min_t(int, kw_len, BNXT_VPD_FLD_LEN - 1);
len = pci_vpd_info_field_size(&vpd_data[pos]);
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);
exit:
kfree(vpd_data);
Expand Down

0 comments on commit 54c0bcc

Please sign in to comment.