Commit f834d572 authored by Jinjie Ruan's avatar Jinjie Ruan Committed by Paolo Abeni

net: dsa: microchip: Use scoped function to simplfy code

Avoids the need for manual cleanup of_node_put() in early exits
from the loop by using for_each_available_child_of_node_scoped().
Reviewed-by: default avatarAndrew Lunn <andrew@lunn.ch>
Reviewed-by: default avatarJonathan Cameron <Jonathan.Cameron@huawei.com>
Signed-off-by: default avatarJinjie Ruan <ruanjinjie@huawei.com>
Reviewed-by: default avatarFlorian Fainelli <florian.fainelli@broadcom.com>
Signed-off-by: default avatarPaolo Abeni <pabeni@redhat.com>
parent 3a3eea20
...@@ -4717,7 +4717,7 @@ static int ksz_parse_drive_strength(struct ksz_device *dev) ...@@ -4717,7 +4717,7 @@ static int ksz_parse_drive_strength(struct ksz_device *dev)
int ksz_switch_register(struct ksz_device *dev) int ksz_switch_register(struct ksz_device *dev)
{ {
const struct ksz_chip_data *info; const struct ksz_chip_data *info;
struct device_node *port, *ports; struct device_node *ports;
phy_interface_t interface; phy_interface_t interface;
unsigned int port_num; unsigned int port_num;
int ret; int ret;
...@@ -4803,12 +4803,11 @@ int ksz_switch_register(struct ksz_device *dev) ...@@ -4803,12 +4803,11 @@ int ksz_switch_register(struct ksz_device *dev)
if (!ports) if (!ports)
ports = of_get_child_by_name(dev->dev->of_node, "ports"); ports = of_get_child_by_name(dev->dev->of_node, "ports");
if (ports) { if (ports) {
for_each_available_child_of_node(ports, port) { for_each_available_child_of_node_scoped(ports, port) {
if (of_property_read_u32(port, "reg", if (of_property_read_u32(port, "reg",
&port_num)) &port_num))
continue; continue;
if (!(dev->port_mask & BIT(port_num))) { if (!(dev->port_mask & BIT(port_num))) {
of_node_put(port);
of_node_put(ports); of_node_put(ports);
return -EINVAL; return -EINVAL;
} }
......
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