From patchwork Sun Jan 29 18:23: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: 50033 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp1848993wrn; Sun, 29 Jan 2023 10:47:13 -0800 (PST) X-Google-Smtp-Source: AK7set8hyDr2qZy4HH3g7qxPtcmFvrQfB4+u8FKpFQU4Lif5EXb3+9tsitSCKMzgSoUkC6Bkc672 X-Received: by 2002:a05:6a21:9993:b0:bc:cd2c:dfce with SMTP id ve19-20020a056a21999300b000bccd2cdfcemr4053168pzb.31.1675018033446; Sun, 29 Jan 2023 10:47:13 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1675018033; cv=none; d=google.com; s=arc-20160816; b=zDhe/0WHIituZNzSWjB+7m7ctnoIWGBgEZCJECX8dkDhCYpSu7pIEGzapHOuIsPvDJ uaW9I4Q7UKexAFW8x+jCWnjRllxx89p5hIG9ZJqXJiP2bfcCnhY/BX+gANnBofdK+KrU 2wEuwyBOGydF8p8FfrFJ/3jqGi/Vlx6NI0PweCdAsSKnTR0+47OI4fEPap8pqb4p3TSx ikVdLvkGttrVlj1pOqE0qoZtFtj7iIONeb97iLa1p5UdOgprulWhNa67qS9cMghWacQs lPc702ai+u9Xb2aEvzuj6UK2yfZP3VuvxJZA5mXrsZEBRUCQ921kcYBnxr3CVw+V8Dp/ nlgQ== 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 :references:in-reply-to:message-id:date:subject:cc:to:from; bh=sqe2krDouTgNp0WG3ZUem2JqbK1Ia+qR60WkfRXDAdU=; b=JnhMvFygYUuR2bKMXRgUooN5p+ToKCQbm785MNWOGRF4vAkzjSOzof90OLj+tCnyqX A53ZPKZlCARBaG80bMpK2TymlKJ/o2vSkCm2CDr8M2NV4YzQMneqLMEP/TUHKYfWYp0q cQUQBovRU7FDykpAOLYQdRgiWldC2RXYhk+VscYUBNtdjulo+5gxv0BbvCRuExHYCN6/ oSr2SNYrZJ08Yx01BI0P83h1WFXtbelnk7kjnLfAvgFBeYSDpen8NbEH6j1VKVvyQRJC qbEy/HghuAU8ixGSCsQ8glfnLh7yxHZXPTyyHmFMWX/7AEAP7QCuVsP2Ea+vyJUAEog3 zHow== 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 k12-20020a633d0c000000b004ac9348e706si10650061pga.113.2023.01.29.10.47.01; Sun, 29 Jan 2023 10:47:13 -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 S235305AbjA2SXq (ORCPT + 99 others); Sun, 29 Jan 2023 13:23:46 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41468 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235290AbjA2SXo (ORCPT ); Sun, 29 Jan 2023 13:23:44 -0500 Received: from smtp.smtpout.orange.fr (smtp-11.smtpout.orange.fr [80.12.242.11]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2319F1BAF7 for ; Sun, 29 Jan 2023 10:23:40 -0800 (PST) Received: from pop-os.home ([86.243.2.178]) by smtp.orange.fr with ESMTPA id MCKlpGwDQMaRbMCL4pnjkG; Sun, 29 Jan 2023 19:23:38 +0100 X-ME-Helo: pop-os.home X-ME-Auth: Y2hyaXN0b3BoZS5qYWlsbGV0QHdhbmFkb28uZnI= X-ME-Date: Sun, 29 Jan 2023 19:23:38 +0100 X-ME-IP: 86.243.2.178 From: Christophe JAILLET To: gregkh@linuxfoundation.org, peterz@infradead.org, pmladek@suse.com, john.ogness@linutronix.de, baolu.lu@linux.intel.com, tglx@linutronix.de, mingo@kernel.org Cc: linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org, Christophe JAILLET Subject: [PATCH 3/3] usb: early: xhci-dbc: Use memcpy_and_pad() Date: Sun, 29 Jan 2023 19:23:10 +0100 Message-Id: X-Mailer: git-send-email 2.34.1 In-Reply-To: References: MIME-Version: 1.0 X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_NONE, 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?1756383709172256391?= X-GMAIL-MSGID: =?utf-8?q?1756383709172256391?= Instead of zeroing some memory and then copying data in part or all of it, use memcpy_and_pad(). This avoids writing some memory twice and should save a few cycles. Signed-off-by: Christophe JAILLET --- drivers/usb/early/xhci-dbc.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/usb/early/xhci-dbc.c b/drivers/usb/early/xhci-dbc.c index 965a24e47c0f..341408410ed9 100644 --- a/drivers/usb/early/xhci-dbc.c +++ b/drivers/usb/early/xhci-dbc.c @@ -499,8 +499,7 @@ static int xdbc_bulk_transfer(void *data, int size, bool read) addr = xdbc.in_dma; xdbc.flags |= XDBC_FLAGS_IN_PROCESS; } else { - memset(xdbc.out_buf, 0, XDBC_MAX_PACKET); - memcpy(xdbc.out_buf, data, size); + memcpy_and_pad(xdbc.out_buf, XDBC_MAX_PACKET, data, size, 0); addr = xdbc.out_dma; xdbc.flags |= XDBC_FLAGS_OUT_PROCESS; }