public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH v1 1/1] usb: gadget: configfs: Use memcpy_and_pad()
@ 2023-02-02 15:17 Andy Shevchenko
  2023-02-02 22:21 ` David Laight
  0 siblings, 1 reply; 3+ messages in thread
From: Andy Shevchenko @ 2023-02-02 15:17 UTC (permalink / raw)
  To: Greg Kroah-Hartman, Jó Ágila Bitsch, Andy Shevchenko,
	linux-usb, linux-kernel

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


^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2023-02-03 11:27 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-02-02 15:17 [PATCH v1 1/1] usb: gadget: configfs: Use memcpy_and_pad() Andy Shevchenko
2023-02-02 22:21 ` David Laight
2023-02-03 11:27   ` 'Andy Shevchenko'

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox