diff options
author | Florian Fainelli <f.fainelli@gmail.com> | 2017-01-26 13:45:52 -0500 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2017-01-26 15:43:53 -0500 |
commit | 293784a8f856e854b4742be4aacf435062d91e9c (patch) | |
tree | 1fa42ba1ef912b78e184e5bbddc046ae8d0df2e8 /net/dsa/dsa.c | |
parent | 55ed0ce0898e15fec30d2ca2a563d7934b082375 (diff) |
net: dsa: Make most functions take a dsa_port argument
In preparation for allowing platform data, and therefore no valid
device_node pointer, make most DSA functions takes a pointer to a
dsa_port structure whenever possible. While at it, introduce a
dsa_port_is_valid() helper function which checks whether port->dn is
NULL or not at the moment.
Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/dsa/dsa.c')
-rw-r--r-- | net/dsa/dsa.c | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/net/dsa/dsa.c b/net/dsa/dsa.c index 1f3afeb673d6..07e863369e04 100644 --- a/net/dsa/dsa.c +++ b/net/dsa/dsa.c | |||
@@ -110,8 +110,9 @@ dsa_switch_probe(struct device *parent, struct device *host_dev, int sw_addr, | |||
110 | 110 | ||
111 | /* basic switch operations **************************************************/ | 111 | /* basic switch operations **************************************************/ |
112 | int dsa_cpu_dsa_setup(struct dsa_switch *ds, struct device *dev, | 112 | int dsa_cpu_dsa_setup(struct dsa_switch *ds, struct device *dev, |
113 | struct device_node *port_dn, int port) | 113 | struct dsa_port *dport, int port) |
114 | { | 114 | { |
115 | struct device_node *port_dn = dport->dn; | ||
115 | struct phy_device *phydev; | 116 | struct phy_device *phydev; |
116 | int ret, mode; | 117 | int ret, mode; |
117 | 118 | ||
@@ -141,15 +142,15 @@ int dsa_cpu_dsa_setup(struct dsa_switch *ds, struct device *dev, | |||
141 | 142 | ||
142 | static int dsa_cpu_dsa_setups(struct dsa_switch *ds, struct device *dev) | 143 | static int dsa_cpu_dsa_setups(struct dsa_switch *ds, struct device *dev) |
143 | { | 144 | { |
144 | struct device_node *port_dn; | 145 | struct dsa_port *dport; |
145 | int ret, port; | 146 | int ret, port; |
146 | 147 | ||
147 | for (port = 0; port < DSA_MAX_PORTS; port++) { | 148 | for (port = 0; port < DSA_MAX_PORTS; port++) { |
148 | if (!(dsa_is_cpu_port(ds, port) || dsa_is_dsa_port(ds, port))) | 149 | if (!(dsa_is_cpu_port(ds, port) || dsa_is_dsa_port(ds, port))) |
149 | continue; | 150 | continue; |
150 | 151 | ||
151 | port_dn = ds->ports[port].dn; | 152 | dport = &ds->ports[port]; |
152 | ret = dsa_cpu_dsa_setup(ds, dev, port_dn, port); | 153 | ret = dsa_cpu_dsa_setup(ds, dev, dport, port); |
153 | if (ret) | 154 | if (ret) |
154 | return ret; | 155 | return ret; |
155 | } | 156 | } |
@@ -364,8 +365,10 @@ dsa_switch_setup(struct dsa_switch_tree *dst, int index, | |||
364 | return ds; | 365 | return ds; |
365 | } | 366 | } |
366 | 367 | ||
367 | void dsa_cpu_dsa_destroy(struct device_node *port_dn) | 368 | void dsa_cpu_dsa_destroy(struct dsa_port *port) |
368 | { | 369 | { |
370 | struct device_node *port_dn = port->dn; | ||
371 | |||
369 | if (of_phy_is_fixed_link(port_dn)) | 372 | if (of_phy_is_fixed_link(port_dn)) |
370 | of_phy_deregister_fixed_link(port_dn); | 373 | of_phy_deregister_fixed_link(port_dn); |
371 | } | 374 | } |
@@ -389,7 +392,7 @@ static void dsa_switch_destroy(struct dsa_switch *ds) | |||
389 | for (port = 0; port < DSA_MAX_PORTS; port++) { | 392 | for (port = 0; port < DSA_MAX_PORTS; port++) { |
390 | if (!(dsa_is_cpu_port(ds, port) || dsa_is_dsa_port(ds, port))) | 393 | if (!(dsa_is_cpu_port(ds, port) || dsa_is_dsa_port(ds, port))) |
391 | continue; | 394 | continue; |
392 | dsa_cpu_dsa_destroy(ds->ports[port].dn); | 395 | dsa_cpu_dsa_destroy(&ds->ports[port]); |
393 | 396 | ||
394 | /* Clearing a bit which is not set does no harm */ | 397 | /* Clearing a bit which is not set does no harm */ |
395 | ds->cpu_port_mask |= ~(1 << port); | 398 | ds->cpu_port_mask |= ~(1 << port); |