summaryrefslogtreecommitdiffstats
path: root/include/net/dsa.h
diff options
context:
space:
mode:
authorVivien Didelot2017-10-16 17:12:19 +0200
committerDavid S. Miller2017-10-18 13:24:33 +0200
commitc8652c83bc84ac8db44060ced0036de7628aa5e5 (patch)
treed73285634543e8063d66da030e34a218fc76e805 /include/net/dsa.h
parentnet: dsa: split dsa_port's netdev member (diff)
downloadkernel-qcow2-linux-c8652c83bc84ac8db44060ced0036de7628aa5e5.tar.gz
kernel-qcow2-linux-c8652c83bc84ac8db44060ced0036de7628aa5e5.tar.xz
kernel-qcow2-linux-c8652c83bc84ac8db44060ced0036de7628aa5e5.zip
net: dsa: add dsa_to_port helper
The dsa_port structure is part of DSA core data and must only be updated by the later. It is OK and sometimes necessary for the DSA drivers to access this data, but this has to be read only. For that purpose, add a dsa_to_port() helper which returns a const pointer to a dsa_port structure which must be used by DSA drivers from now on instead of digging into ds->ports[] themselves. Signed-off-by: Vivien Didelot <vivien.didelot@savoirfairelinux.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'include/net/dsa.h')
-rw-r--r--include/net/dsa.h5
1 files changed, 5 insertions, 0 deletions
diff --git a/include/net/dsa.h b/include/net/dsa.h
index 6ed1a17ed1bd..38961ef91d3d 100644
--- a/include/net/dsa.h
+++ b/include/net/dsa.h
@@ -269,6 +269,11 @@ static inline bool dsa_is_normal_port(struct dsa_switch *ds, int p)
return !dsa_is_cpu_port(ds, p) && !dsa_is_dsa_port(ds, p);
}
+static inline const struct dsa_port *dsa_to_port(struct dsa_switch *ds, int p)
+{
+ return &ds->ports[p];
+}
+
static inline u8 dsa_upstream_port(struct dsa_switch *ds)
{
struct dsa_switch_tree *dst = ds->dst;