Commit ceb2f007 authored by Jacob Keller's avatar Jacob Keller Committed by David S. Miller

ice: Use pci_get_dsn()

Replace the open-coded implementation for reading the PCIe DSN with
pci_get_dsn().

The pci_get_dsn() function will perform two pci_read_config_dword calls
to read the lower and upper config dwords. It bitwise ORs them into
a u64 value. Instead of using put_unaligned_le32 to convert the value to
LE32 format, just use the %016llX printf specifier. This will print the
u64 correct, putting the most significant byte of the value first. Since
pci_get_dsn() correctly orders the two dwords into a u64, this should
produce equivalent results in less code.
Signed-off-by: default avatarJacob Keller <jacob.e.keller@intel.com>
Cc: Jeff Kirsher <jeffrey.t.kirsher@intel.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent dbce64cb
...@@ -3087,30 +3087,22 @@ static char *ice_get_opt_fw_name(struct ice_pf *pf) ...@@ -3087,30 +3087,22 @@ static char *ice_get_opt_fw_name(struct ice_pf *pf)
* followed by a EUI-64 identifier (PCIe Device Serial Number) * followed by a EUI-64 identifier (PCIe Device Serial Number)
*/ */
struct pci_dev *pdev = pf->pdev; struct pci_dev *pdev = pf->pdev;
char *opt_fw_filename = NULL; char *opt_fw_filename;
u32 dword; u64 dsn;
u8 dsn[8];
int pos;
/* Determine the name of the optional file using the DSN (two /* Determine the name of the optional file using the DSN (two
* dwords following the start of the DSN Capability). * dwords following the start of the DSN Capability).
*/ */
pos = pci_find_ext_capability(pdev, PCI_EXT_CAP_ID_DSN); dsn = pci_get_dsn(pdev);
if (pos) { if (!dsn)
opt_fw_filename = kzalloc(NAME_MAX, GFP_KERNEL); return NULL;
if (!opt_fw_filename)
return NULL; opt_fw_filename = kzalloc(NAME_MAX, GFP_KERNEL);
if (!opt_fw_filename)
pci_read_config_dword(pdev, pos + 4, &dword); return NULL;
put_unaligned_le32(dword, &dsn[0]);
pci_read_config_dword(pdev, pos + 8, &dword); snprintf(opt_fw_filename, NAME_MAX, "%sice-%016llX.pkg",
put_unaligned_le32(dword, &dsn[4]); ICE_DDP_PKG_PATH, dsn);
snprintf(opt_fw_filename, NAME_MAX,
"%sice-%02x%02x%02x%02x%02x%02x%02x%02x.pkg",
ICE_DDP_PKG_PATH,
dsn[7], dsn[6], dsn[5], dsn[4],
dsn[3], dsn[2], dsn[1], dsn[0]);
}
return opt_fw_filename; return opt_fw_filename;
} }
......
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