From: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
To: "Greg Kroah-Hartman" <gregkh@linuxfoundation.org>,
"Jó Ágila Bitsch" <jgilab@gmail.com>,
"Andy Shevchenko" <andriy.shevchenko@linux.intel.com>,
linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH v1 1/1] usb: gadget: configfs: Use memcpy_and_pad()
Date: Thu, 2 Feb 2023 17:17:36 +0200 [thread overview]
Message-ID: <20230202151736.64552-1-andriy.shevchenko@linux.intel.com> (raw)
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: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
drivers/usb/gadget/configfs.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/drivers/usb/gadget/configfs.c b/drivers/usb/gadget/configfs.c
index 1346b330b358..0ee47e4c22cb 100644
--- a/drivers/usb/gadget/configfs.c
+++ b/drivers/usb/gadget/configfs.c
@@ -909,8 +909,7 @@ static ssize_t webusb_landingPage_store(struct config_item *item, const char *pa
mutex_lock(&gi->lock);
// ensure 0 bytes are set, in case the new landing page is shorter then the old one.
- memset(gi->landing_page, 0, sizeof(gi->landing_page));
- memcpy(gi->landing_page, page, l);
+ memcpy_and_pad(gi->landing_page, sizeof(gi->landing_page), page, l, 0);
mutex_unlock(&gi->lock);
return len;
--
2.39.1
next reply other threads:[~2023-02-02 15:19 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-02-02 15:17 Andy Shevchenko [this message]
2023-02-02 22:21 ` [PATCH v1 1/1] usb: gadget: configfs: Use memcpy_and_pad() David Laight
2023-02-03 11:27 ` 'Andy Shevchenko'
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230202151736.64552-1-andriy.shevchenko@linux.intel.com \
--to=andriy.shevchenko@linux.intel.com \
--cc=gregkh@linuxfoundation.org \
--cc=jgilab@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-usb@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox