Skip to content

Commit

Permalink
ethernet: ucc_geth: replace kmalloc_array()+for loop by kcalloc()
Browse files Browse the repository at this point in the history
Signed-off-by: Rasmus Villemoes <rasmus.villemoes@prevas.dk>
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
  • Loading branch information
Rasmus Villemoes authored and Jakub Kicinski committed Jan 21, 2021
1 parent 64a99fe commit 33deb13
Showing 1 changed file with 4 additions and 10 deletions.
14 changes: 4 additions & 10 deletions drivers/net/ethernet/freescale/ucc_geth.c
Original file line number Diff line number Diff line change
Expand Up @@ -2203,18 +2203,15 @@ static int ucc_geth_alloc_tx(struct ucc_geth_private *ugeth)
for (j = 0; j < ug_info->numQueuesTx; j++) {
/* Setup the skbuff rings */
ugeth->tx_skbuff[j] =
kmalloc_array(ugeth->ug_info->bdRingLenTx[j],
sizeof(struct sk_buff *), GFP_KERNEL);
kcalloc(ugeth->ug_info->bdRingLenTx[j],
sizeof(struct sk_buff *), GFP_KERNEL);

if (ugeth->tx_skbuff[j] == NULL) {
if (netif_msg_ifup(ugeth))
pr_err("Could not allocate tx_skbuff\n");
return -ENOMEM;
}

for (i = 0; i < ugeth->ug_info->bdRingLenTx[j]; i++)
ugeth->tx_skbuff[j][i] = NULL;

ugeth->skb_curtx[j] = ugeth->skb_dirtytx[j] = 0;
bd = ugeth->confBd[j] = ugeth->txBd[j] = ugeth->p_tx_bd_ring[j];
for (i = 0; i < ug_info->bdRingLenTx[j]; i++) {
Expand Down Expand Up @@ -2266,18 +2263,15 @@ static int ucc_geth_alloc_rx(struct ucc_geth_private *ugeth)
for (j = 0; j < ug_info->numQueuesRx; j++) {
/* Setup the skbuff rings */
ugeth->rx_skbuff[j] =
kmalloc_array(ugeth->ug_info->bdRingLenRx[j],
sizeof(struct sk_buff *), GFP_KERNEL);
kcalloc(ugeth->ug_info->bdRingLenRx[j],
sizeof(struct sk_buff *), GFP_KERNEL);

if (ugeth->rx_skbuff[j] == NULL) {
if (netif_msg_ifup(ugeth))
pr_err("Could not allocate rx_skbuff\n");
return -ENOMEM;
}

for (i = 0; i < ugeth->ug_info->bdRingLenRx[j]; i++)
ugeth->rx_skbuff[j][i] = NULL;

ugeth->skb_currx[j] = 0;
bd = ugeth->rxBd[j] = ugeth->p_rx_bd_ring[j];
for (i = 0; i < ug_info->bdRingLenRx[j]; i++) {
Expand Down

0 comments on commit 33deb13

Please sign in to comment.