Skip to content

Commit

Permalink
cxgb4: Use pci_vpd_find_id_string() to find VPD ID string
Browse files Browse the repository at this point in the history
Use pci_vpd_find_id_string() to find the VPD ID string. This simplifies the
code and avoids the need for pci_vpd_lrdt_size().

Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Heiner Kallweit <[email protected]>
Signed-off-by: Bjorn Helgaas <[email protected]>
  • Loading branch information
hkallweit authored and bjorn-helgaas committed Aug 31, 2021
1 parent acfbb1b commit 24c521f
Showing 1 changed file with 5 additions and 8 deletions.
13 changes: 5 additions & 8 deletions drivers/net/ethernet/chelsio/cxgb4/t4_hw.c
Original file line number Diff line number Diff line change
Expand Up @@ -2744,7 +2744,7 @@ int t4_seeprom_wp(struct adapter *adapter, bool enable)
int t4_get_raw_vpd_params(struct adapter *adapter, struct vpd_params *p)
{
unsigned int id_len, pn_len, sn_len, na_len;
int sn, pn, na, addr, ret = 0;
int id, sn, pn, na, addr, ret = 0;
u8 *vpd, base_val = 0;

vpd = vmalloc(VPD_LEN);
Expand All @@ -2764,13 +2764,10 @@ int t4_get_raw_vpd_params(struct adapter *adapter, struct vpd_params *p)
if (ret < 0)
goto out;

if (vpd[0] != PCI_VPD_LRDT_ID_STRING) {
dev_err(adapter->pdev_dev, "missing VPD ID string\n");
ret = -EINVAL;
ret = pci_vpd_find_id_string(vpd, VPD_LEN, &id_len);
if (ret < 0)
goto out;
}

id_len = pci_vpd_lrdt_size(vpd);
id = ret;

ret = pci_vpd_check_csum(vpd, VPD_LEN);
if (ret) {
Expand All @@ -2796,7 +2793,7 @@ int t4_get_raw_vpd_params(struct adapter *adapter, struct vpd_params *p)
goto out;
na = ret;

memcpy(p->id, vpd + PCI_VPD_LRDT_TAG_SIZE, min_t(int, id_len, ID_LEN));
memcpy(p->id, vpd + id, min_t(int, id_len, ID_LEN));
strim(p->id);
memcpy(p->sn, vpd + sn, min_t(int, sn_len, SERNUM_LEN));
strim(p->sn);
Expand Down

0 comments on commit 24c521f

Please sign in to comment.