aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEilon Greenstein <eilong@broadcom.com>2009-08-12 04:23:34 -0400
committerDavid S. Miller <davem@davemloft.net>2009-08-13 02:02:50 -0400
commit37f9ce6231cafb2973e09f7f72ad62bc6348d1b3 (patch)
tree1f2c37ef98e3d9528dcf8a215c64de7fcfa0aa2a
parente3553b29c6f395c6692afccc2ed5eff9c3d1daef (diff)
bnx2x: Combine get_pcie_width and get_pcie_speed
The functions bnx2x_get_pcie_width() and bnx2x_get_pcie_speed() were combined into bnx2x_get_pcie_width_speed() so that there is only 1 PCI read to PCICFG_OFFSET + PCICFG_LINK_CONTROL rather then 2 reads. Signed-off-by: Benjamin Li <benli@broadcom.com> Signed-off-by: Eilon Greenstein <eilong@broadcom.com> Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r--drivers/net/bnx2x_main.c34
1 files changed, 16 insertions, 18 deletions
diff --git a/drivers/net/bnx2x_main.c b/drivers/net/bnx2x_main.c
index c289670a55af..807c1565ef80 100644
--- a/drivers/net/bnx2x_main.c
+++ b/drivers/net/bnx2x_main.c
@@ -11671,31 +11671,26 @@ err_out:
11671 return rc; 11671 return rc;
11672} 11672}
11673 11673
11674static int __devinit bnx2x_get_pcie_width(struct bnx2x *bp) 11674static void __devinit bnx2x_get_pcie_width_speed(struct bnx2x *bp,
11675 int *width, int *speed)
11675{ 11676{
11676 u32 val = REG_RD(bp, PCICFG_OFFSET + PCICFG_LINK_CONTROL); 11677 u32 val = REG_RD(bp, PCICFG_OFFSET + PCICFG_LINK_CONTROL);
11677 11678
11678 val = (val & PCICFG_LINK_WIDTH) >> PCICFG_LINK_WIDTH_SHIFT; 11679 *width = (val & PCICFG_LINK_WIDTH) >> PCICFG_LINK_WIDTH_SHIFT;
11679 return val;
11680}
11681
11682/* return value of 1=2.5GHz 2=5GHz */
11683static int __devinit bnx2x_get_pcie_speed(struct bnx2x *bp)
11684{
11685 u32 val = REG_RD(bp, PCICFG_OFFSET + PCICFG_LINK_CONTROL);
11686 11680
11687 val = (val & PCICFG_LINK_SPEED) >> PCICFG_LINK_SPEED_SHIFT; 11681 /* return value of 1=2.5GHz 2=5GHz */
11688 return val; 11682 *speed = (val & PCICFG_LINK_SPEED) >> PCICFG_LINK_SPEED_SHIFT;
11689} 11683}
11684
11690static int __devinit bnx2x_check_firmware(struct bnx2x *bp) 11685static int __devinit bnx2x_check_firmware(struct bnx2x *bp)
11691{ 11686{
11687 const struct firmware *firmware = bp->firmware;
11692 struct bnx2x_fw_file_hdr *fw_hdr; 11688 struct bnx2x_fw_file_hdr *fw_hdr;
11693 struct bnx2x_fw_file_section *sections; 11689 struct bnx2x_fw_file_section *sections;
11694 u16 *ops_offsets;
11695 u32 offset, len, num_ops; 11690 u32 offset, len, num_ops;
11691 u16 *ops_offsets;
11696 int i; 11692 int i;
11697 const struct firmware *firmware = bp->firmware; 11693 const u8 *fw_ver;
11698 const u8 * fw_ver;
11699 11694
11700 if (firmware->size < sizeof(struct bnx2x_fw_file_hdr)) 11695 if (firmware->size < sizeof(struct bnx2x_fw_file_hdr))
11701 return -EINVAL; 11696 return -EINVAL;
@@ -11709,7 +11704,8 @@ static int __devinit bnx2x_check_firmware(struct bnx2x *bp)
11709 offset = be32_to_cpu(sections[i].offset); 11704 offset = be32_to_cpu(sections[i].offset);
11710 len = be32_to_cpu(sections[i].len); 11705 len = be32_to_cpu(sections[i].len);
11711 if (offset + len > firmware->size) { 11706 if (offset + len > firmware->size) {
11712 printk(KERN_ERR PFX "Section %d length is out of bounds\n", i); 11707 printk(KERN_ERR PFX "Section %d length is out of "
11708 "bounds\n", i);
11713 return -EINVAL; 11709 return -EINVAL;
11714 } 11710 }
11715 } 11711 }
@@ -11721,7 +11717,8 @@ static int __devinit bnx2x_check_firmware(struct bnx2x *bp)
11721 11717
11722 for (i = 0; i < be32_to_cpu(fw_hdr->init_ops_offsets.len) / 2; i++) { 11718 for (i = 0; i < be32_to_cpu(fw_hdr->init_ops_offsets.len) / 2; i++) {
11723 if (be16_to_cpu(ops_offsets[i]) > num_ops) { 11719 if (be16_to_cpu(ops_offsets[i]) > num_ops) {
11724 printk(KERN_ERR PFX "Section offset %d is out of bounds\n", i); 11720 printk(KERN_ERR PFX "Section offset %d is out of "
11721 "bounds\n", i);
11725 return -EINVAL; 11722 return -EINVAL;
11726 } 11723 }
11727 } 11724 }
@@ -11878,6 +11875,7 @@ static int __devinit bnx2x_init_one(struct pci_dev *pdev,
11878 static int version_printed; 11875 static int version_printed;
11879 struct net_device *dev = NULL; 11876 struct net_device *dev = NULL;
11880 struct bnx2x *bp; 11877 struct bnx2x *bp;
11878 int pcie_width, pcie_speed;
11881 int rc; 11879 int rc;
11882 11880
11883 if (version_printed++ == 0) 11881 if (version_printed++ == 0)
@@ -11918,11 +11916,11 @@ static int __devinit bnx2x_init_one(struct pci_dev *pdev,
11918 goto init_one_exit; 11916 goto init_one_exit;
11919 } 11917 }
11920 11918
11919 bnx2x_get_pcie_width_speed(bp, &pcie_width, &pcie_speed);
11921 printk(KERN_INFO "%s: %s (%c%d) PCI-E x%d %s found at mem %lx," 11920 printk(KERN_INFO "%s: %s (%c%d) PCI-E x%d %s found at mem %lx,"
11922 " IRQ %d, ", dev->name, board_info[ent->driver_data].name, 11921 " IRQ %d, ", dev->name, board_info[ent->driver_data].name,
11923 (CHIP_REV(bp) >> 12) + 'A', (CHIP_METAL(bp) >> 4), 11922 (CHIP_REV(bp) >> 12) + 'A', (CHIP_METAL(bp) >> 4),
11924 bnx2x_get_pcie_width(bp), 11923 pcie_width, (pcie_speed == 2) ? "5GHz (Gen2)" : "2.5GHz",
11925 (bnx2x_get_pcie_speed(bp) == 2) ? "5GHz (Gen2)" : "2.5GHz",
11926 dev->base_addr, bp->pdev->irq); 11924 dev->base_addr, bp->pdev->irq);
11927 printk(KERN_CONT "node addr %pM\n", dev->dev_addr); 11925 printk(KERN_CONT "node addr %pM\n", dev->dev_addr);
11928 11926