diff options
author | Brice Goglin <brice@myri.com> | 2008-11-20 04:50:28 -0500 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2008-11-20 04:50:28 -0500 |
commit | 00b5e50549aa9da770f1161907b4ed68aa4ece3a (patch) | |
tree | 55065e4764799ed9294354cfcdc1a74f6edb5aa1 | |
parent | d6279c88f246adf94b7f7a014c5f19d527bc785b (diff) |
myri10ge: remove hardcoded sram_size
Removes the use of a hardcoded sram_size, determine string_spec
location from the MCP header instead.
Signed-off-by: Brice Goglin <brice@myri.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r-- | drivers/net/myri10ge/myri10ge.c | 23 |
1 files changed, 13 insertions, 10 deletions
diff --git a/drivers/net/myri10ge/myri10ge.c b/drivers/net/myri10ge/myri10ge.c index cd856d7ce9f1..c724d96fd1e5 100644 --- a/drivers/net/myri10ge/myri10ge.c +++ b/drivers/net/myri10ge/myri10ge.c | |||
@@ -3739,6 +3739,7 @@ static int myri10ge_probe(struct pci_dev *pdev, const struct pci_device_id *ent) | |||
3739 | int i; | 3739 | int i; |
3740 | int status = -ENXIO; | 3740 | int status = -ENXIO; |
3741 | int dac_enabled; | 3741 | int dac_enabled; |
3742 | unsigned hdr_offset, ss_offset; | ||
3742 | 3743 | ||
3743 | netdev = alloc_etherdev_mq(sizeof(*mgp), MYRI10GE_MAX_SLICES); | 3744 | netdev = alloc_etherdev_mq(sizeof(*mgp), MYRI10GE_MAX_SLICES); |
3744 | if (netdev == NULL) { | 3745 | if (netdev == NULL) { |
@@ -3806,14 +3807,6 @@ static int myri10ge_probe(struct pci_dev *pdev, const struct pci_device_id *ent) | |||
3806 | if (mgp->mtrr >= 0) | 3807 | if (mgp->mtrr >= 0) |
3807 | mgp->wc_enabled = 1; | 3808 | mgp->wc_enabled = 1; |
3808 | #endif | 3809 | #endif |
3809 | /* Hack. need to get rid of these magic numbers */ | ||
3810 | mgp->sram_size = | ||
3811 | 2 * 1024 * 1024 - (2 * (48 * 1024) + (32 * 1024)) - 0x100; | ||
3812 | if (mgp->sram_size > mgp->board_span) { | ||
3813 | dev_err(&pdev->dev, "board span %ld bytes too small\n", | ||
3814 | mgp->board_span); | ||
3815 | goto abort_with_mtrr; | ||
3816 | } | ||
3817 | mgp->sram = ioremap_wc(mgp->iomem_base, mgp->board_span); | 3810 | mgp->sram = ioremap_wc(mgp->iomem_base, mgp->board_span); |
3818 | if (mgp->sram == NULL) { | 3811 | if (mgp->sram == NULL) { |
3819 | dev_err(&pdev->dev, "ioremap failed for %ld bytes at 0x%lx\n", | 3812 | dev_err(&pdev->dev, "ioremap failed for %ld bytes at 0x%lx\n", |
@@ -3821,9 +3814,19 @@ static int myri10ge_probe(struct pci_dev *pdev, const struct pci_device_id *ent) | |||
3821 | status = -ENXIO; | 3814 | status = -ENXIO; |
3822 | goto abort_with_mtrr; | 3815 | goto abort_with_mtrr; |
3823 | } | 3816 | } |
3817 | hdr_offset = | ||
3818 | ntohl(__raw_readl(mgp->sram + MCP_HEADER_PTR_OFFSET)) & 0xffffc; | ||
3819 | ss_offset = hdr_offset + offsetof(struct mcp_gen_header, string_specs); | ||
3820 | mgp->sram_size = ntohl(__raw_readl(mgp->sram + ss_offset)); | ||
3821 | if (mgp->sram_size > mgp->board_span || | ||
3822 | mgp->sram_size <= MYRI10GE_FW_OFFSET) { | ||
3823 | dev_err(&pdev->dev, | ||
3824 | "invalid sram_size %dB or board span %ldB\n", | ||
3825 | mgp->sram_size, mgp->board_span); | ||
3826 | goto abort_with_ioremap; | ||
3827 | } | ||
3824 | memcpy_fromio(mgp->eeprom_strings, | 3828 | memcpy_fromio(mgp->eeprom_strings, |
3825 | mgp->sram + mgp->sram_size - MYRI10GE_EEPROM_STRINGS_SIZE, | 3829 | mgp->sram + mgp->sram_size, MYRI10GE_EEPROM_STRINGS_SIZE); |
3826 | MYRI10GE_EEPROM_STRINGS_SIZE); | ||
3827 | memset(mgp->eeprom_strings + MYRI10GE_EEPROM_STRINGS_SIZE - 2, 0, 2); | 3830 | memset(mgp->eeprom_strings + MYRI10GE_EEPROM_STRINGS_SIZE - 2, 0, 2); |
3828 | status = myri10ge_read_mac_addr(mgp); | 3831 | status = myri10ge_read_mac_addr(mgp); |
3829 | if (status) | 3832 | if (status) |