mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Nikolay Kulikov <nikolayof23@gmail.com>
To: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org,
	 Nikolay Kulikov <nikolayof23@gmail.com>
Subject: [PATCH] usb: gadget: u_ether: replace memcpy() with ether_addr_copy() for MAC
Date: Wed, 19 Aug 2026 23:56:47 +0300	[thread overview]
Message-ID: <20260819-gether_copy_ether_addr-v1-1-18a12e0175f1@gmail.com> (raw)

There is a function for copying a MAC address buffer in
include/linux/etherdevice.h, so use it instead of memcpy().

Signed-off-by: Nikolay Kulikov <nikolayof23@gmail.com>
---
 drivers/usb/gadget/function/u_ether.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/usb/gadget/function/u_ether.c b/drivers/usb/gadget/function/u_ether.c
index 59d85d6a84a8..62f95de03f32 100644
--- a/drivers/usb/gadget/function/u_ether.c
+++ b/drivers/usb/gadget/function/u_ether.c
@@ -779,7 +779,7 @@ struct eth_dev *gether_setup_name(struct usb_gadget *g,
 			"using random %s ethernet address\n", "host");
 
 	if (ethaddr)
-		memcpy(ethaddr, dev->host_mac, ETH_ALEN);
+		ether_addr_copy(ethaddr, dev->host_mac);
 
 	net->netdev_ops = &eth_netdev_ops;
 
@@ -929,7 +929,7 @@ int gether_set_dev_addr(struct net_device *net, const char *dev_addr)
 	dev = netdev_priv(net);
 	if (get_ether_addr(dev_addr, new_addr))
 		return -EINVAL;
-	memcpy(dev->dev_mac, new_addr, ETH_ALEN);
+	ether_addr_copy(dev->dev_mac, new_addr);
 	net->addr_assign_type = NET_ADDR_SET;
 	return 0;
 }
@@ -959,7 +959,7 @@ int gether_set_host_addr(struct net_device *net, const char *host_addr)
 	dev = netdev_priv(net);
 	if (get_ether_addr(host_addr, new_addr))
 		return -EINVAL;
-	memcpy(dev->host_mac, new_addr, ETH_ALEN);
+	ether_addr_copy(dev->host_mac, new_addr);
 	return 0;
 }
 EXPORT_SYMBOL_GPL(gether_set_host_addr);
@@ -1001,7 +1001,7 @@ void gether_get_host_addr_u8(struct net_device *net, u8 host_mac[ETH_ALEN])
 	struct eth_dev *dev;
 
 	dev = netdev_priv(net);
-	memcpy(host_mac, dev->host_mac, ETH_ALEN);
+	ether_addr_copy(host_mac, dev->host_mac);
 }
 EXPORT_SYMBOL_GPL(gether_get_host_addr_u8);
 

---
base-commit: e6664f2b33db9b6811eb4cec109f06cb2b4f458d
change-id: 20260818-gether_copy_ether_addr-e1fad0b218b0

Best regards,
--  
Nikolay Kulikov <nikolayof23@gmail.com>


                 reply	other threads:[~2026-08-19 20:56 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=20260819-gether_copy_ether_addr-v1-1-18a12e0175f1@gmail.com \
    --to=nikolayof23@gmail.com \
    --cc=gregkh@linuxfoundation.org \
    --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

all inboxes | Powered by JetHome®