From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.2 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id E62B4C10F00 for ; Fri, 22 Feb 2019 12:58:44 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id B74692086C for ; Fri, 22 Feb 2019 12:58:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1550840324; bh=qeRTyujybP4NM3oAD6Tl4q2Mq2qRpukAkyJ9ZA8Z/ak=; h=From:To:Cc:Subject:Date:List-ID:From; b=eEcgtCZp+/YwbgIKfnE635IyskGZoRyffLihkf+mIyQrDipknAPhj+SBYcOMwAU53 CFh6h/sNUGWlaIkbhWCnEl9mJ7J8EMYVk4rqYujR9DD5VhyHB6jYqqLFsSdQ1FUOjT fi/QAxcmcP5zbxygob+l+zHGM8iwY8b1BQ/YU3co= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726977AbfBVM6j (ORCPT ); Fri, 22 Feb 2019 07:58:39 -0500 Received: from mail.kernel.org ([198.145.29.99]:39092 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726712AbfBVM6j (ORCPT ); Fri, 22 Feb 2019 07:58:39 -0500 Received: from localhost.localdomain (unknown [117.99.84.51]) (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 7EEF820823; Fri, 22 Feb 2019 12:58:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1550840318; bh=qeRTyujybP4NM3oAD6Tl4q2Mq2qRpukAkyJ9ZA8Z/ak=; h=From:To:Cc:Subject:Date:From; b=HYQfFQh9XAEdwuQZYzEGqWz41vbUdrmSymGjeUW7HdCnd53V+4NP9ZKx1K3CFQsib KtBOQkEKmTToG5YdakqFbVlCGtdjk7h7Ddf9ZnQPx743ZCnKe19fWO/G7j9FinuNml gpow7TkYG5oQGKGYVeifA7PbibN9tr7TSLIl3aP4= From: Vinod Koul To: "David S. Miller" Cc: linux-arm-msm@vger.kernel.org, Bjorn Andersson , Xiaofei Shen , Andrew Lunn , Vivien Didelot , Florian Fainelli , Niklas Cassel , netdev@vger.kernel.org, Vinod Koul Subject: [PATCH] net: dsa: read mac address from DT for slave device Date: Fri, 22 Feb 2019 18:28:15 +0530 Message-Id: <20190222125815.12866-1-vkoul@kernel.org> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@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 --- include/net/dsa.h | 1 + net/dsa/dsa2.c | 1 + net/dsa/slave.c | 5 ++++- 3 files changed, 6 insertions(+), 1 deletion(-) diff --git a/include/net/dsa.h b/include/net/dsa.h index b3eefe8e18fd..aa24ce756679 100644 --- a/include/net/dsa.h +++ b/include/net/dsa.h @@ -198,6 +198,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 a1917025e155..afb7d9fa42f6 100644 --- a/net/dsa/dsa2.c +++ b/net/dsa/dsa2.c @@ -261,6 +261,7 @@ static int dsa_port_setup(struct dsa_port *dp) int err = 0; memset(&dp->devlink_port, 0, sizeof(dp->devlink_port)); + dp->mac = of_get_mac_address(dp->dn); if (dp->type != DSA_PORT_TYPE_UNUSED) err = devlink_port_register(ds->devlink, &dp->devlink_port, diff --git a/net/dsa/slave.c b/net/dsa/slave.c index a3fcc1d01615..8e64c4e947c6 100644 --- a/net/dsa/slave.c +++ b/net/dsa/slave.c @@ -1308,7 +1308,10 @@ int dsa_slave_create(struct dsa_port *port) slave_dev->features = master->vlan_features | NETIF_F_HW_TC; 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->switchdev_ops = &dsa_slave_switchdev_ops; -- 2.20.1