@@ -78,14 +78,19 @@ static void dsa_dst_del_ds(struct dsa_switch_tree *dst,
78
78
kref_put (& dst -> refcount , dsa_free_dst );
79
79
}
80
80
81
- static bool dsa_port_is_dsa (struct device_node * port )
81
+ static bool dsa_port_is_valid (struct dsa_port * port )
82
82
{
83
- return !!of_parse_phandle ( port , "link" , 0 ) ;
83
+ return !!port -> dn ;
84
84
}
85
85
86
- static bool dsa_port_is_cpu (struct device_node * port )
86
+ static bool dsa_port_is_dsa (struct dsa_port * port )
87
87
{
88
- return !!of_parse_phandle (port , "ethernet" , 0 );
88
+ return !!of_parse_phandle (port -> dn , "link" , 0 );
89
+ }
90
+
91
+ static bool dsa_port_is_cpu (struct dsa_port * port )
92
+ {
93
+ return !!of_parse_phandle (port -> dn , "ethernet" , 0 );
89
94
}
90
95
91
96
static bool dsa_ds_find_port (struct dsa_switch * ds ,
@@ -119,15 +124,15 @@ static struct dsa_switch *dsa_dst_find_port(struct dsa_switch_tree *dst,
119
124
120
125
static int dsa_port_complete (struct dsa_switch_tree * dst ,
121
126
struct dsa_switch * src_ds ,
122
- struct device_node * port ,
127
+ struct dsa_port * port ,
123
128
u32 src_port )
124
129
{
125
130
struct device_node * link ;
126
131
int index ;
127
132
struct dsa_switch * dst_ds ;
128
133
129
134
for (index = 0 ;; index ++ ) {
130
- link = of_parse_phandle (port , "link" , index );
135
+ link = of_parse_phandle (port -> dn , "link" , index );
131
136
if (!link )
132
137
break ;
133
138
@@ -150,13 +155,13 @@ static int dsa_port_complete(struct dsa_switch_tree *dst,
150
155
*/
151
156
static int dsa_ds_complete (struct dsa_switch_tree * dst , struct dsa_switch * ds )
152
157
{
153
- struct device_node * port ;
158
+ struct dsa_port * port ;
154
159
u32 index ;
155
160
int err ;
156
161
157
162
for (index = 0 ; index < DSA_MAX_PORTS ; index ++ ) {
158
- port = ds -> ports [index ]. dn ;
159
- if (!port )
163
+ port = & ds -> ports [index ];
164
+ if (!dsa_port_is_valid ( port ) )
160
165
continue ;
161
166
162
167
if (!dsa_port_is_dsa (port ))
@@ -196,7 +201,7 @@ static int dsa_dst_complete(struct dsa_switch_tree *dst)
196
201
return 0 ;
197
202
}
198
203
199
- static int dsa_dsa_port_apply (struct device_node * port , u32 index ,
204
+ static int dsa_dsa_port_apply (struct dsa_port * port , u32 index ,
200
205
struct dsa_switch * ds )
201
206
{
202
207
int err ;
@@ -211,13 +216,13 @@ static int dsa_dsa_port_apply(struct device_node *port, u32 index,
211
216
return 0 ;
212
217
}
213
218
214
- static void dsa_dsa_port_unapply (struct device_node * port , u32 index ,
219
+ static void dsa_dsa_port_unapply (struct dsa_port * port , u32 index ,
215
220
struct dsa_switch * ds )
216
221
{
217
222
dsa_cpu_dsa_destroy (port );
218
223
}
219
224
220
- static int dsa_cpu_port_apply (struct device_node * port , u32 index ,
225
+ static int dsa_cpu_port_apply (struct dsa_port * port , u32 index ,
221
226
struct dsa_switch * ds )
222
227
{
223
228
int err ;
@@ -234,21 +239,21 @@ static int dsa_cpu_port_apply(struct device_node *port, u32 index,
234
239
return 0 ;
235
240
}
236
241
237
- static void dsa_cpu_port_unapply (struct device_node * port , u32 index ,
242
+ static void dsa_cpu_port_unapply (struct dsa_port * port , u32 index ,
238
243
struct dsa_switch * ds )
239
244
{
240
245
dsa_cpu_dsa_destroy (port );
241
246
ds -> cpu_port_mask &= ~BIT (index );
242
247
243
248
}
244
249
245
- static int dsa_user_port_apply (struct device_node * port , u32 index ,
250
+ static int dsa_user_port_apply (struct dsa_port * port , u32 index ,
246
251
struct dsa_switch * ds )
247
252
{
248
253
const char * name ;
249
254
int err ;
250
255
251
- name = of_get_property (port , "label" , NULL );
256
+ name = of_get_property (port -> dn , "label" , NULL );
252
257
if (!name )
253
258
name = "eth%d" ;
254
259
@@ -262,7 +267,7 @@ static int dsa_user_port_apply(struct device_node *port, u32 index,
262
267
return 0 ;
263
268
}
264
269
265
- static void dsa_user_port_unapply (struct device_node * port , u32 index ,
270
+ static void dsa_user_port_unapply (struct dsa_port * port , u32 index ,
266
271
struct dsa_switch * ds )
267
272
{
268
273
if (ds -> ports [index ].netdev ) {
@@ -274,7 +279,7 @@ static void dsa_user_port_unapply(struct device_node *port, u32 index,
274
279
275
280
static int dsa_ds_apply (struct dsa_switch_tree * dst , struct dsa_switch * ds )
276
281
{
277
- struct device_node * port ;
282
+ struct dsa_port * port ;
278
283
u32 index ;
279
284
int err ;
280
285
@@ -308,8 +313,8 @@ static int dsa_ds_apply(struct dsa_switch_tree *dst, struct dsa_switch *ds)
308
313
}
309
314
310
315
for (index = 0 ; index < DSA_MAX_PORTS ; index ++ ) {
311
- port = ds -> ports [index ]. dn ;
312
- if (!port )
316
+ port = & ds -> ports [index ];
317
+ if (!dsa_port_is_valid ( port ) )
313
318
continue ;
314
319
315
320
if (dsa_port_is_dsa (port )) {
@@ -336,12 +341,12 @@ static int dsa_ds_apply(struct dsa_switch_tree *dst, struct dsa_switch *ds)
336
341
337
342
static void dsa_ds_unapply (struct dsa_switch_tree * dst , struct dsa_switch * ds )
338
343
{
339
- struct device_node * port ;
344
+ struct dsa_port * port ;
340
345
u32 index ;
341
346
342
347
for (index = 0 ; index < DSA_MAX_PORTS ; index ++ ) {
343
- port = ds -> ports [index ]. dn ;
344
- if (!port )
348
+ port = & ds -> ports [index ];
349
+ if (!dsa_port_is_valid ( port ) )
345
350
continue ;
346
351
347
352
if (dsa_port_is_dsa (port )) {
@@ -425,15 +430,15 @@ static void dsa_dst_unapply(struct dsa_switch_tree *dst)
425
430
dst -> applied = false;
426
431
}
427
432
428
- static int dsa_cpu_parse (struct device_node * port , u32 index ,
433
+ static int dsa_cpu_parse (struct dsa_port * port , u32 index ,
429
434
struct dsa_switch_tree * dst ,
430
435
struct dsa_switch * ds )
431
436
{
432
437
enum dsa_tag_protocol tag_protocol ;
433
438
struct net_device * ethernet_dev ;
434
439
struct device_node * ethernet ;
435
440
436
- ethernet = of_parse_phandle (port , "ethernet" , 0 );
441
+ ethernet = of_parse_phandle (port -> dn , "ethernet" , 0 );
437
442
if (!ethernet )
438
443
return - EINVAL ;
439
444
@@ -466,13 +471,13 @@ static int dsa_cpu_parse(struct device_node *port, u32 index,
466
471
467
472
static int dsa_ds_parse (struct dsa_switch_tree * dst , struct dsa_switch * ds )
468
473
{
469
- struct device_node * port ;
474
+ struct dsa_port * port ;
470
475
u32 index ;
471
476
int err ;
472
477
473
478
for (index = 0 ; index < DSA_MAX_PORTS ; index ++ ) {
474
- port = ds -> ports [index ]. dn ;
475
- if (!port )
479
+ port = & ds -> ports [index ];
480
+ if (!dsa_port_is_valid ( port ) )
476
481
continue ;
477
482
478
483
if (dsa_port_is_cpu (port )) {
@@ -533,7 +538,7 @@ static int dsa_parse_ports_dn(struct device_node *ports, struct dsa_switch *ds)
533
538
* to have access to a correct value, just like what
534
539
* net/dsa/dsa.c::dsa_switch_setup_one does.
535
540
*/
536
- if (!dsa_port_is_cpu (port ))
541
+ if (!dsa_port_is_cpu (& ds -> ports [ reg ] ))
537
542
ds -> enabled_port_mask |= 1 << reg ;
538
543
}
539
544
0 commit comments