diff options
author | Petri Gynther <pgynther@google.com> | 2015-03-25 15:35:11 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2015-03-27 17:26:13 -0400 |
commit | ebbd96fb2861f591df011cd0eac67dd367596cca (patch) | |
tree | 13f882e9dd5d369747dd07424cd8e6828246b056 /drivers | |
parent | 9dbac28fc193e3972f566f120dce67d69a1df634 (diff) |
net: bcmgenet: simplify bcmgenet_init_dma()
Do the two kcalloc() calls first, before proceeding into Rx/Tx DMA init.
Makes the error case handling much simpler.
Signed-off-by: Petri Gynther <pgynther@google.com>
Reviewed-by: Florian Fainelli <f.fainelli@gmail.com>
Reviewed-by: Jaedon Shin <jaedon.shin@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/net/ethernet/broadcom/genet/bcmgenet.c | 33 |
1 files changed, 17 insertions, 16 deletions
diff --git a/drivers/net/ethernet/broadcom/genet/bcmgenet.c b/drivers/net/ethernet/broadcom/genet/bcmgenet.c index 550bf98d0730..1c9f9b418c52 100644 --- a/drivers/net/ethernet/broadcom/genet/bcmgenet.c +++ b/drivers/net/ethernet/broadcom/genet/bcmgenet.c | |||
@@ -2050,9 +2050,6 @@ static int bcmgenet_init_dma(struct bcmgenet_priv *priv) | |||
2050 | 2050 | ||
2051 | netif_dbg(priv, hw, priv->dev, "%s\n", __func__); | 2051 | netif_dbg(priv, hw, priv->dev, "%s\n", __func__); |
2052 | 2052 | ||
2053 | /* Init rDma */ | ||
2054 | bcmgenet_rdma_writel(priv, DMA_MAX_BURST_LENGTH, DMA_SCB_BURST_SIZE); | ||
2055 | |||
2056 | /* Initialize common Rx ring structures */ | 2053 | /* Initialize common Rx ring structures */ |
2057 | priv->rx_bds = priv->base + priv->hw_params->rdma_offset; | 2054 | priv->rx_bds = priv->base + priv->hw_params->rdma_offset; |
2058 | priv->num_rx_bds = TOTAL_DESC; | 2055 | priv->num_rx_bds = TOTAL_DESC; |
@@ -2066,25 +2063,13 @@ static int bcmgenet_init_dma(struct bcmgenet_priv *priv) | |||
2066 | cb->bd_addr = priv->rx_bds + i * DMA_DESC_SIZE; | 2063 | cb->bd_addr = priv->rx_bds + i * DMA_DESC_SIZE; |
2067 | } | 2064 | } |
2068 | 2065 | ||
2069 | /* Initialize Rx queues */ | ||
2070 | ret = bcmgenet_init_rx_queues(priv->dev); | ||
2071 | if (ret) { | ||
2072 | netdev_err(priv->dev, "failed to initialize Rx queues\n"); | ||
2073 | bcmgenet_free_rx_buffers(priv); | ||
2074 | kfree(priv->rx_cbs); | ||
2075 | return ret; | ||
2076 | } | ||
2077 | |||
2078 | /* Init tDma */ | ||
2079 | bcmgenet_tdma_writel(priv, DMA_MAX_BURST_LENGTH, DMA_SCB_BURST_SIZE); | ||
2080 | |||
2081 | /* Initialize common TX ring structures */ | 2066 | /* Initialize common TX ring structures */ |
2082 | priv->tx_bds = priv->base + priv->hw_params->tdma_offset; | 2067 | priv->tx_bds = priv->base + priv->hw_params->tdma_offset; |
2083 | priv->num_tx_bds = TOTAL_DESC; | 2068 | priv->num_tx_bds = TOTAL_DESC; |
2084 | priv->tx_cbs = kcalloc(priv->num_tx_bds, sizeof(struct enet_cb), | 2069 | priv->tx_cbs = kcalloc(priv->num_tx_bds, sizeof(struct enet_cb), |
2085 | GFP_KERNEL); | 2070 | GFP_KERNEL); |
2086 | if (!priv->tx_cbs) { | 2071 | if (!priv->tx_cbs) { |
2087 | __bcmgenet_fini_dma(priv); | 2072 | kfree(priv->rx_cbs); |
2088 | return -ENOMEM; | 2073 | return -ENOMEM; |
2089 | } | 2074 | } |
2090 | 2075 | ||
@@ -2093,6 +2078,22 @@ static int bcmgenet_init_dma(struct bcmgenet_priv *priv) | |||
2093 | cb->bd_addr = priv->tx_bds + i * DMA_DESC_SIZE; | 2078 | cb->bd_addr = priv->tx_bds + i * DMA_DESC_SIZE; |
2094 | } | 2079 | } |
2095 | 2080 | ||
2081 | /* Init rDma */ | ||
2082 | bcmgenet_rdma_writel(priv, DMA_MAX_BURST_LENGTH, DMA_SCB_BURST_SIZE); | ||
2083 | |||
2084 | /* Initialize Rx queues */ | ||
2085 | ret = bcmgenet_init_rx_queues(priv->dev); | ||
2086 | if (ret) { | ||
2087 | netdev_err(priv->dev, "failed to initialize Rx queues\n"); | ||
2088 | bcmgenet_free_rx_buffers(priv); | ||
2089 | kfree(priv->rx_cbs); | ||
2090 | kfree(priv->tx_cbs); | ||
2091 | return ret; | ||
2092 | } | ||
2093 | |||
2094 | /* Init tDma */ | ||
2095 | bcmgenet_tdma_writel(priv, DMA_MAX_BURST_LENGTH, DMA_SCB_BURST_SIZE); | ||
2096 | |||
2096 | /* Initialize Tx queues */ | 2097 | /* Initialize Tx queues */ |
2097 | bcmgenet_init_tx_queues(priv->dev); | 2098 | bcmgenet_init_tx_queues(priv->dev); |
2098 | 2099 | ||