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

bnxt: Read VPD with pci_vpd_alloc()

Use pci_vpd_alloc() to dynamically allocate a properly sized buffer and
read the full VPD data into it.

This simplifies the code, and we no longer have to make assumptions about
VPD size.
Signed-off-by: default avatarHeiner Kallweit <hkallweit1@gmail.com>
Reported-by: default avatarkernel test robot <lkp@intel.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent da417885
...@@ -13171,22 +13171,17 @@ static int bnxt_init_mac_addr(struct bnxt *bp) ...@@ -13171,22 +13171,17 @@ static int bnxt_init_mac_addr(struct bnxt *bp)
return rc; return rc;
} }
#define BNXT_VPD_LEN 512
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; int i, len, pos, ro_size, size;
ssize_t vpd_size; unsigned int vpd_size;
u8 *vpd_data; u8 *vpd_data;
vpd_data = kmalloc(BNXT_VPD_LEN, GFP_KERNEL); vpd_data = pci_vpd_alloc(pdev, &vpd_size);
if (!vpd_data) if (IS_ERR(vpd_data)) {
pci_warn(pdev, "Unable to read VPD\n");
return; return;
vpd_size = pci_read_vpd(pdev, 0, BNXT_VPD_LEN, vpd_data);
if (vpd_size <= 0) {
netdev_err(bp->dev, "Unable to read VPD\n");
goto exit;
} }
i = pci_vpd_find_tag(vpd_data, vpd_size, PCI_VPD_LRDT_RO_DATA); i = pci_vpd_find_tag(vpd_data, vpd_size, PCI_VPD_LRDT_RO_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