]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
um: vector: Use mac_pton() for MAC address parsing
authorTiwei Bie <tiwei.btw@antgroup.com>
Tue, 6 May 2025 04:51:17 +0000 (12:51 +0800)
committerJohannes Berg <johannes.berg@intel.com>
Mon, 2 Jun 2025 09:24:04 +0000 (11:24 +0200)
Use mac_pton() instead of custom approach.

Suggested-by: Geert Uytterhoeven <geert@linux-m68k.org>
Signed-off-by: Tiwei Bie <tiwei.btw@antgroup.com>
Link: https://patch.msgid.link/20250506045117.1896661-3-tiwei.btw@antgroup.com
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
arch/um/drivers/vector_kern.c

index 7822421057ea7f10bdfae5aa5a56bfd42fee9371..5226d2c52e6ab67500a295ecce03878a94b3f75f 100644 (file)
@@ -1543,21 +1543,14 @@ static void vector_timer_expire(struct timer_list *t)
 static void vector_setup_etheraddr(struct net_device *dev, char *str)
 {
        u8 addr[ETH_ALEN];
-       char *end;
-       int i;
 
        if (str == NULL)
                goto random;
 
-       for (i = 0; i < 6; i++) {
-               addr[i] = simple_strtoul(str, &end, 16);
-               if ((end == str) ||
-                  ((*end != ':') && (*end != ',') && (*end != '\0'))) {
-                       netdev_err(dev,
-                               "Failed to parse '%s' as an ethernet address\n", str);
-                       goto random;
-               }
-               str = end + 1;
+       if (!mac_pton(str, addr)) {
+               netdev_err(dev,
+                       "Failed to parse '%s' as an ethernet address\n", str);
+               goto random;
        }
        if (is_multicast_ether_addr(addr)) {
                netdev_err(dev,