From patchwork Thu Jul 19 08:20:28 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bartosz Golaszewski X-Patchwork-Id: 10533783 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 E12FD600F4 for ; Thu, 19 Jul 2018 08:20:39 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D0843293D3 for ; Thu, 19 Jul 2018 08:20:39 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C1F572939B; Thu, 19 Jul 2018 08:20: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=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 69F312939B for ; Thu, 19 Jul 2018 08:20:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731479AbeGSJCg (ORCPT ); Thu, 19 Jul 2018 05:02:36 -0400 Received: from mail-wr1-f66.google.com ([209.85.221.66]:36645 "EHLO mail-wr1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731186AbeGSJCf (ORCPT ); Thu, 19 Jul 2018 05:02:35 -0400 Received: by mail-wr1-f66.google.com with SMTP id h9-v6so7146783wro.3 for ; Thu, 19 Jul 2018 01:20:36 -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=d0qNtBWtv5HWQy/kUDtOXthITMbaUfiwfKESg2lHVYM=; b=MhBHL33ej5mDKwzEXxwoDFsibzfJFpBjmbuCV/y07Gn9cB4ozGvTNyQ3IaDME1Xp6D ZaCAZbmp/6fo/pDsaytNP1isueLeqLU1XVmHNm9I/r8W88K7kRufOi+szuEEuLfS74U/ yL56vm6U7Nqv7GKcfqODdCHgNVOfsyLTvKxKf0rQRJ9g1y3NhpG2uFZAPF3DDQnFVZo3 f4HeGX4E/h65wS9HWkvmzhfVdqMg22BjUVhPEBoEbwiAxTDxruIOdNo2NPueq623Pw6m FyeTIdvUbeQkImacUS+KHtwkV+UT2lAmt/sILlcL62OK8TLxipZINFgk3f9UcBMFtlpC IsNw== 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=d0qNtBWtv5HWQy/kUDtOXthITMbaUfiwfKESg2lHVYM=; b=T1vC3be/o9oJu27UbJaGMEKp+02XrgvV8cSULkYY0wbIhVaIt6k8eU5R3TUj7Szac1 QfsgpYNWhvh2ZWcRwaQC4pgel/NbFmv6zSFX24T6MoycK4ohmOdCR9dwFJ51x4KQt8kX TwOs6DFBaQScdxQipdg1CDmH1ucZ9xpfSXl9u11xiLrZ1blRApOGn/Z5KGeQ4/Fs63NU PNvLMFgwNu+ag8Qf1LXQ3Qj06oT99HkrzBarp4KHGmQvrkF4+9V2yh1H9AGC9iNWEZ/k uJFVY+3qUgUVBIRH/gM6EUuHgnlmZZGPRJUilo9eiGgIBwItC787GU+ztb/LC2SEx6rS g58Q== X-Gm-Message-State: AOUpUlEiAdmRWLWLbpPKIElpars/IjZbIADWnd3urI7qiMQ4SdIW6ekY 0bbLBRxIO4Y3BOL28RNDRwQFdWlNSi4= X-Google-Smtp-Source: AAOMgpfL5hCLOazHVWXmiLHh1BuE/Hn7YNAOS8tJYFSHc94pnLsCxxaJGT79aI9qK2h36JJ2GbVqwA== X-Received: by 2002:adf:9f13:: with SMTP id l19-v6mr6723087wrf.206.1531988435884; Thu, 19 Jul 2018 01:20:35 -0700 (PDT) Received: from brgl-bgdev.baylibre.local (AStLambert-681-1-40-185.w90-86.abo.wanadoo.fr. [90.86.159.185]) by smtp.gmail.com with ESMTPSA id h43-v6sm1716338wrh.1.2018.07.19.01.20.34 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 19 Jul 2018 01:20:35 -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 , Andrew Lunn 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 v2 3/3] net: add MTD support to eth_platform_get_mac_address() Date: Thu, 19 Jul 2018 10:20:28 +0200 Message-Id: <20180719082028.26116-4-brgl@bgdev.pl> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180719082028.26116-1-brgl@bgdev.pl> References: <20180719082028.26116-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 MTD doesn't support nvmem yet. Some platforms use MTD to read the MAC address from SPI flash. If we want this function to generalize reading the MAC address, we need to separately try to use MTD. Signed-off-by: Bartosz Golaszewski --- net/ethernet/eth.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/net/ethernet/eth.c b/net/ethernet/eth.c index af3b4b1b77eb..addbb3375e3b 100644 --- a/net/ethernet/eth.c +++ b/net/ethernet/eth.c @@ -55,6 +55,7 @@ #include #include #include +#include #include #include #include @@ -568,6 +569,23 @@ int eth_platform_get_mac_address(struct device *dev, u8 *mac_addr) } } +#ifdef CONFIG_MTD + /* NOTE: this should go away as soon as MTD gets nvmem support. */ + if (!addr) { + struct mtd_info *mtd; + int rv; + + mtd = get_mtd_device_nm("MAC-Address"); + if (!IS_ERR(mtd)) { + rv = mtd_read(mtd, 0, ETH_ALEN, &alen, addrbuf); + if (rv == 0) + addr = addrbuf; + + put_mtd_device(mtd); + } + } +#endif /* CONFIG_MTD */ + if (!addr || !is_valid_ether_addr(addr)) return -ENODEV;