Message ID | 20240830070037.3529832-1-ruanjinjie@huawei.com (mailing list archive) |
---|---|
State | Changes Requested |
Delegated to: | Netdev Maintainers |
Headers | show |
Series | [net-next,v2,RESEND] net: dsa: Simplify with scoped for each OF child loop | expand |
On Fri, Aug 30, 2024 at 03:00:37PM +0800, Jinjie Ruan wrote: > Use scoped for_each_available_child_of_node_scoped() when iterating over > device nodes to make code a bit simpler. > > Signed-off-by: Jinjie Ruan <ruanjinjie@huawei.com> > --- > v1 -> v2 RESNED: > - Remove the goto. > - next -> net-next > --- > net/dsa/dsa.c | 24 ++++++++++-------------- > 1 file changed, 10 insertions(+), 14 deletions(-) > > diff --git a/net/dsa/dsa.c b/net/dsa/dsa.c > index 668c729946ea..24f566838621 100644 > --- a/net/dsa/dsa.c > +++ b/net/dsa/dsa.c > @@ -1264,9 +1264,8 @@ static int dsa_port_parse_of(struct dsa_port *dp, struct device_node *dn) > static int dsa_switch_parse_ports_of(struct dsa_switch *ds, > struct device_node *dn) > { > - struct device_node *ports, *port; > + struct device_node *ports; > struct dsa_port *dp; > - int err = 0; Why? Patches should be small, simple, obviously correct. This change makes the patch more complex, harder to review, and less obviously correct. All these patches have questionable value. Most probably don't fix anything which is broken. They are using up a lot of Reviewer/Maintainer time. Don't make it worse by making unneeded changes. Andrew --- pw-bot: cr
diff --git a/net/dsa/dsa.c b/net/dsa/dsa.c index 668c729946ea..24f566838621 100644 --- a/net/dsa/dsa.c +++ b/net/dsa/dsa.c @@ -1264,9 +1264,8 @@ static int dsa_port_parse_of(struct dsa_port *dp, struct device_node *dn) static int dsa_switch_parse_ports_of(struct dsa_switch *ds, struct device_node *dn) { - struct device_node *ports, *port; + struct device_node *ports; struct dsa_port *dp; - int err = 0; u32 reg; ports = of_get_child_by_name(dn, "ports"); @@ -1279,33 +1278,30 @@ static int dsa_switch_parse_ports_of(struct dsa_switch *ds, } } - for_each_available_child_of_node(ports, port) { - err = of_property_read_u32(port, "reg", ®); + for_each_available_child_of_node_scoped(ports, port) { + int err = of_property_read_u32(port, "reg", ®); if (err) { - of_node_put(port); - goto out_put_node; + of_node_put(ports); + return err; } if (reg >= ds->num_ports) { dev_err(ds->dev, "port %pOF index %u exceeds num_ports (%u)\n", port, reg, ds->num_ports); - of_node_put(port); - err = -EINVAL; - goto out_put_node; + of_node_put(ports); + return -EINVAL; } dp = dsa_to_port(ds, reg); err = dsa_port_parse_of(dp, port); if (err) { - of_node_put(port); - goto out_put_node; + of_node_put(ports); + return err; } } -out_put_node: - of_node_put(ports); - return err; + return 0; } static int dsa_switch_parse_member_of(struct dsa_switch *ds,
Use scoped for_each_available_child_of_node_scoped() when iterating over device nodes to make code a bit simpler. Signed-off-by: Jinjie Ruan <ruanjinjie@huawei.com> --- v1 -> v2 RESNED: - Remove the goto. - next -> net-next --- net/dsa/dsa.c | 24 ++++++++++-------------- 1 file changed, 10 insertions(+), 14 deletions(-)