From patchwork Tue Nov 13 14:01:21 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bartosz Golaszewski X-Patchwork-Id: 10680713 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 433EF14DB for ; Tue, 13 Nov 2018 14:02:22 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 332C62A9BB for ; Tue, 13 Nov 2018 14:02:22 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 26F872A9C0; Tue, 13 Nov 2018 14:02:22 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B9B1B2A9BE for ; Tue, 13 Nov 2018 14:02:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2387922AbeKNAAg (ORCPT ); Tue, 13 Nov 2018 19:00:36 -0500 Received: from mail-wm1-f67.google.com ([209.85.128.67]:37569 "EHLO mail-wm1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387883AbeKNAAf (ORCPT ); Tue, 13 Nov 2018 19:00:35 -0500 Received: by mail-wm1-f67.google.com with SMTP id p2-v6so11485332wmc.2 for ; Tue, 13 Nov 2018 06:02:18 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bgdev-pl.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=f7gfNo0gVKcDfyj3+9h+7K8WG/3dMlnqMt9RiFsd5OU=; b=oGMfCF5OK/DFgVAZh3Rr9U5F+3+4HDDdwtYaoNXWsvJdQ9FPpc2idSDfHlsKVgZbuH RejXdfaoXgVLoZjHBw6+KgD+sHBNqrCqQmLJDDmfMvb0M3lSpvjp37Cgl8pwaAE1XKtY WqEdsMolG/O8VhNJHsbYh45O7FRUPQ14M1cA5mLypKrVYs7lh8Q5Kk0CBiKNMG1qHt1Y hVnqj5V+4roGp6UtwBUgpWh6Njxh1UgU7jAlakCED4RMksvPt7S5mHVZRaUmBZc2P6f0 xWdQfvqe33aZjMryRKn6M/RVxTuu4AG3Q2C54iWIHLxK/Ik6I19JRTSM0lUIX4+UVrP/ QXlg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=f7gfNo0gVKcDfyj3+9h+7K8WG/3dMlnqMt9RiFsd5OU=; b=BPTv66ILr1PMDxEYgpScxiAnaBc93jIax0WhsvcNYVxYjJZoawtSaXEWsl3mgyBAxM lujBwh7fMPCgQxJqt7fWb8cnQXYC84qTT7Dg/U4pgLj7ryvc+anscB0RrgbIjBxFP7iA 9hL85podmVobfjMJ5iEyJGCEG+Djw/2F41LOSpY1ebHSIYBZXKK/fIzcdFi/Z4ykOJnm jH8pmfjLInBUV7nWggelsuHLcBFVAxaftDf6wiBCnQRexGRSLsSaFYubMILzNQHjHtdY +tWUNBCdG3jptvUxSnxURCZ5STbgJsVzw/8wqy/IAB3QX54evxtcl2A/JZSOFwsTRbJ6 fQFQ== X-Gm-Message-State: AGRZ1gKxOCTtHFfek3p46apTSW5WRwwZmKz7Cm/AKVgE+e5jSkNgyQ7b YMd7JPnZWYmECLuPyBgs2pUKrQ== X-Google-Smtp-Source: AJdET5eC/isFPP/JoAHtDczboZRSpAdwg7+nsuETdSWEk/5qbg/R9UpvhswrRmqH3RC9hQD4j2v5tw== X-Received: by 2002:a1c:2746:: with SMTP id n67-v6mr3358593wmn.116.1542117737445; Tue, 13 Nov 2018 06:02:17 -0800 (PST) Received: from debian-brgl.home ([2a01:cb1d:af:5b00:6d6c:8493:1ab5:dad7]) by smtp.gmail.com with ESMTPSA id m69-v6sm16604122wmb.8.2018.11.13.06.02.15 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 13 Nov 2018 06:02:16 -0800 (PST) From: Bartosz Golaszewski To: Sekhar Nori , Kevin Hilman , Russell King , Arnd Bergmann , Greg Kroah-Hartman , David Woodhouse , Brian Norris , Boris Brezillon , Marek Vasut , Richard Weinberger , Nicolas Ferre , "David S . Miller" , Grygorii Strashko , Srinivas Kandagatla , Andrew Lunn , Florian Fainelli , Rob Herring , Frank Rowand , Wolfram Sang Cc: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-i2c@vger.kernel.org, linux-mtd@lists.infradead.org, netdev@vger.kernel.org, linux-omap@vger.kernel.org, devicetree@vger.kernel.org, Bartosz Golaszewski Subject: [PATCH v2 13/25] net: davinci_emac: use nvmem_get_mac_address() Date: Tue, 13 Nov 2018 15:01:21 +0100 Message-Id: <20181113140133.17385-14-brgl@bgdev.pl> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181113140133.17385-1-brgl@bgdev.pl> References: <20181113140133.17385-1-brgl@bgdev.pl> MIME-Version: 1.0 Sender: linux-omap-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-omap@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Bartosz Golaszewski All DaVinci boards still supported in board files now define nvmem cells containing the MAC address. We want to stop using the setup callback from at24 so the MAC address for those users will no longer be provided over platform data. If we didn't get a valid MAC in pdata, try nvmem before resorting to a random MAC. Signed-off-by: Bartosz Golaszewski --- drivers/net/ethernet/ti/davinci_emac.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/drivers/net/ethernet/ti/davinci_emac.c b/drivers/net/ethernet/ti/davinci_emac.c index 9153db120352..840820402cd0 100644 --- a/drivers/net/ethernet/ti/davinci_emac.c +++ b/drivers/net/ethernet/ti/davinci_emac.c @@ -1912,11 +1912,15 @@ 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)) { - /* Use random MAC if none passed */ - 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); + /* 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); + } } ndev->netdev_ops = &emac_netdev_ops;