Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit a2c7023f authored by Xiaofei Shen's avatar Xiaofei Shen Committed by David S. Miller
Browse files

net: dsa: read mac address from DT for slave device



Before creating a slave netdevice, get the mac address from DTS and
apply in case it is valid.

Signed-off-by: default avatarXiaofei Shen <xiaofeis@codeaurora.org>
Signed-off-by: default avatarVinod Koul <vkoul@kernel.org>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent f5d54767
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -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;
+1 −0
Original line number Diff line number Diff line
@@ -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:
+4 −1
Original line number Diff line number Diff line
@@ -1393,6 +1393,9 @@ 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;
	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;