diff options
author | Sascha Hauer <s.hauer@pengutronix.de> | 2024-02-02 16:11:47 +0100 |
---|---|---|
committer | Sascha Hauer <s.hauer@pengutronix.de> | 2024-02-05 08:47:09 +0100 |
commit | 96a5f863fbda1833d53aaef45abbb0960586b5ef (patch) | |
tree | 654dbac9e4a8bc0aa57a59b1f693216a0527a959 | |
parent | 107eeef8f2a95142e2118bf4783cecc82778814a (diff) | |
download | barebox-96a5f863fbda.tar.gz barebox-96a5f863fbda.tar.xz |
eth: replace ethaddr_to_string() with %pM
Now that we can print MAC addresses using the %pM format specifier we
can get rid of ethaddr_to_string(). Do this treewide.
Link: https://lore.barebox.org/20240202151147.226876-2-s.hauer@pengutronix.de
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
-rw-r--r-- | arch/arm/boards/protonic-imx6/board.c | 5 | ||||
-rw-r--r-- | arch/arm/boards/skov-imx6/board.c | 5 | ||||
-rw-r--r-- | include/net.h | 1 | ||||
-rw-r--r-- | lib/parameter.c | 3 | ||||
-rw-r--r-- | net/eth.c | 13 | ||||
-rw-r--r-- | net/lib.c | 7 | ||||
-rw-r--r-- | net/net.c | 8 |
7 files changed, 10 insertions, 32 deletions
diff --git a/arch/arm/boards/protonic-imx6/board.c b/arch/arm/boards/protonic-imx6/board.c index 5c5e7d6155..9e62dc1544 100644 --- a/arch/arm/boards/protonic-imx6/board.c +++ b/arch/arm/boards/protonic-imx6/board.c @@ -200,10 +200,7 @@ static int prt_imx6_set_mac(struct prt_imx6_priv *priv, return 0; if (!is_valid_ether_addr(&rfid->mac[0])) { - unsigned char ethaddr_str[sizeof("xx:xx:xx:xx:xx:xx")]; - - ethaddr_to_string(&rfid->mac[0], ethaddr_str); - dev_err(dev, "bad MAC addr: %s\n", ethaddr_str); + dev_err(dev, "bad MAC addr: %pM\n", &rfid->mac[0]); return -EILSEQ; } diff --git a/arch/arm/boards/skov-imx6/board.c b/arch/arm/boards/skov-imx6/board.c index b3f170cfdf..8ebb4a6e58 100644 --- a/arch/arm/boards/skov-imx6/board.c +++ b/arch/arm/boards/skov-imx6/board.c @@ -30,10 +30,7 @@ static int eth_of_fixup_node(struct device_node *root, const char *node_path, int ret; if (!is_valid_ether_addr(ethaddr)) { - unsigned char ethaddr_str[sizeof("xx:xx:xx:xx:xx:xx")]; - - ethaddr_to_string(ethaddr, ethaddr_str); - dev_err(skov_priv->dev, "The mac-address %s is invalid.\n", ethaddr_str); + dev_err(skov_priv->dev, "The mac-address %pM is invalid.\n", ethaddr); return -EINVAL; } diff --git a/include/net.h b/include/net.h index 40287a3503..ffc1093ae6 100644 --- a/include/net.h +++ b/include/net.h @@ -358,7 +358,6 @@ IPaddr_t getenv_ip(const char *name); int setenv_ip(const char *name, IPaddr_t ip); int string_to_ethaddr(const char *str, u8 enetaddr[6]); -void ethaddr_to_string(const u8 enetaddr[6], char *str); #ifdef CONFIG_NET_RESOLV int resolv(const char *host, IPaddr_t *ip); diff --git a/lib/parameter.c b/lib/parameter.c index aac33e3a19..dc80f3f858 100644 --- a/lib/parameter.c +++ b/lib/parameter.c @@ -846,7 +846,6 @@ struct param_mac { }; int string_to_ethaddr(const char *str, u8 enetaddr[6]); -void ethaddr_to_string(const u8 enetaddr[6], char *str); static inline struct param_mac *to_param_mac(struct param_d *p) { @@ -894,7 +893,7 @@ static const char *param_mac_get(struct device *dev, struct param_d *p) return NULL; } - ethaddr_to_string(pm->mac, p->value); + sprintf(p->value, "%pM", pm->mac); return p->value; } @@ -55,11 +55,8 @@ int eth_set_ethaddr(struct eth_device *edev, const char *ethaddr) static void register_preset_mac_address(struct eth_device *edev, const char *ethaddr) { - unsigned char ethaddr_str[sizeof("xx:xx:xx:xx:xx:xx")]; - if (is_valid_ether_addr(ethaddr)) { - ethaddr_to_string(ethaddr, ethaddr_str); - dev_info(&edev->dev, "got preset MAC address: %s\n", ethaddr_str); + dev_info(&edev->dev, "got preset MAC address: %pM\n", ethaddr); eth_set_ethaddr(edev, ethaddr); } } @@ -557,7 +554,6 @@ void eth_open_all(void) static int populate_ethaddr(void) { - char str[sizeof("xx:xx:xx:xx:xx:xx")]; struct eth_device *edev; bool generated = false; int ret; @@ -575,11 +571,12 @@ static int populate_ethaddr(void) if (ret) continue; - ethaddr_to_string(edev->ethaddr, str); if (generated) - dev_notice(&edev->dev, "Generated MAC address from unique id: %s\n", str); + dev_notice(&edev->dev, "Generated MAC address from unique id: %pM\n", + edev->ethaddr); else - dev_info(&edev->dev, "Got preset MAC address from NVMEM: %s\n", str); + dev_info(&edev->dev, "Got preset MAC address from NVMEM: %pM\n", + edev->ethaddr); eth_set_ethaddr(edev, edev->ethaddr); } @@ -37,13 +37,6 @@ int string_to_ethaddr(const char *str, u8 enetaddr[ETH_ALEN]) return 0; } -void ethaddr_to_string(const u8 enetaddr[ETH_ALEN], char *str) -{ - sprintf(str, "%02x:%02x:%02x:%02x:%02x:%02x", - enetaddr[0], enetaddr[1], enetaddr[2], enetaddr[3], - enetaddr[4], enetaddr[5]); -} - int string_to_ip(const char *s, IPaddr_t *ip) { IPaddr_t addr = 0; @@ -418,17 +418,13 @@ static struct net_connection *net_new(struct eth_device *edev, IPaddr_t dest, } if (!is_valid_ether_addr(edev->ethaddr)) { - char str[sizeof("xx:xx:xx:xx:xx:xx")]; - ret = generate_ether_addr(edev->ethaddr, edev->dev.id); if (ret) random_ether_addr(edev->ethaddr); - ethaddr_to_string(edev->ethaddr, str); - - dev_warn(&edev->dev, "No MAC address set. Using %s %s\n", + dev_warn(&edev->dev, "No MAC address set. Using %s %pM\n", ret == 1 ? "address computed from unique ID" : "random address", - str); + edev->ethaddr); eth_set_ethaddr(edev, edev->ethaddr); } |