Merge Official Source

Signed-off-by: Tianling Shen <cnsztl@immortalwrt.org>
This commit is contained in:
Tianling Shen 2021-08-06 10:16:48 +08:00
commit b16f148167
No known key found for this signature in database
GPG Key ID: 6850B6345C862176
63 changed files with 5093 additions and 552 deletions

View File

@ -75,6 +75,7 @@ JFFS2OPTS += $(MKFS_DEVTABLE_OPT)
SQUASHFS_BLOCKSIZE := $(CONFIG_TARGET_SQUASHFS_BLOCK_SIZE)k
SQUASHFSOPT := -b $(SQUASHFS_BLOCKSIZE)
SQUASHFSOPT += -p '/dev d 755 0 0' -p '/dev/console c 600 0 0 5 1'
SQUASHFSOPT += $(if $(CONFIG_SELINUX),-xattr,-no-xattrs)
SQUASHFSCOMP := gzip
LZMA_XZ_OPTIONS := -Xpreset 9 -Xe -Xlc 0 -Xlp 2 -Xpb 2
ifeq ($(CONFIG_SQUASHFS_XZ),y)

View File

@ -33,7 +33,7 @@ supivot() { # <new_root> <old_root>
}
switch_to_ramfs() {
RAMFS_COPY_LOSETUP="$(command -v losetup)"
RAMFS_COPY_LOSETUP="$(command -v /usr/sbin/losetup)"
RAMFS_COPY_LVM="$(command -v lvm)"
for binary in \
@ -64,6 +64,10 @@ switch_to_ramfs() {
/bin/mount -o remount,ro /mnt
/bin/umount -l /mnt
grep -e "^/dev/dm-.*" -e "^/dev/loop.*" /proc/mounts | while read bdev mp _r; do
umount $mp
done
[ "$RAMFS_COPY_LOSETUP" ] && losetup -D
[ "$RAMFS_COPY_LVM" ] && {
mkdir -p /tmp/lvm/cache

View File

@ -20,38 +20,19 @@ diff --git a/ath10k-5.10/core.c b/ath10k-5.10/core.c
index 5f4e12196..9ed7b9883 100644
--- a/ath10k-5.10/core.c
+++ b/ath10k-5.10/core.c
@@ -8,6 +8,9 @@
@@ -8,6 +8,7 @@
#include <linux/module.h>
#include <linux/firmware.h>
#include <linux/of.h>
+#include <linux/of_net.h>
+#include <linux/of_platform.h>
+#include <linux/property.h>
#include <linux/property.h>
#include <linux/dmi.h>
#include <linux/ctype.h>
@@ -2961,8 +2963,14 @@ EXPORT_SYMBOL(ath10k_core_stop);
static int ath10k_core_probe_fw(struct ath10k *ar)
{
struct bmi_target_info target_info;
+ const char *mac;
int ret = 0;
+#ifdef CONFIG_OF
+ /* register the platform to be found by the of api */
+ of_platform_device_create(ar->dev->of_node, NULL, NULL);
+#endif
+
ret = ath10k_hif_power_up(ar, ATH10K_FIRMWARE_MODE_NORMAL);
if (ret) {
ath10k_err(ar, "could not power on hif bus (%d)\n", ret);
@@ -3062,6 +3068,10 @@ static int ath10k_core_probe_fw(struct ath10k *ar)
@@ -3062,6 +3068,8 @@ static int ath10k_core_probe_fw(struct ath10k *ar)
device_get_mac_address(ar->dev, ar->mac_addr, sizeof(ar->mac_addr));
+ mac = of_get_mac_address(ar->dev->of_node);
+ if (!IS_ERR(mac))
+ ether_addr_copy(ar->mac_addr, mac);
+ of_get_mac_address(ar->dev->of_node, ar->mac_addr);
+
ret = ath10k_core_init_firmware_features(ar);
if (ret) {

View File

@ -375,7 +375,7 @@ $(eval $(call KernelPackage,ip6-vti))
define KernelPackage/xfrm-interface
SUBMENU:=$(NETWORK_SUPPORT_MENU)
TITLE:=IPsec XFRM Interface
DEPENDS:=+kmod-ipsec4 +IPV6:kmod-ipsec6
DEPENDS:=@IPV6 +kmod-ipsec4 +kmod-ipsec6
KCONFIG:=CONFIG_XFRM_INTERFACE
FILES:=$(LINUX_DIR)/net/xfrm/xfrm_interface.ko
AUTOLOAD:=$(call AutoProbe,xfrm_interface)

View File

@ -20,38 +20,19 @@ diff --git a/drivers/net/wireless/ath/ath10k/core.c b/drivers/net/wireless/ath/a
index 5f4e12196..9ed7b9883 100644
--- a/drivers/net/wireless/ath/ath10k/core.c
+++ b/drivers/net/wireless/ath/ath10k/core.c
@@ -8,6 +8,9 @@
@@ -8,6 +8,7 @@
#include <linux/module.h>
#include <linux/firmware.h>
#include <linux/of.h>
+#include <linux/of_net.h>
+#include <linux/of_platform.h>
+#include <linux/property.h>
#include <linux/property.h>
#include <linux/dmi.h>
#include <linux/ctype.h>
@@ -2961,8 +2963,14 @@ EXPORT_SYMBOL(ath10k_core_stop);
static int ath10k_core_probe_fw(struct ath10k *ar)
{
struct bmi_target_info target_info;
+ const char *mac;
int ret = 0;
+#ifdef CONFIG_OF
+ /* register the platform to be found by the of api */
+ of_platform_device_create(ar->dev->of_node, NULL, NULL);
+#endif
+
ret = ath10k_hif_power_up(ar, ATH10K_FIRMWARE_MODE_NORMAL);
if (ret) {
ath10k_err(ar, "could not power on hif bus (%d)\n", ret);
@@ -3062,6 +3068,10 @@ static int ath10k_core_probe_fw(struct ath10k *ar)
@@ -3062,6 +3068,8 @@ static int ath10k_core_probe_fw(struct ath10k *ar)
device_get_mac_address(ar->dev, ar->mac_addr, sizeof(ar->mac_addr));
+ mac = of_get_mac_address(ar->dev->of_node);
+ if (!IS_ERR(mac))
+ ether_addr_copy(ar->mac_addr, mac);
+ of_get_mac_address(ar->dev->of_node, ar->mac_addr);
+
ret = ath10k_core_init_firmware_features(ar);
if (ret) {

View File

@ -1,19 +1,18 @@
--- a/drivers/net/wireless/ralink/rt2x00/rt2x00dev.c
+++ b/drivers/net/wireless/ralink/rt2x00/rt2x00dev.c
@@ -990,8 +990,13 @@ static void rt2x00lib_rate(struct ieee80
@@ -990,6 +990,12 @@ static void rt2x00lib_rate(struct ieee80
void rt2x00lib_set_mac_address(struct rt2x00_dev *rt2x00dev, u8 *eeprom_mac_addr)
{
+ struct rt2x00_platform_data *pdata;
const char *mac_addr;
+
+ pdata = rt2x00dev->dev->platform_data;
+ if (pdata && pdata->mac_address)
+ ether_addr_copy(eeprom_mac_addr, pdata->mac_address);
+
mac_addr = of_get_mac_address(rt2x00dev->dev->of_node);
if (!IS_ERR(mac_addr))
ether_addr_copy(eeprom_mac_addr, mac_addr);
of_get_mac_address(rt2x00dev->dev->of_node, eeprom_mac_addr);
if (!is_valid_ether_addr(eeprom_mac_addr)) {
--- a/include/linux/rt2x00_platform.h
+++ b/include/linux/rt2x00_platform.h
@@ -14,6 +14,7 @@

View File

@ -0,0 +1,245 @@
From 83216e3988cd196183542937c9bd58b279f946af Mon Sep 17 00:00:00 2001
From: Michael Walle <michael@walle.cc>
Date: Mon, 12 Apr 2021 19:47:17 +0200
Subject: of: net: pass the dst buffer to of_get_mac_address()
of_get_mac_address() returns a "const void*" pointer to a MAC address.
Lately, support to fetch the MAC address by an NVMEM provider was added.
But this will only work with platform devices. It will not work with
PCI devices (e.g. of an integrated root complex) and esp. not with DSA
ports.
There is an of_* variant of the nvmem binding which works without
devices. The returned data of a nvmem_cell_read() has to be freed after
use. On the other hand the return of_get_mac_address() points to some
static data without a lifetime. The trick for now, was to allocate a
device resource managed buffer which is then returned. This will only
work if we have an actual device.
Change it, so that the caller of of_get_mac_address() has to supply a
buffer where the MAC address is written to. Unfortunately, this will
touch all drivers which use the of_get_mac_address().
Usually the code looks like:
const char *addr;
addr = of_get_mac_address(np);
if (!IS_ERR(addr))
ether_addr_copy(ndev->dev_addr, addr);
This can then be simply rewritten as:
of_get_mac_address(np, ndev->dev_addr);
Sometimes is_valid_ether_addr() is used to test the MAC address.
of_get_mac_address() already makes sure, it just returns a valid MAC
address. Thus we can just test its return code. But we have to be
careful if there are still other sources for the MAC address before the
of_get_mac_address(). In this case we have to keep the
is_valid_ether_addr() call.
The following coccinelle patch was used to convert common cases to the
new style. Afterwards, I've manually gone over the drivers and fixed the
return code variable: either used a new one or if one was already
available use that. Mansour Moufid, thanks for that coccinelle patch!
<spml>
@a@
identifier x;
expression y, z;
@@
- x = of_get_mac_address(y);
+ x = of_get_mac_address(y, z);
<...
- ether_addr_copy(z, x);
...>
@@
identifier a.x;
@@
- if (<+... x ...+>) {}
@@
identifier a.x;
@@
if (<+... x ...+>) {
...
}
- else {}
@@
identifier a.x;
expression e;
@@
- if (<+... x ...+>@e)
- {}
- else
+ if (!(e))
{...}
@@
expression x, y, z;
@@
- x = of_get_mac_address(y, z);
+ of_get_mac_address(y, z);
... when != x
</spml>
All drivers, except drivers/net/ethernet/aeroflex/greth.c, were
compile-time tested.
Suggested-by: Andrew Lunn <andrew@lunn.ch>
Signed-off-by: Michael Walle <michael@walle.cc>
Reviewed-by: Andrew Lunn <andrew@lunn.ch>
Signed-off-by: David S. Miller <davem@davemloft.net>
---
arch/arm/mach-mvebu/kirkwood.c | 3 +-
arch/powerpc/sysdev/tsi108_dev.c | 5 +-
drivers/net/ethernet/aeroflex/greth.c | 6 +--
drivers/net/ethernet/allwinner/sun4i-emac.c | 10 ++--
drivers/net/ethernet/altera/altera_tse_main.c | 7 +--
drivers/net/ethernet/arc/emac_main.c | 8 +--
drivers/net/ethernet/atheros/ag71xx.c | 7 +--
drivers/net/ethernet/broadcom/bcm4908_enet.c | 7 +--
drivers/net/ethernet/broadcom/bcmsysport.c | 7 +--
drivers/net/ethernet/broadcom/bgmac-bcma.c | 10 ++--
drivers/net/ethernet/broadcom/bgmac-platform.c | 11 ++--
drivers/net/ethernet/cadence/macb_main.c | 11 ++--
drivers/net/ethernet/cavium/octeon/octeon_mgmt.c | 8 +--
drivers/net/ethernet/cavium/thunder/thunder_bgx.c | 5 +-
drivers/net/ethernet/davicom/dm9000.c | 10 ++--
drivers/net/ethernet/ethoc.c | 6 +--
drivers/net/ethernet/ezchip/nps_enet.c | 7 +--
drivers/net/ethernet/freescale/fec_main.c | 7 +--
drivers/net/ethernet/freescale/fec_mpc52xx.c | 7 +--
drivers/net/ethernet/freescale/fman/mac.c | 9 ++--
.../net/ethernet/freescale/fs_enet/fs_enet-main.c | 5 +-
drivers/net/ethernet/freescale/gianfar.c | 8 +--
drivers/net/ethernet/freescale/ucc_geth.c | 5 +-
drivers/net/ethernet/hisilicon/hisi_femac.c | 7 +--
drivers/net/ethernet/hisilicon/hix5hd2_gmac.c | 7 +--
drivers/net/ethernet/lantiq_xrx200.c | 7 +--
drivers/net/ethernet/marvell/mv643xx_eth.c | 5 +-
drivers/net/ethernet/marvell/mvneta.c | 6 +--
.../net/ethernet/marvell/prestera/prestera_main.c | 11 ++--
drivers/net/ethernet/marvell/pxa168_eth.c | 9 +---
drivers/net/ethernet/marvell/sky2.c | 8 ++-
drivers/net/ethernet/mediatek/mtk_eth_soc.c | 11 ++--
drivers/net/ethernet/micrel/ks8851_common.c | 7 ++-
drivers/net/ethernet/microchip/lan743x_main.c | 5 +-
drivers/net/ethernet/nxp/lpc_eth.c | 4 +-
drivers/net/ethernet/qualcomm/qca_spi.c | 10 ++--
drivers/net/ethernet/qualcomm/qca_uart.c | 9 +---
drivers/net/ethernet/renesas/ravb_main.c | 12 +++--
drivers/net/ethernet/renesas/sh_eth.c | 5 +-
.../net/ethernet/samsung/sxgbe/sxgbe_platform.c | 13 ++---
drivers/net/ethernet/socionext/sni_ave.c | 10 ++--
.../net/ethernet/stmicro/stmmac/dwmac-anarion.c | 2 +-
.../ethernet/stmicro/stmmac/dwmac-dwc-qos-eth.c | 2 +-
.../net/ethernet/stmicro/stmmac/dwmac-generic.c | 2 +-
drivers/net/ethernet/stmicro/stmmac/dwmac-imx.c | 2 +-
.../net/ethernet/stmicro/stmmac/dwmac-intel-plat.c | 2 +-
.../net/ethernet/stmicro/stmmac/dwmac-ipq806x.c | 2 +-
.../net/ethernet/stmicro/stmmac/dwmac-lpc18xx.c | 2 +-
.../net/ethernet/stmicro/stmmac/dwmac-mediatek.c | 2 +-
drivers/net/ethernet/stmicro/stmmac/dwmac-meson.c | 2 +-
.../net/ethernet/stmicro/stmmac/dwmac-meson8b.c | 2 +-
drivers/net/ethernet/stmicro/stmmac/dwmac-oxnas.c | 2 +-
.../ethernet/stmicro/stmmac/dwmac-qcom-ethqos.c | 2 +-
drivers/net/ethernet/stmicro/stmmac/dwmac-rk.c | 2 +-
.../net/ethernet/stmicro/stmmac/dwmac-socfpga.c | 2 +-
drivers/net/ethernet/stmicro/stmmac/dwmac-sti.c | 2 +-
drivers/net/ethernet/stmicro/stmmac/dwmac-stm32.c | 2 +-
drivers/net/ethernet/stmicro/stmmac/dwmac-sun8i.c | 2 +-
drivers/net/ethernet/stmicro/stmmac/dwmac-sunxi.c | 2 +-
.../net/ethernet/stmicro/stmmac/dwmac-visconti.c | 2 +-
drivers/net/ethernet/stmicro/stmmac/stmmac.h | 2 +-
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 2 +-
.../net/ethernet/stmicro/stmmac/stmmac_platform.c | 14 ++---
.../net/ethernet/stmicro/stmmac/stmmac_platform.h | 2 +-
drivers/net/ethernet/ti/am65-cpsw-nuss.c | 19 ++++---
drivers/net/ethernet/ti/cpsw.c | 7 +--
drivers/net/ethernet/ti/cpsw_new.c | 7 +--
drivers/net/ethernet/ti/davinci_emac.c | 8 +--
drivers/net/ethernet/ti/netcp_core.c | 7 +--
drivers/net/ethernet/wiznet/w5100-spi.c | 8 ++-
drivers/net/ethernet/wiznet/w5100.c | 2 +-
drivers/net/ethernet/xilinx/ll_temac_main.c | 8 +--
drivers/net/ethernet/xilinx/xilinx_axienet_main.c | 15 +++---
drivers/net/ethernet/xilinx/xilinx_emaclite.c | 8 +--
drivers/net/wireless/ath/ath9k/init.c | 5 +-
drivers/net/wireless/mediatek/mt76/eeprom.c | 9 +---
drivers/net/wireless/ralink/rt2x00/rt2x00dev.c | 6 +--
drivers/of/of_net.c | 60 ++++++++++------------
drivers/staging/octeon/ethernet.c | 10 ++--
drivers/staging/wfx/main.c | 7 ++-
include/linux/of_net.h | 6 +--
include/net/dsa.h | 2 +-
net/dsa/dsa2.c | 2 +-
net/dsa/slave.c | 2 +-
net/ethernet/eth.c | 11 ++--
85 files changed, 218 insertions(+), 364 deletions(-)
diff --git a/drivers/net/wireless/ath/ath9k/init.c b/drivers/net/wireless/ath/ath9k/init.c
index 01f9c26f9bf37..e9a36dd7144f1 100644
--- a/drivers/net/wireless/ath/ath9k/init.c
+++ b/drivers/net/wireless/ath/ath9k/init.c
@@ -617,7 +617,6 @@ static int ath9k_of_init(struct ath_softc *sc)
struct ath_hw *ah = sc->sc_ah;
struct ath_common *common = ath9k_hw_common(ah);
enum ath_bus_type bus_type = common->bus_ops->ath_bus_type;
- const char *mac;
char eeprom_name[100];
int ret;
@@ -640,9 +639,7 @@ static int ath9k_of_init(struct ath_softc *sc)
ah->ah_flags |= AH_NO_EEP_SWAP;
}
- mac = of_get_mac_address(np);
- if (!IS_ERR(mac))
- ether_addr_copy(common->macaddr, mac);
+ of_get_mac_address(np, common->macaddr);
return 0;
}
diff --git a/drivers/net/wireless/mediatek/mt76/eeprom.c b/drivers/net/wireless/mediatek/mt76/eeprom.c
index 665b54c5c8ae5..6d895738222ad 100644
--- a/drivers/net/wireless/mediatek/mt76/eeprom.c
+++ b/drivers/net/wireless/mediatek/mt76/eeprom.c
@@ -91,15 +91,9 @@ void
void
mt76_eeprom_override(struct mt76_dev *dev)
{
-#ifdef CONFIG_OF
struct device_node *np = dev->dev->of_node;
- const u8 *mac = NULL;
- if (np)
- mac = of_get_mac_address(np);
- if (!IS_ERR_OR_NULL(mac))
- ether_addr_copy(dev->macaddr, mac);
-#endif
+ of_get_mac_address(np, dev->macaddr);
if (!is_valid_ether_addr(dev->macaddr)) {
eth_random_addr(dev->macaddr);
diff --git a/drivers/net/wireless/ralink/rt2x00/rt2x00dev.c b/drivers/net/wireless/ralink/rt2x00/rt2x00dev.c
index 61a4f1ad31e28..e95c101c27111 100644
--- a/drivers/net/wireless/ralink/rt2x00/rt2x00dev.c
+++ b/drivers/net/wireless/ralink/rt2x00/rt2x00dev.c
@@ -989,11 +989,7 @@ static void rt2x00lib_rate(struct ieee80211_rate *entry,
void rt2x00lib_set_mac_address(struct rt2x00_dev *rt2x00dev, u8 *eeprom_mac_addr)
{
- const char *mac_addr;
-
- mac_addr = of_get_mac_address(rt2x00dev->dev->of_node);
- if (!IS_ERR(mac_addr))
- ether_addr_copy(eeprom_mac_addr, mac_addr);
+ of_get_mac_address(rt2x00dev->dev->of_node, eeprom_mac_addr);
if (!is_valid_ether_addr(eeprom_mac_addr)) {
eth_random_addr(eeprom_mac_addr);
--
cgit 1.2.3-1.el7

View File

@ -0,0 +1,206 @@
From 83216e3988cd196183542937c9bd58b279f946af Mon Sep 17 00:00:00 2001
From: Michael Walle <michael@walle.cc>
Date: Mon, 12 Apr 2021 19:47:17 +0200
Subject: of: net: pass the dst buffer to of_get_mac_address()
of_get_mac_address() returns a "const void*" pointer to a MAC address.
Lately, support to fetch the MAC address by an NVMEM provider was added.
But this will only work with platform devices. It will not work with
PCI devices (e.g. of an integrated root complex) and esp. not with DSA
ports.
There is an of_* variant of the nvmem binding which works without
devices. The returned data of a nvmem_cell_read() has to be freed after
use. On the other hand the return of_get_mac_address() points to some
static data without a lifetime. The trick for now, was to allocate a
device resource managed buffer which is then returned. This will only
work if we have an actual device.
Change it, so that the caller of of_get_mac_address() has to supply a
buffer where the MAC address is written to. Unfortunately, this will
touch all drivers which use the of_get_mac_address().
Usually the code looks like:
const char *addr;
addr = of_get_mac_address(np);
if (!IS_ERR(addr))
ether_addr_copy(ndev->dev_addr, addr);
This can then be simply rewritten as:
of_get_mac_address(np, ndev->dev_addr);
Sometimes is_valid_ether_addr() is used to test the MAC address.
of_get_mac_address() already makes sure, it just returns a valid MAC
address. Thus we can just test its return code. But we have to be
careful if there are still other sources for the MAC address before the
of_get_mac_address(). In this case we have to keep the
is_valid_ether_addr() call.
The following coccinelle patch was used to convert common cases to the
new style. Afterwards, I've manually gone over the drivers and fixed the
return code variable: either used a new one or if one was already
available use that. Mansour Moufid, thanks for that coccinelle patch!
<spml>
@a@
identifier x;
expression y, z;
@@
- x = of_get_mac_address(y);
+ x = of_get_mac_address(y, z);
<...
- ether_addr_copy(z, x);
...>
@@
identifier a.x;
@@
- if (<+... x ...+>) {}
@@
identifier a.x;
@@
if (<+... x ...+>) {
...
}
- else {}
@@
identifier a.x;
expression e;
@@
- if (<+... x ...+>@e)
- {}
- else
+ if (!(e))
{...}
@@
expression x, y, z;
@@
- x = of_get_mac_address(y, z);
+ of_get_mac_address(y, z);
... when != x
</spml>
All drivers, except drivers/net/ethernet/aeroflex/greth.c, were
compile-time tested.
Suggested-by: Andrew Lunn <andrew@lunn.ch>
Signed-off-by: Michael Walle <michael@walle.cc>
Reviewed-by: Andrew Lunn <andrew@lunn.ch>
Signed-off-by: David S. Miller <davem@davemloft.net>
---
arch/arm/mach-mvebu/kirkwood.c | 3 +-
arch/powerpc/sysdev/tsi108_dev.c | 5 +-
drivers/net/ethernet/aeroflex/greth.c | 6 +--
drivers/net/ethernet/allwinner/sun4i-emac.c | 10 ++--
drivers/net/ethernet/altera/altera_tse_main.c | 7 +--
drivers/net/ethernet/arc/emac_main.c | 8 +--
drivers/net/ethernet/atheros/ag71xx.c | 7 +--
drivers/net/ethernet/broadcom/bcm4908_enet.c | 7 +--
drivers/net/ethernet/broadcom/bcmsysport.c | 7 +--
drivers/net/ethernet/broadcom/bgmac-bcma.c | 10 ++--
drivers/net/ethernet/broadcom/bgmac-platform.c | 11 ++--
drivers/net/ethernet/cadence/macb_main.c | 11 ++--
drivers/net/ethernet/cavium/octeon/octeon_mgmt.c | 8 +--
drivers/net/ethernet/cavium/thunder/thunder_bgx.c | 5 +-
drivers/net/ethernet/davicom/dm9000.c | 10 ++--
drivers/net/ethernet/ethoc.c | 6 +--
drivers/net/ethernet/ezchip/nps_enet.c | 7 +--
drivers/net/ethernet/freescale/fec_main.c | 7 +--
drivers/net/ethernet/freescale/fec_mpc52xx.c | 7 +--
drivers/net/ethernet/freescale/fman/mac.c | 9 ++--
.../net/ethernet/freescale/fs_enet/fs_enet-main.c | 5 +-
drivers/net/ethernet/freescale/gianfar.c | 8 +--
drivers/net/ethernet/freescale/ucc_geth.c | 5 +-
drivers/net/ethernet/hisilicon/hisi_femac.c | 7 +--
drivers/net/ethernet/hisilicon/hix5hd2_gmac.c | 7 +--
drivers/net/ethernet/lantiq_xrx200.c | 7 +--
drivers/net/ethernet/marvell/mv643xx_eth.c | 5 +-
drivers/net/ethernet/marvell/mvneta.c | 6 +--
.../net/ethernet/marvell/prestera/prestera_main.c | 11 ++--
drivers/net/ethernet/marvell/pxa168_eth.c | 9 +---
drivers/net/ethernet/marvell/sky2.c | 8 ++-
drivers/net/ethernet/mediatek/mtk_eth_soc.c | 11 ++--
drivers/net/ethernet/micrel/ks8851_common.c | 7 ++-
drivers/net/ethernet/microchip/lan743x_main.c | 5 +-
drivers/net/ethernet/nxp/lpc_eth.c | 4 +-
drivers/net/ethernet/qualcomm/qca_spi.c | 10 ++--
drivers/net/ethernet/qualcomm/qca_uart.c | 9 +---
drivers/net/ethernet/renesas/ravb_main.c | 12 +++--
drivers/net/ethernet/renesas/sh_eth.c | 5 +-
.../net/ethernet/samsung/sxgbe/sxgbe_platform.c | 13 ++---
drivers/net/ethernet/socionext/sni_ave.c | 10 ++--
.../net/ethernet/stmicro/stmmac/dwmac-anarion.c | 2 +-
.../ethernet/stmicro/stmmac/dwmac-dwc-qos-eth.c | 2 +-
.../net/ethernet/stmicro/stmmac/dwmac-generic.c | 2 +-
drivers/net/ethernet/stmicro/stmmac/dwmac-imx.c | 2 +-
.../net/ethernet/stmicro/stmmac/dwmac-intel-plat.c | 2 +-
.../net/ethernet/stmicro/stmmac/dwmac-ipq806x.c | 2 +-
.../net/ethernet/stmicro/stmmac/dwmac-lpc18xx.c | 2 +-
.../net/ethernet/stmicro/stmmac/dwmac-mediatek.c | 2 +-
drivers/net/ethernet/stmicro/stmmac/dwmac-meson.c | 2 +-
.../net/ethernet/stmicro/stmmac/dwmac-meson8b.c | 2 +-
drivers/net/ethernet/stmicro/stmmac/dwmac-oxnas.c | 2 +-
.../ethernet/stmicro/stmmac/dwmac-qcom-ethqos.c | 2 +-
drivers/net/ethernet/stmicro/stmmac/dwmac-rk.c | 2 +-
.../net/ethernet/stmicro/stmmac/dwmac-socfpga.c | 2 +-
drivers/net/ethernet/stmicro/stmmac/dwmac-sti.c | 2 +-
drivers/net/ethernet/stmicro/stmmac/dwmac-stm32.c | 2 +-
drivers/net/ethernet/stmicro/stmmac/dwmac-sun8i.c | 2 +-
drivers/net/ethernet/stmicro/stmmac/dwmac-sunxi.c | 2 +-
.../net/ethernet/stmicro/stmmac/dwmac-visconti.c | 2 +-
drivers/net/ethernet/stmicro/stmmac/stmmac.h | 2 +-
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 2 +-
.../net/ethernet/stmicro/stmmac/stmmac_platform.c | 14 ++---
.../net/ethernet/stmicro/stmmac/stmmac_platform.h | 2 +-
drivers/net/ethernet/ti/am65-cpsw-nuss.c | 19 ++++---
drivers/net/ethernet/ti/cpsw.c | 7 +--
drivers/net/ethernet/ti/cpsw_new.c | 7 +--
drivers/net/ethernet/ti/davinci_emac.c | 8 +--
drivers/net/ethernet/ti/netcp_core.c | 7 +--
drivers/net/ethernet/wiznet/w5100-spi.c | 8 ++-
drivers/net/ethernet/wiznet/w5100.c | 2 +-
drivers/net/ethernet/xilinx/ll_temac_main.c | 8 +--
drivers/net/ethernet/xilinx/xilinx_axienet_main.c | 15 +++---
drivers/net/ethernet/xilinx/xilinx_emaclite.c | 8 +--
drivers/net/wireless/ath/ath9k/init.c | 5 +-
drivers/net/wireless/mediatek/mt76/eeprom.c | 9 +---
drivers/net/wireless/ralink/rt2x00/rt2x00dev.c | 6 +--
drivers/of/of_net.c | 60 ++++++++++------------
drivers/staging/octeon/ethernet.c | 10 ++--
drivers/staging/wfx/main.c | 7 ++-
include/linux/of_net.h | 6 +--
include/net/dsa.h | 2 +-
net/dsa/dsa2.c | 2 +-
net/dsa/slave.c | 2 +-
net/ethernet/eth.c | 11 ++--
85 files changed, 218 insertions(+), 364 deletions(-)
diff --git a/drivers/net/wireless/mediatek/mt76/eeprom.c b/drivers/net/wireless/mediatek/mt76/eeprom.c
index 665b54c5c8ae5..6d895738222ad 100644
--- a/eeprom.c
+++ b/eeprom.c
@@ -91,15 +91,9 @@ void
{
struct mt76_dev *dev = phy->dev;
-#ifdef CONFIG_OF
struct device_node *np = dev->dev->of_node;
- const u8 *mac = NULL;
- if (np)
- mac = of_get_mac_address(np);
- if (!IS_ERR_OR_NULL(mac))
- ether_addr_copy(phy->macaddr, mac);
-#endif
+ of_get_mac_address(np, phy->macaddr);
if (!is_valid_ether_addr(phy->macaddr)) {
eth_random_addr(phy->macaddr);
--
cgit 1.2.3-1.el7

View File

@ -3,11 +3,11 @@ include $(INCLUDE_DIR)/kernel.mk
PKG_NAME:=nat46
PKG_MIRROR_HASH:=3b424241de42b96d47217decf6f9071153cd0c11651f1ee006700836c6660fe8
PKG_MIRROR_HASH:=a74a9a84605bac6186adf37025b3880eb9cf5931791bb61d47e69b8898cac411
PKG_SOURCE_URL:=https://github.com/ayourtch/nat46.git
PKG_SOURCE_DATE:=2021-05-17
PKG_SOURCE_DATE:=2021-06-24
PKG_SOURCE_PROTO:=git
PKG_SOURCE_VERSION:=0d5860d63a8037e001e293091ebf6219cc2f9255
PKG_SOURCE_VERSION:=9b3a8197421d987d77e1b9df4159cfe0b9820ee9
PKG_MAINTAINER:=Hans Dedecker <dedeckeh@gmail.com>
PKG_LICENSE:=GPL-2.0

View File

@ -187,8 +187,22 @@ append_notinterface() {
xappend "--except-interface=$ifname"
}
ismounted() {
local filename="$1"
local dirname
for dirname in $EXTRA_MOUNT ; do
case "$filename" in
"${dirname}/"* | "${dirname}" )
return 1
;;
esac
done
return 0
}
append_addnhosts() {
append EXTRA_MOUNT "$1"
ismounted "$1" || append EXTRA_MOUNT "$1"
xappend "--addn-hosts=$1"
}
@ -803,9 +817,10 @@ dnsmasq_start()
config_get_bool disabled "$cfg" disabled 0
[ "$disabled" -gt 0 ] && return 0
# reset list of DOMAINS and DNS servers (for each dnsmasq instance)
# reset list of DOMAINS, DNS servers and EXTRA mounts (for each dnsmasq instance)
DNS_SERVERS=""
DOMAIN=""
EXTRA_MOUNT=""
CONFIGFILE="${BASECONFIGFILE}.${cfg}"
CONFIGFILE_TMP="${CONFIGFILE}.$$"
HOSTFILE="${BASEHOSTFILE}.${cfg}"
@ -931,6 +946,14 @@ dnsmasq_start()
config_list_foreach "$cfg" "interface" append_interface
config_list_foreach "$cfg" "notinterface" append_notinterface
}
config_get_bool ignore_hosts_dir "$cfg" ignore_hosts_dir 0
if [ "$ignore_hosts_dir" = "1" ]; then
xappend "--addn-hosts=$HOSTFILE"
append EXTRA_MOUNT "$HOSTFILE"
else
xappend "--addn-hosts=$(dirname $HOSTFILE)"
append EXTRA_MOUNT "$(dirname $HOSTFILE)"
fi
config_list_foreach "$cfg" "addnhosts" append_addnhosts
config_list_foreach "$cfg" "bogusnxdomain" append_bogusnxdomain
append_parm "$cfg" "leasefile" "--dhcp-leasefile" "/tmp/dhcp.leases"
@ -1026,12 +1049,6 @@ dnsmasq_start()
xappend "--dhcp-broadcast=tag:needs-broadcast"
config_get_bool ignore_hosts_dir "$cfg" ignore_hosts_dir 0
if [ "$ignore_hosts_dir" = "1" ]; then
xappend "--addn-hosts=$HOSTFILE"
else
xappend "--addn-hosts=$(dirname $HOSTFILE)"
fi
config_get dnsmasqconfdir "$cfg" confdir "/tmp/dnsmasq.d"
xappend "--conf-dir=$dnsmasqconfdir"
@ -1125,10 +1142,9 @@ dnsmasq_start()
procd_set_param respawn
procd_add_jail dnsmasq ubus log
procd_add_jail_mount $CONFIGFILE $TRUSTANCHORSFILE $HOSTFILE $RFC6761FILE
procd_add_jail_mount $EXTRA_MOUNT $DHCPBOGUSHOSTNAMEFILE $DHCPSCRIPT $DHCPSCRIPT_DEPENDS
procd_add_jail_mount $CONFIGFILE $DHCPBOGUSHOSTNAMEFILE $DHCPSCRIPT $DHCPSCRIPT_DEPENDS
procd_add_jail_mount $EXTRA_MOUNT $RFC6761FILE $TRUSTANCHORSFILE
procd_add_jail_mount $dnsmasqconffile $dnsmasqconfdir $resolvdir $user_dhcpscript
procd_add_jail_mount /dev/null /dev/urandom
procd_add_jail_mount /etc/passwd /etc/group /etc/TZ /etc/hosts /etc/ethers
procd_add_jail_mount_rw /var/run/dnsmasq/ $leasefile

View File

@ -8,13 +8,13 @@
include $(TOPDIR)/rules.mk
PKG_NAME:=ethtool
PKG_VERSION:=5.12
PKG_VERSION:=5.13
PKG_RELEASE:=1
PKG_MAINTAINER:=Felix Fietkau <nbd@nbd.name>
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.xz
PKG_SOURCE_URL:=@KERNEL/software/network/ethtool
PKG_HASH:=f5ddfa9c75053d8011b8c8c99ec4e2d3c83cd1972f638692d62e37fa3ef36f07
PKG_HASH:=e63a7254c6cf2e443d9989c8c34a94e136d789ae1cf5da55397439b055e48cf3
PKG_LICENSE:=GPL-2.0
PKG_LICENSE_FILES:=COPYING
@ -23,8 +23,6 @@ PKG_FIXUP:=autoreconf
PKG_INSTALL:=1
PKG_BUILD_PARALLEL:=1
PKG_CONFIG_DEPENDS:=CONFIG_ETHTOOL_PRETTY_DUMP
include $(INCLUDE_DIR)/package.mk
define Package/ethtool
@ -32,6 +30,16 @@ define Package/ethtool
CATEGORY:=Network
TITLE:=Display or change ethernet card settings
URL:=http://www.kernel.org/pub/software/network/ethtool/
VARIANT:=tiny
endef
define Package/ethtool-full
$(Package/ethtool)
TITLE += (full)
VARIANT:=full
PROVIDES:=ethtool
CONFLICTS:=ethtool
DEPENDS:=+libmnl
endef
define Package/ethtool/description
@ -39,18 +47,12 @@ define Package/ethtool/description
network interface
endef
define Package/ethtool/config
config ETHTOOL_PRETTY_DUMP
depends on PACKAGE_ethtool
bool "Enable pretty printing"
endef
Package/ethtool-full/description:=$(Package/ethtool/description)
CONFIGURE_ARGS += --disable-netlink
ifeq ($(CONFIG_ETHTOOL_PRETTY_DUMP),y)
CONFIGURE_ARGS += --enable-pretty-dump
ifeq ($(BUILD_VARIANT),full)
CONFIGURE_ARGS += --enable-netlink --enable-pretty-dump
else
CONFIGURE_ARGS += --disable-pretty-dump
CONFIGURE_ARGS += --disable-netlink --disable-pretty-dump
endif
define Package/ethtool/install
@ -58,4 +60,7 @@ define Package/ethtool/install
$(INSTALL_BIN) $(PKG_BUILD_DIR)/ethtool $(1)/usr/sbin
endef
Package/ethtool-full/install=$(Package/ethtool/install)
$(eval $(call BuildPackage,ethtool))
$(eval $(call BuildPackage,ethtool-full))

View File

@ -12,9 +12,9 @@ PKG_RELEASE:=$(AUTORELEASE)
PKG_SOURCE_PROTO:=git
PKG_SOURCE_URL=$(PROJECT_GIT)/project/fstools.git
PKG_MIRROR_HASH:=77c24dabca546a376d1b4ee0d00975ca1382f468c357cd6128724fff43eaecad
PKG_SOURCE_DATE:=2021-07-30
PKG_SOURCE_VERSION:=b7bf18563769e26d24cdace973d09f9c438bbd34
PKG_MIRROR_HASH:=9cf9b4fd5951196813deb5c71dd24ad7af89348f7e647545b38760332953a8dc
PKG_SOURCE_DATE:=2021-08-05
PKG_SOURCE_VERSION:=d4f01298105bb8c97e7ac0cad0e78f0ffe261354
CMAKE_INSTALL:=1
PKG_LICENSE:=GPL-2.0

View File

@ -12,9 +12,9 @@ PKG_RELEASE:=$(AUTORELEASE)
PKG_SOURCE_PROTO:=git
PKG_SOURCE_URL=$(PROJECT_GIT)/project/procd.git
PKG_SOURCE_DATE:=2021-07-25
PKG_SOURCE_VERSION:=f26233edb6a550bf23d51d5d4c864baf093e46e1
PKG_MIRROR_HASH:=6160291a1b94cf89e4e438440ef393119f88c6182937d557a9e2864e765322a6
PKG_SOURCE_DATE:=2021-08-05
PKG_SOURCE_VERSION:=f5d9b14fea85e3272cac5200fb32a5c99ba7fdff
PKG_MIRROR_HASH:=0be2b84480d63a431721bf01ca95f927717f11c6cecccd1fc7c0e7ea6f2d4e51
CMAKE_INSTALL:=1
PKG_LICENSE:=GPL-2.0

View File

@ -329,6 +329,78 @@ _procd_add_config_trigger() {
json_close_array
}
_procd_add_mount_trigger() {
json_add_array
_procd_add_array_data "$1"
local action="$2"
local multi=0
shift ; shift
json_add_array
_procd_add_array_data "if"
if [ "$2" ]; then
json_add_array
_procd_add_array_data "or"
multi=1
fi
while [ "$1" ]; do
json_add_array
_procd_add_array_data "eq" "target" "$1"
shift
json_close_array
done
[ $multi = 1 ] && json_close_array
json_add_array
_procd_add_array_data "run_script" /etc/init.d/$name $action
json_close_array
json_close_array
_procd_add_timeout
json_close_array
}
_procd_add_action_mount_trigger() {
local script=$(readlink "$initscript")
local name=$(basename ${script:-$initscript})
local action="$1"
local mpath
shift
_procd_open_trigger
_procd_add_mount_trigger mount.add $action "$@"
_procd_close_trigger
}
procd_get_mountpoints() {
(
__procd_check_mount() {
local cfg="$1"
local path="${2%%/}/"
local target
config_get target "$cfg" target
target="${target%%/}/"
[ "$path" != "${path##$target}" ] && echo "${target%%/}"
}
config_load fstab
for mpath in "$@"; do
config_foreach __procd_check_mount mount "$mpath"
done
) | sort -u
}
_procd_add_start_mount_trigger() {
_procd_add_action_mount_trigger start $(procd_get_mountpoints "$@")
}
_procd_add_reload_mount_trigger() {
_procd_add_action_mount_trigger reload $(procd_get_mountpoints "$@")
}
_procd_add_raw_trigger() {
json_add_array
_procd_add_array_data "$1"
@ -560,8 +632,11 @@ _procd_wrapper \
procd_add_raw_trigger \
procd_add_config_trigger \
procd_add_interface_trigger \
procd_add_mount_trigger \
procd_add_reload_trigger \
procd_add_reload_interface_trigger \
procd_add_reload_mount_trigger \
procd_add_start_mount_trigger \
procd_open_trigger \
procd_close_trigger \
procd_open_instance \

View File

@ -5,9 +5,9 @@ PKG_RELEASE:=2
PKG_SOURCE_PROTO:=git
PKG_SOURCE_URL=$(PROJECT_GIT)/project/ubox.git
PKG_SOURCE_DATE:=2020-10-25
PKG_SOURCE_VERSION:=9ef886819dd48303d8ced4cdbc9afbf32682535c
PKG_MIRROR_HASH:=e2d93b798b91de98cb003f7b3be97d3d8a2413c8612b527d096c86ac5365cbdd
PKG_SOURCE_DATE:=2021-08-03
PKG_SOURCE_VERSION:=205defb597295a4a8966db3e618cfe41a29bed99
PKG_MIRROR_HASH:=22da1601424c13af8751424b4216f32910a26da49408b6f309158ed8cee93034
CMAKE_INSTALL:=1
PKG_LICENSE:=GPL-2.0

View File

@ -0,0 +1,139 @@
// SPDX-License-Identifier: GPL-2.0-or-later OR MIT
#include "qca953x.dtsi"
#include <dt-bindings/gpio/gpio.h>
#include <dt-bindings/input/input.h>
/ {
compatible = "glinet,gl-x300b", "qca,qca9531";
model = "GL.iNet GL-X300B";
keys {
compatible = "gpio-keys";
pinctrl-names = "default";
pinctrl-0 = <&jtag_disable_pins>;
reset {
label = "reset";
linux,code = <KEY_RESTART>;
gpios = <&gpio 3 GPIO_ACTIVE_LOW>;
};
};
leds {
compatible = "gpio-leds";
wlan2g {
label = "green:wlan2g";
gpios = <&gpio 4 GPIO_ACTIVE_LOW>;
linux,default-trigger = "phy0tpt";
};
wan {
label = "green:wan";
gpios = <&gpio 13 GPIO_ACTIVE_LOW>;
};
lte {
label = "green:lte";
gpios = <&gpio 15 GPIO_ACTIVE_LOW>;
};
};
gpio-export {
compatible = "gpio-export";
minipcie {
gpio-export,name = "minipcie";
gpio-export,output = <0>;
gpios = <&gpio 0 GPIO_ACTIVE_HIGH>;
};
rs485tx_en {
gpio-export,name = "rs485tx_en";
gpio-export,output = <0>;
gpios = <&gpio 1 GPIO_ACTIVE_HIGH>;
};
ble_rst {
gpio-export,name = "ble_rst";
gpio-export,output = <0>;
gpios = <&gpio 16 GPIO_ACTIVE_HIGH>;
};
};
watchdog {
compatible = "hw_wdt";
dog_en_gpio = <12>;
feed_dog_gpio = <2>;
feed_dog_interval = <100000000>;
};
};
&usb0 {
status = "okay";
};
&usb_phy {
status = "okay";
};
&spi {
status = "okay";
flash@0 {
compatible = "jedec,spi-nor";
reg = <0>;
spi-max-frequency = <25000000>;
nor_partitions: partitions {
compatible = "fixed-partitions";
#address-cells = <1>;
#size-cells = <1>;
partition@0 {
label = "u-boot";
reg = <0x000000 0x040000>;
read-only;
};
partition@40000 {
label = "u-boot-env";
reg = <0x040000 0x010000>;
};
art: partition@50000 {
label = "art";
reg = <0x050000 0x010000>;
read-only;
};
partition@60000 {
compatible = "denx,uimage";
label = "firmware";
reg = <0x060000 0xfa0000>;
};
};
};
};
&eth0 {
status = "okay";
mtd-mac-address = <&art 0x0>;
phy-handle = <&swphy4>;
};
&eth1 {
mtd-mac-address = <&art 0x0>;
mtd-mac-address-increment = <1>;
};
&wmac {
status = "okay";
mtd-cal-data = <&art 0x1000>;
};

View File

@ -1519,7 +1519,6 @@ static int ag71xx_probe(struct platform_device *pdev)
struct net_device *dev;
struct resource *res;
struct ag71xx *ag;
const void *mac_addr;
u32 max_frame_len;
int tx_size, err;
@ -1668,12 +1667,10 @@ static int ag71xx_probe(struct platform_device *pdev)
ag->stop_desc->ctrl = 0;
ag->stop_desc->next = (u32) ag->stop_desc_dma;
mac_addr = of_get_mac_address(np);
if (IS_ERR_OR_NULL(mac_addr) || !is_valid_ether_addr(mac_addr)) {
of_get_mac_address(np, dev->dev_addr);
if (!is_valid_ether_addr(dev->dev_addr)) {
dev_err(&pdev->dev, "invalid MAC address, using random address\n");
eth_random_addr(dev->dev_addr);
} else {
memcpy(dev->dev_addr, mac_addr, ETH_ALEN);
}
#if LINUX_VERSION_CODE >= KERNEL_VERSION(5,10,0)

View File

@ -219,6 +219,7 @@ qxwlan,e750a-v4-16m)
ucidef_set_led_switch "lan" "LAN" "green:lan" "switch0" "0x02"
ucidef_set_led_netdev "wan" "WAN" "green:wan" "eth1"
;;
glinet,gl-x300b|\
glinet,gl-x750)
ucidef_set_led_netdev "wan" "WAN" "green:wan" "eth1"
;;

View File

@ -272,6 +272,11 @@ ath79_setup_interfaces()
ucidef_add_switch "switch0" \
"0@eth0" "1:lan" "2:lan"
;;
glinet,gl-x300b)
ucidef_set_interface_wan "eth1"
ucidef_add_switch "switch0" \
"0@eth0" "4:lan"
;;
iodata,etg3-r|\
iodata,wn-ac1167dgr|\
iodata,wn-ac1600dgr|\

View File

@ -1270,6 +1270,15 @@ define Device/glinet_gl-usb150
endef
TARGET_DEVICES += glinet_gl-usb150
define Device/glinet_gl-x300b
SOC := qca9531
DEVICE_VENDOR := GL.iNet
DEVICE_MODEL := GL-X300B
DEVICE_PACKAGES := kmod-usb2
IMAGE_SIZE := 16000k
endef
TARGET_DEVICES += glinet_gl-x300b
define Device/glinet_gl-x750
SOC := qca9531
DEVICE_VENDOR := GL.iNet

View File

@ -25,23 +25,13 @@ Signed-off-by: David S. Miller <davem@davemloft.net>
#include <linux/platform_device.h>
#include <linux/slab.h>
#include <linux/string.h>
@@ -620,6 +621,7 @@ static int bcm4908_enet_probe(struct pla
struct device *dev = &pdev->dev;
struct net_device *netdev;
struct bcm4908_enet *enet;
+ const u8 *mac;
int err;
netdev = devm_alloc_etherdev(dev, sizeof(*enet));
@@ -647,7 +649,11 @@ static int bcm4908_enet_probe(struct pla
@@ -647,7 +649,9 @@ static int bcm4908_enet_probe(struct pla
return err;
SET_NETDEV_DEV(netdev, &pdev->dev);
- eth_hw_addr_random(netdev);
+ mac = of_get_mac_address(dev->of_node);
+ if (!IS_ERR(mac))
+ ether_addr_copy(netdev->dev_addr, mac);
+ else
+ of_get_mac_address(dev->of_node, netdev->dev_addr);
+ if (!is_valid_ether_addr(netdev->dev_addr))
+ eth_hw_addr_random(netdev);
netdev->netdev_ops = &bcm4908_enet_netdev_ops;
netdev->min_mtu = ETH_ZLEN;

View File

@ -167,7 +167,6 @@ static int ath9k_fixup_probe(struct platform_device *pdev)
struct device_node *node = dev->of_node;
struct ath9k_fixup *priv;
struct resource *res;
const void *mac;
int ret;
if (ath9k_num_fixups >= ATH9K_MAX_FIXUPS)
@ -200,9 +199,8 @@ static int ath9k_fixup_probe(struct platform_device *pdev)
priv->pdata.led_active_high = of_property_read_bool(node,
"ath,led-active-high");
mac = of_get_mac_address(node);
if (!IS_ERR_OR_NULL(mac)) {
memcpy(priv->mac, mac, ETH_ALEN);
of_get_mac_address(node, priv->mac);
if (is_valid_ether_addr(priv->mac)) {
dev_info(dev, "mtd mac %pM\n", priv->mac);
} else {
random_ether_addr(priv->mac);

View File

@ -1119,7 +1119,6 @@ static int b43_sprom_probe(struct platform_device *pdev)
struct device *dev = &pdev->dev;
struct device_node *node = dev->of_node;
struct b43_sprom *priv = &b43_sprom;
const void *mac;
int ret;
priv->dev = dev;
@ -1129,9 +1128,8 @@ static int b43_sprom_probe(struct platform_device *pdev)
of_property_read_u32(node, "pci-bus", &priv->pci_bus);
of_property_read_u32(node, "pci-dev", &priv->pci_dev);
mac = of_get_mac_address(node);
if (!IS_ERR_OR_NULL(mac)) {
memcpy(priv->mac, mac, ETH_ALEN);
of_get_mac_address(node, priv->mac);
if (is_valid_ether_addr(priv->mac)) {
dev_info(dev, "mtd mac %pM\n", priv->mac);
} else {
random_ether_addr(priv->mac);

View File

@ -864,7 +864,6 @@ static int bcm6368_enetsw_probe(struct platform_device *pdev)
struct device_node *node = dev->of_node;
struct net_device *ndev;
struct resource *res;
const void *mac;
unsigned i;
int ret;
@ -953,9 +952,8 @@ static int bcm6368_enetsw_probe(struct platform_device *pdev)
priv->dma_chan_int_mask = DMAC_IR_PKTDONE_MASK;
priv->dma_chan_width = DMA_CHAN_WIDTH;
mac = of_get_mac_address(node);
if (!IS_ERR_OR_NULL(mac)) {
memcpy(ndev->dev_addr, mac, ETH_ALEN);
of_get_mac_address(node, ndev->dev_addr);
if (is_valid_ether_addr(ndev->dev_addr)) {
dev_info(dev, "mtd mac %pM\n", ndev->dev_addr);
} else {
random_ether_addr(ndev->dev_addr);

View File

@ -0,0 +1,77 @@
From f10843e04a075202dbb39dfcee047e3a2fdf5a8d Mon Sep 17 00:00:00 2001
From: Michael Walle <michael@walle.cc>
Date: Mon, 12 Apr 2021 19:47:18 +0200
Subject: of: net: fix of_get_mac_addr_nvmem() for non-platform devices
of_get_mac_address() already supports fetching the MAC address by an
nvmem provider. But until now, it was just working for platform devices.
Esp. it was not working for DSA ports and PCI devices. It gets more
common that PCI devices have a device tree binding since SoCs contain
integrated root complexes.
Use the nvmem of_* binding to fetch the nvmem cells by a struct
device_node. We still have to try to read the cell by device first
because there might be a nvmem_cell_lookup associated with that device.
Signed-off-by: Michael Walle <michael@walle.cc>
Reviewed-by: Andrew Lunn <andrew@lunn.ch>
Signed-off-by: David S. Miller <davem@davemloft.net>
---
drivers/of/of_net.c | 35 ++++++++++++++++++++++++++++++-----
1 file changed, 30 insertions(+), 5 deletions(-)
--- a/drivers/of/of_net.c
+++ b/drivers/of/of_net.c
@@ -11,6 +11,7 @@
#include <linux/phy.h>
#include <linux/export.h>
#include <linux/device.h>
+#include <linux/nvmem-consumer.h>
/**
* of_get_phy_mode - Get phy mode for given device_node
@@ -59,15 +60,39 @@ static int of_get_mac_addr(struct device
static int of_get_mac_addr_nvmem(struct device_node *np, u8 *addr)
{
struct platform_device *pdev = of_find_device_by_node(np);
+ struct nvmem_cell *cell;
+ const void *mac;
+ size_t len;
int ret;
- if (!pdev)
- return -ENODEV;
+ /* Try lookup by device first, there might be a nvmem_cell_lookup
+ * associated with a given device.
+ */
+ if (pdev) {
+ ret = nvmem_get_mac_address(&pdev->dev, addr);
+ put_device(&pdev->dev);
+ return ret;
+ }
+
+ cell = of_nvmem_cell_get(np, "mac-address");
+ if (IS_ERR(cell))
+ return PTR_ERR(cell);
+
+ mac = nvmem_cell_read(cell, &len);
+ nvmem_cell_put(cell);
+
+ if (IS_ERR(mac))
+ return PTR_ERR(mac);
+
+ if (len != ETH_ALEN || !is_valid_ether_addr(mac)) {
+ kfree(mac);
+ return -EINVAL;
+ }
- ret = nvmem_get_mac_address(&pdev->dev, addr);
- put_device(&pdev->dev);
+ memcpy(addr, mac, ETH_ALEN);
+ kfree(mac);
- return ret;
+ return 0;
}
/**

View File

@ -0,0 +1,48 @@
From: Rob Herring <robh@kernel.org>
Date: Tue, 3 Aug 2021 15:56:55 -0600
Subject: [PATCH] PCI: of: Don't fail devm_pci_alloc_host_bridge() on missing
'ranges'
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Commit 669cbc708122 ("PCI: Move DT resource setup into
devm_pci_alloc_host_bridge()") made devm_pci_alloc_host_bridge() fail on
any DT resource parsing errors, but Broadcom iProc uses
devm_pci_alloc_host_bridge() on BCMA bus devices that don't have DT
resources. In particular, there is no 'ranges' property. Fix iProc by
making 'ranges' optional.
If 'ranges' is required by a platform, there's going to be more errors
latter on if it is missing.
Fixes: 669cbc708122 ("PCI: Move DT resource setup into devm_pci_alloc_host_bridge()")
Reported-by: Rafał Miłecki <zajec5@gmail.com>
Cc: Srinath Mannam <srinath.mannam@broadcom.com>
Cc: Roman Bacik <roman.bacik@broadcom.com>
Cc: Bharat Gooty <bharat.gooty@broadcom.com>
Cc: Abhishek Shah <abhishek.shah@broadcom.com>
Cc: Jitendra Bhivare <jitendra.bhivare@broadcom.com>
Cc: Ray Jui <ray.jui@broadcom.com>
Cc: Florian Fainelli <f.fainelli@gmail.com>
Cc: BCM Kernel Feedback <bcm-kernel-feedback-list@broadcom.com>
Cc: Scott Branden <sbranden@broadcom.com>
Cc: Bjorn Helgaas <bhelgaas@google.com>
Cc: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
Signed-off-by: Rob Herring <robh@kernel.org>
Acked-by: Bjorn Helgaas <bhelgaas@google.com>
---
drivers/pci/of.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
--- a/drivers/pci/of.c
+++ b/drivers/pci/of.c
@@ -295,7 +295,7 @@ static int devm_of_pci_get_host_bridge_r
/* Check for ranges property */
err = of_pci_range_parser_init(&parser, dev_node);
if (err)
- goto failed;
+ return 0;
dev_dbg(dev, "Parsing ranges property...\n");
for_each_of_pci_range(&parser, &range) {

View File

@ -0,0 +1,74 @@
From: Rob Herring <robh@kernel.org>
Date: Tue, 3 Aug 2021 15:56:56 -0600
Subject: [PATCH] PCI: iproc: Fix BCMA probe resource handling
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
In commit 7ef1c871da16 ("PCI: iproc: Use
pci_parse_request_of_pci_ranges()"), calling
devm_request_pci_bus_resources() was dropped from the common iProc
probe code, but is still needed for BCMA bus probing. Without it, there
will be lots of warnings like this:
pci 0000:00:00.0: BAR 8: no space for [mem size 0x00c00000]
pci 0000:00:00.0: BAR 8: failed to assign [mem size 0x00c00000]
Add back calling devm_request_pci_bus_resources() and adding the
resources to pci_host_bridge.windows for BCMA bus probe.
Fixes: 7ef1c871da16 ("PCI: iproc: Use pci_parse_request_of_pci_ranges()")
Reported-by: Rafał Miłecki <zajec5@gmail.com>
Cc: Srinath Mannam <srinath.mannam@broadcom.com>
Cc: Roman Bacik <roman.bacik@broadcom.com>
Cc: Bharat Gooty <bharat.gooty@broadcom.com>
Cc: Abhishek Shah <abhishek.shah@broadcom.com>
Cc: Jitendra Bhivare <jitendra.bhivare@broadcom.com>
Cc: Ray Jui <ray.jui@broadcom.com>
Cc: Florian Fainelli <f.fainelli@gmail.com>
Cc: BCM Kernel Feedback <bcm-kernel-feedback-list@broadcom.com>
Cc: Scott Branden <sbranden@broadcom.com>
Cc: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
Cc: "Krzysztof Wilczyński" <kw@linux.com>
Cc: Bjorn Helgaas <bhelgaas@google.com>
Signed-off-by: Rob Herring <robh@kernel.org>
---
drivers/pci/controller/pcie-iproc-bcma.c | 16 ++++++----------
1 file changed, 6 insertions(+), 10 deletions(-)
--- a/drivers/pci/controller/pcie-iproc-bcma.c
+++ b/drivers/pci/controller/pcie-iproc-bcma.c
@@ -35,7 +35,6 @@ static int iproc_pcie_bcma_probe(struct
{
struct device *dev = &bdev->dev;
struct iproc_pcie *pcie;
- LIST_HEAD(resources);
struct pci_host_bridge *bridge;
int ret;
@@ -60,19 +59,16 @@ static int iproc_pcie_bcma_probe(struct
pcie->mem.end = bdev->addr_s[0] + SZ_128M - 1;
pcie->mem.name = "PCIe MEM space";
pcie->mem.flags = IORESOURCE_MEM;
- pci_add_resource(&resources, &pcie->mem);
+ pci_add_resource(&bridge->windows, &pcie->mem);
+ ret = devm_request_pci_bus_resources(dev, &bridge->windows);
+ if (ret)
+ return ret;
pcie->map_irq = iproc_pcie_bcma_map_irq;
- ret = iproc_pcie_setup(pcie, &resources);
- if (ret) {
- dev_err(dev, "PCIe controller setup failed\n");
- pci_free_resource_list(&resources);
- return ret;
- }
-
bcma_set_drvdata(bdev, pcie);
- return 0;
+
+ return iproc_pcie_setup(pcie, &bridge->windows);
}
static void iproc_pcie_bcma_remove(struct bcma_device *bdev)

View File

@ -0,0 +1,77 @@
From f10843e04a075202dbb39dfcee047e3a2fdf5a8d Mon Sep 17 00:00:00 2001
From: Michael Walle <michael@walle.cc>
Date: Mon, 12 Apr 2021 19:47:18 +0200
Subject: of: net: fix of_get_mac_addr_nvmem() for non-platform devices
of_get_mac_address() already supports fetching the MAC address by an
nvmem provider. But until now, it was just working for platform devices.
Esp. it was not working for DSA ports and PCI devices. It gets more
common that PCI devices have a device tree binding since SoCs contain
integrated root complexes.
Use the nvmem of_* binding to fetch the nvmem cells by a struct
device_node. We still have to try to read the cell by device first
because there might be a nvmem_cell_lookup associated with that device.
Signed-off-by: Michael Walle <michael@walle.cc>
Reviewed-by: Andrew Lunn <andrew@lunn.ch>
Signed-off-by: David S. Miller <davem@davemloft.net>
---
drivers/of/of_net.c | 35 ++++++++++++++++++++++++++++++-----
1 file changed, 30 insertions(+), 5 deletions(-)
--- a/drivers/of/of_net.c
+++ b/drivers/of/of_net.c
@@ -11,6 +11,7 @@
#include <linux/phy.h>
#include <linux/export.h>
#include <linux/device.h>
+#include <linux/nvmem-consumer.h>
/**
* of_get_phy_mode - Get phy mode for given device_node
@@ -53,15 +54,39 @@ static int of_get_mac_addr(struct device
static int of_get_mac_addr_nvmem(struct device_node *np, u8 *addr)
{
struct platform_device *pdev = of_find_device_by_node(np);
+ struct nvmem_cell *cell;
+ const void *mac;
+ size_t len;
int ret;
- if (!pdev)
- return -ENODEV;
+ /* Try lookup by device first, there might be a nvmem_cell_lookup
+ * associated with a given device.
+ */
+ if (pdev) {
+ ret = nvmem_get_mac_address(&pdev->dev, addr);
+ put_device(&pdev->dev);
+ return ret;
+ }
+
+ cell = of_nvmem_cell_get(np, "mac-address");
+ if (IS_ERR(cell))
+ return PTR_ERR(cell);
+
+ mac = nvmem_cell_read(cell, &len);
+ nvmem_cell_put(cell);
+
+ if (IS_ERR(mac))
+ return PTR_ERR(mac);
+
+ if (len != ETH_ALEN || !is_valid_ether_addr(mac)) {
+ kfree(mac);
+ return -EINVAL;
+ }
- ret = nvmem_get_mac_address(&pdev->dev, addr);
- put_device(&pdev->dev);
+ memcpy(addr, mac, ETH_ALEN);
+ kfree(mac);
- return ret;
+ return 0;
}
/**

View File

@ -397,6 +397,7 @@ CONFIG_ARM_GIC_MAX_NR=1
# CONFIG_ARM_PSCI_CPUIDLE is not set
# CONFIG_ARM_PTDUMP_DEBUGFS is not set
# CONFIG_ARM_SBSA_WATCHDOG is not set
# CONFIG_ARM_SCMI_PROTOCOL is not set
# CONFIG_ARM_SCPI_PROTOCOL is not set
# CONFIG_ARM_SDE_INTERFACE is not set
# CONFIG_ARM_SMCCC_SOC_ID is not set
@ -1754,7 +1755,7 @@ CONFIG_EPOLL=y
# CONFIG_ET131X is not set
CONFIG_ETHERNET=y
# CONFIG_ETHOC is not set
# CONFIG_ETHTOOL_NETLINK is not set
CONFIG_ETHTOOL_NETLINK=y
CONFIG_EVENTFD=y
# CONFIG_EVM is not set
# CONFIG_EXFAT_FS is not set

View File

@ -14,7 +14,7 @@ Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
--- a/drivers/net/ethernet/broadcom/bgmac-bcma.c
+++ b/drivers/net/ethernet/broadcom/bgmac-bcma.c
@@ -268,6 +268,7 @@ static int bgmac_probe(struct bcma_devic
@@ -266,6 +266,7 @@ static int bgmac_probe(struct bcma_devic
bgmac->feature_flags |= BGMAC_FEAT_CLKCTLST;
bgmac->feature_flags |= BGMAC_FEAT_NO_RESET;
bgmac->feature_flags |= BGMAC_FEAT_FORCE_SPEED_2500;

View File

@ -1,27 +0,0 @@
From c94b2cfd25c282e2974accc1b07da98ae7139b47 Mon Sep 17 00:00:00 2001
From: Ansuel Smith <ansuelsmth@gmail.com>
Date: Fri, 23 Jul 2021 12:14:33 +0200
Subject: [PATCH 1/2] drivers: net: mediatek: register of_platform for every
port
Currently the nvmem framework require the devicenode to be registred on
the of_platform or of_get_mac_address fail to get the macaddress if
defined using an nvmem cell. Fix this by registrering these special node
so they can be found by of_find_device_by_node.
Signed-off-by: Ansuel Smith <ansuelsmth@gmail.com>
---
drivers/net/ethernet/mediatek/mtk_eth_soc.c | 2 ++
1 file changed, 2 insertions(+)
--- a/drivers/net/ethernet/mediatek/mtk_eth_soc.c
+++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.c
@@ -3005,6 +3005,8 @@ static int mtk_add_mac(struct mtk_eth *e
eth->netdev[id]->dev.of_node = np;
eth->netdev[id]->max_mtu = MTK_MAX_RX_LENGTH - MTK_RX_ETH_HLEN;
+
+ of_platform_device_create(np, NULL, NULL);
return 0;

View File

@ -1,35 +0,0 @@
From 8bab551f44204fc5d43977063cd704112c17c750 Mon Sep 17 00:00:00 2001
From: Ansuel Smith <ansuelsmth@gmail.com>
Date: Fri, 23 Jul 2021 12:17:27 +0200
Subject: [PATCH 2/2] dsa: register every port with of_platform
The declaration of a different mac-addr using the nvmem framework is
currently broken. The dsa code use the generic of_get_mac_address where
the nvmem function require the device node to be registred in the
of_platform to be found by of_find_device_by_node. Register every port
in the of_platform so they can corrently found and a custom mac-addr can
correctly be declared using a nvmem-cell declared in the dts.
Signed-off-by: Ansuel Smith <ansuelsmth@gmail.com>
---
net/dsa/dsa2.c | 2 +
1 file changed, 2 insertion(+)
--- a/net/dsa/dsa2.c
+++ b/net/dsa/dsa2.c
@@ -14,6 +14,7 @@
#include <linux/rtnetlink.h>
#include <linux/of.h>
#include <linux/of_net.h>
+#include <linux/of_platform.h>
#include <net/devlink.h>
#include "dsa_priv.h"
@@ -288,6 +289,7 @@ static int dsa_port_setup(struct dsa_por
break;
case DSA_PORT_TYPE_USER:
+ of_platform_device_create(dp->dn, NULL, NULL);
dp->mac = of_get_mac_address(dp->dn);
err = dsa_slave_create(dp);
if (err)

View File

@ -14,7 +14,7 @@ Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
--- a/drivers/net/ethernet/broadcom/bgmac-bcma.c
+++ b/drivers/net/ethernet/broadcom/bgmac-bcma.c
@@ -268,6 +268,7 @@ static int bgmac_probe(struct bcma_devic
@@ -266,6 +266,7 @@ static int bgmac_probe(struct bcma_devic
bgmac->feature_flags |= BGMAC_FEAT_CLKCTLST;
bgmac->feature_flags |= BGMAC_FEAT_NO_RESET;
bgmac->feature_flags |= BGMAC_FEAT_FORCE_SPEED_2500;

View File

@ -1,27 +0,0 @@
From c94b2cfd25c282e2974accc1b07da98ae7139b47 Mon Sep 17 00:00:00 2001
From: Ansuel Smith <ansuelsmth@gmail.com>
Date: Fri, 23 Jul 2021 12:14:33 +0200
Subject: [PATCH 1/2] drivers: net: mediatek: register of_platform for every
port
Currently the nvmem framework require the devicenode to be registred on
the of_platform or of_get_mac_address fail to get the macaddress if
defined using an nvmem cell. Fix this by registrering these special node
so they can be found by of_find_device_by_node.
Signed-off-by: Ansuel Smith <ansuelsmth@gmail.com>
---
drivers/net/ethernet/mediatek/mtk_eth_soc.c | 2 ++
1 file changed, 2 insertions(+)
--- a/drivers/net/ethernet/mediatek/mtk_eth_soc.c
+++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.c
@@ -3034,6 +3034,8 @@ static int mtk_add_mac(struct mtk_eth *e
eth->netdev[id]->dev.of_node = np;
eth->netdev[id]->max_mtu = MTK_MAX_RX_LENGTH - MTK_RX_ETH_HLEN;
+
+ of_platform_device_create(np, NULL, NULL);
return 0;

View File

@ -1,35 +0,0 @@
From 8bab551f44204fc5d43977063cd704112c17c750 Mon Sep 17 00:00:00 2001
From: Ansuel Smith <ansuelsmth@gmail.com>
Date: Fri, 23 Jul 2021 12:17:27 +0200
Subject: [PATCH 2/2] dsa: register every port with of_platform
The declaration of a different mac-addr using the nvmem framework is
currently broken. The dsa code use the generic of_get_mac_address where
the nvmem function require the device node to be registred in the
of_platform to be found by of_find_device_by_node. Register every port
in the of_platform so they can corrently found and a custom mac-addr can
correctly be declared using a nvmem-cell declared in the dts.
Signed-off-by: Ansuel Smith <ansuelsmth@gmail.com>
---
net/dsa/dsa2.c | 2 +
1 file changed, 2 insertion(+)
--- a/net/dsa/dsa2.c
+++ b/net/dsa/dsa2.c
@@ -14,6 +14,7 @@
#include <linux/rtnetlink.h>
#include <linux/of.h>
#include <linux/of_net.h>
+#include <linux/of_platform.h>
#include <net/devlink.h>
#include "dsa_priv.h"
@@ -318,6 +319,7 @@ static int dsa_port_setup(struct dsa_por
break;
devlink_port_registered = true;
+ of_platform_device_create(dp->dn, NULL, NULL);
dp->mac = of_get_mac_address(dp->dn);
err = dsa_slave_create(dp);
if (err)

View File

@ -17,28 +17,19 @@ Signed-off-by: Ansuel Smith <ansuelsmth@gmail.com>
--- a/drivers/of/of_net.c
+++ b/drivers/of/of_net.c
@@ -11,6 +11,7 @@
#include <linux/phy.h>
@@ -12,6 +12,7 @@
#include <linux/export.h>
#include <linux/device.h>
#include <linux/nvmem-consumer.h>
+#include <linux/mtd/mtd.h>
/**
* of_get_phy_mode - Get phy mode for given device_node
@@ -45,7 +46,7 @@ int of_get_phy_mode(struct device_node *
}
EXPORT_SYMBOL_GPL(of_get_phy_mode);
-static const void *of_get_mac_addr(struct device_node *np, const char *name)
+static void *of_get_mac_addr(struct device_node *np, const char *name)
{
struct property *pp = of_find_property(np, name, NULL);
@@ -78,6 +79,55 @@ static const void *of_get_mac_addr_nvmem
return mac;
@@ -95,6 +96,52 @@ static int of_get_mac_addr_nvmem(struct
return 0;
}
+static const void *of_get_mac_address_mtd(struct device_node *np)
+static int of_get_mac_address_mtd(struct device_node *np, u8 *addr)
+{
+#ifdef CONFIG_MTD
+ struct platform_device *pdev = of_find_device_by_node(np);
@ -50,18 +41,17 @@ Signed-off-by: Ansuel Smith <ansuelsmth@gmail.com>
+ const __be32 *list;
+ phandle phandle;
+ u8 mac[ETH_ALEN];
+ void *addr;
+
+ list = of_get_property(np, "mtd-mac-address", &size);
+ if (!list || (size != (2 * sizeof(*list))))
+ return NULL;
+ return -ENODEV;
+
+ phandle = be32_to_cpup(list++);
+ if (phandle)
+ mtd_np = of_find_node_by_phandle(phandle);
+
+ if (!mtd_np)
+ return NULL;
+ return -ENODEV;
+
+ part = of_get_property(mtd_np, "label", NULL);
+ if (!part)
@ -69,28 +59,26 @@ Signed-off-by: Ansuel Smith <ansuelsmth@gmail.com>
+
+ mtd = get_mtd_device_nm(part);
+ if (IS_ERR(mtd))
+ return NULL;
+ return -ENODEV;
+
+ ret = mtd_read(mtd, be32_to_cpup(list), 6, &retlen, mac);
+ put_mtd_device(mtd);
+
+ if (!is_valid_ether_addr(mac))
+ return NULL;
+ return -EINVAL;
+
+ addr = devm_kmemdup(&pdev->dev, mac, ETH_ALEN, GFP_KERNEL);
+ if (!addr)
+ return ERR_PTR(-ENOMEM);
+ memcpy(addr, mac, ETH_ALEN);
+
+ return addr;
+ return 0;
+#endif
+ return NULL;
+ return -EINVAL;
+}
+
+
/**
* Search the device tree for the best MAC address to use. 'mac-address' is
* checked first, because that is supposed to contain to "most recent" MAC
@@ -98,6 +148,10 @@ static const void *of_get_mac_addr_nvmem
@@ -115,6 +162,10 @@ static int of_get_mac_addr_nvmem(struct
* this case, the real MAC is in 'local-mac-address', and 'mac-address' exists
* but is all zeros.
*
@ -98,17 +86,17 @@ Signed-off-by: Ansuel Smith <ansuelsmth@gmail.com>
+ * If a mtd-mac-address property exists, try to fetch the MAC address from the
+ * specified mtd device.
+ *
* Return: Will be a valid pointer on success and ERR_PTR in case of error.
* Return: 0 on success and errno in case of error.
*/
const void *of_get_mac_address(struct device_node *np)
@@ -116,6 +170,10 @@ const void *of_get_mac_address(struct de
if (addr)
return addr;
int of_get_mac_address(struct device_node *np, u8 *addr)
@@ -136,6 +187,10 @@ int of_get_mac_address(struct device_nod
if (!ret)
return 0;
+ addr = of_get_mac_address_mtd(np);
+ if (addr)
+ return addr;
+ ret = of_get_mac_address_mtd(np, addr);
+ if (!ret)
+ return 0;
+
return of_get_mac_addr_nvmem(np);
return of_get_mac_addr_nvmem(np, addr);
}
EXPORT_SYMBOL(of_get_mac_address);

View File

@ -20,52 +20,7 @@ Signed-off-by: Ansuel Smith <ansuelsmth@gmail.com>
--- a/drivers/of/of_net.c
+++ b/drivers/of/of_net.c
@@ -55,31 +55,36 @@ static void *of_get_mac_addr(struct devi
return NULL;
}
-static const void *of_get_mac_addr_nvmem(struct device_node *np)
+static void *of_get_mac_addr_nvmem(struct device_node *np, int *err)
{
int ret;
- const void *mac;
+ void *mac;
u8 nvmem_mac[ETH_ALEN];
struct platform_device *pdev = of_find_device_by_node(np);
- if (!pdev)
- return ERR_PTR(-ENODEV);
+ if (!pdev) {
+ *err = -ENODEV;
+ return NULL;
+ }
ret = nvmem_get_mac_address(&pdev->dev, &nvmem_mac);
if (ret) {
put_device(&pdev->dev);
- return ERR_PTR(ret);
+ *err = ret;
+ return NULL;
}
mac = devm_kmemdup(&pdev->dev, nvmem_mac, ETH_ALEN, GFP_KERNEL);
put_device(&pdev->dev);
- if (!mac)
- return ERR_PTR(-ENOMEM);
+ if (!mac) {
+ *err = -ENOMEM;
+ return NULL;
+ }
return mac;
}
-static const void *of_get_mac_address_mtd(struct device_node *np)
+static void *of_get_mac_address_mtd(struct device_node *np)
{
#ifdef CONFIG_MTD
struct platform_device *pdev = of_find_device_by_node(np);
@@ -152,28 +157,54 @@ static const void *of_get_mac_address_mt
@@ -166,31 +166,56 @@ static int of_get_mac_address_mtd(struct
* If a mtd-mac-address property exists, try to fetch the MAC address from the
* specified mtd device.
*
@ -77,52 +32,53 @@ Signed-off-by: Ansuel Smith <ansuelsmth@gmail.com>
+ * not overflow to other bytes if the increment is over 255.
+ * (example 00:01:02:03:04:ff + 1 == 00:01:02:03:04:00)
+ *
* Return: Will be a valid pointer on success and ERR_PTR in case of error.
* Return: 0 on success and errno in case of error.
*/
const void *of_get_mac_address(struct device_node *np)
int of_get_mac_address(struct device_node *np, u8 *addr)
{
- const void *addr;
+ u32 inc_idx, mac_inc;
+ int ret = 0;
+ u8 *addr;
+
int ret;
+ /* Check first if the increment byte is present and valid.
+ * If not set assume to increment the last byte if found.
+ */
+ if (of_property_read_u32(np, "mac-address-increment-byte", &inc_idx))
+ inc_idx = 5;
+ if (inc_idx < 3 || inc_idx > 5)
+ return ERR_PTR(-EINVAL);
+ return -EINVAL;
+
if (!np)
return -ENODEV;
addr = of_get_mac_addr(np, "mac-address");
if (addr)
- return addr;
ret = of_get_mac_addr(np, "mac-address", addr);
if (!ret)
- return 0;
+ goto found;
addr = of_get_mac_addr(np, "local-mac-address");
if (addr)
- return addr;
ret = of_get_mac_addr(np, "local-mac-address", addr);
if (!ret)
- return 0;
+ goto found;
addr = of_get_mac_addr(np, "address");
if (addr)
- return addr;
ret = of_get_mac_addr(np, "address", addr);
if (!ret)
- return 0;
+ goto found;
addr = of_get_mac_address_mtd(np);
if (addr)
- return addr;
ret = of_get_mac_address_mtd(np, addr);
if (!ret)
- return 0;
+ goto found;
+
+ addr = of_get_mac_addr_nvmem(np, &ret);
+ ret = of_get_mac_addr_nvmem(np, addr);
+ if (ret)
+ return ERR_PTR(ret);
+ return ret;
+
+found:
+ if (!of_property_read_u32(np, "mac-address-increment", &mac_inc))
+ addr[inc_idx] += mac_inc;
- return of_get_mac_addr_nvmem(np);
+ return addr;
- return of_get_mac_addr_nvmem(np, addr);
+ return ret;
}
EXPORT_SYMBOL(of_get_mac_address);

View File

@ -1,19 +1,16 @@
--- a/drivers/of/of_net.c
+++ b/drivers/of/of_net.c
@@ -132,6 +132,33 @@ static void *of_get_mac_address_mtd(stru
return NULL;
@@ -141,6 +141,30 @@ static int of_get_mac_address_mtd(struct
return -EINVAL;
}
+static int of_add_mac_address(struct device_node *np, u8* addr)
+{
+ struct property *prop;
+ u8 *np_addr;
+
+ np_addr = of_get_mac_addr(np, "mac-address");
+ if (np_addr) {
+ memcpy(np_addr, addr, ETH_ALEN);
+ return 0;
+ }
+ prop = of_find_property(np, "mac-address", NULL);
+ if (prop)
+ kfree(prop);
+
+ prop = kzalloc(sizeof(*prop), GFP_KERNEL);
+ if (!prop)
@ -34,11 +31,11 @@
/**
* Search the device tree for the best MAC address to use. 'mac-address' is
@@ -205,6 +232,7 @@ found:
@@ -216,6 +240,7 @@ found:
if (!of_property_read_u32(np, "mac-address-increment", &mac_inc))
addr[inc_idx] += mac_inc;
+ of_add_mac_address(np, addr);
return addr;
return ret;
}
EXPORT_SYMBOL(of_get_mac_address);

View File

@ -0,0 +1,61 @@
From patchwork Thu Aug 5 22:23:30 2021
Content-Type: text/plain; charset="utf-8"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
X-Patchwork-Submitter: Daniel Golle <daniel@makrotopia.org>
X-Patchwork-Id: 12422209
Date: Thu, 5 Aug 2021 23:23:30 +0100
From: Daniel Golle <daniel@makrotopia.org>
To: linux-arm-kernel@lists.infradead.org, netdev@vger.kernel.org,
linux-kernel@vger.kernel.org
Cc: "David S. Miller" <davem@davemloft.net>, Andrew Lunn <andrew@lunn.ch>,
Michael Walle <michael@walle.cc>
Subject: [PATCH] ARM: kirkwood: add missing <linux/if_ether.h> for ETH_ALEN
Message-ID: <YQxk4jrbm31NM1US@makrotopia.org>
MIME-Version: 1.0
Content-Disposition: inline
X-BeenThere: linux-arm-kernel@lists.infradead.org
X-Mailman-Version: 2.1.34
Precedence: list
List-Id: <linux-arm-kernel.lists.infradead.org>
List-Archive: <http://lists.infradead.org/pipermail/linux-arm-kernel/>
Sender: "linux-arm-kernel" <linux-arm-kernel-bounces@lists.infradead.org>
After commit 83216e3988cd1 ("of: net: pass the dst buffer to
of_get_mac_address()") build fails for kirkwood as ETH_ALEN is not
defined.
arch/arm/mach-mvebu/kirkwood.c: In function 'kirkwood_dt_eth_fixup':
arch/arm/mach-mvebu/kirkwood.c:87:13: error: 'ETH_ALEN' undeclared (first use in this function); did you mean 'ESTALE'?
u8 tmpmac[ETH_ALEN];
^~~~~~~~
ESTALE
arch/arm/mach-mvebu/kirkwood.c:87:13: note: each undeclared identifier is reported only once for each function it appears in
arch/arm/mach-mvebu/kirkwood.c:87:6: warning: unused variable 'tmpmac' [-Wunused-variable]
u8 tmpmac[ETH_ALEN];
^~~~~~
make[5]: *** [scripts/Makefile.build:262: arch/arm/mach-mvebu/kirkwood.o] Error 1
make[5]: *** Waiting for unfinished jobs....
Add missing #include <linux/if_ether.h> to fix this.
Cc: David S. Miller <davem@davemloft.net>
Cc: Andrew Lunn <andrew@lunn.ch>
Cc: Michael Walle <michael@walle.cc>
Reported-by: https://buildbot.openwrt.org/master/images/#/builders/56/builds/220/steps/44/logs/stdio
Fixes: 83216e3988cd1 ("of: net: pass the dst buffer to of_get_mac_address()")
Signed-off-by: Daniel Golle <daniel@makrotopia.org>
---
arch/arm/mach-mvebu/kirkwood.c | 1 +
1 file changed, 1 insertion(+)
--- a/arch/arm/mach-mvebu/kirkwood.c
+++ b/arch/arm/mach-mvebu/kirkwood.c
@@ -14,6 +14,7 @@
#include <linux/kernel.h>
#include <linux/init.h>
#include <linux/mbus.h>
+#include <linux/if_ether.h>
#include <linux/of.h>
#include <linux/of_address.h>
#include <linux/of_net.h>

View File

@ -17,28 +17,19 @@ Signed-off-by: Ansuel Smith <ansuelsmth@gmail.com>
--- a/drivers/of/of_net.c
+++ b/drivers/of/of_net.c
@@ -11,6 +11,7 @@
#include <linux/phy.h>
@@ -12,6 +12,7 @@
#include <linux/export.h>
#include <linux/device.h>
#include <linux/nvmem-consumer.h>
+#include <linux/mtd/mtd.h>
/**
* of_get_phy_mode - Get phy mode for given device_node
@@ -39,7 +40,7 @@ int of_get_phy_mode(struct device_node *
}
EXPORT_SYMBOL_GPL(of_get_phy_mode);
-static const void *of_get_mac_addr(struct device_node *np, const char *name)
+static void *of_get_mac_addr(struct device_node *np, const char *name)
{
struct property *pp = of_find_property(np, name, NULL);
@@ -72,6 +73,55 @@ static const void *of_get_mac_addr_nvmem
return mac;
@@ -89,6 +90,52 @@ static int of_get_mac_addr_nvmem(struct
return 0;
}
+static const void *of_get_mac_address_mtd(struct device_node *np)
+static int of_get_mac_address_mtd(struct device_node *np, u8 *addr)
+{
+#ifdef CONFIG_MTD
+ struct platform_device *pdev = of_find_device_by_node(np);
@ -50,18 +41,17 @@ Signed-off-by: Ansuel Smith <ansuelsmth@gmail.com>
+ const __be32 *list;
+ phandle phandle;
+ u8 mac[ETH_ALEN];
+ void *addr;
+
+ list = of_get_property(np, "mtd-mac-address", &size);
+ if (!list || (size != (2 * sizeof(*list))))
+ return NULL;
+ return -ENODEV;
+
+ phandle = be32_to_cpup(list++);
+ if (phandle)
+ mtd_np = of_find_node_by_phandle(phandle);
+
+ if (!mtd_np)
+ return NULL;
+ return -ENODEV;
+
+ part = of_get_property(mtd_np, "label", NULL);
+ if (!part)
@ -69,28 +59,26 @@ Signed-off-by: Ansuel Smith <ansuelsmth@gmail.com>
+
+ mtd = get_mtd_device_nm(part);
+ if (IS_ERR(mtd))
+ return NULL;
+ return -ENODEV;
+
+ ret = mtd_read(mtd, be32_to_cpup(list), 6, &retlen, mac);
+ put_mtd_device(mtd);
+
+ if (!is_valid_ether_addr(mac))
+ return NULL;
+ return -EINVAL;
+
+ addr = devm_kmemdup(&pdev->dev, mac, ETH_ALEN, GFP_KERNEL);
+ if (!addr)
+ return ERR_PTR(-ENOMEM);
+ memcpy(addr, mac, ETH_ALEN);
+
+ return addr;
+ return 0;
+#endif
+ return NULL;
+ return -EINVAL;
+}
+
+
/**
* Search the device tree for the best MAC address to use. 'mac-address' is
* checked first, because that is supposed to contain to "most recent" MAC
@@ -92,6 +142,10 @@ static const void *of_get_mac_addr_nvmem
@@ -109,6 +156,10 @@ static int of_get_mac_addr_nvmem(struct
* this case, the real MAC is in 'local-mac-address', and 'mac-address' exists
* but is all zeros.
*
@ -98,17 +86,17 @@ Signed-off-by: Ansuel Smith <ansuelsmth@gmail.com>
+ * If a mtd-mac-address property exists, try to fetch the MAC address from the
+ * specified mtd device.
+ *
* Return: Will be a valid pointer on success and ERR_PTR in case of error.
* Return: 0 on success and errno in case of error.
*/
const void *of_get_mac_address(struct device_node *np)
@@ -110,6 +164,10 @@ const void *of_get_mac_address(struct de
if (addr)
return addr;
int of_get_mac_address(struct device_node *np, u8 *addr)
@@ -130,6 +181,10 @@ int of_get_mac_address(struct device_nod
if (!ret)
return 0;
+ addr = of_get_mac_address_mtd(np);
+ if (addr)
+ return addr;
+ ret = of_get_mac_address_mtd(np, addr);
+ if (!ret)
+ return 0;
+
return of_get_mac_addr_nvmem(np);
return of_get_mac_addr_nvmem(np, addr);
}
EXPORT_SYMBOL(of_get_mac_address);

View File

@ -20,52 +20,7 @@ Signed-off-by: Ansuel Smith <ansuelsmth@gmail.com>
--- a/drivers/of/of_net.c
+++ b/drivers/of/of_net.c
@@ -49,31 +49,36 @@ static void *of_get_mac_addr(struct devi
return NULL;
}
-static const void *of_get_mac_addr_nvmem(struct device_node *np)
+static void *of_get_mac_addr_nvmem(struct device_node *np, int *err)
{
int ret;
- const void *mac;
+ void *mac;
u8 nvmem_mac[ETH_ALEN];
struct platform_device *pdev = of_find_device_by_node(np);
- if (!pdev)
- return ERR_PTR(-ENODEV);
+ if (!pdev) {
+ *err = -ENODEV;
+ return NULL;
+ }
ret = nvmem_get_mac_address(&pdev->dev, &nvmem_mac);
if (ret) {
put_device(&pdev->dev);
- return ERR_PTR(ret);
+ *err = ret;
+ return NULL;
}
mac = devm_kmemdup(&pdev->dev, nvmem_mac, ETH_ALEN, GFP_KERNEL);
put_device(&pdev->dev);
- if (!mac)
- return ERR_PTR(-ENOMEM);
+ if (!mac) {
+ *err = -ENOMEM;
+ return NULL;
+ }
return mac;
}
-static const void *of_get_mac_address_mtd(struct device_node *np)
+static void *of_get_mac_address_mtd(struct device_node *np)
{
#ifdef CONFIG_MTD
struct platform_device *pdev = of_find_device_by_node(np);
@@ -146,28 +151,54 @@ static const void *of_get_mac_address_mt
@@ -160,31 +160,56 @@ static int of_get_mac_address_mtd(struct
* If a mtd-mac-address property exists, try to fetch the MAC address from the
* specified mtd device.
*
@ -77,52 +32,53 @@ Signed-off-by: Ansuel Smith <ansuelsmth@gmail.com>
+ * not overflow to other bytes if the increment is over 255.
+ * (example 00:01:02:03:04:ff + 1 == 00:01:02:03:04:00)
+ *
* Return: Will be a valid pointer on success and ERR_PTR in case of error.
* Return: 0 on success and errno in case of error.
*/
const void *of_get_mac_address(struct device_node *np)
int of_get_mac_address(struct device_node *np, u8 *addr)
{
- const void *addr;
+ u32 inc_idx, mac_inc;
+ int ret = 0;
+ u8 *addr;
+
int ret;
+ /* Check first if the increment byte is present and valid.
+ * If not set assume to increment the last byte if found.
+ */
+ if (of_property_read_u32(np, "mac-address-increment-byte", &inc_idx))
+ inc_idx = 5;
+ if (inc_idx < 3 || inc_idx > 5)
+ return ERR_PTR(-EINVAL);
+ return -EINVAL;
+
if (!np)
return -ENODEV;
addr = of_get_mac_addr(np, "mac-address");
if (addr)
- return addr;
ret = of_get_mac_addr(np, "mac-address", addr);
if (!ret)
- return 0;
+ goto found;
addr = of_get_mac_addr(np, "local-mac-address");
if (addr)
- return addr;
ret = of_get_mac_addr(np, "local-mac-address", addr);
if (!ret)
- return 0;
+ goto found;
addr = of_get_mac_addr(np, "address");
if (addr)
- return addr;
ret = of_get_mac_addr(np, "address", addr);
if (!ret)
- return 0;
+ goto found;
addr = of_get_mac_address_mtd(np);
if (addr)
- return addr;
ret = of_get_mac_address_mtd(np, addr);
if (!ret)
- return 0;
+ goto found;
+
+ addr = of_get_mac_addr_nvmem(np, &ret);
+ ret = of_get_mac_addr_nvmem(np, addr);
+ if (ret)
+ return ERR_PTR(ret);
+ return ret;
+
+found:
+ if (!of_property_read_u32(np, "mac-address-increment", &mac_inc))
+ addr[inc_idx] += mac_inc;
- return of_get_mac_addr_nvmem(np);
+ return addr;
- return of_get_mac_addr_nvmem(np, addr);
+ return ret;
}
EXPORT_SYMBOL(of_get_mac_address);

View File

@ -1,19 +1,16 @@
--- a/drivers/of/of_net.c
+++ b/drivers/of/of_net.c
@@ -126,6 +126,33 @@ static void *of_get_mac_address_mtd(stru
return NULL;
@@ -135,6 +135,30 @@ static int of_get_mac_address_mtd(struct
return -EINVAL;
}
+static int of_add_mac_address(struct device_node *np, u8* addr)
+{
+ struct property *prop;
+ u8 *np_addr;
+
+ np_addr = of_get_mac_addr(np, "mac-address");
+ if (np_addr) {
+ memcpy(np_addr, addr, ETH_ALEN);
+ return 0;
+ }
+ prop = of_find_property(np, "mac-address", NULL);
+ if (prop)
+ kfree(prop);
+
+ prop = kzalloc(sizeof(*prop), GFP_KERNEL);
+ if (!prop)
@ -34,11 +31,11 @@
/**
* Search the device tree for the best MAC address to use. 'mac-address' is
@@ -199,6 +226,7 @@ found:
@@ -210,6 +234,7 @@ found:
if (!of_property_read_u32(np, "mac-address-increment", &mac_inc))
addr[inc_idx] += mac_inc;
+ of_add_mac_address(np, addr);
return addr;
return ret;
}
EXPORT_SYMBOL(of_get_mac_address);

View File

@ -194,7 +194,7 @@ Signed-off-by: Felix Fietkau <nbd@nbd.name>
mtk_tx_irq_disable(eth, ~0);
mtk_rx_irq_disable(eth, ~0);
@@ -2951,6 +3025,13 @@ static int mtk_probe(struct platform_dev
@@ -2948,6 +3022,13 @@ static int mtk_probe(struct platform_dev
spin_lock_init(&eth->page_lock);
spin_lock_init(&eth->tx_irq_lock);
spin_lock_init(&eth->rx_irq_lock);

View File

@ -54,7 +54,7 @@ Signed-off-by: Felix Fietkau <nbd@nbd.name>
return 0;
}
@@ -3165,6 +3173,13 @@ static int mtk_probe(struct platform_dev
@@ -3162,6 +3170,13 @@ static int mtk_probe(struct platform_dev
goto err_free_dev;
}
@ -68,7 +68,7 @@ Signed-off-by: Felix Fietkau <nbd@nbd.name>
for (i = 0; i < MTK_MAX_DEVS; i++) {
if (!eth->netdev[i])
continue;
@@ -3239,6 +3254,7 @@ static const struct mtk_soc_data mt7621_
@@ -3236,6 +3251,7 @@ static const struct mtk_soc_data mt7621_
.hw_features = MTK_HW_FEATURES,
.required_clks = MT7621_CLKS_BITMAP,
.required_pctl = false,
@ -76,7 +76,7 @@ Signed-off-by: Felix Fietkau <nbd@nbd.name>
};
static const struct mtk_soc_data mt7622_data = {
@@ -3247,6 +3263,7 @@ static const struct mtk_soc_data mt7622_
@@ -3244,6 +3260,7 @@ static const struct mtk_soc_data mt7622_
.hw_features = MTK_HW_FEATURES,
.required_clks = MT7622_CLKS_BITMAP,
.required_pctl = false,

View File

@ -44,7 +44,7 @@ Signed-off-by: Felix Fietkau <nbd@nbd.name>
skip_rx:
ring->data[idx] = new_data;
@@ -2882,6 +2888,25 @@ static int mtk_set_rxnfc(struct net_devi
@@ -2879,6 +2885,25 @@ static int mtk_set_rxnfc(struct net_devi
return ret;
}
@ -70,7 +70,7 @@ Signed-off-by: Felix Fietkau <nbd@nbd.name>
static const struct ethtool_ops mtk_ethtool_ops = {
.get_link_ksettings = mtk_get_link_ksettings,
.set_link_ksettings = mtk_set_link_ksettings,
@@ -2913,6 +2938,7 @@ static const struct net_device_ops mtk_n
@@ -2910,6 +2935,7 @@ static const struct net_device_ops mtk_n
#ifdef CONFIG_NET_POLL_CONTROLLER
.ndo_poll_controller = mtk_poll_controller,
#endif
@ -78,7 +78,7 @@ Signed-off-by: Felix Fietkau <nbd@nbd.name>
};
static int mtk_add_mac(struct mtk_eth *eth, struct device_node *np)
@@ -3178,6 +3204,10 @@ static int mtk_probe(struct platform_dev
@@ -3175,6 +3201,10 @@ static int mtk_probe(struct platform_dev
eth->base + MTK_ETH_PPE_BASE, 2);
if (err)
goto err_free_dev;

View File

@ -0,0 +1,61 @@
From patchwork Thu Aug 5 22:23:30 2021
Content-Type: text/plain; charset="utf-8"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
X-Patchwork-Submitter: Daniel Golle <daniel@makrotopia.org>
X-Patchwork-Id: 12422209
Date: Thu, 5 Aug 2021 23:23:30 +0100
From: Daniel Golle <daniel@makrotopia.org>
To: linux-arm-kernel@lists.infradead.org, netdev@vger.kernel.org,
linux-kernel@vger.kernel.org
Cc: "David S. Miller" <davem@davemloft.net>, Andrew Lunn <andrew@lunn.ch>,
Michael Walle <michael@walle.cc>
Subject: [PATCH] ARM: kirkwood: add missing <linux/if_ether.h> for ETH_ALEN
Message-ID: <YQxk4jrbm31NM1US@makrotopia.org>
MIME-Version: 1.0
Content-Disposition: inline
X-BeenThere: linux-arm-kernel@lists.infradead.org
X-Mailman-Version: 2.1.34
Precedence: list
List-Id: <linux-arm-kernel.lists.infradead.org>
List-Archive: <http://lists.infradead.org/pipermail/linux-arm-kernel/>
Sender: "linux-arm-kernel" <linux-arm-kernel-bounces@lists.infradead.org>
After commit 83216e3988cd1 ("of: net: pass the dst buffer to
of_get_mac_address()") build fails for kirkwood as ETH_ALEN is not
defined.
arch/arm/mach-mvebu/kirkwood.c: In function 'kirkwood_dt_eth_fixup':
arch/arm/mach-mvebu/kirkwood.c:87:13: error: 'ETH_ALEN' undeclared (first use in this function); did you mean 'ESTALE'?
u8 tmpmac[ETH_ALEN];
^~~~~~~~
ESTALE
arch/arm/mach-mvebu/kirkwood.c:87:13: note: each undeclared identifier is reported only once for each function it appears in
arch/arm/mach-mvebu/kirkwood.c:87:6: warning: unused variable 'tmpmac' [-Wunused-variable]
u8 tmpmac[ETH_ALEN];
^~~~~~
make[5]: *** [scripts/Makefile.build:262: arch/arm/mach-mvebu/kirkwood.o] Error 1
make[5]: *** Waiting for unfinished jobs....
Add missing #include <linux/if_ether.h> to fix this.
Cc: David S. Miller <davem@davemloft.net>
Cc: Andrew Lunn <andrew@lunn.ch>
Cc: Michael Walle <michael@walle.cc>
Reported-by: https://buildbot.openwrt.org/master/images/#/builders/56/builds/220/steps/44/logs/stdio
Fixes: 83216e3988cd1 ("of: net: pass the dst buffer to of_get_mac_address()")
Signed-off-by: Daniel Golle <daniel@makrotopia.org>
---
arch/arm/mach-mvebu/kirkwood.c | 1 +
1 file changed, 1 insertion(+)
--- a/arch/arm/mach-mvebu/kirkwood.c
+++ b/arch/arm/mach-mvebu/kirkwood.c
@@ -14,6 +14,7 @@
#include <linux/kernel.h>
#include <linux/init.h>
#include <linux/mbus.h>
+#include <linux/if_ether.h>
#include <linux/of.h>
#include <linux/of_address.h>
#include <linux/of_net.h>

View File

@ -905,8 +905,6 @@ static int edma_axi_probe(struct platform_device *pdev)
}
for_each_available_child_of_node(np, pnp) {
const char *mac_addr;
/* this check is needed if parent and daughter dts have
* different number of gmac nodes
*/
@ -915,9 +913,7 @@ static int edma_axi_probe(struct platform_device *pdev)
break;
}
mac_addr = of_get_mac_address(pnp);
if (!IS_ERR(mac_addr))
memcpy(edma_netdev[idx_mac]->dev_addr, mac_addr, ETH_ALEN);
of_get_mac_address(pnp, edma_netdev[idx_mac]->dev_addr);
idx_mac++;
}

View File

@ -721,7 +721,7 @@ Signed-off-by: John Crispin <blogic@openwrt.org>
netif_trans_update(dev);
netif_wake_queue(dev);
return;
@@ -618,14 +822,19 @@ static const struct net_device_ops ltq_e
@@ -618,14 +822,18 @@ static const struct net_device_ops ltq_e
.ndo_tx_timeout = ltq_etop_tx_timeout,
};
@ -733,7 +733,6 @@ Signed-off-by: John Crispin <blogic@openwrt.org>
struct ltq_etop_priv *priv;
- struct resource *res;
+ struct resource *res, *gbit_res, irqres[2];
+ const u8 *mac;
int err;
- int i;
+
@ -745,7 +744,7 @@ Signed-off-by: John Crispin <blogic@openwrt.org>
res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
if (!res) {
@@ -651,31 +860,64 @@ ltq_etop_probe(struct platform_device *p
@@ -651,31 +860,62 @@ ltq_etop_probe(struct platform_device *p
goto err_out;
}
@ -785,9 +784,7 @@ Signed-off-by: John Crispin <blogic@openwrt.org>
+ if (err)
+ pr_err("Can't find phy-mode for port\n");
+
+ mac = of_get_mac_address(pdev->dev.of_node);
+ if (mac)
+ memcpy(priv->mac, mac, ETH_ALEN);
+ of_get_mac_address(pdev->dev.of_node, priv->mac);
+
+ priv->clk_ppe = clk_get(&pdev->dev, NULL);
+ if (IS_ERR(priv->clk_ppe))

View File

@ -721,7 +721,7 @@ Signed-off-by: John Crispin <blogic@openwrt.org>
netif_trans_update(dev);
netif_wake_queue(dev);
return;
@@ -625,14 +829,19 @@ static const struct net_device_ops ltq_e
@@ -625,14 +829,18 @@ static const struct net_device_ops ltq_e
.ndo_tx_timeout = ltq_etop_tx_timeout,
};
@ -733,7 +733,6 @@ Signed-off-by: John Crispin <blogic@openwrt.org>
struct ltq_etop_priv *priv;
- struct resource *res;
+ struct resource *res, *gbit_res, irqres[2];
+ const u8 *mac;
int err;
- int i;
+
@ -745,7 +744,7 @@ Signed-off-by: John Crispin <blogic@openwrt.org>
res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
if (!res) {
@@ -658,31 +867,62 @@ ltq_etop_probe(struct platform_device *p
@@ -658,31 +867,60 @@ ltq_etop_probe(struct platform_device *p
goto err_out;
}
@ -783,9 +782,7 @@ Signed-off-by: John Crispin <blogic@openwrt.org>
+ priv->rx_irq = irqres[1].start;
+ priv->mii_mode = of_get_phy_mode(pdev->dev.of_node);
+
+ mac = of_get_mac_address(pdev->dev.of_node);
+ if (mac)
+ memcpy(priv->mac, mac, ETH_ALEN);
+ of_get_mac_address(pdev->dev.of_node, priv->mac);
+
+ priv->clk_ppe = clk_get(&pdev->dev, NULL);
+ if (IS_ERR(priv->clk_ppe))

View File

@ -10514,7 +10514,7 @@ Signed-off-by: Madalin Bucur <madalin.bucur@nxp.com>
+module_exit(dpa_ptp_unload);
--- /dev/null
+++ b/drivers/net/ethernet/freescale/sdk_dpaa/mac-api.c
@@ -0,0 +1,909 @@
@@ -0,0 +1,907 @@
+/* Copyright 2008-2012 Freescale Semiconductor, Inc.
+ *
+ * Redistribution and use in source and binary forms, with or without
@ -11582,7 +11582,6 @@ Signed-off-by: Madalin Bucur <madalin.bucur@nxp.com>
+ struct mac_device *mac_dev;
+ struct platform_device *of_dev;
+ struct resource res;
+ const uint8_t *mac_addr;
+ const char *char_prop;
+ int nph;
+ u32 cell_index;
@ -11701,14 +11700,13 @@ Signed-off-by: Madalin Bucur <madalin.bucur@nxp.com>
+ mac_dev->cell_index -= 8;
+
+ /* Get the MAC address */
+ mac_addr = of_get_mac_address(mac_node);
+ if (unlikely(mac_addr == NULL)) {
+ of_get_mac_address(mac_node, mac_dev->addr);
+ if (unlikely(!is_valid_ether_addr(mac_dev->addr))) {
+ dev_err(dev, "of_get_mac_address(%s) failed\n",
+ mac_node->full_name);
+ _errno = -EINVAL;
+ goto _return_dev_set_drvdata;
+ }
+ memcpy(mac_dev->addr, mac_addr, sizeof(mac_dev->addr));
+
+ /* Verify the number of port handles */
+ nph = of_count_phandle_with_args(mac_node, "fsl,fman-ports", NULL);

View File

@ -6638,7 +6638,7 @@ Signed-off-by: Anjaneyulu Jagarlmudi <anji.jagarlmudi@nxp.com>
+}
--- /dev/null
+++ b/drivers/staging/fsl_ppfe/pfe_ls1012a_platform.c
@@ -0,0 +1,394 @@
@@ -0,0 +1,388 @@
+/*
+ * Copyright 2015-2016 Freescale Semiconductor, Inc.
+ * Copyright 2017 NXP
@ -6680,7 +6680,6 @@ Signed-off-by: Anjaneyulu Jagarlmudi <anji.jagarlmudi@nxp.com>
+ int size;
+ int ii = 0, phy_id = 0;
+ const u32 *addr;
+ const void *mac_addr;
+
+ for (ii = 0; ii < if_cnt; ii++) {
+ gem = of_get_next_child(parent, gem);
@ -6699,12 +6698,7 @@ Signed-off-by: Anjaneyulu Jagarlmudi <anji.jagarlmudi@nxp.com>
+
+ pdata->ls1012a_eth_pdata[port].gem_id = port;
+
+ mac_addr = of_get_mac_address(gem);
+
+ if (mac_addr) {
+ memcpy(pdata->ls1012a_eth_pdata[port].mac_addr, mac_addr,
+ ETH_ALEN);
+ }
+ of_get_mac_address(gem, pdata->ls1012a_eth_pdata[port].mac_addr);
+
+ pdata->ls1012a_eth_pdata[port].mii_config = of_get_phy_mode(gem);
+

View File

@ -33,15 +33,9 @@ Signed-off-by: Calvin Johnson <calvin.johnson@nxp.com>
int size;
int ii = 0, phy_id = 0;
const u32 *addr;
@@ -49,18 +49,11 @@ static int pfe_get_gemac_if_proprties(st
pdata->ls1012a_eth_pdata[port].gem_id = port;
@@ -49,12 +49,6 @@ static int pfe_get_gemac_if_proprties(st
mac_addr = of_get_mac_address(gem);
-
if (mac_addr) {
memcpy(pdata->ls1012a_eth_pdata[port].mac_addr, mac_addr,
ETH_ALEN);
}
of_get_mac_address(gem, pdata->ls1012a_eth_pdata[port].mac_addr);
- pdata->ls1012a_eth_pdata[port].mii_config = of_get_phy_mode(gem);
-

View File

@ -30,9 +30,3 @@ Signed-off-by: Anji Jagarlmudi <anji.jagarlmudi@nxp.com>
pdata->ls1012a_eth_pdata[port].gem_id = port;
mac_addr = of_get_mac_address(gem);
- if (mac_addr) {
+ if (!IS_ERR_OR_NULL(mac_addr)) {
memcpy(pdata->ls1012a_eth_pdata[port].mac_addr, mac_addr,
ETH_ALEN);
}

View File

@ -206,6 +206,8 @@ CONFIG_HAS_DMA=y
CONFIG_HAS_IOMEM=y
CONFIG_HAS_IOPORT_MAP=y
CONFIG_HOLES_IN_ZONE=y
CONFIG_HW_RANDOM=y
CONFIG_HW_RANDOM_MTK=y
CONFIG_I2C=y
CONFIG_I2C_BOARDINFO=y
CONFIG_I2C_CHARDEV=y

View File

@ -14,7 +14,7 @@ Signed-off-by: Frank Wunderlich <frank-w@public-files.de>
--- a/drivers/net/ethernet/mediatek/mtk_eth_soc.c
+++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.c
@@ -3274,6 +3274,7 @@ static const struct mtk_soc_data mt7623_
@@ -3269,6 +3269,7 @@ static const struct mtk_soc_data mt7623_
.hw_features = MTK_HW_FEATURES,
.required_clks = MT7623_CLKS_BITMAP,
.required_pctl = true,

View File

@ -51,7 +51,7 @@ Signed-off-by: Felix Fietkau <nbd@nbd.name>
if (MTK_HAS_CAPS(eth->soc->caps, MTK_SOC_MT7628)) {
ret = device_reset(eth->dev);
if (ret) {
@@ -3076,6 +3084,16 @@ static int mtk_probe(struct platform_dev
@@ -3071,6 +3079,16 @@ static int mtk_probe(struct platform_dev
}
}

View File

@ -12,20 +12,18 @@ Tested-by: Johannes Kimmel <fff@bareminimum.eu>
Signed-off-by: Roman Kuzmitskii <damex.pp@icloud.com>
--- a/drivers/staging/octeon/ethernet.c
+++ b/drivers/staging/octeon/ethernet.c
@@ -408,9 +408,12 @@ int cvm_oct_common_init(struct net_devic
@@ -408,7 +408,11 @@ int cvm_oct_common_init(struct net_devic
int cvm_oct_common_init(struct net_device *dev)
{
struct octeon_ethernet *priv = netdev_priv(dev);
const u8 *mac = NULL;
+ const u8 *label = NULL;
- if (priv->of_node)
+ if (priv->of_node) {
mac = of_get_mac_address(priv->of_node);
int ret;
+
+ if (priv->of_node)
+ label = of_get_property(priv->of_node, "label", NULL);
+ }
if (!IS_ERR_OR_NULL(mac))
ether_addr_copy(dev->dev_addr, mac);
ret = of_get_mac_address(priv->of_node, dev->dev_addr);
if (ret)
@@ -445,6 +448,9 @@ int cvm_oct_common_init(struct net_devic
if (dev->netdev_ops->ndo_stop)
dev->netdev_ops->ndo_stop(dev);

View File

@ -12,20 +12,18 @@ Tested-by: Johannes Kimmel <fff@bareminimum.eu>
Signed-off-by: Roman Kuzmitskii <damex.pp@icloud.com>
--- a/drivers/staging/octeon/ethernet.c
+++ b/drivers/staging/octeon/ethernet.c
@@ -408,9 +408,12 @@ int cvm_oct_common_init(struct net_devic
@@ -408,7 +408,11 @@ int cvm_oct_common_init(struct net_devic
int cvm_oct_common_init(struct net_device *dev)
{
struct octeon_ethernet *priv = netdev_priv(dev);
const u8 *mac = NULL;
+ const u8 *label = NULL;
- if (priv->of_node)
+ if (priv->of_node) {
mac = of_get_mac_address(priv->of_node);
int ret;
+
+ if (priv->of_node)
+ label = of_get_property(priv->of_node, "label", NULL);
+ }
if (!IS_ERR_OR_NULL(mac))
ether_addr_copy(dev->dev_addr, mac);
ret = of_get_mac_address(priv->of_node, dev->dev_addr);
if (ret)
@@ -445,6 +448,9 @@ int cvm_oct_common_init(struct net_devic
if (dev->netdev_ops->ndo_stop)
dev->netdev_ops->ndo_stop(dev);

View File

@ -11,6 +11,7 @@
led-failsafe = &led_power_yellow;
led-running = &led_power_blue;
led-upgrade = &led_power_yellow;
label-mac-device = &ethernet;
};
chosen {

View File

@ -1368,7 +1368,6 @@ static int __init fe_init(struct net_device *dev)
{
struct fe_priv *priv = netdev_priv(dev);
struct device_node *port;
const char *mac_addr;
int err;
if (priv->soc->reset_fe)
@ -1389,9 +1388,7 @@ static int __init fe_init(struct net_device *dev)
fe_reset_phy(priv);
mac_addr = of_get_mac_address(priv->dev->of_node);
if (!IS_ERR_OR_NULL(mac_addr))
ether_addr_copy(dev->dev_addr, mac_addr);
of_get_mac_address(priv->dev->of_node, dev->dev_addr);
/* If the mac address is invalid, use random mac address */
if (!is_valid_ether_addr(dev->dev_addr)) {

View File

@ -1968,7 +1968,6 @@ static int __init rtl838x_eth_probe(struct platform_device *pdev)
struct device_node *dn = pdev->dev.of_node;
struct rtl838x_eth_priv *priv;
struct resource *res, *mem;
const void *mac;
phy_interface_t phy_mode;
struct phylink *phylink;
int err = 0, i, rxrings, rxringlen;
@ -2089,10 +2088,9 @@ static int __init rtl838x_eth_probe(struct platform_device *pdev)
* 1) from device tree data
* 2) from internal registers set by bootloader
*/
mac = of_get_mac_address(pdev->dev.of_node);
if (!IS_ERR(mac)) {
memcpy(dev->dev_addr, mac, ETH_ALEN);
rtl838x_set_mac_hw(dev, (u8 *)mac);
of_get_mac_address(pdev->dev.of_node, dev->dev_addr);
if (is_valid_ether_addr(dev->dev_addr)) {
rtl838x_set_mac_hw(dev, (u8 *)dev->dev_addr);
} else {
dev->dev_addr[0] = (sw_r32(priv->r->mac) >> 8) & 0xff;
dev->dev_addr[1] = sw_r32(priv->r->mac) & 0xff;