Received: by 2002:a05:6602:18e:0:0:0:0 with SMTP id m14csp2485117ioo; Mon, 23 May 2022 21:28:49 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy8QDBMvs0HetJo+riyYNVyr2hLlrok840TG97rgSe80L0KnSmYzvydsLpL5M91Abz6TKFl X-Received: by 2002:a05:6402:75a:b0:42a:bbb9:504c with SMTP id p26-20020a056402075a00b0042abbb9504cmr27249876edy.348.1653366529240; Mon, 23 May 2022 21:28:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1653366529; cv=none; d=google.com; s=arc-20160816; b=gzCTld3MJ9yvZciAj6Kp8f8YrvIK/PpaFDBtC6WwJmy6aH0w6zzFm93TWfWqPJRICE KgKZRRtya+DluP62TMatTG57+RCPsZXFQGqZVHVZZeugh+g3/glzAU4C+oBXcGsIgfVB wSZP0ZC1c9NHTsG9+Fm7QeUyqJCew6O1FhLOq3clRlx80LmyLREONwml+Tm8zZxNQ7SU VzTt9ZcILlYxOJyMymtMU0VkCz6ZPsmvpCtYPIF1BVhFWlxXFIxNu/LmraMPfQyWshJr qoHUQ1mW/paxnfPK4N3Xtu8Sebtw1bVlo/QHM12sHNdoQtpREvHm0aHQqS7jos5pDWmD DKXw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:subject:user-agent:mime-version:date:message-id; bh=y8sUNiKVhNfB/zo6RVIUIDbNFzUArkogrNiMpMsddmM=; b=UfVcyX0Le5ugtmDSW/4WcRawCI+2LqfbvpdsgDvvqSCFQn0zEjKhmawZR3MMXC4uCU lX/L5EgDhRDR9jeCI4kxtPt8jIu8m+0kxw0qHv5r3Zmg0cs6i0uRCKO7oPEN0lBbpm4I CbgFcZOR7klpf6+n2zppsHlN9e8tPOH3nZF8ZxxfFhWRf8CKSZriWDU8t4ArJvZrcL5f 4Va5l9tljZnMYHjvK1ezJ/VKg+cN25At38OgAKvmCGe4iF9ahLZhQnN3qy0yemZBVwLF 2qliaExUmAl0lRMbG9pPwCuR9xLcNRdSzps4RySg4oqJ2xVOTfwsMkzZ21/YGxslAFHC 8QWw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id s4-20020aa7c544000000b0042ac2b5fb50si13305155edr.589.2022.05.23.21.28.24; Mon, 23 May 2022 21:28:49 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234031AbiEXDvp (ORCPT + 99 others); Mon, 23 May 2022 23:51:45 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52464 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232910AbiEXDvm (ORCPT ); Mon, 23 May 2022 23:51:42 -0400 Received: from mail.meizu.com (unknown [14.29.68.187]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1CD6114089; Mon, 23 May 2022 20:51:38 -0700 (PDT) Received: from IT-EXMB-1-125.meizu.com (172.16.1.125) by mz-mail04.meizu.com (172.16.1.16) with Microsoft SMTP Server (TLS) id 14.3.487.0; Tue, 24 May 2022 11:51:37 +0800 Received: from [172.16.137.70] (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 11:51:36 +0800 Message-ID: <43b269f3-2970-e75d-34d0-d738a8c1fb81@meizu.com> Date: Tue, 24 May 2022 11:51:35 +0800 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.9.0 Subject: Re: [PATCH V2] octeon_ep: Remove unnecessary cast To: Joe Perches CC: , , , , , , References: <53b4a92efb83d893230f47ae9988282f3875b355.camel@perches.com> <1653362915-22831-1-git-send-email-baihaowen@meizu.com> <059725f837c8a869cc2358d2850f6776b05a9fe2.camel@perches.com> From: baihaowen In-Reply-To: <059725f837c8a869cc2358d2850f6776b05a9fe2.camel@perches.com> Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 8bit 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) X-Spam-Status: No, score=-3.6 required=5.0 tests=BAYES_00,MAY_BE_FORGED, NICE_REPLY_A,SPF_HELO_NONE,SPF_SOFTFAIL,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 在 2022/5/24 上午11:48, Joe Perches 写道: > On Tue, 2022-05-24 at 11:28 +0800, Haowen Bai wrote: >> ./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. > [] >> diff --git a/drivers/net/ethernet/marvell/octeon_ep/octep_rx.c b/drivers/net/ethernet/marvell/octeon_ep/octep_rx.c > [] >> @@ -158,8 +158,7 @@ static int octep_setup_oq(struct octep_device *oct, int q_no) >> goto desc_dma_alloc_err; >> } >> >> - oq->buff_info = (struct octep_rx_buffer *) >> - vzalloc(oq->max_count * OCTEP_OQ_RECVBUF_SIZE); >> + oq->buff_info = vcalloc(oq->max_count, OCTEP_OQ_RECVBUF_SIZE); > trivia: > > Perhaps better to remove the used once #define OCTEP_OQ_RECVBUF_SIZE > and use the more obvious > > oq->buff_info = vcalloc(oq->max_count, sizeof(struct octep_rx_buffer)); > > though I believe the vcalloc may be better as kvcalloc as max_count isn't > particularly high and struct octep_rx_buffer is small. > > Maybe: > --- > 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/net/ethernet/marvell/octeon_ep/octep_rx.c > index d9ae0937d17a8..d6a0da61db449 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; > } > > - oq->buff_info = (struct octep_rx_buffer *) > - vzalloc(oq->max_count * OCTEP_OQ_RECVBUF_SIZE); > + oq->buff_info = 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; > > oq_fill_buff_err: > - vfree(oq->buff_info); > + kvfree(oq->buff_info); > oq->buff_info = 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) > > octep_oq_free_ring_buffers(oq); > > - vfree(oq->buff_info); > + kvfree(oq->buff_info); > > if (oq->desc_ring) > dma_free_coherent(oq->dev, > diff --git a/drivers/net/ethernet/marvell/octeon_ep/octep_rx.h b/drivers/net/ethernet/marvell/octeon_ep/octep_rx.h > index 782a24f27f3e0..34a32d95cd4b3 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; > }; > > -#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. */ > > Good work, thanks for suggestion. -- Haowen Bai suggestionSynonymsBetasuggestion (noun)idea(generic)thought(generic)suggestion (noun)propositionprofferproposal(generic)suggestion (noun)tracehintsmall indefinite quantity(generic)small indefinite amount(generic)Source: WordNetLanguageToolbasic