e1000: Use kcalloc()
Replace kmalloc+memsetout the driver. Slightly modified by Auke Kok. Signed-off-by: Yan Burman <burman.yan@gmail.com> Signed-off-by: Auke Kok <auke-jan.h.kok@intel.com> Signed-off-by: Jeff Garzik <jeff@garzik.org>
This commit is contained in:
@@ -1354,31 +1354,27 @@ e1000_sw_init(struct e1000_adapter *adapter)
|
||||
static int __devinit
|
||||
e1000_alloc_queues(struct e1000_adapter *adapter)
|
||||
{
|
||||
int size;
|
||||
|
||||
size = sizeof(struct e1000_tx_ring) * adapter->num_tx_queues;
|
||||
adapter->tx_ring = kmalloc(size, GFP_KERNEL);
|
||||
adapter->tx_ring = kcalloc(adapter->num_tx_queues,
|
||||
sizeof(struct e1000_tx_ring), GFP_KERNEL);
|
||||
if (!adapter->tx_ring)
|
||||
return -ENOMEM;
|
||||
memset(adapter->tx_ring, 0, size);
|
||||
|
||||
size = sizeof(struct e1000_rx_ring) * adapter->num_rx_queues;
|
||||
adapter->rx_ring = kmalloc(size, GFP_KERNEL);
|
||||
adapter->rx_ring = kcalloc(adapter->num_rx_queues,
|
||||
sizeof(struct e1000_rx_ring), GFP_KERNEL);
|
||||
if (!adapter->rx_ring) {
|
||||
kfree(adapter->tx_ring);
|
||||
return -ENOMEM;
|
||||
}
|
||||
memset(adapter->rx_ring, 0, size);
|
||||
|
||||
#ifdef CONFIG_E1000_NAPI
|
||||
size = sizeof(struct net_device) * adapter->num_rx_queues;
|
||||
adapter->polling_netdev = kmalloc(size, GFP_KERNEL);
|
||||
adapter->polling_netdev = kcalloc(adapter->num_rx_queues,
|
||||
sizeof(struct net_device),
|
||||
GFP_KERNEL);
|
||||
if (!adapter->polling_netdev) {
|
||||
kfree(adapter->tx_ring);
|
||||
kfree(adapter->rx_ring);
|
||||
return -ENOMEM;
|
||||
}
|
||||
memset(adapter->polling_netdev, 0, size);
|
||||
#endif
|
||||
|
||||
return E1000_SUCCESS;
|
||||
@@ -1774,18 +1770,18 @@ e1000_setup_rx_resources(struct e1000_adapter *adapter,
|
||||
}
|
||||
memset(rxdr->buffer_info, 0, size);
|
||||
|
||||
size = sizeof(struct e1000_ps_page) * rxdr->count;
|
||||
rxdr->ps_page = kmalloc(size, GFP_KERNEL);
|
||||
rxdr->ps_page = kcalloc(rxdr->count, sizeof(struct e1000_ps_page),
|
||||
GFP_KERNEL);
|
||||
if (!rxdr->ps_page) {
|
||||
vfree(rxdr->buffer_info);
|
||||
DPRINTK(PROBE, ERR,
|
||||
"Unable to allocate memory for the receive descriptor ring\n");
|
||||
return -ENOMEM;
|
||||
}
|
||||
memset(rxdr->ps_page, 0, size);
|
||||
|
||||
size = sizeof(struct e1000_ps_page_dma) * rxdr->count;
|
||||
rxdr->ps_page_dma = kmalloc(size, GFP_KERNEL);
|
||||
rxdr->ps_page_dma = kcalloc(rxdr->count,
|
||||
sizeof(struct e1000_ps_page_dma),
|
||||
GFP_KERNEL);
|
||||
if (!rxdr->ps_page_dma) {
|
||||
vfree(rxdr->buffer_info);
|
||||
kfree(rxdr->ps_page);
|
||||
@@ -1793,7 +1789,6 @@ e1000_setup_rx_resources(struct e1000_adapter *adapter,
|
||||
"Unable to allocate memory for the receive descriptor ring\n");
|
||||
return -ENOMEM;
|
||||
}
|
||||
memset(rxdr->ps_page_dma, 0, size);
|
||||
|
||||
if (adapter->hw.mac_type <= e1000_82547_rev_2)
|
||||
desc_len = sizeof(struct e1000_rx_desc);
|
||||
|
Reference in New Issue
Block a user