aboutsummaryrefslogtreecommitdiffstats
path: root/package
diff options
context:
space:
mode:
authorAnsuel Smith <ansuelsmth@gmail.com>2021-07-23 20:19:43 +0200
committerDavid Bauer <mail@david-bauer.net>2021-08-05 01:46:26 +0200
commit91a52f22a13d768f5b16a2fd0e1d74ffe36f9cb1 (patch)
treef28017e5a42615c51b599d6de96c9fb91d27d476 /package
parentedb6bc199049769be76bb3966debcc2b31511e4b (diff)
downloadupstream-91a52f22a13d768f5b16a2fd0e1d74ffe36f9cb1.tar.gz
upstream-91a52f22a13d768f5b16a2fd0e1d74ffe36f9cb1.tar.bz2
upstream-91a52f22a13d768f5b16a2fd0e1d74ffe36f9cb1.zip
treewide: backport support for nvmem on non platform devices
In the current state, nvmem cells are only detected on platform device. To quickly fix the problem, we register the affected problematic driver with the of_platform but that is more an hack than a real solution. Backport from net-next the required patch so that nvmem can work also with non-platform devices and rework our current patch. Drop the mediatek and dsa workaround and rework the ath10k patches. Rework every driver that use the of_get_mac_address api. Signed-off-by: Ansuel Smith <ansuelsmth@gmail.com>
Diffstat (limited to 'package')
-rw-r--r--package/kernel/ath10k-ct/patches/203-ath10k-Try-to-get-mac-address-from-dts.patch25
-rw-r--r--package/kernel/mac80211/patches/ath10k/984-ath10k-Try-to-get-mac-address-from-dts.patch (renamed from package/kernel/mac80211/patches/ath/984-ath10k-Try-to-get-mac-address-from-dts.patch)25
-rw-r--r--package/kernel/mac80211/patches/rt2x00/607-rt2x00-add_platform_data_mac_addr.patch11
-rw-r--r--package/kernel/mac80211/patches/subsys/782-net-next-1-of-net-pass-the-dst-buffer-to-of_get_mac_address.patch245
-rw-r--r--package/kernel/mt76/patches/001-of-net-pass-the-dst-buffer-to-of_get_mac_address.patch206
5 files changed, 462 insertions, 50 deletions
diff --git a/package/kernel/ath10k-ct/patches/203-ath10k-Try-to-get-mac-address-from-dts.patch b/package/kernel/ath10k-ct/patches/203-ath10k-Try-to-get-mac-address-from-dts.patch
index b5c53baf67..3b5d9d45ac 100644
--- a/package/kernel/ath10k-ct/patches/203-ath10k-Try-to-get-mac-address-from-dts.patch
+++ b/package/kernel/ath10k-ct/patches/203-ath10k-Try-to-get-mac-address-from-dts.patch
@@ -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) {
diff --git a/package/kernel/mac80211/patches/ath/984-ath10k-Try-to-get-mac-address-from-dts.patch b/package/kernel/mac80211/patches/ath10k/984-ath10k-Try-to-get-mac-address-from-dts.patch
index d0eb43fdea..5f427f6b8f 100644
--- a/package/kernel/mac80211/patches/ath/984-ath10k-Try-to-get-mac-address-from-dts.patch
+++ b/package/kernel/mac80211/patches/ath10k/984-ath10k-Try-to-get-mac-address-from-dts.patch
@@ -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) {
diff --git a/package/kernel/mac80211/patches/rt2x00/607-rt2x00-add_platform_data_mac_addr.patch b/package/kernel/mac80211/patches/rt2x00/607-rt2x00-add_platform_data_mac_addr.patch
index b5b2c61037..79f99ffdf4 100644
--- a/package/kernel/mac80211/patches/rt2x00/607-rt2x00-add_platform_data_mac_addr.patch
+++ b/package/kernel/mac80211/patches/rt2x00/607-rt2x00-add_platform_data_mac_addr.patch
@@ -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 @@
diff --git a/package/kernel/mac80211/patches/subsys/782-net-next-1-of-net-pass-the-dst-buffer-to-of_get_mac_address.patch b/package/kernel/mac80211/patches/subsys/782-net-next-1-of-net-pass-the-dst-buffer-to-of_get_mac_address.patch
new file mode 100644
index 0000000000..b9731552c0
--- /dev/null
+++ b/package/kernel/mac80211/patches/subsys/782-net-next-1-of-net-pass-the-dst-buffer-to-of_get_mac_address.patch
@@ -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
diff --git a/package/kernel/mt76/patches/001-of-net-pass-the-dst-buffer-to-of_get_mac_address.patch b/package/kernel/mt76/patches/001-of-net-pass-the-dst-buffer-to-of_get_mac_address.patch
new file mode 100644
index 0000000000..66075f2771
--- /dev/null
+++ b/package/kernel/mt76/patches/001-of-net-pass-the-dst-buffer-to-of_get_mac_address.patch
@@ -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
+