From: Vivien Didelot <vivien.didelot@savoirfairelinux.com>
To: netdev@vger.kernel.org
Cc: linux-kernel@vger.kernel.org, kernel@savoirfairelinux.com,
"David S. Miller" <davem@davemloft.net>,
Florian Fainelli <f.fainelli@gmail.com>,
Andrew Lunn <andrew@lunn.ch>,
Vivien Didelot <vivien.didelot@savoirfairelinux.com>
Subject: [PATCH net-next 1/7] net: dsa: get ports within parsing code
Date: Fri, 27 Oct 2017 15:55:13 -0400 [thread overview]
Message-ID: <20171027195519.5931-2-vivien.didelot@savoirfairelinux.com> (raw)
In-Reply-To: <20171027195519.5931-1-vivien.didelot@savoirfairelinux.com>
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>
---
net/dsa/dsa2.c | 33 ++++++++++-----------------------
1 file changed, 10 insertions(+), 23 deletions(-)
diff --git a/net/dsa/dsa2.c b/net/dsa/dsa2.c
index ec58654a71cd..26d2ff013eb1 100644
--- a/net/dsa/dsa2.c
+++ b/net/dsa/dsa2.c
@@ -589,11 +589,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", ®);
@@ -664,26 +670,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;
@@ -692,11 +683,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 {
--
2.14.3
next prev parent reply other threads:[~2017-10-27 19:55 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-10-27 19:55 [PATCH net-next 0/7] net: dsa: add port parsing functions Vivien Didelot
2017-10-27 19:55 ` Vivien Didelot [this message]
2017-10-30 18:37 ` [PATCH net-next 1/7] net: dsa: get ports within parsing code Florian Fainelli
2017-10-27 19:55 ` [PATCH net-next 2/7] net: dsa: add port parse functions Vivien Didelot
2017-10-30 18:37 ` Florian Fainelli
2017-10-27 19:55 ` [PATCH net-next 3/7] net: dsa: get port type at parse time Vivien Didelot
2017-10-30 18:39 ` Florian Fainelli
2017-10-30 18:46 ` Vivien Didelot
2017-10-30 18:46 ` Florian Fainelli
2017-10-27 19:55 ` [PATCH net-next 4/7] net: dsa: check master device before put Vivien Didelot
2017-10-27 19:55 ` [PATCH net-next 5/7] net: dsa: get master device at port parsing time Vivien Didelot
2017-10-30 18:41 ` Florian Fainelli
2017-10-27 19:55 ` [PATCH net-next 6/7] net: dsa: get port name at parse time Vivien Didelot
2017-10-30 18:44 ` Florian Fainelli
2017-10-27 19:55 ` [PATCH net-next 7/7] net: dsa: remove name arg from slave create Vivien Didelot
2017-10-30 18:44 ` Florian Fainelli
2017-11-01 2:48 ` [PATCH net-next 0/7] net: dsa: add port parsing functions David Miller
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20171027195519.5931-2-vivien.didelot@savoirfairelinux.com \
--to=vivien.didelot@savoirfairelinux.com \
--cc=andrew@lunn.ch \
--cc=davem@davemloft.net \
--cc=f.fainelli@gmail.com \
--cc=kernel@savoirfairelinux.com \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).