diff options
author | Matt Carlson <mcarlson@broadcom.com> | 2010-09-15 05:00:00 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2010-09-15 17:16:15 -0400 |
commit | a4a8bb15aed20ff74aa3ca14a4f2c0d62efd8391 (patch) | |
tree | 4bb8ecf2f523b5659877e48fb74a6079d1baf396 /drivers/net/tg3.c | |
parent | 02e96080af2b70313f2ffc8c1b03ae2f9d8c65ac (diff) |
tg3: Dynamically allocate VPD data memory
This patch eases stack pressure by dynamically allocating the memory
used to temporarily store VPD data.
Reviewed-by: Benjamin Li <benli@broadcom.com>
Reviewed-by: Michael Chan <mchan@broadcom.com>
Signed-off-by: Matt Carlson <mcarlson@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, 11 insertions, 4 deletions
diff --git a/drivers/net/tg3.c b/drivers/net/tg3.c index a4fbe4f85ff..0d0deaae5f4 100644 --- a/drivers/net/tg3.c +++ b/drivers/net/tg3.c | |||
@@ -12415,14 +12415,18 @@ skip_phy_reset: | |||
12415 | 12415 | ||
12416 | static void __devinit tg3_read_vpd(struct tg3 *tp) | 12416 | static void __devinit tg3_read_vpd(struct tg3 *tp) |
12417 | { | 12417 | { |
12418 | u8 vpd_data[TG3_NVM_VPD_LEN]; | 12418 | u8 *vpd_data; |
12419 | unsigned int block_end, rosize, len; | 12419 | unsigned int block_end, rosize, len; |
12420 | int j, i = 0; | 12420 | int j, i = 0; |
12421 | u32 magic; | 12421 | u32 magic; |
12422 | 12422 | ||
12423 | if ((tp->tg3_flags3 & TG3_FLG3_NO_NVRAM) || | 12423 | if ((tp->tg3_flags3 & TG3_FLG3_NO_NVRAM) || |
12424 | tg3_nvram_read(tp, 0x0, &magic)) | 12424 | tg3_nvram_read(tp, 0x0, &magic)) |
12425 | goto out_not_found; | 12425 | goto out_no_vpd; |
12426 | |||
12427 | vpd_data = kmalloc(TG3_NVM_VPD_LEN, GFP_KERNEL); | ||
12428 | if (!vpd_data) | ||
12429 | goto out_no_vpd; | ||
12426 | 12430 | ||
12427 | if (magic == TG3_EEPROM_MAGIC) { | 12431 | if (magic == TG3_EEPROM_MAGIC) { |
12428 | for (i = 0; i < TG3_NVM_VPD_LEN; i += 4) { | 12432 | for (i = 0; i < TG3_NVM_VPD_LEN; i += 4) { |
@@ -12506,9 +12510,12 @@ partno: | |||
12506 | 12510 | ||
12507 | memcpy(tp->board_part_number, &vpd_data[i], len); | 12511 | memcpy(tp->board_part_number, &vpd_data[i], len); |
12508 | 12512 | ||
12509 | return; | ||
12510 | |||
12511 | out_not_found: | 12513 | out_not_found: |
12514 | kfree(vpd_data); | ||
12515 | if (!tp->board_part_number[0]) | ||
12516 | return; | ||
12517 | |||
12518 | out_no_vpd: | ||
12512 | if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5906) | 12519 | if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5906) |
12513 | strcpy(tp->board_part_number, "BCM95906"); | 12520 | strcpy(tp->board_part_number, "BCM95906"); |
12514 | else if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_57780 && | 12521 | else if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_57780 && |