mirror of
https://github.com/Fishwaldo/Star64_linux.git
synced 2025-07-23 15:27:29 +00:00
pci: Add VPD information field helper functions
This patch adds a preprocessor constant to describe the PCI VPD information field header size and an inline function to extract the size of the information field itself. Signed-off-by: Matt Carlson <mcarlson@broadcom.com> Signed-off-by: Michael Chan <mchan@broadcom.com> Acked-by: Jesse Barnes <jbarnes@virtuousgeek.org> Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
parent
b55ac1b226
commit
e1d5bdabb9
3 changed files with 23 additions and 8 deletions
|
@ -7784,14 +7784,15 @@ bnx2_read_vpd_fw_ver(struct bnx2 *bp)
|
||||||
goto vpd_done;
|
goto vpd_done;
|
||||||
|
|
||||||
while (i < (block_end - 2)) {
|
while (i < (block_end - 2)) {
|
||||||
int len = data[i + 2];
|
int len = pci_vpd_info_field_size(&data[i]);
|
||||||
|
|
||||||
if (i + 3 + len > block_end)
|
if (i + PCI_VPD_INFO_FLD_HDR_SIZE + len > block_end)
|
||||||
goto vpd_done;
|
goto vpd_done;
|
||||||
|
|
||||||
if (data[i] == 'M' && data[i + 1] == 'N') {
|
if (data[i] == 'M' && data[i + 1] == 'N') {
|
||||||
if (len != 4 ||
|
if (len != 4 ||
|
||||||
memcmp(&data[i + 3], "1028", 4))
|
memcmp(&data[i + PCI_VPD_INFO_FLD_HDR_SIZE],
|
||||||
|
"1028", 4))
|
||||||
goto vpd_done;
|
goto vpd_done;
|
||||||
mn_match = true;
|
mn_match = true;
|
||||||
|
|
||||||
|
@ -7800,9 +7801,9 @@ bnx2_read_vpd_fw_ver(struct bnx2 *bp)
|
||||||
goto vpd_done;
|
goto vpd_done;
|
||||||
|
|
||||||
v0_len = len;
|
v0_len = len;
|
||||||
v0_str = &data[i + 3];
|
v0_str = &data[i + PCI_VPD_INFO_FLD_HDR_SIZE];
|
||||||
}
|
}
|
||||||
i += 3 + len;
|
i += PCI_VPD_INFO_FLD_HDR_SIZE + len;
|
||||||
|
|
||||||
if (mn_match && v0_str) {
|
if (mn_match && v0_str) {
|
||||||
memcpy(bp->fw_version, v0_str, v0_len);
|
memcpy(bp->fw_version, v0_str, v0_len);
|
||||||
|
|
|
@ -12604,9 +12604,9 @@ static void __devinit tg3_read_partno(struct tg3 *tp)
|
||||||
while (i < (block_end - 2)) {
|
while (i < (block_end - 2)) {
|
||||||
if (vpd_data[i + 0] == 'P' &&
|
if (vpd_data[i + 0] == 'P' &&
|
||||||
vpd_data[i + 1] == 'N') {
|
vpd_data[i + 1] == 'N') {
|
||||||
int partno_len = vpd_data[i + 2];
|
int partno_len = pci_vpd_info_field_size(&vpd_data[i]);
|
||||||
|
|
||||||
i += 3;
|
i += PCI_VPD_INFO_FLD_HDR_SIZE;
|
||||||
if (partno_len > TG3_BPN_SIZE ||
|
if (partno_len > TG3_BPN_SIZE ||
|
||||||
(partno_len + i) > TG3_NVM_VPD_LEN)
|
(partno_len + i) > TG3_NVM_VPD_LEN)
|
||||||
goto out_not_found;
|
goto out_not_found;
|
||||||
|
@ -12617,7 +12617,8 @@ static void __devinit tg3_read_partno(struct tg3 *tp)
|
||||||
/* Success. */
|
/* Success. */
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
i += 3 + vpd_data[i + 2];
|
i += PCI_VPD_INFO_FLD_HDR_SIZE +
|
||||||
|
pci_vpd_info_field_size(&vpd_data[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Part number not found. */
|
/* Part number not found. */
|
||||||
|
|
|
@ -1373,6 +1373,8 @@ void pci_request_acs(void);
|
||||||
#define PCI_VPD_LRDT_TAG_SIZE 3
|
#define PCI_VPD_LRDT_TAG_SIZE 3
|
||||||
#define PCI_VPD_SRDT_TAG_SIZE 1
|
#define PCI_VPD_SRDT_TAG_SIZE 1
|
||||||
|
|
||||||
|
#define PCI_VPD_INFO_FLD_HDR_SIZE 3
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* pci_vpd_lrdt_size - Extracts the Large Resource Data Type length
|
* pci_vpd_lrdt_size - Extracts the Large Resource Data Type length
|
||||||
* @lrdt: Pointer to the beginning of the Large Resource Data Type tag
|
* @lrdt: Pointer to the beginning of the Large Resource Data Type tag
|
||||||
|
@ -1395,6 +1397,17 @@ static inline u8 pci_vpd_srdt_size(const u8 *srdt)
|
||||||
return (*srdt) & PCI_VPD_SRDT_LEN_MASK;
|
return (*srdt) & PCI_VPD_SRDT_LEN_MASK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* pci_vpd_info_field_size - Extracts the information field length
|
||||||
|
* @lrdt: Pointer to the beginning of an information field header
|
||||||
|
*
|
||||||
|
* Returns the extracted information field length.
|
||||||
|
*/
|
||||||
|
static inline u8 pci_vpd_info_field_size(const u8 *info_field)
|
||||||
|
{
|
||||||
|
return info_field[2];
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* pci_vpd_find_tag - Locates the Resource Data Type tag provided
|
* pci_vpd_find_tag - Locates the Resource Data Type tag provided
|
||||||
* @buf: Pointer to buffered vpd data
|
* @buf: Pointer to buffered vpd data
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue