diff options
author | Matt Carlson <mcarlson@broadcom.com> | 2009-12-03 03:36:23 -0500 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2009-12-03 16:18:06 -0500 |
commit | 94c982bd9f07b801f03cebe32b20f893b4ad6d27 (patch) | |
tree | 2df6b908732f09f8882a8e8a91b0dc083fce2dde | |
parent | 141518c95870228da4e050fbe31a8f0c9df82c72 (diff) |
tg3: Use pci_read_vpd() instead of private method
If the driver needs to use PCI configuration space to read the VPD data,
the accesses could collide with the pci_read_vpd() function. This patch
converts the driver to use pci_read_vpd() to avoid any potential
collisions.
Signed-off-by: Matt Carlson <mcarlson@broadcom.com>
Reviewed-by: Michael Chan <mchan@broadcom.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r-- | drivers/net/tg3.c | 35 |
1 files changed, 12 insertions, 23 deletions
diff --git a/drivers/net/tg3.c b/drivers/net/tg3.c index 2576effca845..f41debcf2025 100644 --- a/drivers/net/tg3.c +++ b/drivers/net/tg3.c | |||
@@ -12455,31 +12455,20 @@ static void __devinit tg3_read_partno(struct tg3 *tp) | |||
12455 | memcpy(&vpd_data[i], &tmp, sizeof(tmp)); | 12455 | memcpy(&vpd_data[i], &tmp, sizeof(tmp)); |
12456 | } | 12456 | } |
12457 | } else { | 12457 | } else { |
12458 | int vpd_cap; | 12458 | ssize_t cnt; |
12459 | 12459 | unsigned int pos = 0, i = 0; | |
12460 | vpd_cap = pci_find_capability(tp->pdev, PCI_CAP_ID_VPD); | 12460 | |
12461 | for (i = 0; i < TG3_NVM_VPD_LEN; i += 4) { | 12461 | for (; pos < TG3_NVM_VPD_LEN && i < 3; i++, pos += cnt) { |
12462 | u32 tmp, j = 0; | 12462 | cnt = pci_read_vpd(tp->pdev, pos, |
12463 | __le32 v; | 12463 | TG3_NVM_VPD_LEN - pos, |
12464 | u16 tmp16; | 12464 | &vpd_data[pos]); |
12465 | 12465 | if (cnt == -ETIMEDOUT || -EINTR) | |
12466 | pci_write_config_word(tp->pdev, vpd_cap + PCI_VPD_ADDR, | 12466 | cnt = 0; |
12467 | i); | 12467 | else if (cnt < 0) |
12468 | while (j++ < 100) { | ||
12469 | pci_read_config_word(tp->pdev, vpd_cap + | ||
12470 | PCI_VPD_ADDR, &tmp16); | ||
12471 | if (tmp16 & 0x8000) | ||
12472 | break; | ||
12473 | msleep(1); | ||
12474 | } | ||
12475 | if (!(tmp16 & 0x8000)) | ||
12476 | goto out_not_found; | 12468 | goto out_not_found; |
12477 | |||
12478 | pci_read_config_dword(tp->pdev, vpd_cap + PCI_VPD_DATA, | ||
12479 | &tmp); | ||
12480 | v = cpu_to_le32(tmp); | ||
12481 | memcpy(&vpd_data[i], &v, sizeof(v)); | ||
12482 | } | 12469 | } |
12470 | if (pos != TG3_NVM_VPD_LEN) | ||
12471 | goto out_not_found; | ||
12483 | } | 12472 | } |
12484 | 12473 | ||
12485 | /* Now parse and find the part number. */ | 12474 | /* Now parse and find the part number. */ |