diff options
author | Matt Carlson <mcarlson@broadcom.com> | 2009-12-03 03:36:22 -0500 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2009-12-03 16:18:04 -0500 |
commit | 141518c95870228da4e050fbe31a8f0c9df82c72 (patch) | |
tree | 377e3cb707cf848213f5aeb653dd50cae572135c /drivers/net/tg3.c | |
parent | b703df6f628ab63eaa875232551b1f2f0503b9af (diff) |
tg3: Add some VPD preprocessor constants
This patch cleans up the VPD code by creating preprocessor definitions
and using them in the place of hardcoded constants.
Signed-off-by: Matt Carlson <mcarlson@broadcom.com>
Reviewed-by: Michael Chan <mchan@broadcom.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/tg3.c')
-rw-r--r-- | drivers/net/tg3.c | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/drivers/net/tg3.c b/drivers/net/tg3.c index 36f2e1b8cbb1..2576effca845 100644 --- a/drivers/net/tg3.c +++ b/drivers/net/tg3.c | |||
@@ -12433,7 +12433,7 @@ skip_phy_reset: | |||
12433 | 12433 | ||
12434 | static void __devinit tg3_read_partno(struct tg3 *tp) | 12434 | static void __devinit tg3_read_partno(struct tg3 *tp) |
12435 | { | 12435 | { |
12436 | unsigned char vpd_data[256]; /* in little-endian format */ | 12436 | unsigned char vpd_data[TG3_NVM_VPD_LEN]; /* in little-endian format */ |
12437 | unsigned int i; | 12437 | unsigned int i; |
12438 | u32 magic; | 12438 | u32 magic; |
12439 | 12439 | ||
@@ -12442,14 +12442,14 @@ static void __devinit tg3_read_partno(struct tg3 *tp) | |||
12442 | goto out_not_found; | 12442 | goto out_not_found; |
12443 | 12443 | ||
12444 | if (magic == TG3_EEPROM_MAGIC) { | 12444 | if (magic == TG3_EEPROM_MAGIC) { |
12445 | for (i = 0; i < 256; i += 4) { | 12445 | for (i = 0; i < TG3_NVM_VPD_LEN; i += 4) { |
12446 | u32 tmp; | 12446 | u32 tmp; |
12447 | 12447 | ||
12448 | /* The data is in little-endian format in NVRAM. | 12448 | /* The data is in little-endian format in NVRAM. |
12449 | * Use the big-endian read routines to preserve | 12449 | * Use the big-endian read routines to preserve |
12450 | * the byte order as it exists in NVRAM. | 12450 | * the byte order as it exists in NVRAM. |
12451 | */ | 12451 | */ |
12452 | if (tg3_nvram_read_be32(tp, 0x100 + i, &tmp)) | 12452 | if (tg3_nvram_read_be32(tp, TG3_NVM_VPD_OFF + i, &tmp)) |
12453 | goto out_not_found; | 12453 | goto out_not_found; |
12454 | 12454 | ||
12455 | memcpy(&vpd_data[i], &tmp, sizeof(tmp)); | 12455 | memcpy(&vpd_data[i], &tmp, sizeof(tmp)); |
@@ -12458,7 +12458,7 @@ static void __devinit tg3_read_partno(struct tg3 *tp) | |||
12458 | int vpd_cap; | 12458 | int vpd_cap; |
12459 | 12459 | ||
12460 | vpd_cap = pci_find_capability(tp->pdev, PCI_CAP_ID_VPD); | 12460 | vpd_cap = pci_find_capability(tp->pdev, PCI_CAP_ID_VPD); |
12461 | for (i = 0; i < 256; i += 4) { | 12461 | for (i = 0; i < TG3_NVM_VPD_LEN; i += 4) { |
12462 | u32 tmp, j = 0; | 12462 | u32 tmp, j = 0; |
12463 | __le32 v; | 12463 | __le32 v; |
12464 | u16 tmp16; | 12464 | u16 tmp16; |
@@ -12483,7 +12483,7 @@ static void __devinit tg3_read_partno(struct tg3 *tp) | |||
12483 | } | 12483 | } |
12484 | 12484 | ||
12485 | /* Now parse and find the part number. */ | 12485 | /* Now parse and find the part number. */ |
12486 | for (i = 0; i < 254; ) { | 12486 | for (i = 0; i < TG3_NVM_VPD_LEN - 2; ) { |
12487 | unsigned char val = vpd_data[i]; | 12487 | unsigned char val = vpd_data[i]; |
12488 | unsigned int block_end; | 12488 | unsigned int block_end; |
12489 | 12489 | ||
@@ -12502,7 +12502,7 @@ static void __devinit tg3_read_partno(struct tg3 *tp) | |||
12502 | (vpd_data[i + 2] << 8))); | 12502 | (vpd_data[i + 2] << 8))); |
12503 | i += 3; | 12503 | i += 3; |
12504 | 12504 | ||
12505 | if (block_end > 256) | 12505 | if (block_end > TG3_NVM_VPD_LEN) |
12506 | goto out_not_found; | 12506 | goto out_not_found; |
12507 | 12507 | ||
12508 | while (i < (block_end - 2)) { | 12508 | while (i < (block_end - 2)) { |
@@ -12511,7 +12511,8 @@ static void __devinit tg3_read_partno(struct tg3 *tp) | |||
12511 | int partno_len = vpd_data[i + 2]; | 12511 | int partno_len = vpd_data[i + 2]; |
12512 | 12512 | ||
12513 | i += 3; | 12513 | i += 3; |
12514 | if (partno_len > 24 || (partno_len + i) > 256) | 12514 | if (partno_len > TG3_BPN_SIZE || |
12515 | (partno_len + i) > TG3_NVM_VPD_LEN) | ||
12515 | goto out_not_found; | 12516 | goto out_not_found; |
12516 | 12517 | ||
12517 | memcpy(tp->board_part_number, | 12518 | memcpy(tp->board_part_number, |