Skip to content

Commit 7ec764e

Browse files
viviendavem330
authored andcommitted
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>
1 parent 3775b1b commit 7ec764e

1 file changed

Lines changed: 22 additions & 20 deletions

File tree

‎net/dsa/master.c‎

Lines changed: 22 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,10 @@ static void dsa_master_get_ethtool_stats(struct net_device *dev,
1717
uint64_t *data)
1818
{
1919
struct dsa_switch_tree *dst = dev->dsa_ptr;
20-
struct dsa_port *port = dst->cpu_dp;
21-
struct dsa_switch *ds = port->ds;
22-
const struct ethtool_ops *ops = port->orig_ethtool_ops;
20+
struct dsa_port *cpu_dp = dst->cpu_dp;
21+
const struct ethtool_ops *ops = cpu_dp->orig_ethtool_ops;
22+
struct dsa_switch *ds = cpu_dp->ds;
23+
int port = cpu_dp->index;
2324
int count = 0;
2425

2526
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,
2829
}
2930

3031
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);
3233
}
3334

3435
static int dsa_master_get_sset_count(struct net_device *dev, int sset)
3536
{
3637
struct dsa_switch_tree *dst = dev->dsa_ptr;
37-
struct dsa_port *port = dst->cpu_dp;
38-
struct dsa_switch *ds = port->ds;
39-
const struct ethtool_ops *ops = port->orig_ethtool_ops;
38+
struct dsa_port *cpu_dp = dst->cpu_dp;
39+
const struct ethtool_ops *ops = cpu_dp->orig_ethtool_ops;
40+
struct dsa_switch *ds = cpu_dp->ds;
4041
int count = 0;
4142

4243
if (ops && ops->get_sset_count)
@@ -52,16 +53,17 @@ static void dsa_master_get_strings(struct net_device *dev, uint32_t stringset,
5253
uint8_t *data)
5354
{
5455
struct dsa_switch_tree *dst = dev->dsa_ptr;
55-
struct dsa_port *port = dst->cpu_dp;
56-
struct dsa_switch *ds = port->ds;
57-
const struct ethtool_ops *ops = port->orig_ethtool_ops;
56+
struct dsa_port *cpu_dp = dst->cpu_dp;
57+
const struct ethtool_ops *ops = cpu_dp->orig_ethtool_ops;
58+
struct dsa_switch *ds = cpu_dp->ds;
59+
int port = cpu_dp->index;
5860
int len = ETH_GSTRING_LEN;
5961
int mcount = 0, count;
6062
unsigned int i;
6163
uint8_t pfx[4];
6264
uint8_t *ndata;
6365

64-
snprintf(pfx, sizeof(pfx), "p%.2d", port->index);
66+
snprintf(pfx, sizeof(pfx), "p%.2d", port);
6567
/* We do not want to be NULL-terminated, since this is a prefix */
6668
pfx[sizeof(pfx) - 1] = '_';
6769

@@ -76,7 +78,7 @@ static void dsa_master_get_strings(struct net_device *dev, uint32_t stringset,
7678
* the output after to prepend our CPU port prefix we
7779
* constructed earlier
7880
*/
79-
ds->ops->get_strings(ds, port->index, ndata);
81+
ds->ops->get_strings(ds, port, ndata);
8082
count = ds->ops->get_sset_count(ds);
8183
for (i = 0; i < count; i++) {
8284
memmove(ndata + (i * len + sizeof(pfx)),
@@ -89,17 +91,17 @@ static void dsa_master_get_strings(struct net_device *dev, uint32_t stringset,
8991
int dsa_master_ethtool_setup(struct net_device *dev)
9092
{
9193
struct dsa_switch_tree *dst = dev->dsa_ptr;
92-
struct dsa_port *port = dst->cpu_dp;
93-
struct dsa_switch *ds = port->ds;
94+
struct dsa_port *cpu_dp = dst->cpu_dp;
95+
struct dsa_switch *ds = cpu_dp->ds;
9496
struct ethtool_ops *ops;
9597

9698
ops = devm_kzalloc(ds->dev, sizeof(*ops), GFP_KERNEL);
9799
if (!ops)
98100
return -ENOMEM;
99101

100-
port->orig_ethtool_ops = dev->ethtool_ops;
101-
if (port->orig_ethtool_ops)
102-
memcpy(ops, port->orig_ethtool_ops, sizeof(*ops));
102+
cpu_dp->orig_ethtool_ops = dev->ethtool_ops;
103+
if (cpu_dp->orig_ethtool_ops)
104+
memcpy(ops, cpu_dp->orig_ethtool_ops, sizeof(*ops));
103105

104106
ops->get_sset_count = dsa_master_get_sset_count;
105107
ops->get_ethtool_stats = dsa_master_get_ethtool_stats;
@@ -113,8 +115,8 @@ int dsa_master_ethtool_setup(struct net_device *dev)
113115
void dsa_master_ethtool_restore(struct net_device *dev)
114116
{
115117
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;
117119

118-
dev->ethtool_ops = port->orig_ethtool_ops;
119-
port->orig_ethtool_ops = NULL;
120+
dev->ethtool_ops = cpu_dp->orig_ethtool_ops;
121+
cpu_dp->orig_ethtool_ops = NULL;
120122
}

0 commit comments

Comments
 (0)