net: add a helpers for loading netdev->dev_addr from FW
Subsystems (39)
Jakub Kicinski
maintainerv3 cover net: add a helpers for loading netdev->dev_addr from FW
We're trying to make all writes to netdev->dev_addr go via helpers. A lot of places pass netdev->dev_addr to of_get_ethdev_address() and device_get_ethdev_addr() so this set adds new functions which wrap the functionality.
v2 performs suggested code moves, adds a couple additional clean ups on the device property side, and an extra patch converting drivers which can benefit from device_get_ethdev_address().
v3 removes OF_NET and corrects kdoc.
Jakub Kicinski (9):
of: net: move of_net under net/
of: net: add a helper for loading netdev->dev_addr
ethernet: use of_get_ethdev_address()
device property: move mac addr helpers to eth.c
eth: fwnode: change the return type of mac address helpers
eth: fwnode: remove the addr len from mac helpers
eth: fwnode: add a helper for loading netdev->dev_addr
ethernet: use device_get_ethdev_address()
ethernet: make more use of device_get_ethdev_address()
drivers/base/property.c | 63 ---------------
drivers/net/ethernet/allwinner/sun4i-emac.c | 2 +-
drivers/net/ethernet/altera/altera_tse_main.c | 2 +-
drivers/net/ethernet/amd/Kconfig | 2 +-
drivers/net/ethernet/apm/xgene-v2/main.c | 2 +-
.../net/ethernet/apm/xgene/xgene_enet_main.c | 2 +-
drivers/net/ethernet/arc/Kconfig | 4 +-
drivers/net/ethernet/arc/emac_main.c | 2 +-
drivers/net/ethernet/atheros/ag71xx.c | 2 +-
drivers/net/ethernet/broadcom/bcm4908_enet.c | 2 +-
drivers/net/ethernet/broadcom/bcmsysport.c | 2 +-
drivers/net/ethernet/broadcom/bgmac-bcma.c | 2 +-
.../net/ethernet/broadcom/bgmac-platform.c | 2 +-
.../net/ethernet/broadcom/genet/bcmgenet.c | 2 +-
drivers/net/ethernet/cadence/macb_main.c | 2 +-
.../net/ethernet/cavium/octeon/octeon_mgmt.c | 2 +-
.../net/ethernet/cavium/thunder/thunder_bgx.c | 6 +-
drivers/net/ethernet/ethoc.c | 2 +-
drivers/net/ethernet/ezchip/Kconfig | 2 +-
drivers/net/ethernet/ezchip/nps_enet.c | 2 +-
drivers/net/ethernet/faraday/ftgmac100.c | 7 +-
drivers/net/ethernet/freescale/fec_mpc52xx.c | 2 +-
.../ethernet/freescale/fs_enet/fs_enet-main.c | 2 +-
drivers/net/ethernet/freescale/gianfar.c | 2 +-
drivers/net/ethernet/freescale/ucc_geth.c | 2 +-
drivers/net/ethernet/hisilicon/hisi_femac.c | 2 +-
drivers/net/ethernet/hisilicon/hix5hd2_gmac.c | 2 +-
drivers/net/ethernet/hisilicon/hns/hns_enet.c | 2 +-
drivers/net/ethernet/korina.c | 2 +-
drivers/net/ethernet/lantiq_xrx200.c | 2 +-
drivers/net/ethernet/litex/Kconfig | 2 +-
drivers/net/ethernet/litex/litex_liteeth.c | 2 +-
drivers/net/ethernet/marvell/mvneta.c | 2 +-
.../net/ethernet/marvell/mvpp2/mvpp2_main.c | 2 +-
drivers/net/ethernet/marvell/pxa168_eth.c | 2 +-
drivers/net/ethernet/marvell/sky2.c | 2 +-
drivers/net/ethernet/mediatek/mtk_eth_soc.c | 2 +-
drivers/net/ethernet/micrel/ks8851_common.c | 2 +-
drivers/net/ethernet/microchip/enc28j60.c | 5 +-
drivers/net/ethernet/mscc/Kconfig | 2 +-
drivers/net/ethernet/nxp/lpc_eth.c | 2 +-
drivers/net/ethernet/qualcomm/emac/emac.c | 5 +-
drivers/net/ethernet/qualcomm/qca_spi.c | 2 +-
drivers/net/ethernet/qualcomm/qca_uart.c | 2 +-
drivers/net/ethernet/renesas/ravb_main.c | 2 +-
.../ethernet/samsung/sxgbe/sxgbe_platform.c | 2 +-
drivers/net/ethernet/smsc/smsc911x.c | 2 +-
drivers/net/ethernet/socionext/netsec.c | 9 +--
drivers/net/ethernet/socionext/sni_ave.c | 2 +-
drivers/net/ethernet/ti/netcp_core.c | 2 +-
drivers/net/ethernet/xilinx/xilinx_emaclite.c | 2 +-
drivers/net/wireless/ath/ath10k/core.c | 2 +-
drivers/of/Kconfig | 4 -
drivers/of/Makefile | 1 -
include/linux/etherdevice.h | 6 ++
include/linux/of_net.h | 8 +-
include/linux/property.h | 5 +-
net/core/Makefile | 1 +
net/core/net-sysfs.c | 2 +-
{drivers/of => net/core}/of_net.c | 25 ++++++
net/ethernet/eth.c | 79 +++++++++++++++++++
61 files changed, 176 insertions(+), 144 deletions(-)
rename {drivers/of => net/core}/of_net.c (85%)Signature · 1 line
2.31.1
Jakub Kicinski
maintainerPATCH v3 1/9 of: net: move of_net under net/
Rob suggests to move of_net.c from under drivers/of/ somewhere to the networking code.
---
v2: new patch
v3: also clean up Kconfig
---
drivers/net/ethernet/amd/Kconfig | 2 +-
drivers/net/ethernet/arc/Kconfig | 4 ++--
drivers/net/ethernet/ezchip/Kconfig | 2 +-
drivers/net/ethernet/litex/Kconfig | 2 +-
drivers/net/ethernet/mscc/Kconfig | 2 +-
drivers/of/Kconfig | 4 ----
drivers/of/Makefile | 1 -
include/linux/of_net.h | 2 +-
net/core/Makefile | 1 +
net/core/net-sysfs.c | 2 +-
{drivers/of => net/core}/of_net.c | 0
11 files changed, 9 insertions(+), 13 deletions(-)
rename {drivers/of => net/core}/of_net.c (100%)drivers/net/ethernet/amd/Kconfig +1 -1
@@ -168,7 +168,7 @@ config SUNLANCE config AMD_XGBE tristate "AMD 10GbE Ethernet driver" - depends on ((OF_NET && OF_ADDRESS) || ACPI || PCI) && HAS_IOMEM + depends on (OF_ADDRESS || ACPI || PCI) && HAS_IOMEM depends on X86 || ARM64 || COMPILE_TEST depends on PTP_1588_CLOCK_OPTIONAL select BITREVERSE
drivers/net/ethernet/arc/Kconfig +2 -2
@@ -25,7 +25,7 @@ config ARC_EMAC_CORE config ARC_EMAC tristate "ARC EMAC support" select ARC_EMAC_CORE - depends on OF_IRQ && OF_NET + depends on OF_IRQ depends on ARC || COMPILE_TEST help On some legacy ARC (Synopsys) FPGA boards such as ARCAngel4/ML50x
@@ -35,7 +35,7 @@ config ARC_EMAC config EMAC_ROCKCHIP tristate "Rockchip EMAC support" select ARC_EMAC_CORE - depends on OF_IRQ && OF_NET && REGULATOR + depends on OF_IRQ && REGULATOR depends on ARCH_ROCKCHIP || COMPILE_TEST help Support for Rockchip RK3036/RK3066/RK3188 EMAC ethernet controllers.
drivers/net/ethernet/ezchip/Kconfig +1 -1
@@ -18,7 +18,7 @@ if NET_VENDOR_EZCHIP config EZCHIP_NPS_MANAGEMENT_ENET tristate "EZchip NPS management enet support" - depends on OF_IRQ && OF_NET + depends on OF_IRQ depends on HAS_IOMEM help Simple LAN device for debug or management purposes.
drivers/net/ethernet/litex/Kconfig +1 -1
@@ -17,7 +17,7 @@ if NET_VENDOR_LITEX config LITEX_LITEETH tristate "LiteX Ethernet support" - depends on OF_NET + depends on OF help If you wish to compile a kernel for hardware with a LiteX LiteEth device then you should answer Y to this.
drivers/net/ethernet/mscc/Kconfig +1 -1
@@ -28,7 +28,7 @@ config MSCC_OCELOT_SWITCH depends on BRIDGE || BRIDGE=n depends on NET_SWITCHDEV depends on HAS_IOMEM - depends on OF_NET + depends on OF select MSCC_OCELOT_SWITCH_LIB select GENERIC_PHY help
drivers/of/Kconfig +0 -4
@@ -70,10 +70,6 @@ config OF_IRQ def_bool y depends on !SPARC && IRQ_DOMAIN -config OF_NET - depends on NETDEVICES - def_bool y - config OF_RESERVED_MEM def_bool OF_EARLY_FLATTREE
drivers/of/Makefile +0 -1
@@ -7,7 +7,6 @@ obj-$(CONFIG_OF_EARLY_FLATTREE) += fdt_address.o obj-$(CONFIG_OF_PROMTREE) += pdt.o obj-$(CONFIG_OF_ADDRESS) += address.o obj-$(CONFIG_OF_IRQ) += irq.o -obj-$(CONFIG_OF_NET) += of_net.o obj-$(CONFIG_OF_UNITTEST) += unittest.o obj-$(CONFIG_OF_RESERVED_MEM) += of_reserved_mem.o obj-$(CONFIG_OF_RESOLVE) += resolver.o
include/linux/of_net.h +1 -1
@@ -8,7 +8,7 @@#include <linux/phy.h> -#ifdef CONFIG_OF_NET +#ifdef CONFIG_OF #include <linux/of.h> struct net_device ;
net/core/Makefile +1 -0
@@ -36,3 +36,4 @@ obj-$(CONFIG_FAILOVER) += failover.o obj-$(CONFIG_NET_SOCK_MSG) += skmsg.o obj-$(CONFIG_BPF_SYSCALL) += sock_map.o obj-$(CONFIG_BPF_SYSCALL) += bpf_sk_storage.o +obj-$(CONFIG_OF) += of_net.o
net/core/net-sysfs.c +1 -1
@@ -1869,7 +1869,7 @@ static struct class net_class __ro_after_init = { .get_ownership = net_get_ownership, }; -#ifdef CONFIG_OF_NET +#ifdef CONFIG_OF static int of_dev_node_match (struct device *dev,const void *data) {for (; dev; dev = dev->parent) {
net/core/of_net.c renamed from drivers/of/of_net.c +0 -0
Signature · 1 line
2.31.1
Re: [PATCH net-next v3 1/9] of: net: move of_net under net/
Quoted 9 lines · Jakub Kicinski
Rob suggests to move
of_net.cfrom underdrivers/of/somewhere to the networking code.Suggested-by Rob Herring <[email protected]>Signed-off-by Jakub Kicinski <[email protected]>---
v2: new patch
v3: also clean upKconfig
Quoted 14 lines
---
drivers/net/ethernet/amd/Kconfig | 2 +-
drivers/net/ethernet/arc/Kconfig | 4 ++--
drivers/net/ethernet/ezchip/Kconfig | 2 +-
drivers/net/ethernet/litex/Kconfig | 2 +-
drivers/net/ethernet/mscc/Kconfig | 2 +-
drivers/of/Kconfig | 4 ----
drivers/of/Makefile | 1 -
include/linux/of_net.h | 2 +-
net/core/Makefile | 1 +
net/core/net-sysfs.c | 2 +-
{drivers/of => net/core}/of_net.c | 0
11 files changed, 9 insertions(+), 13 deletions(-)
rename {drivers/of => net/core}/of_net.c (100%)Thanks for doing this.
Jakub Kicinski
maintainerPATCH v3 2/9 of: net: add a helper for loading netdev->dev_addr
In reply to Jakub KicinskiCommit 406f42fa0d3c ("net-next: When a bond have a massive amount of VLANs...") introduced a rbtree for faster Ethernet address look up. To maintain netdev->dev_addr in this tree we need to make all the writes to it got through appropriate helpers.
There are roughly 40 places where netdev->dev_addr is passed as the destination to a of_get_mac_address() call. Add a helper which takes a dev pointer instead, so it can call an appropriate helper.
Note that of_get_mac_address() already assumes the address is 6 bytes long (ETH_ALEN) so use eth_hw_addr_set().
--- include/linux/of_net.h | 6 ++++++ net/core/of_net.c | 25 +++++++++++++++++++++++++ 2 files changed, 31 insertions(+)
include/linux/of_net.h +6 -0
@@ -14,6 +14,7 @@struct net_device ;extern int of_get_phy_mode (struct device_node *np,phy_interface_t *interface);extern int of_get_mac_address (struct device_node *np,u8 *mac); +int of_get_ethdev_address (struct device_node *np,struct net_device *dev);extern struct net_device *of_find_net_device_by_node (struct device_node *np);#else static inline int of_get_phy_mode(struct device_node *np,
@@ -27,6 +28,11 @@ static inline int of_get_mac_address(struct device_node *np, u8 *mac)return -ENODEV ; } +static inline int of_get_ethdev_address (struct device_node *np,struct net_device *dev) +{ +return -ENODEV ; +} +static inline struct net_device *of_find_net_device_by_node (struct device_node *np) {return NULL ;
net/core/of_net.c +25 -0
@@ -143,3 +143,28 @@ int of_get_mac_address(struct device_node *np, u8 *addr)return of_get_mac_addr_nvmem (np, addr); }EXPORT_SYMBOL (of_get_mac_address); + +/** +* of_get_ethdev_address() +* @np: Caller's Device Node +* @dev: Pointer to netdevice which address will be updated +* +* Search the device tree for the best MAC address to use. +* If found set @dev->dev_addr to that address. +* +* See documentation of of_get_mac_address() for more information on how +* the best address is determined. +* +* Return: 0 on success and errno in case of error. +*/ +int of_get_ethdev_address (struct device_node *np,struct net_device *dev) +{ +u8 addr[ETH_ALEN ]; +int ret; + + ret =of_get_mac_address (np, addr); +if (!ret) +eth_hw_addr_set (dev, addr); +return ret; +} +EXPORT_SYMBOL (of_get_ethdev_address);
Signature · 1 line
2.31.1
Jakub Kicinski
maintainerPATCH v3 3/9 ethernet: use of_get_ethdev_address()
In reply to Jakub KicinskiUse the new of_get_ethdev_address() helper for the cases where dev->dev_addr is passed in directly as the destination.
@@
expression dev, np;
@@
- of_get_mac_address(np, dev->dev_addr)
+ of_get_ethdev_address(np, dev)
--- drivers/net/ethernet/allwinner/sun4i-emac.c | 2 +- drivers/net/ethernet/altera/altera_tse_main.c | 2 +- drivers/net/ethernet/arc/emac_main.c | 2 +- drivers/net/ethernet/atheros/ag71xx.c | 2 +- drivers/net/ethernet/broadcom/bcm4908_enet.c | 2 +- drivers/net/ethernet/broadcom/bcmsysport.c | 2 +- drivers/net/ethernet/broadcom/bgmac-bcma.c | 2 +- drivers/net/ethernet/broadcom/bgmac-platform.c | 2 +- drivers/net/ethernet/cadence/macb_main.c | 2 +- drivers/net/ethernet/cavium/octeon/octeon_mgmt.c | 2 +- drivers/net/ethernet/ethoc.c | 2 +- drivers/net/ethernet/ezchip/nps_enet.c | 2 +- drivers/net/ethernet/freescale/fec_mpc52xx.c | 2 +- drivers/net/ethernet/freescale/fs_enet/fs_enet-main.c | 2 +- drivers/net/ethernet/freescale/gianfar.c | 2 +- drivers/net/ethernet/freescale/ucc_geth.c | 2 +- drivers/net/ethernet/hisilicon/hisi_femac.c | 2 +- drivers/net/ethernet/hisilicon/hix5hd2_gmac.c | 2 +- drivers/net/ethernet/korina.c | 2 +- drivers/net/ethernet/lantiq_xrx200.c | 2 +- drivers/net/ethernet/litex/litex_liteeth.c | 2 +- drivers/net/ethernet/marvell/mvneta.c | 2 +- drivers/net/ethernet/marvell/pxa168_eth.c | 2 +- drivers/net/ethernet/marvell/sky2.c | 2 +- drivers/net/ethernet/mediatek/mtk_eth_soc.c | 2 +- drivers/net/ethernet/micrel/ks8851_common.c | 2 +- drivers/net/ethernet/nxp/lpc_eth.c | 2 +- drivers/net/ethernet/qualcomm/qca_spi.c | 2 +- drivers/net/ethernet/qualcomm/qca_uart.c | 2 +- drivers/net/ethernet/renesas/ravb_main.c | 2 +- drivers/net/ethernet/samsung/sxgbe/sxgbe_platform.c | 2 +- drivers/net/ethernet/socionext/sni_ave.c | 2 +- drivers/net/ethernet/ti/netcp_core.c | 2 +- drivers/net/ethernet/xilinx/xilinx_emaclite.c | 2 +- 34 files changed, 34 insertions(+), 34 deletions(-)
drivers/net/ethernet/allwinner/sun4i-emac.c +1 -1
@@ -852,7 +852,7 @@ static int emac_probe(struct platform_device *pdev) }/* Read MAC-address from DT */ - ret =of_get_mac_address (np, ndev->dev_addr); + ret =of_get_ethdev_address (np, ndev);if (ret) {/* if the MAC address is invalid get a random one */ eth_hw_addr_random (ndev);
drivers/net/ethernet/altera/altera_tse_main.c +1 -1
@@ -1524,7 +1524,7 @@ static int altera_tse_probe(struct platform_device *pdev) priv->rx_dma_buf_sz =ALTERA_RXDMABUFFER_SIZE ;/* get default MAC address from device tree */ - ret =of_get_mac_address (pdev->dev.of_node, ndev->dev_addr); + ret =of_get_ethdev_address (pdev->dev.of_node, ndev);if (ret)eth_hw_addr_random (ndev);
drivers/net/ethernet/arc/emac_main.c +1 -1
@@ -941,7 +941,7 @@ int arc_emac_probe(struct net_device *ndev, int interface) }/* Get MAC address from device tree */ - err =of_get_mac_address (dev->of_node, ndev->dev_addr); + err =of_get_ethdev_address (dev->of_node, ndev);if (err)eth_hw_addr_random (ndev);
drivers/net/ethernet/atheros/ag71xx.c +1 -1
@@ -1968,7 +1968,7 @@ static int ag71xx_probe(struct platform_device *pdev) ag->stop_desc->ctrl =0 ; ag->stop_desc->next = (u32 )ag->stop_desc_dma; - err =of_get_mac_address (np, ndev->dev_addr); + err =of_get_ethdev_address (np, ndev);if (err) {netif_err (ag, probe, ndev,"invalid MAC address, using random address\n" );eth_random_addr (ndev->dev_addr);
drivers/net/ethernet/broadcom/bcm4908_enet.c +1 -1
@@ -715,7 +715,7 @@ static int bcm4908_enet_probe(struct platform_device *pdev)return err;SET_NETDEV_DEV (netdev, &pdev->dev); - err =of_get_mac_address (dev->of_node, netdev->dev_addr); + err =of_get_ethdev_address (dev->of_node, netdev);if (err)eth_hw_addr_random (netdev); netdev->netdev_ops = &bcm4908_enet_netdev_ops;
drivers/net/ethernet/broadcom/bcmsysport.c +1 -1
@@ -2555,7 +2555,7 @@ static int bcm_sysport_probe(struct platform_device *pdev) }/* Initialize netdevice members */ - ret =of_get_mac_address (dn, dev->dev_addr); + ret =of_get_ethdev_address (dn, dev);if (ret) {dev_warn (&pdev->dev,"using random Ethernet MAC\n" );eth_hw_addr_random (dev);
drivers/net/ethernet/broadcom/bgmac-bcma.c +1 -1
@@ -140,7 +140,7 @@ static int bgmac_probe(struct bcma_device *core)bcma_set_drvdata (core, bgmac); - err =of_get_mac_address (bgmac->dev->of_node, bgmac->net_dev->dev_addr); + err =of_get_ethdev_address (bgmac->dev->of_node, bgmac->net_dev);if (err == -EPROBE_DEFER )return err;
drivers/net/ethernet/broadcom/bgmac-platform.c +1 -1
@@ -191,7 +191,7 @@ static int bgmac_probe(struct platform_device *pdev) bgmac->dev = &pdev->dev; bgmac->dma_dev = &pdev->dev; - ret =of_get_mac_address (np, bgmac->net_dev->dev_addr); + ret =of_get_ethdev_address (np, bgmac->net_dev);if (ret == -EPROBE_DEFER )return ret;
drivers/net/ethernet/cadence/macb_main.c +1 -1
@@ -4774,7 +4774,7 @@ static int macb_probe(struct platform_device *pdev)if (bp->caps &MACB_CAPS_NEEDS_RSTONUBR ) bp->rx_intr_mask |=MACB_BIT (RXUBR ); - err =of_get_mac_address (np, bp->dev->dev_addr); + err =of_get_ethdev_address (np, bp->dev);if (err == -EPROBE_DEFER ) goto err_out_free_netdev;else if (err)
drivers/net/ethernet/cavium/octeon/octeon_mgmt.c +1 -1
@@ -1501,7 +1501,7 @@ static int octeon_mgmt_probe(struct platform_device *pdev) netdev->min_mtu =64 -OCTEON_MGMT_RX_HEADROOM ; netdev->max_mtu =16383 -OCTEON_MGMT_RX_HEADROOM -VLAN_HLEN ; - result =of_get_mac_address (pdev->dev.of_node, netdev->dev_addr); + result =of_get_ethdev_address (pdev->dev.of_node, netdev);if (result)eth_hw_addr_random (netdev);
drivers/net/ethernet/ethoc.c +1 -1
@@ -1147,7 +1147,7 @@ static int ethoc_probe(struct platform_device *pdev)eth_hw_addr_set (netdev, pdata->hwaddr); priv->phy_id = pdata->phy_id; }else { -of_get_mac_address (pdev->dev.of_node, netdev->dev_addr); +of_get_ethdev_address (pdev->dev.of_node, netdev); priv->phy_id =-1 ; }
drivers/net/ethernet/ezchip/nps_enet.c +1 -1
@@ -601,7 +601,7 @@ static s32 nps_enet_probe(struct platform_device *pdev)dev_dbg (dev,"Registers base address is 0x%p\n" , priv->regs_base);/* set kernel MAC address to dev */ - err =of_get_mac_address (dev->of_node, ndev->dev_addr); + err =of_get_ethdev_address (dev->of_node, ndev);if (err)eth_hw_addr_random (ndev);
drivers/net/ethernet/freescale/fec_mpc52xx.c +1 -1
@@ -890,7 +890,7 @@ static int mpc52xx_fec_probe(struct platform_device *op)* * First try to read MAC address from DT */ - rv =of_get_mac_address (np, ndev->dev_addr); + rv =of_get_ethdev_address (np, ndev);if (rv) {struct mpc52xx_fec __iomem *fec = priv->fec;
drivers/net/ethernet/freescale/fs_enet/fs_enet-main.c +1 -1
@@ -1005,7 +1005,7 @@ static int fs_enet_probe(struct platform_device *ofdev)spin_lock_init (&fep->lock);spin_lock_init (&fep->tx_lock); -of_get_mac_address (ofdev->dev.of_node, ndev->dev_addr); +of_get_ethdev_address (ofdev->dev.of_node, ndev); ret = fep->ops->allocate_bd (ndev);if (ret)
drivers/net/ethernet/freescale/gianfar.c +1 -1
@@ -753,7 +753,7 @@ static int gfar_of_init(struct platform_device *ofdev, struct net_device **pdev)if (stash_len || stash_idx) priv->device_flags |=FSL_GIANFAR_DEV_HAS_BUF_STASHING ; - err =of_get_mac_address (np, dev->dev_addr); + err =of_get_ethdev_address (np, dev);if (err) {eth_hw_addr_random (dev);dev_info (&ofdev->dev,"Using random MAC address: %pM\n" , dev->dev_addr);
drivers/net/ethernet/freescale/ucc_geth.c +1 -1
@@ -3731,7 +3731,7 @@ static int ucc_geth_probe(struct platform_device* ofdev) goto err_free_netdev; } -of_get_mac_address (np, dev->dev_addr); +of_get_ethdev_address (np, dev); ugeth->ug_info = ug_info; ugeth->dev = device;
drivers/net/ethernet/hisilicon/hisi_femac.c +1 -1
@@ -841,7 +841,7 @@ static int hisi_femac_drv_probe(struct platform_device *pdev) (unsigned long )phy->phy_id, phy_modes(phy->interface)); - ret =of_get_mac_address (node, ndev->dev_addr); + ret =of_get_ethdev_address (node, ndev);if (ret) {eth_hw_addr_random (ndev); dev_warn(dev, "using random MAC address %pM\n",
drivers/net/ethernet/hisilicon/hix5hd2_gmac.c +1 -1
@@ -1219,7 +1219,7 @@ static int hix5hd2_dev_probe(struct platform_device *pdev) goto out_phy_node; } - ret =of_get_mac_address (node, ndev->dev_addr); + ret =of_get_ethdev_address (node, ndev);if (ret) {eth_hw_addr_random (ndev); netdev_warn(ndev, "using random MAC address %pM\n",
drivers/net/ethernet/korina.c +1 -1
@@ -1298,7 +1298,7 @@ static int korina_probe(struct platform_device *pdev)if (mac_addr)eth_hw_addr_set (dev, mac_addr); -else if (of_get_mac_address (pdev->dev.of_node, dev->dev_addr) <0 ) +else if (of_get_ethdev_address (pdev->dev.of_node, dev) <0 )eth_hw_addr_random (dev); clk =devm_clk_get_optional (&pdev->dev,"mdioclk" );
drivers/net/ethernet/lantiq_xrx200.c +1 -1
@@ -527,7 +527,7 @@ static int xrx200_probe(struct platform_device *pdev)return PTR_ERR (priv->clk); } - err =of_get_mac_address (np, net_dev->dev_addr); + err =of_get_ethdev_address (np, net_dev);if (err)eth_hw_addr_random (net_dev);
drivers/net/ethernet/litex/litex_liteeth.c +1 -1
@@ -266,7 +266,7 @@ static int liteeth_probe(struct platform_device *pdev) priv->tx_base = buf_base + priv->num_rx_slots * priv->slot_size; priv->tx_slot =0 ; - err =of_get_mac_address (pdev->dev.of_node, netdev->dev_addr); + err =of_get_ethdev_address (pdev->dev.of_node, netdev);if (err)eth_hw_addr_random (netdev);
drivers/net/ethernet/marvell/mvneta.c +1 -1
@@ -5242,7 +5242,7 @@ static int mvneta_probe(struct platform_device *pdev) goto err_free_ports; } - err =of_get_mac_address (dn, dev->dev_addr); + err =of_get_ethdev_address (dn, dev);if (!err) { mac_from ="device tree" ; }else {
drivers/net/ethernet/marvell/pxa168_eth.c +1 -1
@@ -1434,7 +1434,7 @@ static int pxa168_eth_probe(struct platform_device *pdev)INIT_WORK (&pep->tx_timeout_task, pxa168_eth_tx_timeout_task); - err =of_get_mac_address (pdev->dev.of_node, dev->dev_addr); + err =of_get_ethdev_address (pdev->dev.of_node, dev);if (err) {/* try reading the mac address, if set by the bootloader */ pxa168_eth_get_mac_address (dev, dev->dev_addr);
drivers/net/ethernet/marvell/sky2.c +1 -1
@@ -4720,7 +4720,7 @@ static struct net_device *sky2_init_netdev(struct sky2_hw *hw, unsigned port,* 1) from device tree data * 2) from internal registers set by bootloader */ - ret =of_get_mac_address (hw->pdev->dev.of_node, dev->dev_addr); + ret =of_get_ethdev_address (hw->pdev->dev.of_node, dev);if (ret)memcpy_fromio (dev->dev_addr, hw->regs +B2_MAC_1 + port *8 ,ETH_ALEN );
drivers/net/ethernet/mediatek/mtk_eth_soc.c +1 -1
@@ -2588,7 +2588,7 @@ static int __init mtk_init(struct net_device *dev)struct mtk_eth *eth = mac->hw;int ret; - ret =of_get_mac_address (mac->of_node, dev->dev_addr); + ret =of_get_ethdev_address (mac->of_node, dev);if (ret) {/* If the mac address is invalid, use random mac address */ eth_hw_addr_random (dev);
drivers/net/ethernet/micrel/ks8851_common.c +1 -1
@@ -195,7 +195,7 @@ static void ks8851_init_mac(struct ks8851_net *ks, struct device_node *np)struct net_device *dev = ks->netdev;int ret; - ret =of_get_mac_address (np, dev->dev_addr); + ret =of_get_ethdev_address (np, dev);if (!ret) {ks8851_write_mac_addr (dev);return ;
drivers/net/ethernet/nxp/lpc_eth.c +1 -1
@@ -1350,7 +1350,7 @@ static int lpc_eth_drv_probe(struct platform_device *pdev)__lpc_get_mac (pldat, ndev->dev_addr);if (!is_valid_ether_addr (ndev->dev_addr)) { -of_get_mac_address (np, ndev->dev_addr); +of_get_ethdev_address (np, ndev); }if (!is_valid_ether_addr (ndev->dev_addr))eth_hw_addr_random (ndev);
drivers/net/ethernet/qualcomm/qca_spi.c +1 -1
@@ -968,7 +968,7 @@ qca_spi_probe(struct spi_device *spi)spi_set_drvdata (spi, qcaspi_devs); - ret =of_get_mac_address (spi->dev.of_node, qca->net_dev->dev_addr); + ret =of_get_ethdev_address (spi->dev.of_node, qca->net_dev);if (ret) {eth_hw_addr_random (qca->net_dev); dev_info(&spi->dev, "Using random MAC address: %pM\n",
drivers/net/ethernet/qualcomm/qca_uart.c +1 -1
@@ -347,7 +347,7 @@ static int qca_uart_probe(struct serdev_device *serdev)of_property_read_u32 (serdev->dev.of_node,"current-speed" , &speed); - ret =of_get_mac_address (serdev->dev.of_node, qca->net_dev->dev_addr); + ret =of_get_ethdev_address (serdev->dev.of_node, qca->net_dev);if (ret) {eth_hw_addr_random (qca->net_dev); dev_info(&serdev->dev, "Using random MAC address: %pM\n",
drivers/net/ethernet/renesas/ravb_main.c +1 -1
@@ -132,7 +132,7 @@ static void ravb_read_mac_address(struct device_node *np, {int ret; - ret =of_get_mac_address (np, ndev->dev_addr); + ret =of_get_ethdev_address (np, ndev);if (ret) {u32 mahr =ravb_read (ndev,MAHR );u32 malr =ravb_read (ndev,MALR );
drivers/net/ethernet/samsung/sxgbe/sxgbe_platform.c +1 -1
@@ -118,7 +118,7 @@ static int sxgbe_platform_probe(struct platform_device *pdev) }/* Get MAC address if available (DT) */ -of_get_mac_address (node, priv->dev->dev_addr); +of_get_ethdev_address (node, priv->dev);/* Get the TX/RX IRQ numbers */ for (i =0 , chan =1 ; i <SXGBE_TX_QUEUES ; i++) {
drivers/net/ethernet/socionext/sni_ave.c +1 -1
@@ -1599,7 +1599,7 @@ static int ave_probe(struct platform_device *pdev) ndev->max_mtu =AVE_MAX_ETHFRAME - (ETH_HLEN +ETH_FCS_LEN ); - ret =of_get_mac_address (np, ndev->dev_addr); + ret =of_get_ethdev_address (np, ndev);if (ret) {/* if the mac address is invalid, use random mac address */ eth_hw_addr_random (ndev);
drivers/net/ethernet/ti/netcp_core.c +1 -1
@@ -2035,7 +2035,7 @@ static int netcp_create_interface(struct netcp_device *netcp_device,devm_iounmap (dev, efuse);devm_release_mem_region (dev, res.start, size); }else { - ret =of_get_mac_address (node_interface, ndev->dev_addr); + ret =of_get_ethdev_address (node_interface, ndev);if (ret)eth_random_addr (ndev->dev_addr); }
drivers/net/ethernet/xilinx/xilinx_emaclite.c +1 -1
@@ -1157,7 +1157,7 @@ static int xemaclite_of_probe(struct platform_device *ofdev) lp->tx_ping_pong =get_bool (ofdev,"xlnx,tx-ping-pong" ); lp->rx_ping_pong =get_bool (ofdev,"xlnx,rx-ping-pong" ); - rc =of_get_mac_address (ofdev->dev.of_node, ndev->dev_addr); + rc =of_get_ethdev_address (ofdev->dev.of_node, ndev);if (rc) {dev_warn (dev,"No MAC address found, using random\n" );eth_hw_addr_random (ndev);
Signature · 1 line
2.31.1
Jakub Kicinski
maintainerPATCH v3 4/9 device property: move mac addr helpers to eth.c
In reply to Jakub KicinskiMove the mac address helpers out, eth.c already contains a bunch of similar helpers.
---
v2: new patch
--- drivers/base/property.c | 63 ------------------------------------- include/linux/etherdevice.h | 6 ++++ include/linux/property.h | 4 --- net/ethernet/eth.c | 63 +++++++++++++++++++++++++++++++++++++ 4 files changed, 69 insertions(+), 67 deletions(-)
drivers/base/property.c +0 -63
@@ -15,7 +15,6 @@#include <linux/of_graph.h> #include <linux/of_irq.h> #include <linux/property.h> -#include <linux/etherdevice.h> #include <linux/phy.h> struct fwnode_handle *dev_fwnode (struct device *dev)
@@ -935,68 +934,6 @@ int device_get_phy_mode(struct device *dev) }EXPORT_SYMBOL_GPL (device_get_phy_mode); -static void *fwnode_get_mac_addr (struct fwnode_handle *fwnode, -const char *name,char *addr, -int alen) -{ -int ret =fwnode_property_read_u8_array (fwnode, name, addr, alen); - -if (ret ==0 && alen ==ETH_ALEN &&is_valid_ether_addr (addr)) -return addr; -return NULL ; -} - -/** -* fwnode_get_mac_address - Get the MAC from the firmware node -* @fwnode: Pointer to the firmware node -* @addr: Address of buffer to store the MAC in -* @alen: Length of the buffer pointed to by addr, should be ETH_ALEN -* -* Search the firmware node for the best MAC address to use. 'mac-address' is -* checked first, because that is supposed to contain to "most recent" MAC -* address. If that isn't set, then 'local-mac-address' is checked next, -* because that is the default address. If that isn't set, then the obsolete -* 'address' is checked, just in case we're using an old device tree. -* -* Note that the 'address' property is supposed to contain a virtual address of -* the register set, but some DTS files have redefined that property to be the -* MAC address. -* -* All-zero MAC addresses are rejected, because those could be properties that -* exist in the firmware tables, but were not updated by the firmware. For -* example, the DTS could define 'mac-address' and 'local-mac-address', with -* zero MAC addresses. Some older U-Boots only initialized 'local-mac-address'. -* In this case, the real MAC is in 'local-mac-address', and 'mac-address' -* exists but is all zeros. -*/ -void *fwnode_get_mac_address (struct fwnode_handle *fwnode,char *addr,int alen) -{ -char *res; - - res =fwnode_get_mac_addr (fwnode,"mac-address" , addr, alen); -if (res) -return res; - - res =fwnode_get_mac_addr (fwnode,"local-mac-address" , addr, alen); -if (res) -return res; - -return fwnode_get_mac_addr (fwnode,"address" , addr, alen); -} -EXPORT_SYMBOL (fwnode_get_mac_address); - -/** -* device_get_mac_address - Get the MAC for a given device -* @dev: Pointer to the device -* @addr: Address of buffer to store the MAC in -* @alen: Length of the buffer pointed to by addr, should be ETH_ALEN -*/ -void *device_get_mac_address (struct device *dev,char *addr,int alen) -{ -return fwnode_get_mac_address (dev_fwnode (dev), addr, alen); -} -EXPORT_SYMBOL (device_get_mac_address); -/** * fwnode_irq_get - Get IRQ directly from a fwnode * @fwnode: Pointer to the firmware node
include/linux/etherdevice.h +6 -0
@@ -26,9 +26,15 @@#ifdef __KERNEL__struct device ; +struct fwnode_handle ; +int eth_platform_get_mac_address (struct device *dev,u8 *mac_addr);unsigned char *arch_get_platform_mac_address (void );int nvmem_get_mac_address (struct device *dev,void *addrbuf); +void *device_get_mac_address (struct device *dev,char *addr,int alen); +void *fwnode_get_mac_address (struct fwnode_handle *fwnode, +char *addr,int alen); +u32 eth_get_headlen (const struct net_device *dev,const void *data,u32 len);__be16 eth_type_trans (struct sk_buff *skb,struct net_device *dev);extern const struct header_ops eth_header_ops;
include/linux/property.h +0 -4
@@ -389,11 +389,7 @@ const void *device_get_match_data(struct device *dev);int device_get_phy_mode (struct device *dev); -void *device_get_mac_address (struct device *dev,char *addr,int alen); -int fwnode_get_phy_mode (struct fwnode_handle *fwnode); -void *fwnode_get_mac_address (struct fwnode_handle *fwnode, -char *addr,int alen);struct fwnode_handle *fwnode_graph_get_next_endpoint (const struct fwnode_handle *fwnode,struct fwnode_handle *prev); struct fwnode_handle *
net/ethernet/eth.c +63 -0
72 lines not on this page · raw message
Signature · 1 line
2.31.1
Re: [PATCH net-next v3 4/9] device property: move mac addr helpers to eth.c
Quoted 6 lines · Jakub Kicinski
Move the mac address helpers out,
eth.calready contains a bunch of similar helpers.Suggested-by Heikki Krogerus <[email protected]>Signed-off-by Jakub Kicinski <[email protected]>
FWIW:
Quoted 206 lines
---
v2: new patch--- drivers/base/property.c | 63 ------------------------------------- include/linux/etherdevice.h | 6 ++++ include/linux/property.h | 4 --- net/ethernet/eth.c | 63 +++++++++++++++++++++++++++++++++++++ 4 files changed, 69 insertions(+), 67 deletions(-)drivers/base/property.c +0
-63@@ -15,7 +15,6 @@#include <linux/of_graph.h> #include <linux/of_irq.h> #include <linux/property.h> -#include <linux/etherdevice.h> #include <linux/phy.h> struct fwnode_handle *dev_fwnode (struct device *dev)@@ -935,68 +934,6 @@ int device_get_phy_mode(struct device *dev) }EXPORT_SYMBOL_GPL (device_get_phy_mode); -static void *fwnode_get_mac_addr (struct fwnode_handle *fwnode, -const char *name,char *addr, -int alen) -{ -int ret =fwnode_property_read_u8_array (fwnode, name, addr, alen); - -if (ret ==0 && alen ==ETH_ALEN &&is_valid_ether_addr (addr)) -return addr; -return NULL ; -} - -/** -* fwnode_get_mac_address - Get the MAC from the firmware node -* @fwnode: Pointer to the firmware node -* @addr: Address of buffer to store the MAC in -* @alen: Length of the buffer pointed to by addr, should be ETH_ALEN -* -* Search the firmware node for the best MAC address to use. 'mac-address' is -* checked first, because that is supposed to contain to "most recent" MAC -* address. If that isn't set, then 'local-mac-address' is checked next, -* because that is the default address. If that isn't set, then the obsolete -* 'address' is checked, just in case we're using an old device tree. -* -* Note that the 'address' property is supposed to contain a virtual address of -* the register set, but some DTS files have redefined that property to be the -* MAC address. -* -* All-zero MAC addresses are rejected, because those could be properties that -* exist in the firmware tables, but were not updated by the firmware. For -* example, the DTS could define 'mac-address' and 'local-mac-address', with -* zero MAC addresses. Some older U-Boots only initialized 'local-mac-address'. -* In this case, the real MAC is in 'local-mac-address', and 'mac-address' -* exists but is all zeros. -*/ -void *fwnode_get_mac_address (struct fwnode_handle *fwnode,char *addr,int alen) -{ -char *res; - - res =fwnode_get_mac_addr (fwnode,"mac-address" , addr, alen); -if (res) -return res; - - res =fwnode_get_mac_addr (fwnode,"local-mac-address" , addr, alen); -if (res) -return res; - -return fwnode_get_mac_addr (fwnode,"address" , addr, alen); -} -EXPORT_SYMBOL (fwnode_get_mac_address); - -/** -* device_get_mac_address - Get the MAC for a given device -* @dev: Pointer to the device -* @addr: Address of buffer to store the MAC in -* @alen: Length of the buffer pointed to by addr, should be ETH_ALEN -*/ -void *device_get_mac_address (struct device *dev,char *addr,int alen) -{ -return fwnode_get_mac_address (dev_fwnode (dev), addr, alen); -} -EXPORT_SYMBOL (device_get_mac_address); -/** * fwnode_irq_get - Get IRQ directly from a fwnode * @fwnode: Pointer to the firmware node include/linux/etherdevice.h +6
-0@@ -26,9 +26,15 @@#ifdef __KERNEL__struct device ; +struct fwnode_handle ; +int eth_platform_get_mac_address (struct device *dev,u8 *mac_addr);unsigned char *arch_get_platform_mac_address (void );int nvmem_get_mac_address (struct device *dev,void *addrbuf); +void *device_get_mac_address (struct device *dev,char *addr,int alen); +void *fwnode_get_mac_address (struct fwnode_handle *fwnode, +char *addr,int alen); +u32 eth_get_headlen (const struct net_device *dev,const void *data,u32 len);__be16 eth_type_trans (struct sk_buff *skb,struct net_device *dev);extern const struct header_ops eth_header_ops;include/linux/property.h +0
-4@@ -389,11 +389,7 @@ const void *device_get_match_data(struct device *dev);int device_get_phy_mode (struct device *dev); -void *device_get_mac_address (struct device *dev,char *addr,int alen); -int fwnode_get_phy_mode (struct fwnode_handle *fwnode); -void *fwnode_get_mac_address (struct fwnode_handle *fwnode, -char *addr,int alen);struct fwnode_handle *fwnode_graph_get_next_endpoint (const struct fwnode_handle *fwnode,struct fwnode_handle *prev); struct fwnode_handle *net/ethernet/eth.c +63
-0@@ -51,6 +51,7 @@#include <linux/if_ether.h> #include <linux/of_net.h> #include <linux/pci.h> +#include <linux/property.h> #include <net/dst.h> #include <net/arp.h> #include <net/sock.h> @@ -558,3 +559,65 @@ int nvmem_get_mac_address(struct device *dev, void *addrbuf)return 0 ; }EXPORT_SYMBOL (nvmem_get_mac_address); + +static void *fwnode_get_mac_addr (struct fwnode_handle *fwnode, +const char *name,char *addr, +int alen) +{ +int ret =fwnode_property_read_u8_array (fwnode, name, addr, alen); + +if (ret ==0 && alen ==ETH_ALEN &&is_valid_ether_addr (addr)) +return addr; +return NULL ; +} + +/** +* fwnode_get_mac_address - Get the MAC from the firmware node +* @fwnode: Pointer to the firmware node +* @addr: Address of buffer to store the MAC in +* @alen: Length of the buffer pointed to by addr, should be ETH_ALEN +* +* Search the firmware node for the best MAC address to use. 'mac-address' is +* checked first, because that is supposed to contain to "most recent" MAC +* address. If that isn't set, then 'local-mac-address' is checked next, +* because that is the default address. If that isn't set, then the obsolete +* 'address' is checked, just in case we're using an old device tree. +* +* Note that the 'address' property is supposed to contain a virtual address of +* the register set, but some DTS files have redefined that property to be the +* MAC address. +* +* All-zero MAC addresses are rejected, because those could be properties that +* exist in the firmware tables, but were not updated by the firmware. For +* example, the DTS could define 'mac-address' and 'local-mac-address', with +* zero MAC addresses. Some older U-Boots only initialized 'local-mac-address'. +* In this case, the real MAC is in 'local-mac-address', and 'mac-address' +* exists but is all zeros. +*/ +void *fwnode_get_mac_address (struct fwnode_handle *fwnode,char *addr,int alen) +{ +char *res; + + res =fwnode_get_mac_addr (fwnode,"mac-address" , addr, alen); +if (res) +return res; + + res =fwnode_get_mac_addr (fwnode,"local-mac-address" , addr, alen); +if (res) +return res; + +return fwnode_get_mac_addr (fwnode,"address" , addr, alen); +} +EXPORT_SYMBOL (fwnode_get_mac_address); + +/** +* device_get_mac_address - Get the MAC for a given device +* @dev: Pointer to the device +* @addr: Address of buffer to store the MAC in +* @alen: Length of the buffer pointed to by addr, should be ETH_ALEN +*/ +void *device_get_mac_address (struct device *dev,char *addr,int alen) +{ +return fwnode_get_mac_address (dev_fwnode (dev), addr, alen); +} +EXPORT_SYMBOL (device_get_mac_address);Signature · 1 line
2.31.1
thanks,
Signature · 1 line
heikki
Jakub Kicinski
maintainerPATCH v3 5/9 eth: fwnode: change the return type of mac address helpers
In reply to Jakub Kicinskifwnode_get_mac_address() and device_get_mac_address() return a pointer to the buffer that was passed to them on success or NULL on failure. None of the callers care about the actual value, only if it's NULL or not.
These semantics differ from of_get_mac_address() which returns an int so to avoid confusion make the device helpers return an errno.
---
v2: new patch
--- drivers/net/ethernet/apm/xgene-v2/main.c | 2 +- .../net/ethernet/apm/xgene/xgene_enet_main.c | 2 +- .../net/ethernet/broadcom/genet/bcmgenet.c | 2 +- .../net/ethernet/cavium/thunder/thunder_bgx.c | 6 +-- drivers/net/ethernet/faraday/ftgmac100.c | 4 +- drivers/net/ethernet/hisilicon/hns/hns_enet.c | 2 +- .../net/ethernet/marvell/mvpp2/mvpp2_main.c | 2 +- drivers/net/ethernet/microchip/enc28j60.c | 2 +- drivers/net/ethernet/qualcomm/emac/emac.c | 2 +- drivers/net/ethernet/socionext/netsec.c | 10 ++--- include/linux/etherdevice.h | 5 +-- net/ethernet/eth.c | 39 ++++++++++--------- 12 files changed, 38 insertions(+), 40 deletions(-)
drivers/net/ethernet/apm/xgene-v2/main.c +1 -1
@@ -36,7 +36,7 @@ static int xge_get_resources(struct xge_pdata *pdata)return -ENOMEM ; } -if (!device_get_mac_address (dev, ndev->dev_addr,ETH_ALEN )) +if (device_get_mac_address (dev, ndev->dev_addr,ETH_ALEN ))eth_hw_addr_random (ndev);memcpy (ndev->perm_addr, ndev->dev_addr, ndev->addr_len);
drivers/net/ethernet/apm/xgene/xgene_enet_main.c +1 -1
@@ -1731,7 +1731,7 @@ static int xgene_enet_get_resources(struct xgene_enet_pdata *pdata)xgene_get_port_id_acpi (dev, pdata);#endif -if (!device_get_mac_address (dev, ndev->dev_addr,ETH_ALEN )) +if (device_get_mac_address (dev, ndev->dev_addr,ETH_ALEN ))eth_hw_addr_random (ndev);memcpy (ndev->perm_addr, ndev->dev_addr, ndev->addr_len);
drivers/net/ethernet/broadcom/genet/bcmgenet.c +1 -1
@@ -4084,7 +4084,7 @@ static int bcmgenet_probe(struct platform_device *pdev)if (pd && !IS_ERR_OR_NULL (pd->mac_address))eth_hw_addr_set (dev, pd->mac_address);else -if (!device_get_mac_address (&pdev->dev, dev->dev_addr,ETH_ALEN )) +if (device_get_mac_address (&pdev->dev, dev->dev_addr,ETH_ALEN ))if (has_acpi_companion (&pdev->dev))bcmgenet_get_hw_addr (priv, dev->dev_addr);
drivers/net/ethernet/cavium/thunder/thunder_bgx.c +3 -3
@@ -1387,10 +1387,10 @@ static int acpi_get_mac_address(struct device *dev, struct acpi_device *adev, u8 *dst) {u8 mac[ETH_ALEN ]; -u8 *addr; +int ret; - addr =fwnode_get_mac_address (acpi_fwnode_handle (adev), mac,ETH_ALEN ); -if (!addr) { + ret =fwnode_get_mac_address (acpi_fwnode_handle (adev), mac,ETH_ALEN ); +if (ret) {dev_err (dev,"MAC address invalid: %pM\n" , mac);return -EINVAL ; }
drivers/net/ethernet/faraday/ftgmac100.c +1 -3
@@ -182,10 +182,8 @@ static void ftgmac100_initial_mac(struct ftgmac100 *priv)u8 mac[ETH_ALEN ];unsigned int m;unsigned int l; -void *addr; - addr =device_get_mac_address (priv->dev, mac,ETH_ALEN ); -if (addr) { +if (!device_get_mac_address (priv->dev, mac,ETH_ALEN )) {eth_hw_addr_set (priv->netdev, mac);dev_info (priv->dev,"Read MAC address %pM from device tree\n" , mac);
drivers/net/ethernet/hisilicon/hns/hns_enet.c +1 -1
@@ -1212,7 +1212,7 @@ static void hns_init_mac_addr(struct net_device *ndev) {struct hns_nic_priv *priv =netdev_priv (ndev); -if (!device_get_mac_address (priv->dev, ndev->dev_addr,ETH_ALEN )) { +if (device_get_mac_address (priv->dev, ndev->dev_addr,ETH_ALEN )) {eth_hw_addr_random (ndev);dev_warn (priv->dev,"No valid mac, use random mac %pM" , ndev->dev_addr);
drivers/net/ethernet/marvell/mvpp2/mvpp2_main.c +1 -1
@@ -6081,7 +6081,7 @@ static void mvpp2_port_copy_mac_addr(struct net_device *dev, struct mvpp2 *priv,char hw_mac_addr[ETH_ALEN ] = {0 };char fw_mac_addr[ETH_ALEN ]; -if (fwnode_get_mac_address (fwnode, fw_mac_addr,ETH_ALEN )) { +if (!fwnode_get_mac_address (fwnode, fw_mac_addr,ETH_ALEN )) { *mac_from ="firmware node" ;eth_hw_addr_set (dev, fw_mac_addr);return ;
drivers/net/ethernet/microchip/enc28j60.c +1 -1
@@ -1572,7 +1572,7 @@ static int enc28j60_probe(struct spi_device *spi) goto error_irq; } -if (device_get_mac_address (&spi->dev, macaddr,sizeof (macaddr))) +if (!device_get_mac_address (&spi->dev, macaddr,sizeof (macaddr)))eth_hw_addr_set (dev, macaddr);else eth_hw_addr_random (dev);
drivers/net/ethernet/qualcomm/emac/emac.c +1 -1
@@ -549,7 +549,7 @@ static int emac_probe_resources(struct platform_device *pdev,int ret =0 ;/* get mac address */ -if (device_get_mac_address (&pdev->dev, maddr,ETH_ALEN )) +if (!device_get_mac_address (&pdev->dev, maddr,ETH_ALEN ))eth_hw_addr_set (netdev, maddr);else eth_hw_addr_random (netdev);
drivers/net/ethernet/socionext/netsec.c +5 -5
@@ -1978,10 +1978,10 @@ static int netsec_register_mdio(struct netsec_priv *priv, u32 phy_addr)static int netsec_probe (struct platform_device *pdev) {struct resource *mmio_res, *eeprom_res, *irq_res; -u8 *mac, macbuf[ETH_ALEN ];struct netsec_priv *priv;u32 hw_ver, phy_addr =0 ;struct net_device *ndev; +u8 macbuf[ETH_ALEN ];int ret; mmio_res =platform_get_resource (pdev,IORESOURCE_MEM ,0 );
@@ -2034,12 +2034,12 @@ static int netsec_probe(struct platform_device *pdev) goto free_ndev; } - mac =device_get_mac_address (&pdev->dev, macbuf,sizeof (macbuf)); -if (mac) -eth_hw_addr_set (ndev, mac); + ret =device_get_mac_address (&pdev->dev, macbuf,sizeof (macbuf)); +if (!ret) +eth_hw_addr_set (ndev, macbuf);if (priv->eeprom_base && - (!mac || !is_valid_ether_addr (ndev->dev_addr))) { + (ret || !is_valid_ether_addr (ndev->dev_addr))) {void __iomem *macp = priv->eeprom_base +NETSEC_EEPROM_MAC_ADDRESS ;
include/linux/etherdevice.h +2 -3
@@ -31,9 +31,8 @@ struct fwnode_handle;int eth_platform_get_mac_address (struct device *dev,u8 *mac_addr);unsigned char *arch_get_platform_mac_address (void );int nvmem_get_mac_address (struct device *dev,void *addrbuf); -void *device_get_mac_address (struct device *dev,char *addr,int alen); -void *fwnode_get_mac_address (struct fwnode_handle *fwnode, -char *addr,int alen); +int device_get_mac_address (struct device *dev,char *addr,int alen); +int fwnode_get_mac_address (struct fwnode_handle *fwnode,char *addr,int alen);u32 eth_get_headlen (const struct net_device *dev,const void *data,u32 len);__be16 eth_type_trans (struct sk_buff *skb,struct net_device *dev);
net/ethernet/eth.c +20 -19
@@ -560,15 +560,21 @@ int nvmem_get_mac_address(struct device *dev, void *addrbuf) }EXPORT_SYMBOL (nvmem_get_mac_address); -static void *fwnode_get_mac_addr (struct fwnode_handle *fwnode, -const char *name,char *addr, -int alen) +static int fwnode_get_mac_addr (struct fwnode_handle *fwnode, +const char *name,char *addr,int alen) { -int ret =fwnode_property_read_u8_array (fwnode, name, addr, alen); +int ret; -if (ret ==0 && alen ==ETH_ALEN &&is_valid_ether_addr (addr)) -return addr; -return NULL ; +if (alen !=ETH_ALEN ) +return -EINVAL ; + + ret =fwnode_property_read_u8_array (fwnode, name, addr, alen); +if (ret) +return ret; + +if (!is_valid_ether_addr (addr)) +return -EINVAL ; +return 0 ; }/**
@@ -594,19 +600,14 @@ static void *fwnode_get_mac_addr(struct fwnode_handle *fwnode,* In this case, the real MAC is in 'local-mac-address', and 'mac-address' * exists but is all zeros. */ -void *fwnode_get_mac_address (struct fwnode_handle *fwnode,char *addr,int alen) +int fwnode_get_mac_address (struct fwnode_handle *fwnode,char *addr,int alen) { -char *res; - - res =fwnode_get_mac_addr (fwnode,"mac-address" , addr, alen); -if (res) -return res; - - res =fwnode_get_mac_addr (fwnode,"local-mac-address" , addr, alen); -if (res) -return res; +if (!fwnode_get_mac_addr (fwnode,"mac-address" , addr, alen) || + !fwnode_get_mac_addr (fwnode,"local-mac-address" , addr, alen) || + !fwnode_get_mac_addr (fwnode,"address" , addr, alen)) +return 0 ; -return fwnode_get_mac_addr (fwnode,"address" , addr, alen); +return -ENOENT ; }EXPORT_SYMBOL (fwnode_get_mac_address);
@@ -616,7 +617,7 @@ EXPORT_SYMBOL(fwnode_get_mac_address);* @addr: Address of buffer to store the MAC in * @alen: Length of the buffer pointed to by addr, should be ETH_ALEN */ -void *device_get_mac_address (struct device *dev,char *addr,int alen) +int device_get_mac_address (struct device *dev,char *addr,int alen) {return fwnode_get_mac_address (dev_fwnode (dev), addr, alen); }
Signature · 1 line
2.31.1
Jakub Kicinski
maintainerPATCH v3 6/9 eth: fwnode: remove the addr len from mac helpers
In reply to Jakub KicinskiAll callers pass in ETH_ALEN and the function itself will return -EINVAL for any other address length. Just assume it's ETH_ALEN like all other mac address helpers (nvm, of, platform).
---
v2: new patch
--- drivers/net/ethernet/apm/xgene-v2/main.c | 2 +- .../net/ethernet/apm/xgene/xgene_enet_main.c | 2 +- .../net/ethernet/broadcom/genet/bcmgenet.c | 2 +- .../net/ethernet/cavium/thunder/thunder_bgx.c | 2 +- drivers/net/ethernet/faraday/ftgmac100.c | 2 +- drivers/net/ethernet/hisilicon/hns/hns_enet.c | 2 +- .../net/ethernet/marvell/mvpp2/mvpp2_main.c | 2 +- drivers/net/ethernet/microchip/enc28j60.c | 2 +- drivers/net/ethernet/qualcomm/emac/emac.c | 2 +- drivers/net/ethernet/smsc/smsc911x.c | 2 +- drivers/net/ethernet/socionext/netsec.c | 2 +- drivers/net/wireless/ath/ath10k/core.c | 2 +- include/linux/etherdevice.h | 4 ++-- net/ethernet/eth.c | 21 +++++++------------ 14 files changed, 22 insertions(+), 27 deletions(-)
drivers/net/ethernet/apm/xgene-v2/main.c +1 -1
@@ -36,7 +36,7 @@ static int xge_get_resources(struct xge_pdata *pdata)return -ENOMEM ; } -if (device_get_mac_address (dev, ndev->dev_addr,ETH_ALEN )) +if (device_get_mac_address (dev, ndev->dev_addr))eth_hw_addr_random (ndev);memcpy (ndev->perm_addr, ndev->dev_addr, ndev->addr_len);
drivers/net/ethernet/apm/xgene/xgene_enet_main.c +1 -1
@@ -1731,7 +1731,7 @@ static int xgene_enet_get_resources(struct xgene_enet_pdata *pdata)xgene_get_port_id_acpi (dev, pdata);#endif -if (device_get_mac_address (dev, ndev->dev_addr,ETH_ALEN )) +if (device_get_mac_address (dev, ndev->dev_addr))eth_hw_addr_random (ndev);memcpy (ndev->perm_addr, ndev->dev_addr, ndev->addr_len);
drivers/net/ethernet/broadcom/genet/bcmgenet.c +1 -1
@@ -4084,7 +4084,7 @@ static int bcmgenet_probe(struct platform_device *pdev)if (pd && !IS_ERR_OR_NULL (pd->mac_address))eth_hw_addr_set (dev, pd->mac_address);else -if (device_get_mac_address (&pdev->dev, dev->dev_addr,ETH_ALEN )) +if (device_get_mac_address (&pdev->dev, dev->dev_addr))if (has_acpi_companion (&pdev->dev))bcmgenet_get_hw_addr (priv, dev->dev_addr);
drivers/net/ethernet/cavium/thunder/thunder_bgx.c +1 -1
@@ -1389,7 +1389,7 @@ static int acpi_get_mac_address(struct device *dev, struct acpi_device *adev,u8 mac[ETH_ALEN ];int ret; - ret =fwnode_get_mac_address (acpi_fwnode_handle (adev), mac,ETH_ALEN ); + ret =fwnode_get_mac_address (acpi_fwnode_handle (adev), mac);if (ret) {dev_err (dev,"MAC address invalid: %pM\n" , mac);return -EINVAL ;
drivers/net/ethernet/faraday/ftgmac100.c +1 -1
@@ -183,7 +183,7 @@ static void ftgmac100_initial_mac(struct ftgmac100 *priv)unsigned int m;unsigned int l; -if (!device_get_mac_address (priv->dev, mac,ETH_ALEN )) { +if (!device_get_mac_address (priv->dev, mac)) {eth_hw_addr_set (priv->netdev, mac);dev_info (priv->dev,"Read MAC address %pM from device tree\n" , mac);
drivers/net/ethernet/hisilicon/hns/hns_enet.c +1 -1
@@ -1212,7 +1212,7 @@ static void hns_init_mac_addr(struct net_device *ndev) {struct hns_nic_priv *priv =netdev_priv (ndev); -if (device_get_mac_address (priv->dev, ndev->dev_addr,ETH_ALEN )) { +if (device_get_mac_address (priv->dev, ndev->dev_addr)) {eth_hw_addr_random (ndev);dev_warn (priv->dev,"No valid mac, use random mac %pM" , ndev->dev_addr);
drivers/net/ethernet/marvell/mvpp2/mvpp2_main.c +1 -1
@@ -6081,7 +6081,7 @@ static void mvpp2_port_copy_mac_addr(struct net_device *dev, struct mvpp2 *priv,char hw_mac_addr[ETH_ALEN ] = {0 };char fw_mac_addr[ETH_ALEN ]; -if (!fwnode_get_mac_address (fwnode, fw_mac_addr,ETH_ALEN )) { +if (!fwnode_get_mac_address (fwnode, fw_mac_addr)) { *mac_from ="firmware node" ;eth_hw_addr_set (dev, fw_mac_addr);return ;
drivers/net/ethernet/microchip/enc28j60.c +1 -1
@@ -1572,7 +1572,7 @@ static int enc28j60_probe(struct spi_device *spi) goto error_irq; } -if (!device_get_mac_address (&spi->dev, macaddr,sizeof (macaddr))) +if (!device_get_mac_address (&spi->dev, macaddr))eth_hw_addr_set (dev, macaddr);else eth_hw_addr_random (dev);
drivers/net/ethernet/qualcomm/emac/emac.c +1 -1
@@ -549,7 +549,7 @@ static int emac_probe_resources(struct platform_device *pdev,int ret =0 ;/* get mac address */ -if (!device_get_mac_address (&pdev->dev, maddr,ETH_ALEN )) +if (!device_get_mac_address (&pdev->dev, maddr))eth_hw_addr_set (netdev, maddr);else eth_hw_addr_random (netdev);
drivers/net/ethernet/smsc/smsc911x.c +1 -1
@@ -2375,7 +2375,7 @@ static int smsc911x_probe_config(struct smsc911x_platform_config *config, phy_interface =PHY_INTERFACE_MODE_NA ; config->phy_interface = phy_interface; -device_get_mac_address (dev, config->mac,ETH_ALEN ); +device_get_mac_address (dev, config->mac); err =device_property_read_u32 (dev,"reg-io-width" , &width);if (err == -ENXIO )
drivers/net/ethernet/socionext/netsec.c +1 -1
@@ -2034,7 +2034,7 @@ static int netsec_probe(struct platform_device *pdev) goto free_ndev; } - ret =device_get_mac_address (&pdev->dev, macbuf,sizeof (macbuf)); + ret =device_get_mac_address (&pdev->dev, macbuf);if (!ret)eth_hw_addr_set (ndev, macbuf);
drivers/net/wireless/ath/ath10k/core.c +1 -1
@@ -3224,7 +3224,7 @@ static int ath10k_core_probe_fw(struct ath10k *ar)ath10k_debug_print_board_info (ar); } -device_get_mac_address (ar->dev, ar->mac_addr,sizeof (ar->mac_addr)); +device_get_mac_address (ar->dev, ar->mac_addr); ret =ath10k_core_init_firmware_features (ar);if (ret) {
include/linux/etherdevice.h +2 -2
@@ -31,8 +31,8 @@ struct fwnode_handle;int eth_platform_get_mac_address (struct device *dev,u8 *mac_addr);unsigned char *arch_get_platform_mac_address (void );int nvmem_get_mac_address (struct device *dev,void *addrbuf); -int device_get_mac_address (struct device *dev,char *addr,int alen); -int fwnode_get_mac_address (struct fwnode_handle *fwnode,char *addr,int alen); +int device_get_mac_address (struct device *dev,char *addr); +int fwnode_get_mac_address (struct fwnode_handle *fwnode,char *addr);u32 eth_get_headlen (const struct net_device *dev,const void *data,u32 len);__be16 eth_type_trans (struct sk_buff *skb,struct net_device *dev);
net/ethernet/eth.c +8 -13
@@ -561,14 +561,11 @@ int nvmem_get_mac_address(struct device *dev, void *addrbuf)EXPORT_SYMBOL (nvmem_get_mac_address);static int fwnode_get_mac_addr (struct fwnode_handle *fwnode, -const char *name,char *addr,int alen) +const char *name,char *addr) {int ret; -if (alen !=ETH_ALEN ) -return -EINVAL ; - - ret =fwnode_property_read_u8_array (fwnode, name, addr, alen); + ret =fwnode_property_read_u8_array (fwnode, name, addr,ETH_ALEN );if (ret)return ret;
@@ -581,7 +578,6 @@ static int fwnode_get_mac_addr(struct fwnode_handle *fwnode,* fwnode_get_mac_address - Get the MAC from the firmware node * @fwnode: Pointer to the firmware node * @addr: Address of buffer to store the MAC in -* @alen: Length of the buffer pointed to by addr, should be ETH_ALEN * * Search the firmware node for the best MAC address to use. 'mac-address' is * checked first, because that is supposed to contain to "most recent" MAC
@@ -600,11 +596,11 @@ static int fwnode_get_mac_addr(struct fwnode_handle *fwnode,* In this case, the real MAC is in 'local-mac-address', and 'mac-address' * exists but is all zeros. */ -int fwnode_get_mac_address (struct fwnode_handle *fwnode,char *addr,int alen) +int fwnode_get_mac_address (struct fwnode_handle *fwnode,char *addr) { -if (!fwnode_get_mac_addr (fwnode,"mac-address" , addr, alen) || - !fwnode_get_mac_addr (fwnode,"local-mac-address" , addr, alen) || - !fwnode_get_mac_addr (fwnode,"address" , addr, alen)) +if (!fwnode_get_mac_addr (fwnode,"mac-address" , addr) || + !fwnode_get_mac_addr (fwnode,"local-mac-address" , addr) || + !fwnode_get_mac_addr (fwnode,"address" , addr))return 0 ;return -ENOENT ;
@@ -615,10 +611,9 @@ EXPORT_SYMBOL(fwnode_get_mac_address);* device_get_mac_address - Get the MAC for a given device * @dev: Pointer to the device * @addr: Address of buffer to store the MAC in -* @alen: Length of the buffer pointed to by addr, should be ETH_ALEN */ -int device_get_mac_address (struct device *dev,char *addr,int alen) +int device_get_mac_address (struct device *dev,char *addr) { -return fwnode_get_mac_address (dev_fwnode (dev), addr, alen); +return fwnode_get_mac_address (dev_fwnode (dev), addr); }EXPORT_SYMBOL (device_get_mac_address);
Signature · 1 line
2.31.1
Jakub Kicinski
maintainerPATCH v3 7/9 eth: fwnode: add a helper for loading netdev->dev_addr
In reply to Jakub KicinskiCommit 406f42fa0d3c ("net-next: When a bond have a massive amount of VLANs...") introduced a rbtree for faster Ethernet address look up. To maintain netdev->dev_addr in this tree we need to make all the writes to it got through appropriate helpers.
There is a handful of drivers which pass netdev->dev_addr as the destination buffer to device_get_mac_address(). Add a helper which takes a dev pointer instead, so it can call an appropriate helper.
---
v2: spell out address instead of addr in the function name
v3: fix function name in kdoc
--- include/linux/etherdevice.h | 1 + include/linux/property.h | 1 + net/ethernet/eth.c | 20 ++++++++++++++++++++ 3 files changed, 22 insertions(+)
include/linux/etherdevice.h +1 -0
@@ -32,6 +32,7 @@ int eth_platform_get_mac_address(struct device *dev, u8 *mac_addr);unsigned char *arch_get_platform_mac_address (void );int nvmem_get_mac_address (struct device *dev,void *addrbuf);int device_get_mac_address (struct device *dev,char *addr); +int device_get_ethdev_address (struct device *dev,struct net_device *netdev);int fwnode_get_mac_address (struct fwnode_handle *fwnode,char *addr);u32 eth_get_headlen (const struct net_device *dev,const void *data,u32 len);
include/linux/property.h +1 -0
@@ -15,6 +15,7 @@#include <linux/types.h> struct device ; +struct net_device ;enum dev_prop_type {DEV_PROP_U8 ,
net/ethernet/eth.c +20 -0
@@ -617,3 +617,23 @@ int device_get_mac_address(struct device *dev, char *addr)return fwnode_get_mac_address (dev_fwnode (dev), addr); }EXPORT_SYMBOL (device_get_mac_address); + +/** +* device_get_ethdev_address - Set netdev's MAC address from a given device +* @dev: Pointer to the device +* @netdev: Pointer to netdev to write the address to +* +* Wrapper around device_get_mac_address() which writes the address +* directly to netdev->dev_addr. +*/ +int device_get_ethdev_address (struct device *dev,struct net_device *netdev) +{ +u8 addr[ETH_ALEN ]; +int ret; + + ret =device_get_mac_address (dev, addr); +if (!ret) +eth_hw_addr_set (netdev, addr); +return ret; +} +EXPORT_SYMBOL (device_get_ethdev_address);
Signature · 1 line
2.31.1
Jakub Kicinski
maintainerPATCH v3 8/9 ethernet: use device_get_ethdev_address()
In reply to Jakub KicinskiUse the new device_get_ethdev_address() helper for the cases where dev->dev_addr is passed in directly as the destination.
@@
expression dev, np;
@@
- device_get_mac_address(np, dev->dev_addr, ETH_ALEN)
+ device_get_ethdev_address(np, dev)
--- drivers/net/ethernet/apm/xgene-v2/main.c | 2 +- drivers/net/ethernet/apm/xgene/xgene_enet_main.c | 2 +- drivers/net/ethernet/broadcom/genet/bcmgenet.c | 2 +- drivers/net/ethernet/hisilicon/hns/hns_enet.c | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-)
drivers/net/ethernet/apm/xgene-v2/main.c +1 -1
@@ -36,7 +36,7 @@ static int xge_get_resources(struct xge_pdata *pdata)return -ENOMEM ; } -if (device_get_mac_address (dev, ndev->dev_addr)) +if (device_get_ethdev_address (dev, ndev))eth_hw_addr_random (ndev);memcpy (ndev->perm_addr, ndev->dev_addr, ndev->addr_len);
drivers/net/ethernet/apm/xgene/xgene_enet_main.c +1 -1
@@ -1731,7 +1731,7 @@ static int xgene_enet_get_resources(struct xgene_enet_pdata *pdata)xgene_get_port_id_acpi (dev, pdata);#endif -if (device_get_mac_address (dev, ndev->dev_addr)) +if (device_get_ethdev_address (dev, ndev))eth_hw_addr_random (ndev);memcpy (ndev->perm_addr, ndev->dev_addr, ndev->addr_len);
drivers/net/ethernet/broadcom/genet/bcmgenet.c +1 -1
@@ -4084,7 +4084,7 @@ static int bcmgenet_probe(struct platform_device *pdev)if (pd && !IS_ERR_OR_NULL (pd->mac_address))eth_hw_addr_set (dev, pd->mac_address);else -if (device_get_mac_address (&pdev->dev, dev->dev_addr)) +if (device_get_ethdev_address (&pdev->dev, dev))if (has_acpi_companion (&pdev->dev))bcmgenet_get_hw_addr (priv, dev->dev_addr);
drivers/net/ethernet/hisilicon/hns/hns_enet.c +1 -1
@@ -1212,7 +1212,7 @@ static void hns_init_mac_addr(struct net_device *ndev) {struct hns_nic_priv *priv =netdev_priv (ndev); -if (device_get_mac_address (priv->dev, ndev->dev_addr)) { +if (device_get_ethdev_address (priv->dev, ndev)) {eth_hw_addr_random (ndev);dev_warn (priv->dev,"No valid mac, use random mac %pM" , ndev->dev_addr);
Signature · 1 line
2.31.1
Jakub Kicinski
maintainerPATCH v3 9/9 ethernet: make more use of device_get_ethdev_address()
In reply to Jakub KicinskiConvert a few drivers to device_get_ethdev_address(), saving a few LoC.
The check if addr is valid in netsec is superfluous, device_get_ethdev_addr() already checks that (in fwnode_get_mac_addr()).
---
v2: new patch
--- drivers/net/ethernet/faraday/ftgmac100.c | 5 ++--- drivers/net/ethernet/microchip/enc28j60.c | 5 +---- drivers/net/ethernet/qualcomm/emac/emac.c | 5 +---- drivers/net/ethernet/socionext/netsec.c | 9 ++------- 4 files changed, 6 insertions(+), 18 deletions(-)
drivers/net/ethernet/faraday/ftgmac100.c +2 -3
@@ -183,10 +183,9 @@ static void ftgmac100_initial_mac(struct ftgmac100 *priv)unsigned int m;unsigned int l; -if (!device_get_mac_address (priv->dev, mac)) { -eth_hw_addr_set (priv->netdev, mac); +if (!device_get_ethdev_address (priv->dev, priv->netdev)) {dev_info (priv->dev,"Read MAC address %pM from device tree\n" , - mac); + priv->netdev->dev_addr);return ; }
drivers/net/ethernet/microchip/enc28j60.c +1 -4
@@ -1539,7 +1539,6 @@ static const struct net_device_ops enc28j60_netdev_ops = {static int enc28j60_probe (struct spi_device *spi) { -unsigned char macaddr[ETH_ALEN ];struct net_device *dev;struct enc28j60_net *priv;int ret =0 ;
@@ -1572,9 +1571,7 @@ static int enc28j60_probe(struct spi_device *spi) goto error_irq; } -if (!device_get_mac_address (&spi->dev, macaddr)) -eth_hw_addr_set (dev, macaddr); -else +if (device_get_ethdev_address (&spi->dev, dev))eth_hw_addr_random (dev);enc28j60_set_hw_macaddr (dev);
drivers/net/ethernet/qualcomm/emac/emac.c +1 -4
@@ -545,13 +545,10 @@ static int emac_probe_resources(struct platform_device *pdev, struct emac_adapter *adpt) {struct net_device *netdev = adpt->netdev; -char maddr[ETH_ALEN ];int ret =0 ;/* get mac address */ -if (!device_get_mac_address (&pdev->dev, maddr)) -eth_hw_addr_set (netdev, maddr); -else +if (device_get_ethdev_address (&pdev->dev, netdev))eth_hw_addr_random (netdev);/* Core 0 interrupt */
drivers/net/ethernet/socionext/netsec.c +2 -7
@@ -1981,7 +1981,6 @@ static int netsec_probe(struct platform_device *pdev)struct netsec_priv *priv;u32 hw_ver, phy_addr =0 ;struct net_device *ndev; -u8 macbuf[ETH_ALEN ];int ret; mmio_res =platform_get_resource (pdev,IORESOURCE_MEM ,0 );
@@ -2034,12 +2033,8 @@ static int netsec_probe(struct platform_device *pdev) goto free_ndev; } - ret =device_get_mac_address (&pdev->dev, macbuf); -if (!ret) -eth_hw_addr_set (ndev, macbuf); - -if (priv->eeprom_base && - (ret || !is_valid_ether_addr (ndev->dev_addr))) { + ret =device_get_ethdev_address (&pdev->dev, ndev); +if (ret && priv->eeprom_base) {void __iomem *macp = priv->eeprom_base +NETSEC_EEPROM_MAC_ADDRESS ;
Signature · 1 line
2.31.1
This series was applied to netdev/net-next.git (refs/heads/master) by David S. Miller <[email protected]>:
Hello:
This series was applied to netdev/net-next.git (refs/heads/master) by David S. Miller <[email protected]>:
Quoted 10 lines · On Wed, 6 Oct 2021 18:06:53 -0700 you wrote:
We're trying to make all writes to
netdev->dev_addrgo via helpers. A lot of places passnetdev->dev_addrtoof_get_ethdev_address()anddevice_get_ethdev_addr()so this set adds new functions which wrap the functionality.v2 performs suggested code moves, adds a couple additional clean ups on the device property side, and an extra patch converting drivers which can benefit from
device_get_ethdev_address().[...]
Here is the summary with links:
- [net-next,v3,1/9] of: net: move of_net under net/
https://git.kernel.org/netdev/net-next/c/e330fb14590c - [net-next,v3,2/9] of: net: add a helper for loading netdev->dev_addr https://git.kernel.org/netdev/net-next/c/d466effe282d - [net-next,v3,3/9] ethernet: use of_get_ethdev_address() https://git.kernel.org/netdev/net-next/c/9ca01b25dfff - [net-next,v3,4/9] device property: move mac addr helpers to eth.c https://git.kernel.org/netdev/net-next/c/433baf0719d6 - [net-next,v3,5/9] eth: fwnode: change the return type of mac address helpers https://git.kernel.org/netdev/net-next/c/8017c4d8173c - [net-next,v3,6/9] eth: fwnode: remove the addr len from mac helpers https://git.kernel.org/netdev/net-next/c/0a14501ed818 - [net-next,v3,7/9] eth: fwnode: add a helper for loading netdev->dev_addr https://git.kernel.org/netdev/net-next/c/d9eb44904e87 - [net-next,v3,8/9] ethernet: use device_get_ethdev_address() https://git.kernel.org/netdev/net-next/c/b8eeac565b16 - [net-next,v3,9/9] ethernet: make more use of device_get_ethdev_address() https://git.kernel.org/netdev/net-next/c/894b0fb09215
You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html