Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp1434197imm; Thu, 19 Jul 2018 01:21:30 -0700 (PDT) X-Google-Smtp-Source: AAOMgpfNU4UP7+v8KFx+mCOtR4uXtFcfctrQhy2LhuBXdXLCO2ENBdD3oMPS7cmuobnXsRYkFcfQ X-Received: by 2002:a17:902:a702:: with SMTP id w2-v6mr9272554plq.41.1531988490059; Thu, 19 Jul 2018 01:21:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1531988490; cv=none; d=google.com; s=arc-20160816; b=r9zdwZV/13RRaIAFm8srKGFpWZ5PSLjao+/+PxQGBw/v2v821dRxuDlMlSD5+THlxB zYj2WFUPYlCDqavFzG5iNnGCSYU54iNYsVAinkcZ6sxSvsX8f4pTtYym9VmTTXlr7B29 2rFTqjRqn5FF3m8sS/lrh0ySoowzjiKtMDkfyPCYiIQoEN924M/LDq39N0eVOybesWbI Jq8nOjroHbopwPrbjl5jHB01aYdQNneX1VOsKiPtzuxh1dECCv22OrkIHiMYlE3i5jUY APDXdzL8ua2/HqfTPJTsIifKMP7kneZquvm9dX+NSxbQEUATQkTyOYPxGkfd4V1ZQq8a T8vA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=d0qNtBWtv5HWQy/kUDtOXthITMbaUfiwfKESg2lHVYM=; b=UFQOIkxZZR7YETsZ8UUXnc708GIIjL28eX6CSOzv9K/SCVNKgOhBlBmUBc66dP6Ucy 6XX/+o7bdck0w1i/OOG0Lna7lKgfS+ff3Vssr05cpDQhzEvE+s3JV+bnIiKhnhNGbskc fT8vuhQetL6vQ5c+xpZCtbH1wXh2NH+aevu7+Awk96FeslKspfbMgXjLagpqY7cnubv3 03euYSk4GMyMnOAvDuGR2i9jTe6GlI872A5CxSnHMQL/vpwIkxjeUzOlnoTR5MnhLyD6 0JIrIGQpEZbfch2JzxykJUKN8Kv9WoKwLHKqszdcsL9Icvqo1Cl/BIgeiGT1qoT/6Vhj OMvA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bgdev-pl.20150623.gappssmtp.com header.s=20150623 header.b=MhBHL33e; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id j30-v6si5480973pgm.26.2018.07.19.01.21.15; Thu, 19 Jul 2018 01:21:30 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@bgdev-pl.20150623.gappssmtp.com header.s=20150623 header.b=MhBHL33e; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731605AbeGSJCg (ORCPT + 99 others); Thu, 19 Jul 2018 05:02:36 -0400 Received: from mail-wr1-f68.google.com ([209.85.221.68]:46840 "EHLO mail-wr1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731551AbeGSJCf (ORCPT ); Thu, 19 Jul 2018 05:02:35 -0400 Received: by mail-wr1-f68.google.com with SMTP id s11-v6so7098329wra.13 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=qSY745uzmoLSpa1sLXeAZwlRIcmFEZcLJTXXqv/yvnbMNdpk7Gm38FC935BZcnadzy OZh30sdwBxQJc/Tl1HdGKsxtkL+InrqqWGfmYLv7XPEao9phcDUS3jQAweYUO1Gdi2/I JzIuzC5rVqjwm/T6ovqSdFqsXOBs1pCeSrOIqQg/rGPBIL+9g1/LNq1pbife7+eA43Ea b9gMtOHO3SbWumRMYfO5YJgdDsO20xRrKqJpxPZ27NwJo3X0r1VJmwF38HkxfMJZYM7r leABlNivAVmvkP7EwkmlFkPemJ+K2S8Qqi/RLW2DdvdXeCYWCot+RLQjlgmBQ7mQZhps MLmw== X-Gm-Message-State: AOUpUlGw/iKXRysWOaQ7TX4VTgzSdpapyQ6IzR26rf94cbRkdQg5PH9W fktfBtvXcqfAoPqzHNQOCbK13g== 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-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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; -- 2.17.1