From nobody Sat Jun 27 19:56:06 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 320DFC43217 for ; Fri, 18 Feb 2022 17:47:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234902AbiBRRrP (ORCPT ); Fri, 18 Feb 2022 12:47:15 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:45302 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232849AbiBRRrM (ORCPT ); Fri, 18 Feb 2022 12:47:12 -0500 Received: from smtp.smtpout.orange.fr (smtp01.smtpout.orange.fr [80.12.242.123]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E684D275DE for ; Fri, 18 Feb 2022 09:46:55 -0800 (PST) Received: from pop-os.home ([90.126.236.122]) by smtp.orange.fr with ESMTPA id L7LJnWEKdFTgbL7LKniDHC; Fri, 18 Feb 2022 18:46:54 +0100 X-ME-Helo: pop-os.home X-ME-Auth: YWZlNiIxYWMyZDliZWIzOTcwYTEyYzlhMmU3ZiQ1M2U2MzfzZDfyZTMxZTBkMTYyNDBjNDJlZmQ3ZQ== X-ME-Date: Fri, 18 Feb 2022 18:46:54 +0100 X-ME-IP: 90.126.236.122 From: Christophe JAILLET To: Chas Williams <3chas3@gmail.com> Cc: linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org, Christophe JAILLET , linux-atm-general@lists.sourceforge.net, netdev@vger.kernel.org Subject: [PATCH] atm: nicstar: Use kcalloc() to simplify code Date: Fri, 18 Feb 2022 18:46:51 +0100 Message-Id: <68ec8438f31b1034b37b21a6c1b6c3de195b8adf.1645206403.git.christophe.jaillet@wanadoo.fr> X-Mailer: git-send-email 2.32.0 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" Use kcalloc() instead of kmalloc_array() and a loop to set all the values of the array to NULL. While at it, remove a duplicated assignment to 'scq->num_entries'. Signed-off-by: Christophe JAILLET --- drivers/atm/nicstar.c | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/drivers/atm/nicstar.c b/drivers/atm/nicstar.c index bc5a6ab6fa4b..1a50de39f5b5 100644 --- a/drivers/atm/nicstar.c +++ b/drivers/atm/nicstar.c @@ -861,7 +861,6 @@ static void ns_init_card_error(ns_dev *card, int error) static scq_info *get_scq(ns_dev *card, int size, u32 scd) { scq_info *scq; - int i; =20 if (size !=3D VBR_SCQSIZE && size !=3D CBR_SCQSIZE) return NULL; @@ -875,9 +874,8 @@ static scq_info *get_scq(ns_dev *card, int size, u32 sc= d) kfree(scq); return NULL; } - scq->skb =3D kmalloc_array(size / NS_SCQE_SIZE, - sizeof(*scq->skb), - GFP_KERNEL); + scq->skb =3D kcalloc(size / NS_SCQE_SIZE, sizeof(*scq->skb), + GFP_KERNEL); if (!scq->skb) { dma_free_coherent(&card->pcidev->dev, 2 * size, scq->org, scq->dma); @@ -890,15 +888,11 @@ static scq_info *get_scq(ns_dev *card, int size, u32 = scd) scq->last =3D scq->base + (scq->num_entries - 1); scq->tail =3D scq->last; scq->scd =3D scd; - scq->num_entries =3D size / NS_SCQE_SIZE; scq->tbd_count =3D 0; init_waitqueue_head(&scq->scqfull_waitq); scq->full =3D 0; spin_lock_init(&scq->lock); =20 - for (i =3D 0; i < scq->num_entries; i++) - scq->skb[i] =3D NULL; - return scq; } =20 --=20 2.32.0