From patchwork Fri Mar 29 05:34:58 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vinod Koul X-Patchwork-Id: 161383 Delivered-To: patch@linaro.org Received: by 2002:a02:c6d8:0:0:0:0:0 with SMTP id r24csp1607337jan; Thu, 28 Mar 2019 22:35:25 -0700 (PDT) X-Google-Smtp-Source: APXvYqzYZA0i9SgVQfwswUMLefwYk3XVk3+P1fBHfV/dt1vXGE0Aw4brvyaukcMu0UZbHlMet8yA X-Received: by 2002:a63:4847:: with SMTP id x7mr42401347pgk.233.1553837725749; Thu, 28 Mar 2019 22:35:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1553837725; cv=none; d=google.com; s=arc-20160816; b=yVbI1DiAa/e7RWC6IAscqzixVrwEeMYOnvHgC0R+5xNrZ9c6Wp92i9oyf0kwzz4wrn 1M1SRrN5vU+gJ31l24Wt0woMoDd3Itd0QsfJCZufCqSfw25rLnR7N5XW1ubOcgIA/RUp nvxj3+0v/tqLsHgpMWKxBBVYGUF9CaQ+yrsiX5jiWq8kaeuhhoL5N2aQyLrxvlCzMXhV c/Tt3hCK6Tb2jI4wF6bRzqop//EwAWIfnV5d37wehkGg83duhOOAS9IXnd/x8dxvka1x juonaALlBgv0eyLN3lgJjNShS/Wt2RqHV92Xef49xn5P1uyAIMGh938ejJ1OleqMU49B QGug== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=UhtuMMs2kdiblGiBqU7bOhGBnISElGIBgTxRxJcjmUw=; b=B6HnLvLzzF+ucjmFvAOlO0op9zSrC/P1nUg4WaK52tJGG0FlmfpFE03cLAqunTZOB8 nRG7eiprn4JJB49FuZaPJwhq1t/t53iK9DCi/8wOJpS2Zh+mOESALRBgf3zoRY7IYsJr kqh/DOdrcm2V8tVbOHNpLHsGTbygsxnXk1yX5lN12Ldsu+4KSe6Za/6yW1yUNF7pMdj7 /bs4ShICJgbvKIVbVn9Y9TXpHifw9oqWyrHgz+gmWtQCXtDptTqkbEIYg7AgCdH/NadU IhvCKCndiWJdDH7hiyd7l9GkR9FZV58g1xt/AyZiVllo5IRb0acqp+JZDwOFWfRWkFp3 XvWA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=GaA7KHTf; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id m68si1109126pfb.33.2019.03.28.22.35.25; Thu, 28 Mar 2019 22:35:25 -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=@kernel.org header.s=default header.b=GaA7KHTf; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728551AbfC2FfX (ORCPT + 31 others); Fri, 29 Mar 2019 01:35:23 -0400 Received: from mail.kernel.org ([198.145.29.99]:45460 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726077AbfC2FfW (ORCPT ); Fri, 29 Mar 2019 01:35:22 -0400 Received: from localhost.localdomain (unknown [106.200.210.205]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id C67CC2173C; Fri, 29 Mar 2019 05:35:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1553837721; bh=Hz7xR+e4LP2NZV8Nscu4LHLTew74p5atnOXRGVZqvnU=; h=From:To:Cc:Subject:Date:From; b=GaA7KHTfQs/vYaGFoz+7xe8HndKKDLINzxzQhcjlViSLSUTB3+nFqOuPw9lT2REf5 weORFIc8Tgb86YdsDAHvQJO1zfR4q4oRgEWhWBqprD8frzOW1GlKIRdvXEIdn+zUU6 xbmrsPNS21PqKvBEsQWcCOkrwZnA6F3Ff07+8W8w= From: Vinod Koul To: "David S. Miller" Cc: linux-arm-msm@vger.kernel.org, Bjorn Andersson , Xiaofei Shen , Andrew Lunn , Vivien Didelot , Florian Fainelli , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Vinod Koul Subject: [PATCH v2] net: dsa: read mac address from DT for slave device Date: Fri, 29 Mar 2019 11:04:58 +0530 Message-Id: <20190329053458.11891-1-vkoul@kernel.org> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Xiaofei Shen Before creating a slave netdevice, get the mac address from DTS and apply in case it is valid. Signed-off-by: Xiaofei Shen Signed-off-by: Vinod Koul --- v2: Rebase on net-next. The binding patch is already merged include/net/dsa.h | 1 + net/dsa/dsa2.c | 1 + net/dsa/slave.c | 5 ++++- 3 files changed, 6 insertions(+), 1 deletion(-) -- 2.20.1 diff --git a/include/net/dsa.h b/include/net/dsa.h index ae480bba11f5..0cfc2f828b87 100644 --- a/include/net/dsa.h +++ b/include/net/dsa.h @@ -140,6 +140,7 @@ struct dsa_port { unsigned int index; const char *name; const struct dsa_port *cpu_dp; + const char *mac; struct device_node *dn; unsigned int ageing_time; u8 stp_state; diff --git a/net/dsa/dsa2.c b/net/dsa/dsa2.c index fe0a6197db9c..0e1cce460406 100644 --- a/net/dsa/dsa2.c +++ b/net/dsa/dsa2.c @@ -266,6 +266,7 @@ static int dsa_port_setup(struct dsa_port *dp) return 0; memset(&dp->devlink_port, 0, sizeof(dp->devlink_port)); + dp->mac = of_get_mac_address(dp->dn); switch (dp->type) { case DSA_PORT_TYPE_CPU: diff --git a/net/dsa/slave.c b/net/dsa/slave.c index 093eef6f2599..9e4208140142 100644 --- a/net/dsa/slave.c +++ b/net/dsa/slave.c @@ -1378,7 +1378,10 @@ int dsa_slave_create(struct dsa_port *port) NETIF_F_HW_VLAN_CTAG_FILTER; slave_dev->hw_features |= NETIF_F_HW_TC; slave_dev->ethtool_ops = &dsa_slave_ethtool_ops; - eth_hw_addr_inherit(slave_dev, master); + if (port->mac && is_valid_ether_addr(port->mac)) + ether_addr_copy(slave_dev->dev_addr, port->mac); + else + eth_hw_addr_inherit(slave_dev, master); slave_dev->priv_flags |= IFF_NO_QUEUE; slave_dev->netdev_ops = &dsa_slave_netdev_ops; slave_dev->min_mtu = 0;