diff mbox series

[net-next,v2,14/17] ethernet: ucc_geth: replace kmalloc_array()+for loop by kcalloc()

Message ID 20210119150802.19997-15-rasmus.villemoes@prevas.dk (mailing list archive)
State Accepted
Commit 33deb13c87e561c3b566c60aede124a5e23981c1
Delegated to: Netdev Maintainers
Headers show
Series ucc_geth improvements | expand

Checks

Context Check Description
netdev/cover_letter success Link
netdev/fixes_present success Link
netdev/patch_count fail Series longer than 15 patches
netdev/tree_selection success Clearly marked for net-next
netdev/subject_prefix success Link
netdev/cc_maintainers warning 1 maintainers not CCed: linuxppc-dev@lists.ozlabs.org
netdev/source_inline success Was 0 now: 0
netdev/verify_signedoff success Link
netdev/module_param success Was 0 now: 0
netdev/build_32bit success Errors and warnings before: 0 this patch: 0
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/verify_fixes success Link
netdev/checkpatch warning WARNING: Missing commit description - Add an appropriate one
netdev/build_allmodconfig_warn success Errors and warnings before: 0 this patch: 0
netdev/header_inline success Link
netdev/stable success Stable not CCed

Commit Message

Rasmus Villemoes Jan. 19, 2021, 3:07 p.m. UTC
Signed-off-by: Rasmus Villemoes <rasmus.villemoes@prevas.dk>
---
 drivers/net/ethernet/freescale/ucc_geth.c | 14 ++++----------
 1 file changed, 4 insertions(+), 10 deletions(-)

Comments

Christophe Leroy Jan. 20, 2021, 7:19 a.m. UTC | #1
Can you detail a bit the change ?

At least tell that the loop was a zeroising loop and that kcalloc() already zeroises the allocated 
memory ?

Le 19/01/2021 à 16:07, Rasmus Villemoes a écrit :
> Signed-off-by: Rasmus Villemoes <rasmus.villemoes@prevas.dk>
> ---
>   drivers/net/ethernet/freescale/ucc_geth.c | 14 ++++----------
>   1 file changed, 4 insertions(+), 10 deletions(-)
> 
> diff --git a/drivers/net/ethernet/freescale/ucc_geth.c b/drivers/net/ethernet/freescale/ucc_geth.c
> index 1e9d2f3f47a3..621a9e3e4b65 100644
> --- a/drivers/net/ethernet/freescale/ucc_geth.c
> +++ b/drivers/net/ethernet/freescale/ucc_geth.c
> @@ -2203,8 +2203,8 @@ 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))
> @@ -2212,9 +2212,6 @@ static int ucc_geth_alloc_tx(struct ucc_geth_private *ugeth)
>   			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++) {
> @@ -2266,8 +2263,8 @@ 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))
> @@ -2275,9 +2272,6 @@ static int ucc_geth_alloc_rx(struct ucc_geth_private *ugeth)
>   			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++) {
>
diff mbox series

Patch

diff --git a/drivers/net/ethernet/freescale/ucc_geth.c b/drivers/net/ethernet/freescale/ucc_geth.c
index 1e9d2f3f47a3..621a9e3e4b65 100644
--- a/drivers/net/ethernet/freescale/ucc_geth.c
+++ b/drivers/net/ethernet/freescale/ucc_geth.c
@@ -2203,8 +2203,8 @@  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))
@@ -2212,9 +2212,6 @@  static int ucc_geth_alloc_tx(struct ucc_geth_private *ugeth)
 			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++) {
@@ -2266,8 +2263,8 @@  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))
@@ -2275,9 +2272,6 @@  static int ucc_geth_alloc_rx(struct ucc_geth_private *ugeth)
 			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++) {