diff options
author | Vivien Didelot <vivien.didelot@savoirfairelinux.com> | 2017-10-27 15:55:13 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2017-11-01 11:47:02 +0900 |
commit | 5b32fe070c2ddf31adc42c26dab8af346b652538 (patch) | |
tree | a7d74b24003397edc058bd2f80571a9b82eb2480 /net/dsa | |
parent | 638f5b90d46016372a8e3e0a434f199cc5e12b8c (diff) | |
download | linux-5b32fe070c2ddf31adc42c26dab8af346b652538.tar.gz linux-5b32fe070c2ddf31adc42c26dab8af346b652538.tar.bz2 linux-5b32fe070c2ddf31adc42c26dab8af346b652538.zip |
net: dsa: get ports within parsing code
There is no point into hiding the -EINVAL error code in ERR_PTR from a
dsa_get_ports function, simply get the "ports" node directly from within
the dsa_parse_ports_dn function.
This also has the effect to make the pdata and device tree handling code
symmetrical inside _dsa_register_switch.
At the same time, rename dsa_parse_ports_dn to dsa_parse_ports_of
because _of is a more common suffix for device tree parsing functions.
Signed-off-by: Vivien Didelot <vivien.didelot@savoirfairelinux.com>
Reviewed-by: Florian Fainelli <f.fainelli@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/dsa')
-rw-r--r-- | net/dsa/dsa2.c | 33 |
1 files changed, 10 insertions, 23 deletions
diff --git a/net/dsa/dsa2.c b/net/dsa/dsa2.c index 4d1ccf87c59c..9d57f8dee9a1 100644 --- a/net/dsa/dsa2.c +++ b/net/dsa/dsa2.c @@ -590,11 +590,17 @@ static int dsa_dst_parse(struct dsa_switch_tree *dst) return 0; } -static int dsa_parse_ports_dn(struct device_node *ports, struct dsa_switch *ds) +static int dsa_parse_ports_of(struct device_node *dn, struct dsa_switch *ds) { - struct device_node *port; - int err; + struct device_node *ports, *port; u32 reg; + int err; + + ports = of_get_child_by_name(dn, "ports"); + if (!ports) { + dev_err(ds->dev, "no ports child node found\n"); + return -EINVAL; + } for_each_available_child_of_node(ports, port) { err = of_property_read_u32(port, "reg", ®); @@ -665,26 +671,11 @@ static int dsa_parse_member(struct dsa_chip_data *pd, u32 *tree, u32 *index) return 0; } -static struct device_node *dsa_get_ports(struct dsa_switch *ds, - struct device_node *np) -{ - struct device_node *ports; - - ports = of_get_child_by_name(np, "ports"); - if (!ports) { - dev_err(ds->dev, "no ports child node found\n"); - return ERR_PTR(-EINVAL); - } - - return ports; -} - static int _dsa_register_switch(struct dsa_switch *ds) { struct dsa_chip_data *pdata = ds->dev->platform_data; struct device_node *np = ds->dev->of_node; struct dsa_switch_tree *dst; - struct device_node *ports; u32 tree, index; int i, err; @@ -693,11 +684,7 @@ static int _dsa_register_switch(struct dsa_switch *ds) if (err) return err; - ports = dsa_get_ports(ds, np); - if (IS_ERR(ports)) - return PTR_ERR(ports); - - err = dsa_parse_ports_dn(ports, ds); + err = dsa_parse_ports_of(np, ds); if (err) return err; } else { |