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: 10533797 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 A1BC9600D0 for ; Thu, 19 Jul 2018 08:21:17 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8E1E62939B for ; Thu, 19 Jul 2018 08:21:17 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8070729438; Thu, 19 Jul 2018 08:21:17 +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=-2.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 261D82939B for ; Thu, 19 Jul 2018 08:21:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=phSfF/9pOUp8VXrWEALZjxy4idEkRBr7eJaNYsLrQSQ=; b=pGYGPD/9uwRNEAUgEW5a9uBA4A JYQJslv7PHwOBrmcEBagkbloCfArKiQ4pXT8zD2sksTS+L8I/UML+4Tahe/rgZ3ol2g1t6/N8R+9y 9G9E2/VYUJrl+Z1J30JhgTt7T+vxP/ZbLdy5dYxRtO23eWyG6YXLY9fXkQe2U6mlLUJZ6EQY/dvL+ LUAyvDYCqgGud1HOjHZNN52Ml4gxYn7mZN2CoK/WqsQAYxsLyig8etiER+Xxu4FJ0ZkhPPFXqXRbW hUjvN2dXl6UT2s+mX6Cg2hoBNKiFpDWmx0jPdM5QkyIYmvN9D2YYnYQ41CTuwWxrksdS5g5K65BrF 5bwLnR9g==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1fg4BU-0006N5-S5; Thu, 19 Jul 2018 08:21:12 +0000 Received: from mail-wr1-x443.google.com ([2a00:1450:4864:20::443]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1fg4B3-0005t2-RJ for linux-arm-kernel@lists.infradead.org; Thu, 19 Jul 2018 08:20:47 +0000 Received: by mail-wr1-x443.google.com with SMTP id t6-v6so7119224wrn.7 for ; Thu, 19 Jul 2018 01:20:37 -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=CP1x6wq0Teyf6pDDNAqrS/AIVTYhGeJR90UrC/e2PkhY5aXkLGcXc6xEPv8LQQOQMU 3c1Z60QKh98Lw2W5fGOFXvFE6JAGP1Bx0JXqvQMpew09HfO+58xj2RdEZzK75VUQm/VJ dmgKXSBmcFUZ+QvPErY5ued9hHeA7fn2F5v4bh8EiQZ/p/dFg6at7WkLIH/0OuUau0Fe 9UjQE/Ht5FxMsMz/efQqFcpAIjf22iHcMWml8bSfaS+aAxHdYuacqhkV0ptXa9w+++ai Be0iUZahOs/W6tTKTzciIhK4alc714eD+oxDf/SwAqJ3fVdg0bsTfk5odbLn3kVLuqkf 2XUA== X-Gm-Message-State: AOUpUlFgcJNUKg59kejEcfugP1AcvPLiZX53L5sIZ6MlsIb+0FR/vhEN nw2reHJeL7OATKA/ALv17AydMQ== 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 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> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180719_012045_893174_60634875 X-CRM114-Status: GOOD ( 15.61 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: netdev@vger.kernel.org, linux-omap@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Bartosz Golaszewski MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.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;