diff options
| -rw-r--r-- | drivers/net/bnx2.c | 8 | ||||
| -rw-r--r-- | drivers/net/tg3.c | 13 | ||||
| -rw-r--r-- | include/linux/pci.h | 14 |
3 files changed, 25 insertions, 10 deletions
diff --git a/drivers/net/bnx2.c b/drivers/net/bnx2.c index d3f739a295df..bb403887b549 100644 --- a/drivers/net/bnx2.c +++ b/drivers/net/bnx2.c | |||
| @@ -7773,15 +7773,17 @@ bnx2_read_vpd_fw_ver(struct bnx2 *bp) | |||
| 7773 | unsigned int block_end; | 7773 | unsigned int block_end; |
| 7774 | 7774 | ||
| 7775 | if (val == 0x82 || val == 0x91) { | 7775 | if (val == 0x82 || val == 0x91) { |
| 7776 | i = (i + 3 + (data[i + 1] + (data[i + 2] << 8))); | 7776 | i += PCI_VPD_LRDT_TAG_SIZE + |
| 7777 | pci_vpd_lrdt_size(&data[i]); | ||
| 7777 | continue; | 7778 | continue; |
| 7778 | } | 7779 | } |
| 7779 | 7780 | ||
| 7780 | if (val != 0x90) | 7781 | if (val != 0x90) |
| 7781 | goto vpd_done; | 7782 | goto vpd_done; |
| 7782 | 7783 | ||
| 7783 | block_end = (i + 3 + (data[i + 1] + (data[i + 2] << 8))); | 7784 | block_end = (i + PCI_VPD_LRDT_TAG_SIZE + |
| 7784 | i += 3; | 7785 | pci_vpd_lrdt_size(&data[i])); |
| 7786 | i += PCI_VPD_LRDT_TAG_SIZE; | ||
| 7785 | 7787 | ||
| 7786 | if (block_end > BNX2_VPD_LEN) | 7788 | if (block_end > BNX2_VPD_LEN) |
| 7787 | goto vpd_done; | 7789 | goto vpd_done; |
diff --git a/drivers/net/tg3.c b/drivers/net/tg3.c index 0d06e4007f44..5fccbe459949 100644 --- a/drivers/net/tg3.c +++ b/drivers/net/tg3.c | |||
| @@ -12590,19 +12590,18 @@ static void __devinit tg3_read_partno(struct tg3 *tp) | |||
| 12590 | unsigned int block_end; | 12590 | unsigned int block_end; |
| 12591 | 12591 | ||
| 12592 | if (val == 0x82 || val == 0x91) { | 12592 | if (val == 0x82 || val == 0x91) { |
| 12593 | i = (i + 3 + | 12593 | i += PCI_VPD_LRDT_TAG_SIZE + |
| 12594 | (vpd_data[i + 1] + | 12594 | pci_vpd_lrdt_size(&vpd_data[i]); |
| 12595 | (vpd_data[i + 2] << 8))); | ||
| 12596 | continue; | 12595 | continue; |
| 12597 | } | 12596 | } |
| 12598 | 12597 | ||
| 12599 | if (val != 0x90) | 12598 | if (val != 0x90) |
| 12600 | goto out_not_found; | 12599 | goto out_not_found; |
| 12601 | 12600 | ||
| 12602 | block_end = (i + 3 + | 12601 | block_end = i + PCI_VPD_LRDT_TAG_SIZE + |
| 12603 | (vpd_data[i + 1] + | 12602 | pci_vpd_lrdt_size(&vpd_data[i]); |
| 12604 | (vpd_data[i + 2] << 8))); | 12603 | |
| 12605 | i += 3; | 12604 | i += PCI_VPD_LRDT_TAG_SIZE; |
| 12606 | 12605 | ||
| 12607 | if (block_end > TG3_NVM_VPD_LEN) | 12606 | if (block_end > TG3_NVM_VPD_LEN) |
| 12608 | goto out_not_found; | 12607 | goto out_not_found; |
diff --git a/include/linux/pci.h b/include/linux/pci.h index e2575f86133a..6f62a499023f 100644 --- a/include/linux/pci.h +++ b/include/linux/pci.h | |||
| @@ -1349,5 +1349,19 @@ static inline bool pci_is_pcie(struct pci_dev *dev) | |||
| 1349 | 1349 | ||
| 1350 | void pci_request_acs(void); | 1350 | void pci_request_acs(void); |
| 1351 | 1351 | ||
| 1352 | |||
| 1353 | #define PCI_VPD_LRDT_TAG_SIZE 3 | ||
| 1354 | |||
| 1355 | /** | ||
| 1356 | * pci_vpd_lrdt_size - Extracts the Large Resource Data Type length | ||
| 1357 | * @lrdt: Pointer to the beginning of the Large Resource Data Type tag | ||
| 1358 | * | ||
| 1359 | * Returns the extracted Large Resource Data Type length. | ||
| 1360 | */ | ||
| 1361 | static inline u16 pci_vpd_lrdt_size(const u8 *lrdt) | ||
| 1362 | { | ||
| 1363 | return (u16)lrdt[1] + ((u16)lrdt[2] << 8); | ||
| 1364 | } | ||
| 1365 | |||
| 1352 | #endif /* __KERNEL__ */ | 1366 | #endif /* __KERNEL__ */ |
| 1353 | #endif /* LINUX_PCI_H */ | 1367 | #endif /* LINUX_PCI_H */ |
