From patchwork Thu Feb 2 20:58:10 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christophe JAILLET X-Patchwork-Id: 52172 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp475301wrn; Thu, 2 Feb 2023 13:10:52 -0800 (PST) X-Google-Smtp-Source: AK7set+b4ED8S20IQ3EhpV9xXlW2+KrIuozjOxtO6Tkcb4p8vL7jCqo6VGfa7MyO4ZTfjXgFvpgB X-Received: by 2002:a05:6402:890:b0:47f:bc9b:46ec with SMTP id e16-20020a056402089000b0047fbc9b46ecmr7548672edy.7.1675372252574; Thu, 02 Feb 2023 13:10:52 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1675372252; cv=none; d=google.com; s=arc-20160816; b=FutprYnU+Z6DmPTgxHfTGd7MaUKpWigIRF+U4Xi4HrRxLq7Is1W8sU2+pQwTmEaoCw s1BxId2BkY71MbRyyiIlRAwqKwjlkpokhPFFXvf0zh2yMIpHKO/J8f5BjMaBMALEOCGr H97S8wX9AwR0yss3g1YhjOFM/yVC10nlZWPkf8S/SzNclLL6JyffFLj1t5l1Ew+TN7qx bgw0srlqrJFadY5Sj0H22qdmk/DCo6cJtEQk3K/C2G5CecbnZXea/mF3ClvEUAbH+YvQ Yrm0BbRNgYs5bumERjZS5/n8rhBAVjUJn7AWlMLOtNrI6sxoi2ajN669ZhWSPXuF5/YG 9bRA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from; bh=b/a2q4FMYje2Zd9ifw7qkRtnwZld227ecFIVsA6wR7k=; b=wpdjI6EkX4dKmXYOVs+unWKDbxtyQtdQDpMZdtz35/GbTGUb1mjTgFQULvqJ1EhJ0L jrNUzcXuQ/DXS85b32O+yHqrYgjovacMnuHGYa75uT09qfcoTUbNFJaUvvUBclGiXBQS iH7knqImdZNPe/yK5Xjvt46aOhzB3JW5CSYr5rUvkV1919iHiTocQSQfqxWxwRGzDcfT HuPxLOXmOLwevbTvDRXTvTMLEqAtwDFuJvTKCt6ev+xVvUJ5KdgGljk1dd9P57FqBOCi wKFMcr1POohuKBPig87BXiDIHSgKL4f1p3CsACUYF0A9cZoAIUWHTgjo7RSp9egSFXCS cTpw== 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 Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id b2-20020aa7cd02000000b004a168f66e4dsi484364edw.154.2023.02.02.13.10.28; Thu, 02 Feb 2023 13:10:52 -0800 (PST) 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 S232883AbjBBU6X (ORCPT + 99 others); Thu, 2 Feb 2023 15:58:23 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52422 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229710AbjBBU6V (ORCPT ); Thu, 2 Feb 2023 15:58:21 -0500 Received: from smtp.smtpout.orange.fr (smtp-27.smtpout.orange.fr [80.12.242.27]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 23950166EC for ; Thu, 2 Feb 2023 12:58:18 -0800 (PST) Received: from pop-os.home ([86.243.2.178]) by smtp.orange.fr with ESMTPA id NgespaMSp7c7GNgetpCoUX; Thu, 02 Feb 2023 21:58:16 +0100 X-ME-Helo: pop-os.home X-ME-Auth: Y2hyaXN0b3BoZS5qYWlsbGV0QHdhbmFkb28uZnI= X-ME-Date: Thu, 02 Feb 2023 21:58:16 +0100 X-ME-IP: 86.243.2.178 From: Christophe JAILLET To: Loic Poulain , Kalle Valo , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni Cc: linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org, Christophe JAILLET , wcn36xx@lists.infradead.org, linux-wireless@vger.kernel.org, netdev@vger.kernel.org Subject: [PATCH net-next] wifi: wcn36xx: Slightly optimize PREPARE_HAL_BUF() Date: Thu, 2 Feb 2023 21:58:10 +0100 Message-Id: <7d8ab7fee45222cdbaf80c507525f2d3941587c1.1675371372.git.christophe.jaillet@wanadoo.fr> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_PASS 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1756755134685389512?= X-GMAIL-MSGID: =?utf-8?q?1756755134685389512?= In most (likely all) cases, INIT_HAL_MSG() is called before PREPARE_HAL_BUF(). In such cases calling memset() is useless because: msg_body.header.len = sizeof(msg_body) So, instead of writing twice the memory, we just have a sanity check to make sure that some potential trailing memory is zeroed. It even gives the opportunity to see that by itself and optimize it away. Signed-off-by: Christophe JAILLET Acked-by: Loic Poulain --- drivers/net/wireless/ath/wcn36xx/smd.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/net/wireless/ath/wcn36xx/smd.c b/drivers/net/wireless/ath/wcn36xx/smd.c index 566f0b9c1584..17e1919d1cd8 100644 --- a/drivers/net/wireless/ath/wcn36xx/smd.c +++ b/drivers/net/wireless/ath/wcn36xx/smd.c @@ -475,8 +475,8 @@ static int wcn36xx_smd_send_and_wait(struct wcn36xx *wcn, size_t len) #define PREPARE_HAL_BUF(send_buf, msg_body) \ do { \ - memset(send_buf, 0, msg_body.header.len); \ - memcpy(send_buf, &msg_body, sizeof(msg_body)); \ + memcpy_and_pad(send_buf, msg_body.header.len, \ + &msg_body, sizeof(msg_body), 0); \ } while (0) \ #define PREPARE_HAL_PTT_MSG_BUF(send_buf, p_msg_body) \