From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.0 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,MENTIONS_GIT_HOSTING,SPF_PASS,UNPARSEABLE_RELAY, URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id D2EE5C43219 for ; Thu, 2 May 2019 09:05:44 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id ACF44206DF for ; Thu, 2 May 2019 09:05:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726299AbfEBJFn (ORCPT ); Thu, 2 May 2019 05:05:43 -0400 Received: from smtp-out.xnet.cz ([178.217.244.18]:46782 "EHLO smtp-out.xnet.cz" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726001AbfEBJFn (ORCPT ); Thu, 2 May 2019 05:05:43 -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 3720F4725; Thu, 2 May 2019 11:05:40 +0200 (CEST) Received: from localhost (meh.true.cz [local]) by meh.true.cz (OpenSMTPD) with ESMTPA id d6160ae8; Thu, 2 May 2019 11:05:38 +0200 (CEST) Date: Thu, 2 May 2019 11:05:38 +0200 From: Petr =?utf-8?Q?=C5=A0tetiar?= To: Rob Herring Cc: netdev@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Andrew Lunn , Florian Fainelli , Heiner Kallweit , Frank Rowand , Srinivas Kandagatla , Maxime Ripard , Alban Bedel , Felix Fietkau , John Crispin Subject: Re: [PATCH v2 1/4] of_net: Add NVMEM support to of_get_mac_address Message-ID: <20190502090538.GD346@meh.true.cz> Reply-To: Petr =?utf-8?Q?=C5=A0tetiar?= References: <1556456002-13430-1-git-send-email-ynezz@true.cz> <1556456002-13430-2-git-send-email-ynezz@true.cz> <20190501201925.GA15495@bogus> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190501201925.GA15495@bogus> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Rob Herring [2019-05-01 15:19:25]: Hi Rob, > > + struct property *pp; ... > > + pp = kzalloc(sizeof(*pp), GFP_KERNEL); > > + if (!pp) > > + return NULL; > > + > > + pp->name = "nvmem-mac-address"; > > + pp->length = ETH_ALEN; > > + pp->value = kmemdup(mac, ETH_ALEN, GFP_KERNEL); > > + if (!pp->value || of_add_property(np, pp)) > > + goto free; > > Why add this to the DT? I've just carried it over from v1 ("of_net: add mtd-mac-address support to of_get_mac_address()")[1] as nobody objected about this so far. Honestly I don't know if it's necessary to have it, but so far address, mac-address and local-mac-address properties provide this DT nodes, so I've simply thought, that it would be good to have it for MAC address from NVMEM as well in order to stay consistent. Just FYI, my testing ar9331_8dev_carambola2.dts[2] currently produces following runtime DT content: root@OpenWrt:/# find /sys/firmware/devicetree/ -name *nvmem* -o -name *addr@* /sys/firmware/devicetree/base/ahb/spi@1f000000/flash@0/partitions/partition@ff0000/nvmem-cells /sys/firmware/devicetree/base/ahb/spi@1f000000/flash@0/partitions/partition@ff0000/nvmem-cells/eth-mac-addr@0 /sys/firmware/devicetree/base/ahb/spi@1f000000/flash@0/partitions/partition@ff0000/nvmem-cells/eth-mac-addr@6 /sys/firmware/devicetree/base/ahb/spi@1f000000/flash@0/partitions/partition@ff0000/nvmem-cells/wifi-mac-addr@1002 /sys/firmware/devicetree/base/ahb/wmac@18100000/nvmem-cells /sys/firmware/devicetree/base/ahb/wmac@18100000/nvmem-mac-address /sys/firmware/devicetree/base/ahb/wmac@18100000/nvmem-cell-names /sys/firmware/devicetree/base/ahb/eth@1a000000/nvmem-cells /sys/firmware/devicetree/base/ahb/eth@1a000000/nvmem-mac-address /sys/firmware/devicetree/base/ahb/eth@1a000000/nvmem-cell-names /sys/firmware/devicetree/base/ahb/eth@19000000/nvmem-cells /sys/firmware/devicetree/base/ahb/eth@19000000/nvmem-mac-address /sys/firmware/devicetree/base/ahb/eth@19000000/nvmem-cell-names root@OpenWrt:/# hexdump -C /sys/firmware/devicetree/base/ahb/wmac@18100000/nvmem-mac-address 00000000 00 03 7f 11 52 da |....R.| 00000006 root@OpenWrt:/# ip addr show wlan0 4: wlan0: mtu 1500 qdisc noop state DOWN qlen 1000 link/ether 00:03:7f:11:52:da brd ff:ff:ff:ff:ff:ff 1. https://patchwork.ozlabs.org/patch/1086628/ 2. https://git.openwrt.org/?p=openwrt/staging/ynezz.git;a=blob;f=target/linux/ath79/dts/ar9331_8dev_carambola2.dts;h=349c91e760ca5a56d65c587c949fed5fb6ea980e;hb=349c91e760ca5a56d65c587c949fed5fb6ea980e > You have the struct device ptr, so just use devm_kzalloc() if you need an > allocation. I'll address this in v3, thanks. -- ynezz