Merge branch 'of_net-Add-NVMEM-support-to-of_get_mac_address'
Petr Štetiar says:
====================
of_net: Add NVMEM support to of_get_mac_address
this patch series is a continuation of my previous attempt[1], where I've
tried to wire MTD layer into of_get_mac_address, so it would be possible to
load MAC addresses from various NVMEMs as EEPROMs etc.
Predecessor of this patch which used directly MTD layer has originated in
OpenWrt some time ago and supports already about 497 use cases in 357
device tree files.
During the review process of my 1st attempt I was told, that I shouldn't be
using MTD directly, but that I should rather use new NVMEM subsystem and
during the review process of v2 I was told, that I should handle
EPROBE_DEFFER error as well, during the review process of v3 I was told,
that returning pointer/NULL/ERR_PTR is considered as wrong API design, so
this v4 patch series tries to accommodate all this previous remarks.
First patch is wiring NVMEM support directly into of_get_mac_address as
it's obvious, that adding support for NVMEM into every other driver would
mean adding a lot of repetitive code. This patch allows us to configure MAC
addresses in various devices like ethernet and wireless adapters directly
from of_get_mac_address, which is used by quite a lot of drivers in the
tree already.
Second patch is simply updating documentation with NVMEM bits, and cleaning
up all current binding documentation referencing any of the MAC address
related properties.
Third and fourth patches are simply removing duplicate NVMEM code which is
no longer needed as the first patch has wired NVMEM support directly into
of_get_mac_address.
Patches 5-10 are converting all current users of of_get_mac_address to the
new ERR_PTR encoded error value, as of_get_mac_address could now return
valid pointer, NULL and ERR_PTR.
Just for a better picture, this patch series and one simple patch[2] on top
of it, allows me to configure 8Devices Carambola2 board's MAC addresses
with following DTS (simplified):
&spi {
flash@0 {
partitions {
art: partition@ff0000 {
label = "art";
reg = <0xff0000 0x010000>;
read-only;
nvmem-cells {
compatible = "nvmem-cells";
#address-cells = <1>;
#size-cells = <1>;
eth0_addr: eth-mac-addr@0 {
reg = <0x0 0x6>;
};
eth1_addr: eth-mac-addr@6 {
reg = <0x6 0x6>;
};
wmac_addr: wifi-mac-addr@1002 {
reg = <0x1002 0x6>;
};
};
};
};
};
};
ð0 {
nvmem-cells = <ð0_addr>;
nvmem-cell-names = "mac-address";
};
ð1 {
nvmem-cells = <ð1_addr>;
nvmem-cell-names = "mac-address";
};
&wmac {
nvmem-cells = <&wmac_addr>;
nvmem-cell-names = "mac-address";
};
1. https://patchwork.ozlabs.org/patch/1086628/
2. https://patchwork.ozlabs.org/patch/890738/
====================
Signed-off-by: David S. Miller <davem@davemloft.net>