diff options
Diffstat (limited to 'drivers/net')
-rw-r--r-- | drivers/net/ethoc.c | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/drivers/net/ethoc.c b/drivers/net/ethoc.c index 93b50d674b1e..b79d7e1555d5 100644 --- a/drivers/net/ethoc.c +++ b/drivers/net/ethoc.c | |||
@@ -412,7 +412,7 @@ static int ethoc_rx(struct net_device *dev, int limit) | |||
412 | unsigned int entry; | 412 | unsigned int entry; |
413 | struct ethoc_bd bd; | 413 | struct ethoc_bd bd; |
414 | 414 | ||
415 | entry = priv->num_tx + (priv->cur_rx % priv->num_rx); | 415 | entry = priv->num_tx + priv->cur_rx; |
416 | ethoc_read_bd(priv, entry, &bd); | 416 | ethoc_read_bd(priv, entry, &bd); |
417 | if (bd.stat & RX_BD_EMPTY) { | 417 | if (bd.stat & RX_BD_EMPTY) { |
418 | ethoc_ack_irq(priv, INT_MASK_RX); | 418 | ethoc_ack_irq(priv, INT_MASK_RX); |
@@ -456,7 +456,8 @@ static int ethoc_rx(struct net_device *dev, int limit) | |||
456 | bd.stat &= ~RX_BD_STATS; | 456 | bd.stat &= ~RX_BD_STATS; |
457 | bd.stat |= RX_BD_EMPTY; | 457 | bd.stat |= RX_BD_EMPTY; |
458 | ethoc_write_bd(priv, entry, &bd); | 458 | ethoc_write_bd(priv, entry, &bd); |
459 | priv->cur_rx++; | 459 | if (++priv->cur_rx == priv->num_rx) |
460 | priv->cur_rx = 0; | ||
460 | } | 461 | } |
461 | 462 | ||
462 | return count; | 463 | return count; |
@@ -503,7 +504,7 @@ static int ethoc_tx(struct net_device *dev, int limit) | |||
503 | for (count = 0; count < limit; ++count) { | 504 | for (count = 0; count < limit; ++count) { |
504 | unsigned int entry; | 505 | unsigned int entry; |
505 | 506 | ||
506 | entry = priv->dty_tx % priv->num_tx; | 507 | entry = priv->dty_tx & (priv->num_tx-1); |
507 | 508 | ||
508 | ethoc_read_bd(priv, entry, &bd); | 509 | ethoc_read_bd(priv, entry, &bd); |
509 | 510 | ||
@@ -1000,9 +1001,17 @@ static int __devinit ethoc_probe(struct platform_device *pdev) | |||
1000 | /* calculate the number of TX/RX buffers, maximum 128 supported */ | 1001 | /* calculate the number of TX/RX buffers, maximum 128 supported */ |
1001 | num_bd = min_t(unsigned int, | 1002 | num_bd = min_t(unsigned int, |
1002 | 128, (netdev->mem_end - netdev->mem_start + 1) / ETHOC_BUFSIZ); | 1003 | 128, (netdev->mem_end - netdev->mem_start + 1) / ETHOC_BUFSIZ); |
1003 | priv->num_tx = max(2, num_bd / 4); | 1004 | if (num_bd < 4) { |
1005 | ret = -ENODEV; | ||
1006 | goto error; | ||
1007 | } | ||
1008 | /* num_tx must be a power of two */ | ||
1009 | priv->num_tx = rounddown_pow_of_two(num_bd >> 1); | ||
1004 | priv->num_rx = num_bd - priv->num_tx; | 1010 | priv->num_rx = num_bd - priv->num_tx; |
1005 | 1011 | ||
1012 | dev_dbg(&pdev->dev, "ethoc: num_tx: %d num_rx: %d\n", | ||
1013 | priv->num_tx, priv->num_rx); | ||
1014 | |||
1006 | priv->vma = devm_kzalloc(&pdev->dev, num_bd*sizeof(void*), GFP_KERNEL); | 1015 | priv->vma = devm_kzalloc(&pdev->dev, num_bd*sizeof(void*), GFP_KERNEL); |
1007 | if (!priv->vma) { | 1016 | if (!priv->vma) { |
1008 | ret = -ENOMEM; | 1017 | ret = -ENOMEM; |