summaryrefslogtreecommitdiff
path: root/drivers/net/ethernet/renesas/rswitch_main.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/net/ethernet/renesas/rswitch_main.c')
-rw-r--r--drivers/net/ethernet/renesas/rswitch_main.c18
1 files changed, 9 insertions, 9 deletions
diff --git a/drivers/net/ethernet/renesas/rswitch_main.c b/drivers/net/ethernet/renesas/rswitch_main.c
index 6fe964816322..755232994fcc 100644
--- a/drivers/net/ethernet/renesas/rswitch_main.c
+++ b/drivers/net/ethernet/renesas/rswitch_main.c
@@ -1303,7 +1303,8 @@ static int rswitch_etha_mii_write_c22(struct mii_bus *bus, int phyad,
/* Call of_node_put(port) after done */
static struct device_node *rswitch_get_port_node(struct rswitch_device *rdev)
{
- struct device_node *ports, *port;
+ struct device_node *port = NULL;
+ struct device_node *ports;
int err = 0;
u32 index;
@@ -1312,17 +1313,16 @@ static struct device_node *rswitch_get_port_node(struct rswitch_device *rdev)
if (!ports)
return NULL;
- for_each_available_child_of_node(ports, port) {
- err = of_property_read_u32(port, "reg", &index);
- if (err < 0) {
- port = NULL;
- goto out;
- }
- if (index == rdev->etha->index)
+ for_each_available_child_of_node_scoped(ports, child) {
+ err = of_property_read_u32(child, "reg", &index);
+ if (err < 0)
break;
+ if (index == rdev->etha->index) {
+ port = of_node_get(child);
+ break;
+ }
}
-out:
of_node_put(ports);
return port;