diff options
author | Vivien Didelot <vivien.didelot@savoirfairelinux.com> | 2017-09-29 17:19:16 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2017-09-30 23:15:07 -0400 |
commit | 7ec764eef934409c4e15539440c31bca0b8de005 (patch) | |
tree | 27c65568e4e62abe43034840ec1520d72fd37d46 /net/dsa/master.c | |
parent | 3775b1b7f0c330e59c434d1852d7762ae0a9c164 (diff) |
net: dsa: use cpu_dp in master code
Make it clear that the master device is linked to a CPU port by using
"cpu_dp" for the dsa_port variable in master.c instead of "port", then
use a "port" variable to describe the port index, as usually seen in
other places of DSA core.
This will make the future patch touching dsa_ptr more readable. There is
no functional changes.
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 'net/dsa/master.c')
-rw-r--r-- | net/dsa/master.c | 42 |
1 files changed, 22 insertions, 20 deletions
diff --git a/net/dsa/master.c b/net/dsa/master.c index 5e5147ec5a44..ef15d35f1574 100644 --- a/net/dsa/master.c +++ b/net/dsa/master.c | |||
@@ -17,9 +17,10 @@ static void dsa_master_get_ethtool_stats(struct net_device *dev, | |||
17 | uint64_t *data) | 17 | uint64_t *data) |
18 | { | 18 | { |
19 | struct dsa_switch_tree *dst = dev->dsa_ptr; | 19 | struct dsa_switch_tree *dst = dev->dsa_ptr; |
20 | struct dsa_port *port = dst->cpu_dp; | 20 | struct dsa_port *cpu_dp = dst->cpu_dp; |
21 | struct dsa_switch *ds = port->ds; | 21 | const struct ethtool_ops *ops = cpu_dp->orig_ethtool_ops; |
22 | const struct ethtool_ops *ops = port->orig_ethtool_ops; | 22 | struct dsa_switch *ds = cpu_dp->ds; |
23 | int port = cpu_dp->index; | ||
23 | int count = 0; | 24 | int count = 0; |
24 | 25 | ||
25 | if (ops && ops->get_sset_count && ops->get_ethtool_stats) { | 26 | if (ops && ops->get_sset_count && ops->get_ethtool_stats) { |
@@ -28,15 +29,15 @@ static void dsa_master_get_ethtool_stats(struct net_device *dev, | |||
28 | } | 29 | } |
29 | 30 | ||
30 | if (ds->ops->get_ethtool_stats) | 31 | if (ds->ops->get_ethtool_stats) |
31 | ds->ops->get_ethtool_stats(ds, port->index, data + count); | 32 | ds->ops->get_ethtool_stats(ds, port, data + count); |
32 | } | 33 | } |
33 | 34 | ||
34 | static int dsa_master_get_sset_count(struct net_device *dev, int sset) | 35 | static int dsa_master_get_sset_count(struct net_device *dev, int sset) |
35 | { | 36 | { |
36 | struct dsa_switch_tree *dst = dev->dsa_ptr; | 37 | struct dsa_switch_tree *dst = dev->dsa_ptr; |
37 | struct dsa_port *port = dst->cpu_dp; | 38 | struct dsa_port *cpu_dp = dst->cpu_dp; |
38 | struct dsa_switch *ds = port->ds; | 39 | const struct ethtool_ops *ops = cpu_dp->orig_ethtool_ops; |
39 | const struct ethtool_ops *ops = port->orig_ethtool_ops; | 40 | struct dsa_switch *ds = cpu_dp->ds; |
40 | int count = 0; | 41 | int count = 0; |
41 | 42 | ||
42 | if (ops && ops->get_sset_count) | 43 | if (ops && ops->get_sset_count) |
@@ -52,16 +53,17 @@ static void dsa_master_get_strings(struct net_device *dev, uint32_t stringset, | |||
52 | uint8_t *data) | 53 | uint8_t *data) |
53 | { | 54 | { |
54 | struct dsa_switch_tree *dst = dev->dsa_ptr; | 55 | struct dsa_switch_tree *dst = dev->dsa_ptr; |
55 | struct dsa_port *port = dst->cpu_dp; | 56 | struct dsa_port *cpu_dp = dst->cpu_dp; |
56 | struct dsa_switch *ds = port->ds; | 57 | const struct ethtool_ops *ops = cpu_dp->orig_ethtool_ops; |
57 | const struct ethtool_ops *ops = port->orig_ethtool_ops; | 58 | struct dsa_switch *ds = cpu_dp->ds; |
59 | int port = cpu_dp->index; | ||
58 | int len = ETH_GSTRING_LEN; | 60 | int len = ETH_GSTRING_LEN; |
59 | int mcount = 0, count; | 61 | int mcount = 0, count; |
60 | unsigned int i; | 62 | unsigned int i; |
61 | uint8_t pfx[4]; | 63 | uint8_t pfx[4]; |
62 | uint8_t *ndata; | 64 | uint8_t *ndata; |
63 | 65 | ||
64 | snprintf(pfx, sizeof(pfx), "p%.2d", port->index); | 66 | snprintf(pfx, sizeof(pfx), "p%.2d", port); |
65 | /* We do not want to be NULL-terminated, since this is a prefix */ | 67 | /* We do not want to be NULL-terminated, since this is a prefix */ |
66 | pfx[sizeof(pfx) - 1] = '_'; | 68 | pfx[sizeof(pfx) - 1] = '_'; |
67 | 69 | ||
@@ -76,7 +78,7 @@ static void dsa_master_get_strings(struct net_device *dev, uint32_t stringset, | |||
76 | * the output after to prepend our CPU port prefix we | 78 | * the output after to prepend our CPU port prefix we |
77 | * constructed earlier | 79 | * constructed earlier |
78 | */ | 80 | */ |
79 | ds->ops->get_strings(ds, port->index, ndata); | 81 | ds->ops->get_strings(ds, port, ndata); |
80 | count = ds->ops->get_sset_count(ds); | 82 | count = ds->ops->get_sset_count(ds); |
81 | for (i = 0; i < count; i++) { | 83 | for (i = 0; i < count; i++) { |
82 | memmove(ndata + (i * len + sizeof(pfx)), | 84 | memmove(ndata + (i * len + sizeof(pfx)), |
@@ -89,17 +91,17 @@ static void dsa_master_get_strings(struct net_device *dev, uint32_t stringset, | |||
89 | int dsa_master_ethtool_setup(struct net_device *dev) | 91 | int dsa_master_ethtool_setup(struct net_device *dev) |
90 | { | 92 | { |
91 | struct dsa_switch_tree *dst = dev->dsa_ptr; | 93 | struct dsa_switch_tree *dst = dev->dsa_ptr; |
92 | struct dsa_port *port = dst->cpu_dp; | 94 | struct dsa_port *cpu_dp = dst->cpu_dp; |
93 | struct dsa_switch *ds = port->ds; | 95 | struct dsa_switch *ds = cpu_dp->ds; |
94 | struct ethtool_ops *ops; | 96 | struct ethtool_ops *ops; |
95 | 97 | ||
96 | ops = devm_kzalloc(ds->dev, sizeof(*ops), GFP_KERNEL); | 98 | ops = devm_kzalloc(ds->dev, sizeof(*ops), GFP_KERNEL); |
97 | if (!ops) | 99 | if (!ops) |
98 | return -ENOMEM; | 100 | return -ENOMEM; |
99 | 101 | ||
100 | port->orig_ethtool_ops = dev->ethtool_ops; | 102 | cpu_dp->orig_ethtool_ops = dev->ethtool_ops; |
101 | if (port->orig_ethtool_ops) | 103 | if (cpu_dp->orig_ethtool_ops) |
102 | memcpy(ops, port->orig_ethtool_ops, sizeof(*ops)); | 104 | memcpy(ops, cpu_dp->orig_ethtool_ops, sizeof(*ops)); |
103 | 105 | ||
104 | ops->get_sset_count = dsa_master_get_sset_count; | 106 | ops->get_sset_count = dsa_master_get_sset_count; |
105 | ops->get_ethtool_stats = dsa_master_get_ethtool_stats; | 107 | ops->get_ethtool_stats = dsa_master_get_ethtool_stats; |
@@ -113,8 +115,8 @@ int dsa_master_ethtool_setup(struct net_device *dev) | |||
113 | void dsa_master_ethtool_restore(struct net_device *dev) | 115 | void dsa_master_ethtool_restore(struct net_device *dev) |
114 | { | 116 | { |
115 | struct dsa_switch_tree *dst = dev->dsa_ptr; | 117 | struct dsa_switch_tree *dst = dev->dsa_ptr; |
116 | struct dsa_port *port = dst->cpu_dp; | 118 | struct dsa_port *cpu_dp = dst->cpu_dp; |
117 | 119 | ||
118 | dev->ethtool_ops = port->orig_ethtool_ops; | 120 | dev->ethtool_ops = cpu_dp->orig_ethtool_ops; |
119 | port->orig_ethtool_ops = NULL; | 121 | cpu_dp->orig_ethtool_ops = NULL; |
120 | } | 122 | } |