From patchwork Wed Jul 18 16:10:35 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bartosz Golaszewski X-Patchwork-Id: 10532779 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 B40B5600F4 for ; Wed, 18 Jul 2018 16:11:01 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A582B25EF7 for ; Wed, 18 Jul 2018 16:11:01 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 98D892996B; Wed, 18 Jul 2018 16:11:01 +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 448A125EF7 for ; Wed, 18 Jul 2018 16:11:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731630AbeGRQt0 (ORCPT ); Wed, 18 Jul 2018 12:49:26 -0400 Received: from mail-wm0-f67.google.com ([74.125.82.67]:39019 "EHLO mail-wm0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731599AbeGRQt0 (ORCPT ); Wed, 18 Jul 2018 12:49:26 -0400 Received: by mail-wm0-f67.google.com with SMTP id h20-v6so3434853wmb.4 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=ZehSdg+qYk7DqZPulwi/NX7DBE3iaIpPBd3Ywbvu8xmgqfptuBno9HV3gZI33ZF5fd OORVPtIcWMHRd565Py/sWdP0+nxEU96buw1by2pIYk5L1NKB0xE6EfHjhrM/CwEhOwT1 V8doLBlwZdw1nvnZlxPKx2/Qu/efvgcPHFVSVSTgKum52YMDOPzfqxlw+RHUUXF9MrYY WXqha77MnIUW/IEfgMBlPt+p7UAyHkSbiF9L/HnW0qvXeHp+OYs7RxVQ6sTetbYGbh7m JWWNfxMr0IVDhJ8T8YZ6X99NV1pb9old7R9nIW+tOKOiwWGE2gGR/7Yo0B5FsKRt52KO j+DQ== X-Gm-Message-State: AOUpUlGQdTcqaQf/wrRtjOdDnQvLu1q87HFQN9/GWAergupxbFmwdirK anPNj6VUJ0gx3s3Hf4qmTLtidw== X-Google-Smtp-Source: AAOMgpcTDIBrjTh7f1WdPZSu3h22o8LwJaSr7vKg/uFwwHL1KoYbEvLWo3K/svVKRKNIVRGOV+wTfQ== 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-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 | 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;