summaryrefslogtreecommitdiffstats
path: root/include/net/dsa.h
diff options
context:
space:
mode:
authorVivien Didelot2017-10-26 17:22:51 +0200
committerDavid S. Miller2017-10-27 17:00:09 +0200
commitbff7b688d5b10a8cb8cecefdea5e255408b78f2f (patch)
tree4a75ab18d7dcce75a12d337fb10693a3821b444a /include/net/dsa.h
parentnet: faraday: ftmac100: Use BUG_ON instead of if condition followed by BUG. (diff)
downloadkernel-qcow2-linux-bff7b688d5b10a8cb8cecefdea5e255408b78f2f.tar.gz
kernel-qcow2-linux-bff7b688d5b10a8cb8cecefdea5e255408b78f2f.tar.xz
kernel-qcow2-linux-bff7b688d5b10a8cb8cecefdea5e255408b78f2f.zip
net: dsa: add dsa_is_unused_port helper
As the comment above the chunk states, the b53 driver attempts to disable the unused ports. But using ds->enabled_port_mask is misleading, because this mask reports in fact the user ports. To avoid confusion and fix this, this patch introduces an explicit dsa_is_unused_port helper which ensures the corresponding bit is not masked in any of the switch port masks. 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 'include/net/dsa.h')
-rw-r--r--include/net/dsa.h7
1 files changed, 7 insertions, 0 deletions
diff --git a/include/net/dsa.h b/include/net/dsa.h
index 38961ef91d3d..6b1bc1c8f7e2 100644
--- a/include/net/dsa.h
+++ b/include/net/dsa.h
@@ -254,6 +254,13 @@ struct dsa_switch {
struct dsa_port ports[];
};
+static inline bool dsa_is_unused_port(struct dsa_switch *ds, int p)
+{
+ u32 m = ds->enabled_port_mask | ds->dsa_port_mask | ds->cpu_port_mask;
+
+ return !(m & BIT(p));
+}
+
static inline bool dsa_is_cpu_port(struct dsa_switch *ds, int p)
{
return !!(ds->cpu_port_mask & (1 << p));