From patchwork Mon Jun 25 15:50:18 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bartosz Golaszewski X-Patchwork-Id: 10486863 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 6DD65601D5 for ; Mon, 25 Jun 2018 15:54:39 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 52A47285A5 for ; Mon, 25 Jun 2018 15:54:39 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 46A5A285B9; Mon, 25 Jun 2018 15:54:39 +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.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI, T_DKIM_INVALID autolearn=unavailable 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 E4628285A5 for ; Mon, 25 Jun 2018 15:54:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755719AbeFYPyb (ORCPT ); Mon, 25 Jun 2018 11:54:31 -0400 Received: from mail-wm0-f66.google.com ([74.125.82.66]:36904 "EHLO mail-wm0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754133AbeFYPv3 (ORCPT ); Mon, 25 Jun 2018 11:51:29 -0400 Received: by mail-wm0-f66.google.com with SMTP id r125-v6so10572333wmg.2 for ; Mon, 25 Jun 2018 08:51:28 -0700 (PDT) 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; bh=N/Du8nAZW4V9CZ8iTrJZf89xsDxWDMDJG9gzGrzquaA=; b=hqJ+9FUeb2kdZtI80CafheMPD2rBntwQhXKOHOB5dYFd6y7vNhB9U2qHWhgmvR5V2H iCi/3lCIALlwNbgMw66rx+3ur0fYI45DbFFiRhs0etz2cs7tCB5ZXMiivDKfw+yR2+vQ DcrbrHx+dpbIMBv+gXvJVbpUStJacdNgUZKlA/ifK0lDXM37ZJCn7Uzb0wo/uQg7TArM slb67JSp+9KsKrVhsLuP1h6a2m4aMhUJkmp3bmEiMalzTqYEus1JOPHZS91Mao27GFLU YkuUAfz/fsJWw1/TWPnvAAUyOJVj/OdTnzqP6qL3Mxs9NT1sUjfZrofyM2xrrVzeOZey w8Dw== 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; bh=N/Du8nAZW4V9CZ8iTrJZf89xsDxWDMDJG9gzGrzquaA=; b=TQ3X8rUC+Iar2KQFsvJoW+Sz/0azJpqcvEjgPsf5Oo8YmgqkDIW4gf09+/TLG2aiKp 0wNSarN1qp1JILf9/MfALovIQoLqG4MlW4q4P9muanlk4tvlMNAzm36IXmldGWaYKsTj W/N/NxLJTEWN0PHY4QXO1BoxZcNaqytGcgDU9gG7S8f/uDlnNSaONq7aByILa+8xStXe KYHv4yvPJ2ofDLDvWv94vjroI8oxo+4kt0iUveuOi5+nKAzY5ZdyaHuyQD4r2asSXg/b eLUidkLmrFdArXOgGorFCLUMSMo1n/r3F0enWFxyVWiR01KaX9HU5oHs9xcNfQUTI3T3 UwPg== X-Gm-Message-State: APt69E2GRHqBNDhW8DqmdVM2BWmJj12v5Qpwf4qL3Tm5YFyy+PUfg5n9 C5dThhHa7J8JEenNpxdK3d6G9Q== X-Google-Smtp-Source: ADUXVKLSExRoxdKaLbCRM/aUBc94luSMthfsjKww1IOg3+MLFmH03LsrywH84zbxlm29nr1Ayhi93w== X-Received: by 2002:a1c:928c:: with SMTP id u134-v6mr1427576wmd.106.1529941887867; Mon, 25 Jun 2018 08:51:27 -0700 (PDT) Received: from brgl-bgdev.home ([2a01:cb1d:af:5b00:e837:b8d5:48c1:571b]) by smtp.gmail.com with ESMTPSA id x16-v6sm3523737wro.13.2018.06.25.08.51.26 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 25 Jun 2018 08:51:27 -0700 (PDT) From: Bartosz Golaszewski To: Sekhar Nori , Kevin Hilman , Russell King , Grygorii Strashko , "David S . Miller" , Srinivas Kandagatla , Lukas Wunner , Rob Herring , Florian Fainelli , Dan Carpenter , Ivan Khoronzhuk , David Lechner , Greg Kroah-Hartman Cc: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-omap@vger.kernel.org, netdev@vger.kernel.org, Bartosz Golaszewski Subject: [PATCH 07/14] net: davinci_emac: use nvmem to retrieve the mac address Date: Mon, 25 Jun 2018 17:50:18 +0200 Message-Id: <20180625155025.12567-8-brgl@bgdev.pl> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180625155025.12567-1-brgl@bgdev.pl> References: <20180625155025.12567-1-brgl@bgdev.pl> 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 users which store the MAC address in EEPROM now register relevant nvmem cells. Switch to retrieving the MAC address over the nvmem framework. Signed-off-by: Bartosz Golaszewski --- drivers/net/ethernet/ti/davinci_emac.c | 29 +++++++++++++++++--------- 1 file changed, 19 insertions(+), 10 deletions(-) diff --git a/drivers/net/ethernet/ti/davinci_emac.c b/drivers/net/ethernet/ti/davinci_emac.c index a1a6445b5a7e..22c2322e46be 100644 --- a/drivers/net/ethernet/ti/davinci_emac.c +++ b/drivers/net/ethernet/ti/davinci_emac.c @@ -67,7 +67,7 @@ #include #include #include - +#include #include #include @@ -1696,7 +1696,6 @@ davinci_emac_of_get_pdata(struct platform_device *pdev, struct emac_priv *priv) const struct of_device_id *match; const struct emac_platform_data *auxdata; struct emac_platform_data *pdata = NULL; - const u8 *mac_addr; if (!IS_ENABLED(CONFIG_OF) || !pdev->dev.of_node) return dev_get_platdata(&pdev->dev); @@ -1708,12 +1707,6 @@ davinci_emac_of_get_pdata(struct platform_device *pdev, struct emac_priv *priv) np = pdev->dev.of_node; pdata->version = EMAC_VERSION_2; - if (!is_valid_ether_addr(pdata->mac_addr)) { - mac_addr = of_get_mac_address(np); - if (mac_addr) - ether_addr_copy(pdata->mac_addr, mac_addr); - } - of_property_read_u32(np, "ti,davinci-ctrl-reg-offset", &pdata->ctrl_reg_offset); @@ -1783,7 +1776,9 @@ static int davinci_emac_probe(struct platform_device *pdev) struct cpdma_params dma_params; struct clk *emac_clk; unsigned long emac_bus_frequency; - + struct nvmem_cell *cell; + void *mac_addr; + size_t mac_addr_len; /* obtain emac clock from kernel */ emac_clk = devm_clk_get(&pdev->dev, NULL); @@ -1815,8 +1810,22 @@ static int davinci_emac_probe(struct platform_device *pdev) goto err_free_netdev; } + cell = nvmem_cell_get(&pdev->dev, "mac-address"); + if (!IS_ERR(cell)) { + mac_addr = nvmem_cell_read(cell, &mac_addr_len); + if (!IS_ERR(mac_addr)) { + if (is_valid_ether_addr(mac_addr)) { + dev_info(&pdev->dev, + "Read MAC addr from EEPROM: %pM\n", + mac_addr); + memcpy(priv->mac_addr, mac_addr, ETH_ALEN); + } + kfree(mac_addr); + } + nvmem_cell_put(cell); + } + /* MAC addr and PHY mask , RMII enable info from platform_data */ - memcpy(priv->mac_addr, pdata->mac_addr, ETH_ALEN); priv->phy_id = pdata->phy_id; priv->rmii_en = pdata->rmii_en; priv->version = pdata->version;