Commit 912aae27 authored by Helmut Grohne's avatar Helmut Grohne Committed by David S. Miller

net: dsa: microchip: really look for phy-mode in port nodes

The previous implementation failed to account for the "ports" node. The
actual port nodes are not child nodes of the switch node, but a "ports"
node sits in between.

Fixes: edecfa98 ("net: dsa: microchip: look for phy-mode in port nodes")
Signed-off-by: default avatarHelmut Grohne <helmut.grohne@intenta.de>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 38f7e1c0
...@@ -387,8 +387,8 @@ EXPORT_SYMBOL(ksz_switch_alloc); ...@@ -387,8 +387,8 @@ EXPORT_SYMBOL(ksz_switch_alloc);
int ksz_switch_register(struct ksz_device *dev, int ksz_switch_register(struct ksz_device *dev,
const struct ksz_dev_ops *ops) const struct ksz_dev_ops *ops)
{ {
struct device_node *port, *ports;
phy_interface_t interface; phy_interface_t interface;
struct device_node *port;
unsigned int port_num; unsigned int port_num;
int ret; int ret;
...@@ -429,13 +429,17 @@ int ksz_switch_register(struct ksz_device *dev, ...@@ -429,13 +429,17 @@ int ksz_switch_register(struct ksz_device *dev,
ret = of_get_phy_mode(dev->dev->of_node, &interface); ret = of_get_phy_mode(dev->dev->of_node, &interface);
if (ret == 0) if (ret == 0)
dev->compat_interface = interface; dev->compat_interface = interface;
for_each_available_child_of_node(dev->dev->of_node, port) { ports = of_get_child_by_name(dev->dev->of_node, "ports");
if (of_property_read_u32(port, "reg", &port_num)) if (ports)
continue; for_each_available_child_of_node(ports, port) {
if (port_num >= dev->port_cnt) if (of_property_read_u32(port, "reg",
return -EINVAL; &port_num))
of_get_phy_mode(port, &dev->ports[port_num].interface); continue;
} if (port_num >= dev->port_cnt)
return -EINVAL;
of_get_phy_mode(port,
&dev->ports[port_num].interface);
}
dev->synclko_125 = of_property_read_bool(dev->dev->of_node, dev->synclko_125 = of_property_read_bool(dev->dev->of_node,
"microchip,synclko-125"); "microchip,synclko-125");
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment