From patchwork Fri May 3 14:27:06 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Petr_=C5=A0tetiar?= X-Patchwork-Id: 1094916 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming-netdev@ozlabs.org Delivered-To: patchwork-incoming-netdev@ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=netdev-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=true.cz Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 44wZRr0nnbz9s4V for ; Sat, 4 May 2019 00:35:36 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728216AbfECOfX (ORCPT ); Fri, 3 May 2019 10:35:23 -0400 Received: from smtp-out.xnet.cz ([178.217.244.18]:17188 "EHLO smtp-out.xnet.cz" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728170AbfECOfV (ORCPT ); Fri, 3 May 2019 10:35:21 -0400 Received: from meh.true.cz (meh.true.cz [108.61.167.218]) (Authenticated sender: petr@true.cz) by smtp-out.xnet.cz (Postfix) with ESMTPSA id F2A164AC7; Fri, 3 May 2019 16:27:25 +0200 (CEST) Received: by meh.true.cz (OpenSMTPD) with ESMTP id 0334bf48; Fri, 3 May 2019 16:27:24 +0200 (CEST) From: =?utf-8?q?Petr_=C5=A0tetiar?= To: netdev@vger.kernel.org, devicetree@vger.kernel.org, Andrew Lunn , Florian Fainelli , Heiner Kallweit , Rob Herring , Frank Rowand Cc: Srinivas Kandagatla , Maxime Ripard , =?utf-8?q?Petr_=C5=A0tetiar?= , Alban Bedel , Felix Fietkau , John Crispin , linux-kernel@vger.kernel.org Subject: [PATCH v4 01/10] of_net: add NVMEM support to of_get_mac_address Date: Fri, 3 May 2019 16:27:06 +0200 Message-Id: <1556893635-18549-2-git-send-email-ynezz@true.cz> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1556893635-18549-1-git-send-email-ynezz@true.cz> References: <1556893635-18549-1-git-send-email-ynezz@true.cz> MIME-Version: 1.0 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Many embedded devices have information such as MAC addresses stored inside NVMEMs like EEPROMs and so on. Currently there are only two drivers in the tree which benefit from NVMEM bindings. 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 already used by almost every driver in the tree. 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. Cc: Alban Bedel Signed-off-by: Felix Fietkau Signed-off-by: John Crispin Signed-off-by: Petr Štetiar --- Changes since v1: * moved handling of nvmem after mac-address and local-mac-address properties Changes since v2: * moved of_get_mac_addr_nvmem after of_get_mac_addr(np, "address") call * replaced kzalloc, kmemdup and kfree with it's devm variants * introduced of_has_nvmem_mac_addr helper which checks if DT node has nvmem cell with `mac-address` * of_get_mac_address now returns ERR_PTR encoded error value Changes since v3: * removed of_has_nvmem_mac_addr helper as it's not needed now * of_get_mac_address now returns only valid pointer or ERR_PTR encoded error value drivers/of/of_net.c | 54 ++++++++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 51 insertions(+), 3 deletions(-) diff --git a/drivers/of/of_net.c b/drivers/of/of_net.c index d820f3e..9649cd5 100644 --- a/drivers/of/of_net.c +++ b/drivers/of/of_net.c @@ -8,8 +8,10 @@ #include #include #include +#include #include #include +#include /** * of_get_phy_mode - Get phy mode for given device_node @@ -47,12 +49,52 @@ static const void *of_get_mac_addr(struct device_node *np, const char *name) return NULL; } +static const void *of_get_mac_addr_nvmem(struct device_node *np) +{ + int ret; + u8 mac[ETH_ALEN]; + struct property *pp; + struct platform_device *pdev = of_find_device_by_node(np); + + if (!pdev) + return ERR_PTR(-ENODEV); + + ret = nvmem_get_mac_address(&pdev->dev, &mac); + if (ret) + return ERR_PTR(ret); + + pp = devm_kzalloc(&pdev->dev, sizeof(*pp), GFP_KERNEL); + if (!pp) + return ERR_PTR(-ENOMEM); + + pp->name = "nvmem-mac-address"; + pp->length = ETH_ALEN; + pp->value = devm_kmemdup(&pdev->dev, mac, ETH_ALEN, GFP_KERNEL); + if (!pp->value) { + ret = -ENOMEM; + goto free; + } + + ret = of_add_property(np, pp); + if (ret) + goto free; + + return pp->value; +free: + devm_kfree(&pdev->dev, pp->value); + devm_kfree(&pdev->dev, pp); + + return ERR_PTR(ret); +} + /** * 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 * address. If that isn't set, then 'local-mac-address' is checked next, - * because that is the default address. If that isn't set, then the obsolete - * 'address' is checked, just in case we're using an old device tree. + * because that is the default address. If that isn't set, then the obsolete + * 'address' is checked, just in case we're using an old device tree. If any + * of the above isn't set, then try to get MAC address from nvmem cell named + * 'mac-address'. * * Note that the 'address' property is supposed to contain a virtual address of * the register set, but some DTS files have redefined that property to be the @@ -64,6 +106,8 @@ static const void *of_get_mac_addr(struct device_node *np, const char *name) * addresses. Some older U-Boots only initialized 'local-mac-address'. In * this case, the real MAC is in 'local-mac-address', and 'mac-address' exists * but is all zeros. + * + * Return: Will be a valid pointer on success and ERR_PTR in case of error. */ const void *of_get_mac_address(struct device_node *np) { @@ -77,6 +121,10 @@ const void *of_get_mac_address(struct device_node *np) if (addr) return addr; - return of_get_mac_addr(np, "address"); + addr = of_get_mac_addr(np, "address"); + if (addr) + return addr; + + return of_get_mac_addr_nvmem(np); } EXPORT_SYMBOL(of_get_mac_address); From patchwork Fri May 3 14:27:07 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Petr_=C5=A0tetiar?= X-Patchwork-Id: 1094915 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming-netdev@ozlabs.org Delivered-To: patchwork-incoming-netdev@ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=netdev-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=true.cz Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 44wZRm4VMRz9s4V for ; Sat, 4 May 2019 00:35:32 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728229AbfECOfY (ORCPT ); Fri, 3 May 2019 10:35:24 -0400 Received: from smtp-out.xnet.cz ([178.217.244.18]:17094 "EHLO smtp-out.xnet.cz" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727914AbfECOfU (ORCPT ); Fri, 3 May 2019 10:35:20 -0400 Received: from meh.true.cz (meh.true.cz [108.61.167.218]) (Authenticated sender: petr@true.cz) by smtp-out.xnet.cz (Postfix) with ESMTPSA id 6E3564AC9; Fri, 3 May 2019 16:27:30 +0200 (CEST) Received: by meh.true.cz (OpenSMTPD) with ESMTP id a21e6f1c; Fri, 3 May 2019 16:27:29 +0200 (CEST) From: =?utf-8?q?Petr_=C5=A0tetiar?= To: netdev@vger.kernel.org, devicetree@vger.kernel.org, "David S. Miller" , Rob Herring , Mark Rutland , Andrew Lunn , Vivien Didelot , Florian Fainelli , Yisen Zhuang , Salil Mehta , Woojung Huh , Microchip Linux Driver Support , Kunihiko Hayashi , Masahiro Yamada , Jassi Brar , Kalle Valo , Matthias Brugger Cc: Heiner Kallweit , Frank Rowand , Srinivas Kandagatla , Maxime Ripard , =?utf-8?q?Petr_=C5=A0tetiar?= , linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-wireless@vger.kernel.org, linux-mediatek@lists.infradead.org Subject: [PATCH v4 02/10] dt-bindings: doc: reflect new NVMEM of_get_mac_address behaviour Date: Fri, 3 May 2019 16:27:07 +0200 Message-Id: <1556893635-18549-3-git-send-email-ynezz@true.cz> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1556893635-18549-1-git-send-email-ynezz@true.cz> References: <1556893635-18549-1-git-send-email-ynezz@true.cz> MIME-Version: 1.0 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org As of_get_mac_address now supports NVMEM under the hood, we need to update the bindings documentation with the new nvmem-cell* properties, which would mean copy&pasting a lot of redundant information to every binding documentation currently referencing some of the MAC address properties. So I've just removed all the references to the optional MAC address properties and replaced them with the small note referencing net/ethernet.txt file. Signed-off-by: Petr Štetiar --- Changes since v2: * replaced only MAC address related optional properties with a text referencing ethernet.txt Documentation/devicetree/bindings/net/altera_tse.txt | 5 ++--- Documentation/devicetree/bindings/net/amd-xgbe.txt | 5 +++-- Documentation/devicetree/bindings/net/brcm,amac.txt | 4 ++-- Documentation/devicetree/bindings/net/cpsw.txt | 4 +++- Documentation/devicetree/bindings/net/davinci_emac.txt | 5 +++-- Documentation/devicetree/bindings/net/dsa/dsa.txt | 5 ++--- Documentation/devicetree/bindings/net/ethernet.txt | 6 ++++-- Documentation/devicetree/bindings/net/hisilicon-femac.txt | 4 +++- .../devicetree/bindings/net/hisilicon-hix5hd2-gmac.txt | 4 +++- Documentation/devicetree/bindings/net/keystone-netcp.txt | 10 +++++----- Documentation/devicetree/bindings/net/macb.txt | 5 ++--- Documentation/devicetree/bindings/net/marvell-pxa168.txt | 4 +++- Documentation/devicetree/bindings/net/microchip,enc28j60.txt | 3 ++- Documentation/devicetree/bindings/net/microchip,lan78xx.txt | 5 ++--- Documentation/devicetree/bindings/net/qca,qca7000.txt | 4 +++- Documentation/devicetree/bindings/net/samsung-sxgbe.txt | 4 +++- .../devicetree/bindings/net/snps,dwc-qos-ethernet.txt | 5 +++-- .../devicetree/bindings/net/socionext,uniphier-ave4.txt | 4 ++-- Documentation/devicetree/bindings/net/socionext-netsec.txt | 5 +++-- .../devicetree/bindings/net/wireless/mediatek,mt76.txt | 5 +++-- Documentation/devicetree/bindings/net/wireless/qca,ath9k.txt | 4 ++-- 21 files changed, 58 insertions(+), 42 deletions(-) diff --git a/Documentation/devicetree/bindings/net/altera_tse.txt b/Documentation/devicetree/bindings/net/altera_tse.txt index 0e21df9..0b7d4d3 100644 --- a/Documentation/devicetree/bindings/net/altera_tse.txt +++ b/Documentation/devicetree/bindings/net/altera_tse.txt @@ -46,9 +46,8 @@ Required properties: - reg: phy id used to communicate to phy. - device_type: Must be "ethernet-phy". -Optional properties: -- local-mac-address: See ethernet.txt in the same directory. -- max-frame-size: See ethernet.txt in the same directory. +The MAC address will be determined using the optional properties defined in +ethernet.txt. Example: diff --git a/Documentation/devicetree/bindings/net/amd-xgbe.txt b/Documentation/devicetree/bindings/net/amd-xgbe.txt index 93dcb79..9c27dfc 100644 --- a/Documentation/devicetree/bindings/net/amd-xgbe.txt +++ b/Documentation/devicetree/bindings/net/amd-xgbe.txt @@ -24,8 +24,6 @@ Required properties: - phy-mode: See ethernet.txt file in the same directory Optional properties: -- mac-address: mac address to be assigned to the device. Can be overridden - by UEFI. - dma-coherent: Present if dma operations are coherent - amd,per-channel-interrupt: Indicates that Rx and Tx complete will generate a unique interrupt for each DMA channel - this requires an additional @@ -34,6 +32,9 @@ Optional properties: 0 - 1GbE and 10GbE (default) 1 - 2.5GbE and 10GbE +The MAC address will be determined using the optional properties defined in +ethernet.txt. + The following optional properties are represented by an array with each value corresponding to a particular speed. The first array value represents the setting for the 1GbE speed, the second value for the 2.5GbE speed and diff --git a/Documentation/devicetree/bindings/net/brcm,amac.txt b/Documentation/devicetree/bindings/net/brcm,amac.txt index 0bfad65..0120ebe 100644 --- a/Documentation/devicetree/bindings/net/brcm,amac.txt +++ b/Documentation/devicetree/bindings/net/brcm,amac.txt @@ -16,8 +16,8 @@ Required properties: registers (required for Northstar2) - interrupts: Interrupt number -Optional properties: -- mac-address: See ethernet.txt file in the same directory +The MAC address will be determined using the optional properties +defined in ethernet.txt. Examples: diff --git a/Documentation/devicetree/bindings/net/cpsw.txt b/Documentation/devicetree/bindings/net/cpsw.txt index 3264e19..7c7ac5e 100644 --- a/Documentation/devicetree/bindings/net/cpsw.txt +++ b/Documentation/devicetree/bindings/net/cpsw.txt @@ -49,10 +49,12 @@ Required properties: Optional properties: - dual_emac_res_vlan : Specifies VID to be used to segregate the ports -- mac-address : See ethernet.txt file in the same directory - phy_id : Specifies slave phy id (deprecated, use phy-handle) - phy-handle : See ethernet.txt file in the same directory +The MAC address will be determined using the optional properties +defined in ethernet.txt. + Slave sub-nodes: - fixed-link : See fixed-link.txt file in the same directory diff --git a/Documentation/devicetree/bindings/net/davinci_emac.txt b/Documentation/devicetree/bindings/net/davinci_emac.txt index ca83dcc..5e3579e 100644 --- a/Documentation/devicetree/bindings/net/davinci_emac.txt +++ b/Documentation/devicetree/bindings/net/davinci_emac.txt @@ -20,11 +20,12 @@ Required properties: Optional properties: - phy-handle: See ethernet.txt file in the same directory. If absent, davinci_emac driver defaults to 100/FULL. -- nvmem-cells: phandle, reference to an nvmem node for the MAC address -- nvmem-cell-names: string, should be "mac-address" if nvmem is to be used - ti,davinci-rmii-en: 1 byte, 1 means use RMII - ti,davinci-no-bd-ram: boolean, does EMAC have BD RAM? +The MAC address will be determined using the optional properties +defined in ethernet.txt. + Example (enbw_cmc board): eth0: emac@1e20000 { compatible = "ti,davinci-dm6467-emac"; diff --git a/Documentation/devicetree/bindings/net/dsa/dsa.txt b/Documentation/devicetree/bindings/net/dsa/dsa.txt index d66a529..a237567 100644 --- a/Documentation/devicetree/bindings/net/dsa/dsa.txt +++ b/Documentation/devicetree/bindings/net/dsa/dsa.txt @@ -71,9 +71,8 @@ properties, described in binding documents: Documentation/devicetree/bindings/net/fixed-link.txt for details. -- local-mac-address : See - Documentation/devicetree/bindings/net/ethernet.txt - for details. +The MAC address will be determined using the optional properties +defined in ethernet.txt. Example diff --git a/Documentation/devicetree/bindings/net/ethernet.txt b/Documentation/devicetree/bindings/net/ethernet.txt index a686215..6992444 100644 --- a/Documentation/devicetree/bindings/net/ethernet.txt +++ b/Documentation/devicetree/bindings/net/ethernet.txt @@ -4,12 +4,14 @@ NOTE: All 'phy*' properties documented below are Ethernet specific. For the generic PHY 'phys' property, see Documentation/devicetree/bindings/phy/phy-bindings.txt. -- local-mac-address: array of 6 bytes, specifies the MAC address that was - assigned to the network device; - mac-address: array of 6 bytes, specifies the MAC address that was last used by the boot program; should be used in cases where the MAC address assigned to the device by the boot program is different from the "local-mac-address" property; +- local-mac-address: array of 6 bytes, specifies the MAC address that was + assigned to the network device; +- nvmem-cells: phandle, reference to an nvmem node for the MAC address +- nvmem-cell-names: string, should be "mac-address" if nvmem is to be used - max-speed: number, specifies maximum speed in Mbit/s supported by the device; - max-frame-size: number, maximum transfer unit (IEEE defined MTU), rather than the maximum frame size (there's contradiction in the Devicetree diff --git a/Documentation/devicetree/bindings/net/hisilicon-femac.txt b/Documentation/devicetree/bindings/net/hisilicon-femac.txt index d11af5e..5f96976 100644 --- a/Documentation/devicetree/bindings/net/hisilicon-femac.txt +++ b/Documentation/devicetree/bindings/net/hisilicon-femac.txt @@ -14,7 +14,6 @@ Required properties: the PHY reset signal(optional). - reset-names: should contain the reset signal name "mac"(required) and "phy"(optional). -- mac-address: see ethernet.txt [1]. - phy-mode: see ethernet.txt [1]. - phy-handle: see ethernet.txt [1]. - hisilicon,phy-reset-delays-us: triplet of delays if PHY reset signal given. @@ -22,6 +21,9 @@ Required properties: The 2nd cell is reset pulse in micro seconds. The 3rd cell is reset post-delay in micro seconds. +The MAC address will be determined using the optional properties +defined in ethernet.txt[1]. + [1] Documentation/devicetree/bindings/net/ethernet.txt Example: diff --git a/Documentation/devicetree/bindings/net/hisilicon-hix5hd2-gmac.txt b/Documentation/devicetree/bindings/net/hisilicon-hix5hd2-gmac.txt index eea73ad..cddf46b 100644 --- a/Documentation/devicetree/bindings/net/hisilicon-hix5hd2-gmac.txt +++ b/Documentation/devicetree/bindings/net/hisilicon-hix5hd2-gmac.txt @@ -18,7 +18,6 @@ Required properties: - #size-cells: must be <0>. - phy-mode: see ethernet.txt [1]. - phy-handle: see ethernet.txt [1]. -- mac-address: see ethernet.txt [1]. - clocks: clock phandle and specifier pair. - clock-names: contain the clock name "mac_core"(required) and "mac_ifc"(optional). - resets: should contain the phandle to the MAC core reset signal(optional), @@ -31,6 +30,9 @@ Required properties: The 2nd cell is reset pulse in micro seconds. The 3rd cell is reset post-delay in micro seconds. +The MAC address will be determined using the properties defined in +ethernet.txt[1]. + - PHY subnode: inherits from phy binding [2] [1] Documentation/devicetree/bindings/net/ethernet.txt diff --git a/Documentation/devicetree/bindings/net/keystone-netcp.txt b/Documentation/devicetree/bindings/net/keystone-netcp.txt index 04ba1dc..3a65aab 100644 --- a/Documentation/devicetree/bindings/net/keystone-netcp.txt +++ b/Documentation/devicetree/bindings/net/keystone-netcp.txt @@ -135,14 +135,14 @@ Optional properties: are swapped. The netcp driver will swap the two DWORDs back to the proper order when this property is set to 2 when it obtains the mac address from efuse. -- local-mac-address: the driver is designed to use the of_get_mac_address api - only if efuse-mac is 0. When efuse-mac is 0, the MAC - address is obtained from local-mac-address. If this - attribute is not present, then the driver will use a - random MAC address. - "netcp-device label": phandle to the device specification for each of NetCP sub-module attached to this interface. +The MAC address will be determined using the optional properties defined in +ethernet.txt, as provided by the of_get_mac_address API and only if efuse-mac +is set to 0. If any of the optional MAC address properties are not present, +then the driver will use random MAC address. + Example binding: netcp: netcp@2000000 { diff --git a/Documentation/devicetree/bindings/net/macb.txt b/Documentation/devicetree/bindings/net/macb.txt index 8b80515..9c5e944 100644 --- a/Documentation/devicetree/bindings/net/macb.txt +++ b/Documentation/devicetree/bindings/net/macb.txt @@ -26,9 +26,8 @@ Required properties: Optional elements: 'tsu_clk' - clocks: Phandles to input clocks. -Optional properties: -- nvmem-cells: phandle, reference to an nvmem node for the MAC address -- nvmem-cell-names: string, should be "mac-address" if nvmem is to be used +The MAC address will be determined using the optional properties +defined in ethernet.txt. Optional properties for PHY child node: - reset-gpios : Should specify the gpio for phy reset diff --git a/Documentation/devicetree/bindings/net/marvell-pxa168.txt b/Documentation/devicetree/bindings/net/marvell-pxa168.txt index 845a148..5574af3 100644 --- a/Documentation/devicetree/bindings/net/marvell-pxa168.txt +++ b/Documentation/devicetree/bindings/net/marvell-pxa168.txt @@ -11,7 +11,9 @@ Optional properties: - #address-cells: must be 1 when using sub-nodes. - #size-cells: must be 0 when using sub-nodes. - phy-handle: see ethernet.txt file in the same directory. -- local-mac-address: see ethernet.txt file in the same directory. + +The MAC address will be determined using the optional properties +defined in ethernet.txt. Sub-nodes: Each PHY can be represented as a sub-node. This is not mandatory. diff --git a/Documentation/devicetree/bindings/net/microchip,enc28j60.txt b/Documentation/devicetree/bindings/net/microchip,enc28j60.txt index 24626e0..a827592 100644 --- a/Documentation/devicetree/bindings/net/microchip,enc28j60.txt +++ b/Documentation/devicetree/bindings/net/microchip,enc28j60.txt @@ -21,8 +21,9 @@ Optional properties: - spi-max-frequency: Maximum frequency of the SPI bus when accessing the ENC28J60. According to the ENC28J80 datasheet, the chip allows a maximum of 20 MHz, however, board designs may need to limit this value. -- local-mac-address: See ethernet.txt in the same directory. +The MAC address will be determined using the optional properties +defined in ethernet.txt. Example (for NXP i.MX28 with pin control stuff for GPIO irq): diff --git a/Documentation/devicetree/bindings/net/microchip,lan78xx.txt b/Documentation/devicetree/bindings/net/microchip,lan78xx.txt index 76786a0..11a6795 100644 --- a/Documentation/devicetree/bindings/net/microchip,lan78xx.txt +++ b/Documentation/devicetree/bindings/net/microchip,lan78xx.txt @@ -7,9 +7,8 @@ The Device Tree properties, if present, override the OTP and EEPROM. Required properties: - compatible: Should be one of "usb424,7800", "usb424,7801" or "usb424,7850". -Optional properties: -- local-mac-address: see ethernet.txt -- mac-address: see ethernet.txt +The MAC address will be determined using the optional properties +defined in ethernet.txt. Optional properties of the embedded PHY: - microchip,led-modes: a 0..4 element vector, with each element configuring diff --git a/Documentation/devicetree/bindings/net/qca,qca7000.txt b/Documentation/devicetree/bindings/net/qca,qca7000.txt index e4a8a51..21c36e5 100644 --- a/Documentation/devicetree/bindings/net/qca,qca7000.txt +++ b/Documentation/devicetree/bindings/net/qca,qca7000.txt @@ -23,7 +23,6 @@ Optional properties: Numbers smaller than 1000000 or greater than 16000000 are invalid. Missing the property will set the SPI frequency to 8000000 Hertz. -- local-mac-address : see ./ethernet.txt - qca,legacy-mode : Set the SPI data transfer of the QCA7000 to legacy mode. In this mode the SPI master must toggle the chip select between each data word. In burst mode these gaps aren't @@ -31,6 +30,9 @@ Optional properties: the QCA7000 is setup via GPIO pin strapping. If the property is missing the driver defaults to burst mode. +The MAC address will be determined using the optional properties +defined in ethernet.txt. + SPI Example: /* Freescale i.MX28 SPI master*/ diff --git a/Documentation/devicetree/bindings/net/samsung-sxgbe.txt b/Documentation/devicetree/bindings/net/samsung-sxgbe.txt index 46e5911..2cff6d8 100644 --- a/Documentation/devicetree/bindings/net/samsung-sxgbe.txt +++ b/Documentation/devicetree/bindings/net/samsung-sxgbe.txt @@ -21,10 +21,12 @@ Required properties: range. Optional properties: -- mac-address: 6 bytes, mac address - max-frame-size: Maximum Transfer Unit (IEEE defined MTU), rather than the maximum frame size. +The MAC address will be determined using the optional properties +defined in ethernet.txt. + Example: aliases { diff --git a/Documentation/devicetree/bindings/net/snps,dwc-qos-ethernet.txt b/Documentation/devicetree/bindings/net/snps,dwc-qos-ethernet.txt index 36f1aef..ad3c6e1 100644 --- a/Documentation/devicetree/bindings/net/snps,dwc-qos-ethernet.txt +++ b/Documentation/devicetree/bindings/net/snps,dwc-qos-ethernet.txt @@ -103,8 +103,6 @@ Required properties: Optional properties: - dma-coherent: Present if dma operations are coherent -- mac-address: See ethernet.txt in the same directory -- local-mac-address: See ethernet.txt in the same directory - phy-reset-gpios: Phandle and specifier for any GPIO used to reset the PHY. See ../gpio/gpio.txt. - snps,en-lpi: If present it enables use of the AXI low-power interface @@ -133,6 +131,9 @@ Optional properties: - device_type: Must be "ethernet-phy". - fixed-mode device tree subnode: see fixed-link.txt in the same directory +The MAC address will be determined using the optional properties +defined in ethernet.txt. + Examples: ethernet2@40010000 { clock-names = "phy_ref_clk", "apb_pclk"; diff --git a/Documentation/devicetree/bindings/net/socionext,uniphier-ave4.txt b/Documentation/devicetree/bindings/net/socionext,uniphier-ave4.txt index fc8f017..4e85fc4 100644 --- a/Documentation/devicetree/bindings/net/socionext,uniphier-ave4.txt +++ b/Documentation/devicetree/bindings/net/socionext,uniphier-ave4.txt @@ -31,8 +31,8 @@ Required properties: - socionext,syscon-phy-mode: A phandle to syscon with one argument that configures phy mode. The argument is the ID of MAC instance. -Optional properties: - - local-mac-address: See ethernet.txt in the same directory. +The MAC address will be determined using the optional properties +defined in ethernet.txt. Required subnode: - mdio: A container for child nodes representing phy nodes. diff --git a/Documentation/devicetree/bindings/net/socionext-netsec.txt b/Documentation/devicetree/bindings/net/socionext-netsec.txt index 0cff94f..9d6c9feb 100644 --- a/Documentation/devicetree/bindings/net/socionext-netsec.txt +++ b/Documentation/devicetree/bindings/net/socionext-netsec.txt @@ -26,11 +26,12 @@ Required properties: Optional properties: (See ethernet.txt file in the same directory) - dma-coherent: Boolean property, must only be present if memory accesses performed by the device are cache coherent. -- local-mac-address: See ethernet.txt in the same directory. -- mac-address: See ethernet.txt in the same directory. - max-speed: See ethernet.txt in the same directory. - max-frame-size: See ethernet.txt in the same directory. +The MAC address will be determined using the optional properties +defined in ethernet.txt. + Example: eth0: ethernet@522d0000 { compatible = "socionext,synquacer-netsec"; diff --git a/Documentation/devicetree/bindings/net/wireless/mediatek,mt76.txt b/Documentation/devicetree/bindings/net/wireless/mediatek,mt76.txt index 7b9a776..7466550 100644 --- a/Documentation/devicetree/bindings/net/wireless/mediatek,mt76.txt +++ b/Documentation/devicetree/bindings/net/wireless/mediatek,mt76.txt @@ -13,11 +13,12 @@ properties: Optional properties: -- mac-address: See ethernet.txt in the parent directory -- local-mac-address: See ethernet.txt in the parent directory - ieee80211-freq-limit: See ieee80211.txt - mediatek,mtd-eeprom: Specify a MTD partition + offset containing EEPROM data +The driver is using of_get_mac_address API, so the MAC address can be as well +be set with corresponding optional properties defined in net/ethernet.txt. + Optional nodes: - led: Properties for a connected LED Optional properties: diff --git a/Documentation/devicetree/bindings/net/wireless/qca,ath9k.txt b/Documentation/devicetree/bindings/net/wireless/qca,ath9k.txt index b7396c8..aaaeeb5 100644 --- a/Documentation/devicetree/bindings/net/wireless/qca,ath9k.txt +++ b/Documentation/devicetree/bindings/net/wireless/qca,ath9k.txt @@ -34,9 +34,9 @@ Optional properties: ath9k wireless chip (in this case the calibration / EEPROM data will be loaded from userspace using the kernel firmware loader). -- mac-address: See ethernet.txt in the parent directory -- local-mac-address: See ethernet.txt in the parent directory +The MAC address will be determined using the optional properties defined in +net/ethernet.txt. In this example, the node is defined as child node of the PCI controller: &pci0 { From patchwork Fri May 3 14:27:08 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Petr_=C5=A0tetiar?= X-Patchwork-Id: 1094923 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming-netdev@ozlabs.org Delivered-To: patchwork-incoming-netdev@ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=netdev-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=true.cz Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 44wZSq66Z2z9sNl for ; Sat, 4 May 2019 00:36:27 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728314AbfECOgU (ORCPT ); Fri, 3 May 2019 10:36:20 -0400 Received: from smtp-out.xnet.cz ([178.217.244.18]:17163 "EHLO smtp-out.xnet.cz" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728159AbfECOfS (ORCPT ); Fri, 3 May 2019 10:35:18 -0400 Received: from meh.true.cz (meh.true.cz [108.61.167.218]) (Authenticated sender: petr@true.cz) by smtp-out.xnet.cz (Postfix) with ESMTPSA id 34C214ACB; Fri, 3 May 2019 16:27:32 +0200 (CEST) Received: by meh.true.cz (OpenSMTPD) with ESMTP id 37a7c2d4; Fri, 3 May 2019 16:27:30 +0200 (CEST) From: =?utf-8?q?Petr_=C5=A0tetiar?= To: netdev@vger.kernel.org, devicetree@vger.kernel.org, Nicolas Ferre , "David S. Miller" Cc: Andrew Lunn , Florian Fainelli , Heiner Kallweit , Frank Rowand , Srinivas Kandagatla , Maxime Ripard , =?utf-8?q?Petr_=C5=A0tetiar?= , linux-kernel@vger.kernel.org Subject: [PATCH v4 03/10] net: macb: support of_get_mac_address new ERR_PTR error Date: Fri, 3 May 2019 16:27:08 +0200 Message-Id: <1556893635-18549-4-git-send-email-ynezz@true.cz> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1556893635-18549-1-git-send-email-ynezz@true.cz> References: <1556893635-18549-1-git-send-email-ynezz@true.cz> MIME-Version: 1.0 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org There was NVMEM support added directly to of_get_mac_address, and it uses nvmem_get_mac_address under the hood, so we can remove it. As of_get_mac_address can now return ERR_PTR encoded error values, adjust to that as well. Signed-off-by: Petr Štetiar --- Changes since v2: * ERR_PTR and EPROBE_DEFER handling Changes since v3: * IS_ERR_OR_NULL -> IS_ERR drivers/net/ethernet/cadence/macb_main.c | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/drivers/net/ethernet/cadence/macb_main.c b/drivers/net/ethernet/cadence/macb_main.c index 3da2795..f0466e8 100644 --- a/drivers/net/ethernet/cadence/macb_main.c +++ b/drivers/net/ethernet/cadence/macb_main.c @@ -4172,15 +4172,13 @@ static int macb_probe(struct platform_device *pdev) bp->rx_intr_mask |= MACB_BIT(RXUBR); mac = of_get_mac_address(np); - if (mac) { + if (PTR_ERR(mac) == -EPROBE_DEFER) { + err = -EPROBE_DEFER; + goto err_out_free_netdev; + } else if (!IS_ERR(mac)) { ether_addr_copy(bp->dev->dev_addr, mac); } else { - err = nvmem_get_mac_address(&pdev->dev, bp->dev->dev_addr); - if (err) { - if (err == -EPROBE_DEFER) - goto err_out_free_netdev; - macb_get_hwaddr(bp); - } + macb_get_hwaddr(bp); } err = of_get_phy_mode(np); From patchwork Fri May 3 14:27:09 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Petr_=C5=A0tetiar?= X-Patchwork-Id: 1094922 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming-netdev@ozlabs.org Delivered-To: patchwork-incoming-netdev@ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=netdev-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=true.cz Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 44wZSm53rVz9sP6 for ; Sat, 4 May 2019 00:36:20 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728176AbfECOfS (ORCPT ); Fri, 3 May 2019 10:35:18 -0400 Received: from smtp-out.xnet.cz ([178.217.244.18]:17091 "EHLO smtp-out.xnet.cz" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728018AbfECOfR (ORCPT ); Fri, 3 May 2019 10:35:17 -0400 Received: from meh.true.cz (meh.true.cz [108.61.167.218]) (Authenticated sender: petr@true.cz) by smtp-out.xnet.cz (Postfix) with ESMTPSA id 8BAAE4ACD; Fri, 3 May 2019 16:27:33 +0200 (CEST) Received: by meh.true.cz (OpenSMTPD) with ESMTP id fc19d9f1; Fri, 3 May 2019 16:27:32 +0200 (CEST) From: =?utf-8?q?Petr_=C5=A0tetiar?= To: netdev@vger.kernel.org, devicetree@vger.kernel.org, Grygorii Strashko , "David S. Miller" Cc: Andrew Lunn , Florian Fainelli , Heiner Kallweit , Frank Rowand , Srinivas Kandagatla , Maxime Ripard , =?utf-8?q?Petr_=C5=A0tetiar?= , linux-omap@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v4 04/10] net: davinci: support of_get_mac_address new ERR_PTR error Date: Fri, 3 May 2019 16:27:09 +0200 Message-Id: <1556893635-18549-5-git-send-email-ynezz@true.cz> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1556893635-18549-1-git-send-email-ynezz@true.cz> References: <1556893635-18549-1-git-send-email-ynezz@true.cz> MIME-Version: 1.0 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org There was NVMEM support added directly to of_get_mac_address, and it uses nvmem_get_mac_address under the hood, so we can remove it. As of_get_mac_address can now return ERR_PTR encoded error values, adjust to that as well. Signed-off-by: Petr Štetiar --- Changes since v2: * ERR_PTR handling Changes since v3: * IS_ERR_OR_NULL -> IS_ERR drivers/net/ethernet/ti/davinci_emac.c | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/drivers/net/ethernet/ti/davinci_emac.c b/drivers/net/ethernet/ti/davinci_emac.c index 57450b1..c117a8f 100644 --- a/drivers/net/ethernet/ti/davinci_emac.c +++ b/drivers/net/ethernet/ti/davinci_emac.c @@ -1714,7 +1714,7 @@ static struct net_device_stats *emac_dev_getnetstats(struct net_device *ndev) if (!is_valid_ether_addr(pdata->mac_addr)) { mac_addr = of_get_mac_address(np); - if (mac_addr) + if (!IS_ERR(mac_addr)) ether_addr_copy(pdata->mac_addr, mac_addr); } @@ -1912,15 +1912,11 @@ static int davinci_emac_probe(struct platform_device *pdev) ether_addr_copy(ndev->dev_addr, priv->mac_addr); if (!is_valid_ether_addr(priv->mac_addr)) { - /* Try nvmem if MAC wasn't passed over pdata or DT. */ - rc = nvmem_get_mac_address(&pdev->dev, priv->mac_addr); - if (rc) { - /* Use random MAC if still none obtained. */ - eth_hw_addr_random(ndev); - memcpy(priv->mac_addr, ndev->dev_addr, ndev->addr_len); - dev_warn(&pdev->dev, "using random MAC addr: %pM\n", - priv->mac_addr); - } + /* Use random MAC if still none obtained. */ + eth_hw_addr_random(ndev); + memcpy(priv->mac_addr, ndev->dev_addr, ndev->addr_len); + dev_warn(&pdev->dev, "using random MAC addr: %pM\n", + priv->mac_addr); } ndev->netdev_ops = &emac_netdev_ops; From patchwork Fri May 3 14:27:11 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Petr_=C5=A0tetiar?= X-Patchwork-Id: 1094924 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming-netdev@ozlabs.org Delivered-To: patchwork-incoming-netdev@ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=netdev-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=true.cz Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 44wZT068Z8z9sNl for ; Sat, 4 May 2019 00:36:36 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728323AbfECOgd (ORCPT ); Fri, 3 May 2019 10:36:33 -0400 Received: from smtp-out.xnet.cz ([178.217.244.18]:17096 "EHLO smtp-out.xnet.cz" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728020AbfECOfR (ORCPT ); Fri, 3 May 2019 10:35:17 -0400 Received: from meh.true.cz (meh.true.cz [108.61.167.218]) (Authenticated sender: petr@true.cz) by smtp-out.xnet.cz (Postfix) with ESMTPSA id A44DC4AD0; Fri, 3 May 2019 16:27:44 +0200 (CEST) Received: by meh.true.cz (OpenSMTPD) with ESMTP id 037e069d; Fri, 3 May 2019 16:27:43 +0200 (CEST) From: =?utf-8?q?Petr_=C5=A0tetiar?= To: netdev@vger.kernel.org, devicetree@vger.kernel.org, Steve Glendinning , "David S. Miller" , Microchip Linux Driver Support Cc: Andrew Lunn , Florian Fainelli , Heiner Kallweit , Frank Rowand , Srinivas Kandagatla , Maxime Ripard , =?utf-8?q?Petr_=C5=A0tetiar?= , linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v4 06/10] net: usb: support of_get_mac_address new ERR_PTR error Date: Fri, 3 May 2019 16:27:11 +0200 Message-Id: <1556893635-18549-7-git-send-email-ynezz@true.cz> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1556893635-18549-1-git-send-email-ynezz@true.cz> References: <1556893635-18549-1-git-send-email-ynezz@true.cz> MIME-Version: 1.0 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org There was NVMEM support added to of_get_mac_address, so it could now return ERR_PTR encoded error values, so we need to adjust all current users of of_get_mac_address to this new fact. Signed-off-by: Petr Štetiar --- Changes since v3: * IS_ERR_OR_NULL -> IS_ERR drivers/net/usb/smsc75xx.c | 2 +- drivers/net/usb/smsc95xx.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/net/usb/smsc75xx.c b/drivers/net/usb/smsc75xx.c index ec287c9..d27b627 100644 --- a/drivers/net/usb/smsc75xx.c +++ b/drivers/net/usb/smsc75xx.c @@ -774,7 +774,7 @@ static void smsc75xx_init_mac_address(struct usbnet *dev) /* maybe the boot loader passed the MAC address in devicetree */ mac_addr = of_get_mac_address(dev->udev->dev.of_node); - if (mac_addr) { + if (!IS_ERR(mac_addr)) { memcpy(dev->net->dev_addr, mac_addr, ETH_ALEN); return; } diff --git a/drivers/net/usb/smsc95xx.c b/drivers/net/usb/smsc95xx.c index e3d08626..ab23911 100644 --- a/drivers/net/usb/smsc95xx.c +++ b/drivers/net/usb/smsc95xx.c @@ -917,7 +917,7 @@ static void smsc95xx_init_mac_address(struct usbnet *dev) /* maybe the boot loader passed the MAC address in devicetree */ mac_addr = of_get_mac_address(dev->udev->dev.of_node); - if (mac_addr) { + if (!IS_ERR(mac_addr)) { memcpy(dev->net->dev_addr, mac_addr, ETH_ALEN); return; } From patchwork Fri May 3 14:27:12 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Petr_=C5=A0tetiar?= X-Patchwork-Id: 1094921 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming-netdev@ozlabs.org Delivered-To: patchwork-incoming-netdev@ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=netdev-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=true.cz Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 44wZSc5K2cz9sDn for ; Sat, 4 May 2019 00:36:16 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728190AbfECOfT (ORCPT ); Fri, 3 May 2019 10:35:19 -0400 Received: from smtp-out.xnet.cz ([178.217.244.18]:17092 "EHLO smtp-out.xnet.cz" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727639AbfECOfR (ORCPT ); Fri, 3 May 2019 10:35:17 -0400 Received: from meh.true.cz (meh.true.cz [108.61.167.218]) (Authenticated sender: petr@true.cz) by smtp-out.xnet.cz (Postfix) with ESMTPSA id 2BDF24AD4; Fri, 3 May 2019 16:27:47 +0200 (CEST) Received: by meh.true.cz (OpenSMTPD) with ESMTP id cbd31f28; Fri, 3 May 2019 16:27:45 +0200 (CEST) From: =?utf-8?q?Petr_=C5=A0tetiar?= To: netdev@vger.kernel.org, devicetree@vger.kernel.org, QCA ath9k Development , Kalle Valo , "David S. Miller" , Felix Fietkau , Lorenzo Bianconi , Matthias Brugger , Stanislaw Gruszka , Helmut Schaa Cc: Andrew Lunn , Florian Fainelli , Heiner Kallweit , Frank Rowand , Srinivas Kandagatla , Maxime Ripard , =?utf-8?q?Petr_=C5=A0tetiar?= , linux-wireless@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org Subject: [PATCH v4 07/10] net: wireless: support of_get_mac_address new ERR_PTR error Date: Fri, 3 May 2019 16:27:12 +0200 Message-Id: <1556893635-18549-8-git-send-email-ynezz@true.cz> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1556893635-18549-1-git-send-email-ynezz@true.cz> References: <1556893635-18549-1-git-send-email-ynezz@true.cz> MIME-Version: 1.0 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org There was NVMEM support added to of_get_mac_address, so it could now return ERR_PTR encoded error values, so we need to adjust all current users of of_get_mac_address to this new fact. Signed-off-by: Petr Štetiar Acked-by: Kalle Valo --- Changes since v3: * IS_ERR_OR_NULL -> IS_ERR drivers/net/wireless/ath/ath9k/init.c | 2 +- drivers/net/wireless/mediatek/mt76/eeprom.c | 2 +- drivers/net/wireless/ralink/rt2x00/rt2x00dev.c | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/net/wireless/ath/ath9k/init.c b/drivers/net/wireless/ath/ath9k/init.c index 98141b6..a04d861 100644 --- a/drivers/net/wireless/ath/ath9k/init.c +++ b/drivers/net/wireless/ath/ath9k/init.c @@ -642,7 +642,7 @@ static int ath9k_of_init(struct ath_softc *sc) } mac = of_get_mac_address(np); - if (mac) + if (!IS_ERR(mac)) ether_addr_copy(common->macaddr, mac); return 0; diff --git a/drivers/net/wireless/mediatek/mt76/eeprom.c b/drivers/net/wireless/mediatek/mt76/eeprom.c index a1529920d..0496493 100644 --- a/drivers/net/wireless/mediatek/mt76/eeprom.c +++ b/drivers/net/wireless/mediatek/mt76/eeprom.c @@ -94,7 +94,7 @@ return; mac = of_get_mac_address(np); - if (mac) + if (!IS_ERR(mac)) memcpy(dev->macaddr, mac, ETH_ALEN); #endif diff --git a/drivers/net/wireless/ralink/rt2x00/rt2x00dev.c b/drivers/net/wireless/ralink/rt2x00/rt2x00dev.c index 357c094..19a794a 100644 --- a/drivers/net/wireless/ralink/rt2x00/rt2x00dev.c +++ b/drivers/net/wireless/ralink/rt2x00/rt2x00dev.c @@ -1007,7 +1007,7 @@ 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 (mac_addr) + if (!IS_ERR(mac_addr)) ether_addr_copy(eeprom_mac_addr, mac_addr); if (!is_valid_ether_addr(eeprom_mac_addr)) { From patchwork Fri May 3 14:27:13 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Petr_=C5=A0tetiar?= X-Patchwork-Id: 1094920 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming-netdev@ozlabs.org Delivered-To: patchwork-incoming-netdev@ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=netdev-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=true.cz Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 44wZS86lZwz9s9y for ; Sat, 4 May 2019 00:35:52 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728260AbfECOfl (ORCPT ); Fri, 3 May 2019 10:35:41 -0400 Received: from smtp-out.xnet.cz ([178.217.244.18]:17190 "EHLO smtp-out.xnet.cz" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728171AbfECOfT (ORCPT ); Fri, 3 May 2019 10:35:19 -0400 Received: from meh.true.cz (meh.true.cz [108.61.167.218]) (Authenticated sender: petr@true.cz) by smtp-out.xnet.cz (Postfix) with ESMTPSA id EA69D4AD5; Fri, 3 May 2019 16:27:47 +0200 (CEST) Received: by meh.true.cz (OpenSMTPD) with ESMTP id 27d916b3; Fri, 3 May 2019 16:27:47 +0200 (CEST) From: =?utf-8?q?Petr_=C5=A0tetiar?= To: netdev@vger.kernel.org, devicetree@vger.kernel.org, Greg Kroah-Hartman Cc: Andrew Lunn , Florian Fainelli , Heiner Kallweit , Frank Rowand , Srinivas Kandagatla , Maxime Ripard , =?utf-8?q?Petr_=C5=A0tetiar?= , devel@driverdev.osuosl.org, linux-kernel@vger.kernel.org Subject: [PATCH v4 08/10] staging: octeon-ethernet: support of_get_mac_address new ERR_PTR error Date: Fri, 3 May 2019 16:27:13 +0200 Message-Id: <1556893635-18549-9-git-send-email-ynezz@true.cz> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1556893635-18549-1-git-send-email-ynezz@true.cz> References: <1556893635-18549-1-git-send-email-ynezz@true.cz> MIME-Version: 1.0 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org There was NVMEM support added to of_get_mac_address, so it could now return ERR_PTR encoded error values, so we need to adjust all current users of of_get_mac_address to this new fact. Signed-off-by: Petr Štetiar --- Changes since v3: * IS_ERR_OR_NULL -> IS_ERR drivers/staging/octeon/ethernet.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/octeon/ethernet.c b/drivers/staging/octeon/ethernet.c index 986db76..2b03018 100644 --- a/drivers/staging/octeon/ethernet.c +++ b/drivers/staging/octeon/ethernet.c @@ -421,7 +421,7 @@ int cvm_oct_common_init(struct net_device *dev) if (priv->of_node) mac = of_get_mac_address(priv->of_node); - if (mac) + if (!IS_ERR(mac)) ether_addr_copy(dev->dev_addr, mac); else eth_hw_addr_random(dev); From patchwork Fri May 3 14:27:14 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Petr_=C5=A0tetiar?= X-Patchwork-Id: 1094925 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming-netdev@ozlabs.org Delivered-To: patchwork-incoming-netdev@ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=netdev-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=true.cz Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 44wZTC63cPz9s4V for ; Sat, 4 May 2019 00:36:47 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728096AbfECOfR (ORCPT ); Fri, 3 May 2019 10:35:17 -0400 Received: from smtp-out.xnet.cz ([178.217.244.18]:17089 "EHLO smtp-out.xnet.cz" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726377AbfECOfQ (ORCPT ); Fri, 3 May 2019 10:35:16 -0400 Received: from meh.true.cz (meh.true.cz [108.61.167.218]) (Authenticated sender: petr@true.cz) by smtp-out.xnet.cz (Postfix) with ESMTPSA id 52D994AD8; Fri, 3 May 2019 16:27:50 +0200 (CEST) Received: by meh.true.cz (OpenSMTPD) with ESMTP id 58992be4; Fri, 3 May 2019 16:27:48 +0200 (CEST) From: =?utf-8?q?Petr_=C5=A0tetiar?= To: netdev@vger.kernel.org, devicetree@vger.kernel.org, Jason Cooper , Andrew Lunn , Gregory Clement , Sebastian Hesselbarth , Russell King Cc: Florian Fainelli , Heiner Kallweit , Frank Rowand , Srinivas Kandagatla , Maxime Ripard , =?utf-8?q?Petr_=C5=A0tetiar?= , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH v4 09/10] ARM: Kirkwood: support of_get_mac_address new ERR_PTR error Date: Fri, 3 May 2019 16:27:14 +0200 Message-Id: <1556893635-18549-10-git-send-email-ynezz@true.cz> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1556893635-18549-1-git-send-email-ynezz@true.cz> References: <1556893635-18549-1-git-send-email-ynezz@true.cz> MIME-Version: 1.0 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org There was NVMEM support added to of_get_mac_address, so it could now return ERR_PTR encoded error values, so we need to adjust all current users of of_get_mac_address to this new fact. Signed-off-by: Petr Štetiar --- Changes since v3: * IS_ERR_OR_NULL -> IS_ERR arch/arm/mach-mvebu/kirkwood.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/arch/arm/mach-mvebu/kirkwood.c b/arch/arm/mach-mvebu/kirkwood.c index 0aa8810..9b5f4d6 100644 --- a/arch/arm/mach-mvebu/kirkwood.c +++ b/arch/arm/mach-mvebu/kirkwood.c @@ -92,7 +92,8 @@ static void __init kirkwood_dt_eth_fixup(void) continue; /* skip disabled nodes or nodes with valid MAC address*/ - if (!of_device_is_available(pnp) || of_get_mac_address(np)) + if (!of_device_is_available(pnp) || + !IS_ERR(of_get_mac_address(np))) goto eth_fixup_skip; clk = of_clk_get(pnp, 0); From patchwork Fri May 3 14:27:15 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Petr_=C5=A0tetiar?= X-Patchwork-Id: 1094918 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming-netdev@ozlabs.org Delivered-To: patchwork-incoming-netdev@ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=netdev-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=true.cz Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 44wZRy6jkzz9s9y for ; Sat, 4 May 2019 00:35:41 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728248AbfECOfk (ORCPT ); Fri, 3 May 2019 10:35:40 -0400 Received: from smtp-out.xnet.cz ([178.217.244.18]:17189 "EHLO smtp-out.xnet.cz" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728175AbfECOfT (ORCPT ); Fri, 3 May 2019 10:35:19 -0400 Received: from meh.true.cz (meh.true.cz [108.61.167.218]) (Authenticated sender: petr@true.cz) by smtp-out.xnet.cz (Postfix) with ESMTPSA id BBF064ADA; Fri, 3 May 2019 16:27:51 +0200 (CEST) Received: by meh.true.cz (OpenSMTPD) with ESMTP id a47c137c; Fri, 3 May 2019 16:27:50 +0200 (CEST) From: =?utf-8?q?Petr_=C5=A0tetiar?= To: netdev@vger.kernel.org, devicetree@vger.kernel.org, Benjamin Herrenschmidt , Paul Mackerras , Michael Ellerman Cc: Andrew Lunn , Florian Fainelli , Heiner Kallweit , Frank Rowand , Srinivas Kandagatla , Maxime Ripard , =?utf-8?q?Petr_=C5=A0tetiar?= , linuxppc-dev@lists.ozlabs.org, linux-kernel@vger.kernel.org Subject: [PATCH v4 10/10] powerpc: tsi108: support of_get_mac_address new ERR_PTR error Date: Fri, 3 May 2019 16:27:15 +0200 Message-Id: <1556893635-18549-11-git-send-email-ynezz@true.cz> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1556893635-18549-1-git-send-email-ynezz@true.cz> References: <1556893635-18549-1-git-send-email-ynezz@true.cz> MIME-Version: 1.0 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org There was NVMEM support added to of_get_mac_address, so it could now return ERR_PTR encoded error values, so we need to adjust all current users of of_get_mac_address to this new fact. Signed-off-by: Petr Štetiar --- Changes since v3: * IS_ERR_OR_NULL -> IS_ERR arch/powerpc/sysdev/tsi108_dev.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/powerpc/sysdev/tsi108_dev.c b/arch/powerpc/sysdev/tsi108_dev.c index 1f1af12..c92dcac 100644 --- a/arch/powerpc/sysdev/tsi108_dev.c +++ b/arch/powerpc/sysdev/tsi108_dev.c @@ -105,7 +105,7 @@ static int __init tsi108_eth_of_init(void) } mac_addr = of_get_mac_address(np); - if (mac_addr) + if (!IS_ERR(mac_addr)) memcpy(tsi_eth_data.mac_addr, mac_addr, 6); ph = of_get_property(np, "mdio-handle", NULL);