aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/ll_temac_main.c
diff options
context:
space:
mode:
authorDenis Kirjanov <dkirjanov@hera.kernel.org>2010-06-30 19:39:05 -0400
committerDavid S. Miller <davem@davemloft.net>2010-07-02 01:45:53 -0400
commitfe62c298e5bcff8b3414205b7b54975918b3b5c4 (patch)
tree6c1cb2b694ce4b29ec8963929609ae3a9377c0f1 /drivers/net/ll_temac_main.c
parentee3cb6295144b0adfa75ccaca307643a6998b1e2 (diff)
ll_temac: add error checking to DMA init path
Add error checking to DMA descriptor rings initialization code. Signed-off-by: Denis Kirjanov <dkirjanov@kernel.org> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/ll_temac_main.c')
-rw-r--r--drivers/net/ll_temac_main.c25
1 files changed, 23 insertions, 2 deletions
diff --git a/drivers/net/ll_temac_main.c b/drivers/net/ll_temac_main.c
index 52dcc8495647..7b12d0e8f4bd 100644
--- a/drivers/net/ll_temac_main.c
+++ b/drivers/net/ll_temac_main.c
@@ -202,14 +202,29 @@ static int temac_dma_bd_init(struct net_device *ndev)
202 int i; 202 int i;
203 203
204 lp->rx_skb = kzalloc(sizeof(*lp->rx_skb) * RX_BD_NUM, GFP_KERNEL); 204 lp->rx_skb = kzalloc(sizeof(*lp->rx_skb) * RX_BD_NUM, GFP_KERNEL);
205 if (!lp->rx_skb) {
206 dev_err(&ndev->dev,
207 "can't allocate memory for DMA RX buffer\n");
208 goto out;
209 }
205 /* allocate the tx and rx ring buffer descriptors. */ 210 /* allocate the tx and rx ring buffer descriptors. */
206 /* returns a virtual addres and a physical address. */ 211 /* returns a virtual addres and a physical address. */
207 lp->tx_bd_v = dma_alloc_coherent(ndev->dev.parent, 212 lp->tx_bd_v = dma_alloc_coherent(ndev->dev.parent,
208 sizeof(*lp->tx_bd_v) * TX_BD_NUM, 213 sizeof(*lp->tx_bd_v) * TX_BD_NUM,
209 &lp->tx_bd_p, GFP_KERNEL); 214 &lp->tx_bd_p, GFP_KERNEL);
215 if (!lp->tx_bd_v) {
216 dev_err(&ndev->dev,
217 "unable to allocate DMA TX buffer descriptors");
218 goto out;
219 }
210 lp->rx_bd_v = dma_alloc_coherent(ndev->dev.parent, 220 lp->rx_bd_v = dma_alloc_coherent(ndev->dev.parent,
211 sizeof(*lp->rx_bd_v) * RX_BD_NUM, 221 sizeof(*lp->rx_bd_v) * RX_BD_NUM,
212 &lp->rx_bd_p, GFP_KERNEL); 222 &lp->rx_bd_p, GFP_KERNEL);
223 if (!lp->rx_bd_v) {
224 dev_err(&ndev->dev,
225 "unable to allocate DMA RX buffer descriptors");
226 goto out;
227 }
213 228
214 memset(lp->tx_bd_v, 0, sizeof(*lp->tx_bd_v) * TX_BD_NUM); 229 memset(lp->tx_bd_v, 0, sizeof(*lp->tx_bd_v) * TX_BD_NUM);
215 for (i = 0; i < TX_BD_NUM; i++) { 230 for (i = 0; i < TX_BD_NUM; i++) {
@@ -227,7 +242,7 @@ static int temac_dma_bd_init(struct net_device *ndev)
227 242
228 if (skb == 0) { 243 if (skb == 0) {
229 dev_err(&ndev->dev, "alloc_skb error %d\n", i); 244 dev_err(&ndev->dev, "alloc_skb error %d\n", i);
230 return -1; 245 goto out;
231 } 246 }
232 lp->rx_skb[i] = skb; 247 lp->rx_skb[i] = skb;
233 /* returns physical address of skb->data */ 248 /* returns physical address of skb->data */
@@ -258,6 +273,9 @@ static int temac_dma_bd_init(struct net_device *ndev)
258 lp->dma_out(lp, TX_CURDESC_PTR, lp->tx_bd_p); 273 lp->dma_out(lp, TX_CURDESC_PTR, lp->tx_bd_p);
259 274
260 return 0; 275 return 0;
276
277out:
278 return -ENOMEM;
261} 279}
262 280
263/* --------------------------------------------------------------------- 281/* ---------------------------------------------------------------------
@@ -505,7 +523,10 @@ static void temac_device_reset(struct net_device *ndev)
505 } 523 }
506 lp->dma_out(lp, DMA_CONTROL_REG, DMA_TAIL_ENABLE); 524 lp->dma_out(lp, DMA_CONTROL_REG, DMA_TAIL_ENABLE);
507 525
508 temac_dma_bd_init(ndev); 526 if (temac_dma_bd_init(ndev)) {
527 dev_err(&ndev->dev,
528 "temac_device_reset descriptor allocation failed\n");
529 }
509 530
510 temac_indirect_out32(lp, XTE_RXC0_OFFSET, 0); 531 temac_indirect_out32(lp, XTE_RXC0_OFFSET, 0);
511 temac_indirect_out32(lp, XTE_RXC1_OFFSET, 0); 532 temac_indirect_out32(lp, XTE_RXC1_OFFSET, 0);