[PATCH] pcnet32: Use kcalloc instead of kmalloc and memset
On 2006-03-08 Eric Sesterhenn wrote: converts drivers/net to kzalloc usage. Don Fry modified it to use netif_msg_drv. Tested ia32 and ppc64. Signed-off-by: Eric Sesterhenn <snakebyte@gmx.de> Signed-off-by: Don Fry <brazilnut@us.ibm.com> Signed-off-by: Jeff Garzik <jeff@garzik.org>
This commit is contained in:
parent
6dcd60c2c7
commit
12fa30f35b
1 changed files with 10 additions and 14 deletions
|
@ -1432,7 +1432,7 @@ static int pcnet32_alloc_ring(struct net_device *dev, char *name)
|
||||||
lp->tx_ring_size,
|
lp->tx_ring_size,
|
||||||
&lp->tx_ring_dma_addr);
|
&lp->tx_ring_dma_addr);
|
||||||
if (lp->tx_ring == NULL) {
|
if (lp->tx_ring == NULL) {
|
||||||
if (pcnet32_debug & NETIF_MSG_DRV)
|
if (netif_msg_drv(lp))
|
||||||
printk("\n" KERN_ERR PFX
|
printk("\n" KERN_ERR PFX
|
||||||
"%s: Consistent memory allocation failed.\n",
|
"%s: Consistent memory allocation failed.\n",
|
||||||
name);
|
name);
|
||||||
|
@ -1444,52 +1444,48 @@ static int pcnet32_alloc_ring(struct net_device *dev, char *name)
|
||||||
lp->rx_ring_size,
|
lp->rx_ring_size,
|
||||||
&lp->rx_ring_dma_addr);
|
&lp->rx_ring_dma_addr);
|
||||||
if (lp->rx_ring == NULL) {
|
if (lp->rx_ring == NULL) {
|
||||||
if (pcnet32_debug & NETIF_MSG_DRV)
|
if (netif_msg_drv(lp))
|
||||||
printk("\n" KERN_ERR PFX
|
printk("\n" KERN_ERR PFX
|
||||||
"%s: Consistent memory allocation failed.\n",
|
"%s: Consistent memory allocation failed.\n",
|
||||||
name);
|
name);
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
}
|
}
|
||||||
|
|
||||||
lp->tx_dma_addr = kmalloc(sizeof(dma_addr_t) * lp->tx_ring_size,
|
lp->tx_dma_addr = kcalloc(lp->tx_ring_size, sizeof(dma_addr_t),
|
||||||
GFP_ATOMIC);
|
GFP_ATOMIC);
|
||||||
if (!lp->tx_dma_addr) {
|
if (!lp->tx_dma_addr) {
|
||||||
if (pcnet32_debug & NETIF_MSG_DRV)
|
if (netif_msg_drv(lp))
|
||||||
printk("\n" KERN_ERR PFX
|
printk("\n" KERN_ERR PFX
|
||||||
"%s: Memory allocation failed.\n", name);
|
"%s: Memory allocation failed.\n", name);
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
}
|
}
|
||||||
memset(lp->tx_dma_addr, 0, sizeof(dma_addr_t) * lp->tx_ring_size);
|
|
||||||
|
|
||||||
lp->rx_dma_addr = kmalloc(sizeof(dma_addr_t) * lp->rx_ring_size,
|
lp->rx_dma_addr = kcalloc(lp->rx_ring_size, sizeof(dma_addr_t),
|
||||||
GFP_ATOMIC);
|
GFP_ATOMIC);
|
||||||
if (!lp->rx_dma_addr) {
|
if (!lp->rx_dma_addr) {
|
||||||
if (pcnet32_debug & NETIF_MSG_DRV)
|
if (netif_msg_drv(lp))
|
||||||
printk("\n" KERN_ERR PFX
|
printk("\n" KERN_ERR PFX
|
||||||
"%s: Memory allocation failed.\n", name);
|
"%s: Memory allocation failed.\n", name);
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
}
|
}
|
||||||
memset(lp->rx_dma_addr, 0, sizeof(dma_addr_t) * lp->rx_ring_size);
|
|
||||||
|
|
||||||
lp->tx_skbuff = kmalloc(sizeof(struct sk_buff *) * lp->tx_ring_size,
|
lp->tx_skbuff = kcalloc(lp->tx_ring_size, sizeof(struct sk_buff *),
|
||||||
GFP_ATOMIC);
|
GFP_ATOMIC);
|
||||||
if (!lp->tx_skbuff) {
|
if (!lp->tx_skbuff) {
|
||||||
if (pcnet32_debug & NETIF_MSG_DRV)
|
if (netif_msg_drv(lp))
|
||||||
printk("\n" KERN_ERR PFX
|
printk("\n" KERN_ERR PFX
|
||||||
"%s: Memory allocation failed.\n", name);
|
"%s: Memory allocation failed.\n", name);
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
}
|
}
|
||||||
memset(lp->tx_skbuff, 0, sizeof(struct sk_buff *) * lp->tx_ring_size);
|
|
||||||
|
|
||||||
lp->rx_skbuff = kmalloc(sizeof(struct sk_buff *) * lp->rx_ring_size,
|
lp->rx_skbuff = kcalloc(lp->rx_ring_size, sizeof(struct sk_buff *),
|
||||||
GFP_ATOMIC);
|
GFP_ATOMIC);
|
||||||
if (!lp->rx_skbuff) {
|
if (!lp->rx_skbuff) {
|
||||||
if (pcnet32_debug & NETIF_MSG_DRV)
|
if (netif_msg_drv(lp))
|
||||||
printk("\n" KERN_ERR PFX
|
printk("\n" KERN_ERR PFX
|
||||||
"%s: Memory allocation failed.\n", name);
|
"%s: Memory allocation failed.\n", name);
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
}
|
}
|
||||||
memset(lp->rx_skbuff, 0, sizeof(struct sk_buff *) * lp->rx_ring_size);
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue