Skip to content

Commit 158bc06

Browse files
lunndavem330
authored andcommitted
net: dsa: mv88e6xxx: replace ds with ps where possible
The dsa_switch structure ds is actually needed in very few places, mostly during setup of the switch. The private structure ps is however needed nearly everywhere. Pass ps, not ds internally. [vd: rebased Andrew's patch.] Signed-off-by: Andrew Lunn <[email protected]> Signed-off-by: Vivien Didelot <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 8cd14cc commit 158bc06

File tree

6 files changed

+511
-494
lines changed

6 files changed

+511
-494
lines changed

drivers/net/dsa/mv88e6123.c

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ static const char *mv88e6123_drv_probe(struct device *dsa_dev,
5050

5151
static int mv88e6123_setup_global(struct dsa_switch *ds)
5252
{
53+
struct mv88e6xxx_priv_state *ps = ds_to_priv(ds);
5354
u32 upstream_port = dsa_upstream_port(ds);
5455
int ret;
5556
u32 reg;
@@ -62,7 +63,7 @@ static int mv88e6123_setup_global(struct dsa_switch *ds)
6263
* external PHYs to poll), don't discard packets with
6364
* excessive collisions, and mask all interrupt sources.
6465
*/
65-
ret = mv88e6xxx_reg_write(ds, REG_GLOBAL, GLOBAL_CONTROL, 0x0000);
66+
ret = mv88e6xxx_reg_write(ps, REG_GLOBAL, GLOBAL_CONTROL, 0x0000);
6667
if (ret)
6768
return ret;
6869

@@ -73,26 +74,29 @@ static int mv88e6123_setup_global(struct dsa_switch *ds)
7374
reg = upstream_port << GLOBAL_MONITOR_CONTROL_INGRESS_SHIFT |
7475
upstream_port << GLOBAL_MONITOR_CONTROL_EGRESS_SHIFT |
7576
upstream_port << GLOBAL_MONITOR_CONTROL_ARP_SHIFT;
76-
ret = mv88e6xxx_reg_write(ds, REG_GLOBAL, GLOBAL_MONITOR_CONTROL, reg);
77+
ret = mv88e6xxx_reg_write(ps, REG_GLOBAL, GLOBAL_MONITOR_CONTROL, reg);
7778
if (ret)
7879
return ret;
7980

8081
/* Disable remote management for now, and set the switch's
8182
* DSA device number.
8283
*/
83-
return mv88e6xxx_reg_write(ds, REG_GLOBAL, GLOBAL_CONTROL_2,
84+
return mv88e6xxx_reg_write(ps, REG_GLOBAL, GLOBAL_CONTROL_2,
8485
ds->index & 0x1f);
8586
}
8687

8788
static int mv88e6123_setup(struct dsa_switch *ds)
8889
{
90+
struct mv88e6xxx_priv_state *ps = ds_to_priv(ds);
8991
int ret;
9092

91-
ret = mv88e6xxx_setup_common(ds);
93+
ps->ds = ds;
94+
95+
ret = mv88e6xxx_setup_common(ps);
9296
if (ret < 0)
9397
return ret;
9498

95-
ret = mv88e6xxx_switch_reset(ds, false);
99+
ret = mv88e6xxx_switch_reset(ps, false);
96100
if (ret < 0)
97101
return ret;
98102

drivers/net/dsa/mv88e6131.c

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ static const char *mv88e6131_drv_probe(struct device *dsa_dev,
5656

5757
static int mv88e6131_setup_global(struct dsa_switch *ds)
5858
{
59+
struct mv88e6xxx_priv_state *ps = ds_to_priv(ds);
5960
u32 upstream_port = dsa_upstream_port(ds);
6061
int ret;
6162
u32 reg;
@@ -69,14 +70,14 @@ static int mv88e6131_setup_global(struct dsa_switch *ds)
6970
* to arbitrate between packet queues, set the maximum frame
7071
* size to 1632, and mask all interrupt sources.
7172
*/
72-
ret = mv88e6xxx_reg_write(ds, REG_GLOBAL, GLOBAL_CONTROL,
73+
ret = mv88e6xxx_reg_write(ps, REG_GLOBAL, GLOBAL_CONTROL,
7374
GLOBAL_CONTROL_PPU_ENABLE |
7475
GLOBAL_CONTROL_MAX_FRAME_1632);
7576
if (ret)
7677
return ret;
7778

7879
/* Set the VLAN ethertype to 0x8100. */
79-
ret = mv88e6xxx_reg_write(ds, REG_GLOBAL, GLOBAL_CORE_TAG_TYPE, 0x8100);
80+
ret = mv88e6xxx_reg_write(ps, REG_GLOBAL, GLOBAL_CORE_TAG_TYPE, 0x8100);
8081
if (ret)
8182
return ret;
8283

@@ -87,7 +88,7 @@ static int mv88e6131_setup_global(struct dsa_switch *ds)
8788
reg = upstream_port << GLOBAL_MONITOR_CONTROL_INGRESS_SHIFT |
8889
upstream_port << GLOBAL_MONITOR_CONTROL_EGRESS_SHIFT |
8990
GLOBAL_MONITOR_CONTROL_ARP_DISABLED;
90-
ret = mv88e6xxx_reg_write(ds, REG_GLOBAL, GLOBAL_MONITOR_CONTROL, reg);
91+
ret = mv88e6xxx_reg_write(ps, REG_GLOBAL, GLOBAL_MONITOR_CONTROL, reg);
9192
if (ret)
9293
return ret;
9394

@@ -96,11 +97,11 @@ static int mv88e6131_setup_global(struct dsa_switch *ds)
9697
* DSA device number.
9798
*/
9899
if (ds->dst->pd->nr_chips > 1)
99-
ret = mv88e6xxx_reg_write(ds, REG_GLOBAL, GLOBAL_CONTROL_2,
100+
ret = mv88e6xxx_reg_write(ps, REG_GLOBAL, GLOBAL_CONTROL_2,
100101
GLOBAL_CONTROL_2_MULTIPLE_CASCADE |
101102
(ds->index & 0x1f));
102103
else
103-
ret = mv88e6xxx_reg_write(ds, REG_GLOBAL, GLOBAL_CONTROL_2,
104+
ret = mv88e6xxx_reg_write(ps, REG_GLOBAL, GLOBAL_CONTROL_2,
104105
GLOBAL_CONTROL_2_NO_CASCADE |
105106
(ds->index & 0x1f));
106107
if (ret)
@@ -109,7 +110,7 @@ static int mv88e6131_setup_global(struct dsa_switch *ds)
109110
/* Force the priority of IGMP/MLD snoop frames and ARP frames
110111
* to the highest setting.
111112
*/
112-
return mv88e6xxx_reg_write(ds, REG_GLOBAL2, GLOBAL2_PRIO_OVERRIDE,
113+
return mv88e6xxx_reg_write(ps, REG_GLOBAL2, GLOBAL2_PRIO_OVERRIDE,
113114
GLOBAL2_PRIO_OVERRIDE_FORCE_SNOOP |
114115
7 << GLOBAL2_PRIO_OVERRIDE_SNOOP_SHIFT |
115116
GLOBAL2_PRIO_OVERRIDE_FORCE_ARP |
@@ -118,15 +119,18 @@ static int mv88e6131_setup_global(struct dsa_switch *ds)
118119

119120
static int mv88e6131_setup(struct dsa_switch *ds)
120121
{
122+
struct mv88e6xxx_priv_state *ps = ds_to_priv(ds);
121123
int ret;
122124

123-
ret = mv88e6xxx_setup_common(ds);
125+
ps->ds = ds;
126+
127+
ret = mv88e6xxx_setup_common(ps);
124128
if (ret < 0)
125129
return ret;
126130

127-
mv88e6xxx_ppu_state_init(ds);
131+
mv88e6xxx_ppu_state_init(ps);
128132

129-
ret = mv88e6xxx_switch_reset(ds, false);
133+
ret = mv88e6xxx_switch_reset(ps, false);
130134
if (ret < 0)
131135
return ret;
132136

drivers/net/dsa/mv88e6171.c

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ static const char *mv88e6171_drv_probe(struct device *dsa_dev,
5656

5757
static int mv88e6171_setup_global(struct dsa_switch *ds)
5858
{
59+
struct mv88e6xxx_priv_state *ps = ds_to_priv(ds);
5960
u32 upstream_port = dsa_upstream_port(ds);
6061
int ret;
6162
u32 reg;
@@ -67,7 +68,7 @@ static int mv88e6171_setup_global(struct dsa_switch *ds)
6768
/* Discard packets with excessive collisions, mask all
6869
* interrupt sources, enable PPU.
6970
*/
70-
ret = mv88e6xxx_reg_write(ds, REG_GLOBAL, GLOBAL_CONTROL,
71+
ret = mv88e6xxx_reg_write(ps, REG_GLOBAL, GLOBAL_CONTROL,
7172
GLOBAL_CONTROL_PPU_ENABLE |
7273
GLOBAL_CONTROL_DISCARD_EXCESS);
7374
if (ret)
@@ -81,26 +82,29 @@ static int mv88e6171_setup_global(struct dsa_switch *ds)
8182
upstream_port << GLOBAL_MONITOR_CONTROL_EGRESS_SHIFT |
8283
upstream_port << GLOBAL_MONITOR_CONTROL_ARP_SHIFT |
8384
upstream_port << GLOBAL_MONITOR_CONTROL_MIRROR_SHIFT;
84-
ret = mv88e6xxx_reg_write(ds, REG_GLOBAL, GLOBAL_MONITOR_CONTROL, reg);
85+
ret = mv88e6xxx_reg_write(ps, REG_GLOBAL, GLOBAL_MONITOR_CONTROL, reg);
8586
if (ret)
8687
return ret;
8788

8889
/* Disable remote management for now, and set the switch's
8990
* DSA device number.
9091
*/
91-
return mv88e6xxx_reg_write(ds, REG_GLOBAL, GLOBAL_CONTROL_2,
92+
return mv88e6xxx_reg_write(ps, REG_GLOBAL, GLOBAL_CONTROL_2,
9293
ds->index & 0x1f);
9394
}
9495

9596
static int mv88e6171_setup(struct dsa_switch *ds)
9697
{
98+
struct mv88e6xxx_priv_state *ps = ds_to_priv(ds);
9799
int ret;
98100

99-
ret = mv88e6xxx_setup_common(ds);
101+
ps->ds = ds;
102+
103+
ret = mv88e6xxx_setup_common(ps);
100104
if (ret < 0)
101105
return ret;
102106

103-
ret = mv88e6xxx_switch_reset(ds, true);
107+
ret = mv88e6xxx_switch_reset(ps, true);
104108
if (ret < 0)
105109
return ret;
106110

drivers/net/dsa/mv88e6352.c

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ static const char *mv88e6352_drv_probe(struct device *dsa_dev,
7373

7474
static int mv88e6352_setup_global(struct dsa_switch *ds)
7575
{
76+
struct mv88e6xxx_priv_state *ps = ds_to_priv(ds);
7677
u32 upstream_port = dsa_upstream_port(ds);
7778
int ret;
7879
u32 reg;
@@ -84,7 +85,7 @@ static int mv88e6352_setup_global(struct dsa_switch *ds)
8485
/* Discard packets with excessive collisions,
8586
* mask all interrupt sources, enable PPU (bit 14, undocumented).
8687
*/
87-
ret = mv88e6xxx_reg_write(ds, REG_GLOBAL, GLOBAL_CONTROL,
88+
ret = mv88e6xxx_reg_write(ps, REG_GLOBAL, GLOBAL_CONTROL,
8889
GLOBAL_CONTROL_PPU_ENABLE |
8990
GLOBAL_CONTROL_DISCARD_EXCESS);
9091
if (ret)
@@ -97,28 +98,30 @@ static int mv88e6352_setup_global(struct dsa_switch *ds)
9798
reg = upstream_port << GLOBAL_MONITOR_CONTROL_INGRESS_SHIFT |
9899
upstream_port << GLOBAL_MONITOR_CONTROL_EGRESS_SHIFT |
99100
upstream_port << GLOBAL_MONITOR_CONTROL_ARP_SHIFT;
100-
ret = mv88e6xxx_reg_write(ds, REG_GLOBAL, GLOBAL_MONITOR_CONTROL, reg);
101+
ret = mv88e6xxx_reg_write(ps, REG_GLOBAL, GLOBAL_MONITOR_CONTROL, reg);
101102
if (ret)
102103
return ret;
103104

104105
/* Disable remote management for now, and set the switch's
105106
* DSA device number.
106107
*/
107-
return mv88e6xxx_reg_write(ds, REG_GLOBAL, 0x1c, ds->index & 0x1f);
108+
return mv88e6xxx_reg_write(ps, REG_GLOBAL, 0x1c, ds->index & 0x1f);
108109
}
109110

110111
static int mv88e6352_setup(struct dsa_switch *ds)
111112
{
112113
struct mv88e6xxx_priv_state *ps = ds_to_priv(ds);
113114
int ret;
114115

115-
ret = mv88e6xxx_setup_common(ds);
116+
ps->ds = ds;
117+
118+
ret = mv88e6xxx_setup_common(ps);
116119
if (ret < 0)
117120
return ret;
118121

119122
mutex_init(&ps->eeprom_mutex);
120123

121-
ret = mv88e6xxx_switch_reset(ds, true);
124+
ret = mv88e6xxx_switch_reset(ps, true);
122125
if (ret < 0)
123126
return ret;
124127

@@ -136,7 +139,7 @@ static int mv88e6352_read_eeprom_word(struct dsa_switch *ds, int addr)
136139

137140
mutex_lock(&ps->eeprom_mutex);
138141

139-
ret = mv88e6xxx_reg_write(ds, REG_GLOBAL2, GLOBAL2_EEPROM_OP,
142+
ret = mv88e6xxx_reg_write(ps, REG_GLOBAL2, GLOBAL2_EEPROM_OP,
140143
GLOBAL2_EEPROM_OP_READ |
141144
(addr & GLOBAL2_EEPROM_OP_ADDR_MASK));
142145
if (ret < 0)
@@ -146,7 +149,7 @@ static int mv88e6352_read_eeprom_word(struct dsa_switch *ds, int addr)
146149
if (ret < 0)
147150
goto error;
148151

149-
ret = mv88e6xxx_reg_read(ds, REG_GLOBAL2, GLOBAL2_EEPROM_DATA);
152+
ret = mv88e6xxx_reg_read(ps, REG_GLOBAL2, GLOBAL2_EEPROM_DATA);
150153
error:
151154
mutex_unlock(&ps->eeprom_mutex);
152155
return ret;
@@ -217,9 +220,10 @@ static int mv88e6352_get_eeprom(struct dsa_switch *ds,
217220

218221
static int mv88e6352_eeprom_is_readonly(struct dsa_switch *ds)
219222
{
223+
struct mv88e6xxx_priv_state *ps = ds_to_priv(ds);
220224
int ret;
221225

222-
ret = mv88e6xxx_reg_read(ds, REG_GLOBAL2, GLOBAL2_EEPROM_OP);
226+
ret = mv88e6xxx_reg_read(ps, REG_GLOBAL2, GLOBAL2_EEPROM_OP);
223227
if (ret < 0)
224228
return ret;
225229

@@ -237,11 +241,11 @@ static int mv88e6352_write_eeprom_word(struct dsa_switch *ds, int addr,
237241

238242
mutex_lock(&ps->eeprom_mutex);
239243

240-
ret = mv88e6xxx_reg_write(ds, REG_GLOBAL2, GLOBAL2_EEPROM_DATA, data);
244+
ret = mv88e6xxx_reg_write(ps, REG_GLOBAL2, GLOBAL2_EEPROM_DATA, data);
241245
if (ret < 0)
242246
goto error;
243247

244-
ret = mv88e6xxx_reg_write(ds, REG_GLOBAL2, GLOBAL2_EEPROM_OP,
248+
ret = mv88e6xxx_reg_write(ps, REG_GLOBAL2, GLOBAL2_EEPROM_OP,
245249
GLOBAL2_EEPROM_OP_WRITE |
246250
(addr & GLOBAL2_EEPROM_OP_ADDR_MASK));
247251
if (ret < 0)

0 commit comments

Comments
 (0)