[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <20260125083501.34513-4-enelsonmoore@gmail.com>
Date: Sun, 25 Jan 2026 00:34:57 -0800
From: Ethan Nelson-Moore <enelsonmoore@...il.com>
To: netdev@...r.kernel.org,
linux-usb@...r.kernel.org
Cc: Ethan Nelson-Moore <enelsonmoore@...il.com>,
Andrew Lunn <andrew+netdev@...n.ch>,
"David S. Miller" <davem@...emloft.net>,
Eric Dumazet <edumazet@...gle.com>,
Jakub Kicinski <kuba@...nel.org>,
Paolo Abeni <pabeni@...hat.com>
Subject: [PATCH net-next 3/3] net: usb: kaweth: remove eth_addr_t typedef and bcast_addr definition
It violates kernel code style guidelines to define typedefs for
non-opaque types. Update kaweth to conform to these guidelines by
expanding the eth_addr_t typedef. Also replace the hardcoded MAC address
length of 6 bytes with ETH_ALEN, and use standard kernel APIs to assign
and compare against the broadcast address.
Signed-off-by: Ethan Nelson-Moore <enelsonmoore@...il.com>
---
drivers/net/usb/kaweth.c | 11 +++--------
1 file changed, 3 insertions(+), 8 deletions(-)
diff --git a/drivers/net/usb/kaweth.c b/drivers/net/usb/kaweth.c
index c9efb7df892e..f3fe76e46490 100644
--- a/drivers/net/usb/kaweth.c
+++ b/drivers/net/usb/kaweth.c
@@ -164,8 +164,6 @@ static struct usb_driver kaweth_driver = {
.disable_hub_initiated_lpm = 1,
};
-typedef __u8 eth_addr_t[6];
-
/****************************************************************
* usb_eth_dev
****************************************************************/
@@ -185,7 +183,7 @@ struct kaweth_ethernet_configuration
__u8 size;
__u8 reserved1;
__u8 reserved2;
- eth_addr_t hw_addr;
+ u8 hw_addr[ETH_ALEN];
__u32 statistics_mask;
__le16 segment_size;
__u16 max_multicast_filters;
@@ -882,7 +880,6 @@ static int kaweth_probe(
struct usb_device *udev = interface_to_usbdev(intf);
struct kaweth_device *kaweth;
struct net_device *netdev;
- const eth_addr_t bcast_addr = { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF };
int result = 0;
int rv = -EIO;
@@ -991,9 +988,7 @@ static int kaweth_probe(
dev_info(dev, "MTU: %d\n", le16_to_cpu(kaweth->configuration.segment_size));
dev_info(dev, "Read MAC address %pM\n", kaweth->configuration.hw_addr);
- if(!memcmp(&kaweth->configuration.hw_addr,
- &bcast_addr,
- sizeof(bcast_addr))) {
+ if (is_broadcast_ether_addr((const u8 *)&kaweth->configuration.hw_addr)) {
dev_err(dev, "Firmware not functioning properly, no net device created\n");
goto err_free_netdev;
}
@@ -1043,7 +1038,7 @@ static int kaweth_probe(
if (!kaweth->rx_buf)
goto err_all_but_rxbuf;
- memcpy(netdev->broadcast, &bcast_addr, sizeof(bcast_addr));
+ eth_broadcast_addr(netdev->broadcast);
eth_hw_addr_set(netdev, (u8 *)&kaweth->configuration.hw_addr);
netdev->netdev_ops = &kaweth_netdev_ops;
--
2.43.0
Powered by blists - more mailing lists