Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp701635imm; Wed, 18 Jul 2018 09:12:02 -0700 (PDT) X-Google-Smtp-Source: AAOMgpfLv2b2FCJgLbQ8N5jIWzNUXqEqrXdmQQrbfb5WcxWsASMhMdKTBhC9MYHWbUxkDRik7MRL X-Received: by 2002:a63:6cc8:: with SMTP id h191-v6mr6414203pgc.359.1531930322226; Wed, 18 Jul 2018 09:12:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1531930322; cv=none; d=google.com; s=arc-20160816; b=SEuF0p1dxVqRSv2Xxig56IyCroQ8qswXQNgcmxB9YCYn7ohyP92lYEUv3oRTY3Zac1 ZQx+k/LTHf80kFUxkC6ckEaTFjtDbgrRXEXbE3XZOkHJmX1ycl+BCdvFP8T0fjdZ43uQ uYDuWCmqYTfx9gkbFUqlMSHm33bu43ikUwpzn/3CHs6n6TBWrIsPYDKihKLs7/XloFdY n431oR01+8TCDgaU+z6uZnnfiUp41C6RNNLWJ8d+1cRpfYVNI25U+WiHFvPLWlrEsCph XHi+QZyzcFqTf9Pb89d1ep7LWPHI2lizThHabhg02tKJtEfUiXsYzBukAQiYUJAZmeVy 3zUg== 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=KzIGmhGopa8qvGvH3FjuzEqo3RmKWtro3PgtBoK8plw=; b=LmFRToyMWcodxCxb4MJHaUT8QWb++1zb/zLEMipjsEjUGfEl+oTouP8LgWbf6DE+fr ST2r+HEHTYKXcyFafmz/cRoSrXX+X/YN2l7RoWsj83jX2WyqAcKQS1UXLkGORz8F0x4T uV88Yk/Mzf1TEhHizlaJE0IHG0MbGu883HOjiKeO4wYQPJQ1XmnfgeJz7touk2GiwpkP iieUmTLARlhfdITCy1+IUnsCfo+4jl0E5MRF82UF1oPUX4CnFrr4EPgu1idS+ANMotN5 yJVnaciR5suTapczcm2xGddtE+wGhbL36bko3aLqYdIxj5EvgsEHA6uD+HUEpxpxJVCA Xz5A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bgdev-pl.20150623.gappssmtp.com header.s=20150623 header.b=SlTGuzpT; 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 o2-v6si3609742pgm.288.2018.07.18.09.11.47; Wed, 18 Jul 2018 09:12:02 -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=SlTGuzpT; 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 S1731648AbeGRQt1 (ORCPT + 99 others); Wed, 18 Jul 2018 12:49:27 -0400 Received: from mail-wm0-f67.google.com ([74.125.82.67]:37106 "EHLO mail-wm0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731600AbeGRQtZ (ORCPT ); Wed, 18 Jul 2018 12:49:25 -0400 Received: by mail-wm0-f67.google.com with SMTP id a19-v6so3454059wmb.2 for ; Wed, 18 Jul 2018 09:10:50 -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=KzIGmhGopa8qvGvH3FjuzEqo3RmKWtro3PgtBoK8plw=; b=SlTGuzpTdzpzWjjDNnruv80utH7LQIgJWTow35OdlEo5crkazi0WTjyeQPO6taUGm/ +uZSzWvlBsChyjRZY3+oI9eHsyxZqOKh2ayal0bw4Ka7E4hXmYD/VSzyZAlCkb/nqQOX x3MdS8u0jeXgrgTLUsQbh/lCBoVr/7uF6ASc5Sk6SMLjXOp17XbByM3DSXdGsu/z9wfO Fkv5f5n3D9uYflV7Hi64MMpk9OgJ0CxfXO5exT5xB/gQp+Z1rofsngmRLiFiaLLarXeX DmWzogrSXdKtIkLjfmvCTomM0zwH95FRTRwAGvhW9EVVz2fx9LJ5+EEIoE1w4D56dNwh vw8Q== 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=KzIGmhGopa8qvGvH3FjuzEqo3RmKWtro3PgtBoK8plw=; b=DVnRjxmLc5B8RCYOWZZDrgu7cLA84/qfNpqR1m5Y90E638LqL7tnw58zM/HR6jDWMb ke0EQWh1R/7AkgKtfdw0eLx+drD+Zcyp0I/eevuldbqyhraKO3jEnCX6nSSkdQwCtMv2 kX5OW1+qvn9BykyfDqTpFpoLHypTONw3PVidu57K/OlQIAzPat0F6z0Jg1qK9q7h4jOS kkjbFRDDrddHHyWoLcyFehsfxi9I4NzAVmnQmxVy4mERRByLcviVXxc2FGbYhY4QJnat i3c9SFhKZIq2Bxsmu6YpWLCZKTNHDNmNP7rmd9uqYkhzfsSbHA9FVzXW7gL+Wk8a/uGL GyNA== X-Gm-Message-State: AOUpUlGi6YkEisiGEFmyexXTYUV/36SyQ+gJhl9uBhM45/5a7xhbyP/Q 8ldjnsGWT7r2Yai4nWjjpfWFPg== X-Received: by 2002:a1c:ec9d:: with SMTP id h29-v6mr2062379wmi.94.1531930249254; Wed, 18 Jul 2018 09:10:49 -0700 (PDT) Received: from brgl-bgdev.home ([2a01:cb1d:af:5b00:e837:b8d5:48c1:571b]) by smtp.gmail.com with ESMTPSA id v185-v6sm2847803wme.30.2018.07.18.09.10.47 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 18 Jul 2018 09:10:48 -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 5/5] net: add MTD support to eth_platform_get_mac_address() Date: Wed, 18 Jul 2018 18:10:35 +0200 Message-Id: <20180718161035.7005-6-brgl@bgdev.pl> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180718161035.7005-1-brgl@bgdev.pl> References: <20180718161035.7005-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 | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/net/ethernet/eth.c b/net/ethernet/eth.c index adf5bd03851f..f7dbd2cff7f9 100644 --- a/net/ethernet/eth.c +++ b/net/ethernet/eth.c @@ -55,6 +55,7 @@ #include #include #include +#include #include #include #include @@ -573,6 +574,25 @@ 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) { + from = "MTD"; + addr = addrbuf; + } + + put_mtd_device(mtd); + } + } +#endif /* CONFIG_MTD */ + if (!addr || !is_valid_ether_addr(addr)) return -ENODEV; -- 2.17.1