diff options
author | Guenter Roeck <linux@roeck-us.net> | 2015-02-25 02:02:02 -0500 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2015-02-25 17:57:48 -0500 |
commit | d79d21073626cf022943e5c4c10a97cdf7cb8465 (patch) | |
tree | 529fa340e3b007cce36bb7665f1eef4807bdb5b4 /include/net | |
parent | bb66be1c549a0760500cfad404b3d79a136d0e44 (diff) |
net: dsa: Introduce dsa_is_port_initialized
To avoid race conditions when using the ds->ports[] array,
we need to check if the accessed port has been initialized.
Introduce and use helper function dsa_is_port_initialized
for that purpose and use it where needed.
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'include/net')
-rw-r--r-- | include/net/dsa.h | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/include/net/dsa.h b/include/net/dsa.h index 92be34791963..c542c131d551 100644 --- a/include/net/dsa.h +++ b/include/net/dsa.h | |||
@@ -165,6 +165,11 @@ static inline bool dsa_is_cpu_port(struct dsa_switch *ds, int p) | |||
165 | return !!(ds->index == ds->dst->cpu_switch && p == ds->dst->cpu_port); | 165 | return !!(ds->index == ds->dst->cpu_switch && p == ds->dst->cpu_port); |
166 | } | 166 | } |
167 | 167 | ||
168 | static inline bool dsa_is_port_initialized(struct dsa_switch *ds, int p) | ||
169 | { | ||
170 | return ds->phys_port_mask & (1 << p) && ds->ports[p]; | ||
171 | } | ||
172 | |||
168 | static inline u8 dsa_upstream_port(struct dsa_switch *ds) | 173 | static inline u8 dsa_upstream_port(struct dsa_switch *ds) |
169 | { | 174 | { |
170 | struct dsa_switch_tree *dst = ds->dst; | 175 | struct dsa_switch_tree *dst = ds->dst; |