From patchwork Fri Nov 30 08:21:00 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bartosz Golaszewski X-Patchwork-Id: 10705947 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 6036F13BF for ; Fri, 30 Nov 2018 08:21:28 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 529352FBF1 for ; Fri, 30 Nov 2018 08:21:28 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 46AC42FBFF; Fri, 30 Nov 2018 08:21:28 +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 E80C42FBF1 for ; Fri, 30 Nov 2018 08:21:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727243AbeK3T3y (ORCPT ); Fri, 30 Nov 2018 14:29:54 -0500 Received: from mail-wm1-f68.google.com ([209.85.128.68]:37907 "EHLO mail-wm1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727157AbeK3T3x (ORCPT ); Fri, 30 Nov 2018 14:29:53 -0500 Received: by mail-wm1-f68.google.com with SMTP id k198so4776315wmd.3 for ; Fri, 30 Nov 2018 00:21:22 -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=SMCP04mHX+HN8lYdExPwcBsPbSlvChP1SxdIPmKX1Ytvz+rpx1Z3k8xyxXiPGngx/I H89wzBI3hdnwTm1QfaKyi8iw2uOQLhtULTlj7Ado1sEL21QYE3mTpH+B9jJegADwpFby yANRPw/WRGlMgMO2r60UnuamjqMVnj5NyYWAPIuYhjgc9NIcYJhaoDmqq3QwMKT3ujnE rZ/wi2HNq5JuIlAlgQtUbU+CMSUsZRrVtXTh0xk/gW50jqOgsNd5OJWkbKgxMgG6vjIH aZTwe2oxlqmSTIMNFnf3DAnAQmdpEheCmYeZCPfnpTvFjyjhjRr3ZDSQlopIc7VYFTka 8FWg== 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=HSaIYgcmT+3stLoSDnRq+Qn6xaOyZptiQCMP6bZC+wvubeR6ihHZgNjD3xDX/6g+7m gtzLbDuIPr/inRnz21dnU0UWFfaLq/JYCkyxI9ZU7YbGTm77ROyRybc5n9a631HRODuN xHPTRTfcZM7muxXuCji4dsg0Xy/u9ry4YldZxuO/cjUiSko116n+0cHDa1Jm8C4yoRPN GRM6vnn6o3PwUMGyTesPwN1cZivGGKQaK3zVhTHc2SzkccELN+/vPGD9i1CMrUOiHn06 F+2Mbz6AF4sJp93/RB0uZ3MI8/BqF5+moUV+Eg/pBiR4E9odVCGa8jx319F30XGEpvBC JKRw== X-Gm-Message-State: AA+aEWamJzVWd7KSug3+Ma/BnYaYgvptYEtAYp71PvMadUCwnV2YDkwA w8hH/oC736nw89PfqRvylvIfxQ== X-Google-Smtp-Source: AFSGD/VMhw3YbQrfCsu4V97PPFHUfcGIZvfrQo5y1/MLySEQGXyveI40+Q3kqQ5zsLdpXeB5yysX5Q== X-Received: by 2002:a7b:c095:: with SMTP id r21mr4650862wmh.118.1543566081898; Fri, 30 Nov 2018 00:21:21 -0800 (PST) Received: from debian-brgl.home ([2a01:cb1d:af:5b00:6d6c:8493:1ab5:dad7]) by smtp.gmail.com with ESMTPSA id x197sm6473374wmd.2.2018.11.30.00.21.20 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 30 Nov 2018 00:21:21 -0800 (PST) From: Bartosz Golaszewski To: Grygorii Strashko , Nicolas Ferre , "David S . Miller" , Andrew Lunn , Florian Fainelli , Heiner Kallweit , Rob Herring , Frank Rowand , Sekhar Nori , Kevin Hilman Cc: linux-kernel@vger.kernel.org, netdev@vger.kernel.org, linux-omap@vger.kernel.org, Bartosz Golaszewski Subject: [net-next][PATCH 4/4] net: davinci_emac: use nvmem_get_mac_address() Date: Fri, 30 Nov 2018 09:21:00 +0100 Message-Id: <20181130082100.6241-5-brgl@bgdev.pl> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181130082100.6241-1-brgl@bgdev.pl> References: <20181130082100.6241-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;