From nobody Sun May 19 00:47:39 2024 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 4EE6CC433EF for ; Tue, 24 May 2022 06:41:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232511AbiEXGlZ (ORCPT ); Tue, 24 May 2022 02:41:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39870 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229945AbiEXGlV (ORCPT ); Tue, 24 May 2022 02:41:21 -0400 Received: from mail.meizu.com (edge07.meizu.com [112.91.151.210]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8DDC21836E; Mon, 23 May 2022 23:41:18 -0700 (PDT) Received: from IT-EXMB-1-125.meizu.com (172.16.1.125) by mz-mail11.meizu.com (172.16.1.15) with Microsoft SMTP Server (TLS) id 14.3.487.0; Tue, 24 May 2022 14:41:13 +0800 Received: from meizu.meizu.com (172.16.137.70) by IT-EXMB-1-125.meizu.com (172.16.1.125) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2308.14; Tue, 24 May 2022 14:41:10 +0800 From: Haowen Bai To: Veerasenareddy Burru , Abhijit Ayarekar , "David S. Miller" , "Eric Dumazet" , Jakub Kicinski , Paolo Abeni CC: Haowen Bai , , Subject: [PATCH V3] octeon_ep: Remove unnecessary cast Date: Tue, 24 May 2022 14:41:08 +0800 Message-ID: <1653374469-30555-1-git-send-email-baihaowen@meizu.com> X-Mailer: git-send-email 2.7.4 MIME-Version: 1.0 X-Originating-IP: [172.16.137.70] X-ClientProxiedBy: IT-EXMB-1-126.meizu.com (172.16.1.126) To IT-EXMB-1-125.meizu.com (172.16.1.125) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" ./drivers/net/ethernet/marvell/octeon_ep/octep_rx.c:161:18-40: WARNING: casting value returned by memory allocation function to (struct octep_rx_buffer *) is useless. and we do more optimization: 1. remove casting value 2. use obvious size 3. use kvcalloc instead of vzalloc Signed-off-by: Haowen Bai --- V1->V2: change vzalloc to vcalloc as suggestion. V2->V3: use obvious size; use kvcalloc instead of vzalloc. drivers/net/ethernet/marvell/octeon_ep/octep_rx.c | 8 ++++---- drivers/net/ethernet/marvell/octeon_ep/octep_rx.h | 2 -- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/drivers/net/ethernet/marvell/octeon_ep/octep_rx.c b/drivers/ne= t/ethernet/marvell/octeon_ep/octep_rx.c index d9ae0937d17a..d6a0da61db44 100644 --- a/drivers/net/ethernet/marvell/octeon_ep/octep_rx.c +++ b/drivers/net/ethernet/marvell/octeon_ep/octep_rx.c @@ -158,8 +158,8 @@ static int octep_setup_oq(struct octep_device *oct, int= q_no) goto desc_dma_alloc_err; } =20 - oq->buff_info =3D (struct octep_rx_buffer *) - vzalloc(oq->max_count * OCTEP_OQ_RECVBUF_SIZE); + oq->buff_info =3D kvcalloc(oq->max_count, sizeof(struct octep_rx_buffer), + GFP_KERNEL); if (unlikely(!oq->buff_info)) { dev_err(&oct->pdev->dev, "Failed to allocate buffer info for OQ-%d\n", q_no); @@ -176,7 +176,7 @@ static int octep_setup_oq(struct octep_device *oct, int= q_no) return 0; =20 oq_fill_buff_err: - vfree(oq->buff_info); + kvfree(oq->buff_info); oq->buff_info =3D NULL; buf_list_err: dma_free_coherent(oq->dev, desc_ring_size, @@ -230,7 +230,7 @@ static int octep_free_oq(struct octep_oq *oq) =20 octep_oq_free_ring_buffers(oq); =20 - vfree(oq->buff_info); + kvfree(oq->buff_info); =20 if (oq->desc_ring) dma_free_coherent(oq->dev, diff --git a/drivers/net/ethernet/marvell/octeon_ep/octep_rx.h b/drivers/ne= t/ethernet/marvell/octeon_ep/octep_rx.h index 782a24f27f3e..34a32d95cd4b 100644 --- a/drivers/net/ethernet/marvell/octeon_ep/octep_rx.h +++ b/drivers/net/ethernet/marvell/octeon_ep/octep_rx.h @@ -67,8 +67,6 @@ struct octep_rx_buffer { u64 len; }; =20 -#define OCTEP_OQ_RECVBUF_SIZE (sizeof(struct octep_rx_buffer)) - /* Output Queue statistics. Each output queue has four stats fields. */ struct octep_oq_stats { /* Number of packets received from the Device. */ --=20 2.7.4