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 5/7] net: dsa: get master device at port parsing time
Date: Fri, 27 Oct 2017 15:55:17 -0400 [thread overview]
Message-ID: <20171027195519.5931-6-vivien.didelot@savoirfairelinux.com> (raw)
In-Reply-To: <20171027195519.5931-1-vivien.didelot@savoirfairelinux.com>
Fetching the master device can be done directly when a port is parsed
from device tree or pdata, instead of waiting until dsa_dst_parse.
Now that -EPROBE_DEFER is returned before we add the switch to the tree,
there is no need to check for this error after dsa_dst_parse.
Signed-off-by: Vivien Didelot <vivien.didelot@savoirfairelinux.com>
---
net/dsa/dsa2.c | 44 ++++++++++++++++++--------------------------
1 file changed, 18 insertions(+), 26 deletions(-)
diff --git a/net/dsa/dsa2.c b/net/dsa/dsa2.c
index 5b9dea81d617..be43e06caf7e 100644
--- a/net/dsa/dsa2.c
+++ b/net/dsa/dsa2.c
@@ -470,27 +470,9 @@ static int dsa_cpu_parse(struct dsa_port *port, u32 index,
{
const struct dsa_device_ops *tag_ops;
enum dsa_tag_protocol tag_protocol;
- struct net_device *ethernet_dev;
- struct device_node *ethernet;
- if (port->dn) {
- ethernet = of_parse_phandle(port->dn, "ethernet", 0);
- if (!ethernet)
- return -EINVAL;
- ethernet_dev = of_find_net_device_by_node(ethernet);
- if (!ethernet_dev)
- return -EPROBE_DEFER;
- } else {
- ethernet_dev = dsa_dev_to_net_device(ds->cd->netdev[index]);
- if (!ethernet_dev)
- return -EPROBE_DEFER;
- dev_put(ethernet_dev);
- }
-
- if (!dst->cpu_dp) {
+ if (!dst->cpu_dp)
dst->cpu_dp = port;
- dst->cpu_dp->master = ethernet_dev;
- }
tag_protocol = ds->ops->get_tag_protocol(ds);
tag_ops = dsa_resolve_tag_protocol(tag_protocol);
@@ -584,7 +566,14 @@ static int dsa_port_parse_of(struct dsa_port *dp, struct device_node *dn)
struct device_node *link = of_parse_phandle(dn, "link", 0);
if (ethernet) {
+ struct net_device *master;
+
+ master = of_find_net_device_by_node(ethernet);
+ if (!master)
+ return -EPROBE_DEFER;
+
dp->type = DSA_PORT_TYPE_CPU;
+ dp->master = master;
} else if (link) {
dp->type = DSA_PORT_TYPE_DSA;
} else {
@@ -631,7 +620,16 @@ static int dsa_port_parse(struct dsa_port *dp, const char *name,
struct device *dev)
{
if (!strcmp(name, "cpu")) {
+ struct net_device *master;
+
+ master = dsa_dev_to_net_device(dev);
+ if (!master)
+ return -EPROBE_DEFER;
+
+ dev_put(master);
+
dp->type = DSA_PORT_TYPE_CPU;
+ dp->master = master;
} else if (!strcmp(name, "dsa")) {
dp->type = DSA_PORT_TYPE_DSA;
} else {
@@ -773,14 +771,8 @@ static int _dsa_register_switch(struct dsa_switch *ds)
}
err = dsa_dst_parse(dst);
- if (err) {
- if (err == -EPROBE_DEFER) {
- dsa_dst_del_ds(dst, ds, ds->index);
- return err;
- }
-
+ if (err)
goto out_del_dst;
- }
err = dsa_dst_apply(dst);
if (err) {
--
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 ` [PATCH net-next 1/7] net: dsa: get ports within parsing code Vivien Didelot
2017-10-30 18:37 ` 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 ` Vivien Didelot [this message]
2017-10-30 18:41 ` [PATCH net-next 5/7] net: dsa: get master device at port parsing time 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-6-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).