diff options
author | Jonas Bonn <jonas@southpole.se> | 2010-06-10 22:47:34 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2010-06-11 16:28:34 -0400 |
commit | c527f81475aaa18123eebe3d72a40a25d8e244af (patch) | |
tree | d71dcb9b809da2e8b3d24ab6e937c5d3e99fae9d /drivers/net/ethoc.c | |
parent | 14599f1e341ee219abdd15f4eee5872d6f2d29f1 (diff) |
ethoc: calculate number of buffers in ethoc_probe
This moves the calculation of the number of transmission buffers to
ethoc_probe where it more logically fits with the rest of the memory
allocation code.
Signed-off-by: Jonas Bonn <jonas@southpole.se>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/ethoc.c')
-rw-r--r-- | drivers/net/ethoc.c | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/drivers/net/ethoc.c b/drivers/net/ethoc.c index 6ed2df14ec84..68093cfa153b 100644 --- a/drivers/net/ethoc.c +++ b/drivers/net/ethoc.c | |||
@@ -658,8 +658,6 @@ static int ethoc_mdio_probe(struct net_device *dev) | |||
658 | static int ethoc_open(struct net_device *dev) | 658 | static int ethoc_open(struct net_device *dev) |
659 | { | 659 | { |
660 | struct ethoc *priv = netdev_priv(dev); | 660 | struct ethoc *priv = netdev_priv(dev); |
661 | unsigned int min_tx = 2; | ||
662 | unsigned int num_bd; | ||
663 | int ret; | 661 | int ret; |
664 | 662 | ||
665 | ret = request_irq(dev->irq, ethoc_interrupt, IRQF_SHARED, | 663 | ret = request_irq(dev->irq, ethoc_interrupt, IRQF_SHARED, |
@@ -667,11 +665,6 @@ static int ethoc_open(struct net_device *dev) | |||
667 | if (ret) | 665 | if (ret) |
668 | return ret; | 666 | return ret; |
669 | 667 | ||
670 | /* calculate the number of TX/RX buffers, maximum 128 supported */ | ||
671 | num_bd = min_t(unsigned int, | ||
672 | 128, (dev->mem_end - dev->mem_start + 1) / ETHOC_BUFSIZ); | ||
673 | priv->num_tx = max(min_tx, num_bd / 4); | ||
674 | priv->num_rx = num_bd - priv->num_tx; | ||
675 | ethoc_write(priv, TX_BD_NUM, priv->num_tx); | 668 | ethoc_write(priv, TX_BD_NUM, priv->num_tx); |
676 | 669 | ||
677 | ethoc_init_ring(priv); | 670 | ethoc_init_ring(priv); |
@@ -884,6 +877,7 @@ static int ethoc_probe(struct platform_device *pdev) | |||
884 | struct resource *mem = NULL; | 877 | struct resource *mem = NULL; |
885 | struct ethoc *priv = NULL; | 878 | struct ethoc *priv = NULL; |
886 | unsigned int phy; | 879 | unsigned int phy; |
880 | int num_bd; | ||
887 | int ret = 0; | 881 | int ret = 0; |
888 | 882 | ||
889 | /* allocate networking device */ | 883 | /* allocate networking device */ |
@@ -978,6 +972,12 @@ static int ethoc_probe(struct platform_device *pdev) | |||
978 | priv->dma_alloc = buffer_size; | 972 | priv->dma_alloc = buffer_size; |
979 | } | 973 | } |
980 | 974 | ||
975 | /* calculate the number of TX/RX buffers, maximum 128 supported */ | ||
976 | num_bd = min_t(unsigned int, | ||
977 | 128, (netdev->mem_end - netdev->mem_start + 1) / ETHOC_BUFSIZ); | ||
978 | priv->num_tx = max(2, num_bd / 4); | ||
979 | priv->num_rx = num_bd - priv->num_tx; | ||
980 | |||
981 | /* Allow the platform setup code to pass in a MAC address. */ | 981 | /* Allow the platform setup code to pass in a MAC address. */ |
982 | if (pdev->dev.platform_data) { | 982 | if (pdev->dev.platform_data) { |
983 | struct ethoc_platform_data *pdata = | 983 | struct ethoc_platform_data *pdata = |