aboutsummaryrefslogtreecommitdiffstats
path: root/net/dsa
diff options
context:
space:
mode:
authorVivien Didelot <vivien.didelot@savoirfairelinux.com>2016-08-23 12:38:56 -0400
committerDavid S. Miller <davem@davemloft.net>2016-08-25 00:45:39 -0400
commit9d490b4ee4d7d495a4f4908ea998d2a7355e0807 (patch)
treecb628c4a13aa0c6140d1eef84b64af7059659398 /net/dsa
parentc7b7b483ccc9d64ae577a04d490aa9a975afe891 (diff)
net: dsa: rename switch operations structure
Now that the dsa_switch_driver structure contains only function pointers as it is supposed to, rename it to the more appropriate dsa_switch_ops, uniformly to any other operations structure in the kernel. No functional changes here, basically just the result of something like: s/dsa_switch_driver *drv/dsa_switch_ops *ops/g However keep the {un,}register_switch_driver functions and their dsa_switch_drivers list as is, since they represent the -- likely to be deprecated soon -- legacy DSA registration framework. In the meantime, also fix the following checks from checkpatch.pl to make it happy with this patch: CHECK: Comparison to NULL could be written "!ops" #403: FILE: net/dsa/dsa.c:470: + if (ops == NULL) { CHECK: Comparison to NULL could be written "ds->ops->get_strings" #773: FILE: net/dsa/slave.c:697: + if (ds->ops->get_strings != NULL) CHECK: Comparison to NULL could be written "ds->ops->get_ethtool_stats" #824: FILE: net/dsa/slave.c:785: + if (ds->ops->get_ethtool_stats != NULL) CHECK: Comparison to NULL could be written "ds->ops->get_sset_count" #835: FILE: net/dsa/slave.c:798: + if (ds->ops->get_sset_count != NULL) total: 0 errors, 0 warnings, 4 checks, 784 lines checked Signed-off-by: Vivien Didelot <vivien.didelot@savoirfairelinux.com> Acked-by: Florian Fainelli <f.fainelli@gmail.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/dsa')
-rw-r--r--net/dsa/dsa.c70
-rw-r--r--net/dsa/dsa2.c16
-rw-r--r--net/dsa/slave.c146
3 files changed, 116 insertions, 116 deletions
diff --git a/net/dsa/dsa.c b/net/dsa/dsa.c
index 8d3a28d4e99d..d8d267e9a872 100644
--- a/net/dsa/dsa.c
+++ b/net/dsa/dsa.c
@@ -61,27 +61,27 @@ const struct dsa_device_ops *dsa_device_ops[DSA_TAG_LAST] = {
61static DEFINE_MUTEX(dsa_switch_drivers_mutex); 61static DEFINE_MUTEX(dsa_switch_drivers_mutex);
62static LIST_HEAD(dsa_switch_drivers); 62static LIST_HEAD(dsa_switch_drivers);
63 63
64void register_switch_driver(struct dsa_switch_driver *drv) 64void register_switch_driver(struct dsa_switch_ops *ops)
65{ 65{
66 mutex_lock(&dsa_switch_drivers_mutex); 66 mutex_lock(&dsa_switch_drivers_mutex);
67 list_add_tail(&drv->list, &dsa_switch_drivers); 67 list_add_tail(&ops->list, &dsa_switch_drivers);
68 mutex_unlock(&dsa_switch_drivers_mutex); 68 mutex_unlock(&dsa_switch_drivers_mutex);
69} 69}
70EXPORT_SYMBOL_GPL(register_switch_driver); 70EXPORT_SYMBOL_GPL(register_switch_driver);
71 71
72void unregister_switch_driver(struct dsa_switch_driver *drv) 72void unregister_switch_driver(struct dsa_switch_ops *ops)
73{ 73{
74 mutex_lock(&dsa_switch_drivers_mutex); 74 mutex_lock(&dsa_switch_drivers_mutex);
75 list_del_init(&drv->list); 75 list_del_init(&ops->list);
76 mutex_unlock(&dsa_switch_drivers_mutex); 76 mutex_unlock(&dsa_switch_drivers_mutex);
77} 77}
78EXPORT_SYMBOL_GPL(unregister_switch_driver); 78EXPORT_SYMBOL_GPL(unregister_switch_driver);
79 79
80static struct dsa_switch_driver * 80static struct dsa_switch_ops *
81dsa_switch_probe(struct device *parent, struct device *host_dev, int sw_addr, 81dsa_switch_probe(struct device *parent, struct device *host_dev, int sw_addr,
82 const char **_name, void **priv) 82 const char **_name, void **priv)
83{ 83{
84 struct dsa_switch_driver *ret; 84 struct dsa_switch_ops *ret;
85 struct list_head *list; 85 struct list_head *list;
86 const char *name; 86 const char *name;
87 87
@@ -90,13 +90,13 @@ dsa_switch_probe(struct device *parent, struct device *host_dev, int sw_addr,
90 90
91 mutex_lock(&dsa_switch_drivers_mutex); 91 mutex_lock(&dsa_switch_drivers_mutex);
92 list_for_each(list, &dsa_switch_drivers) { 92 list_for_each(list, &dsa_switch_drivers) {
93 struct dsa_switch_driver *drv; 93 struct dsa_switch_ops *ops;
94 94
95 drv = list_entry(list, struct dsa_switch_driver, list); 95 ops = list_entry(list, struct dsa_switch_ops, list);
96 96
97 name = drv->probe(parent, host_dev, sw_addr, priv); 97 name = ops->probe(parent, host_dev, sw_addr, priv);
98 if (name != NULL) { 98 if (name != NULL) {
99 ret = drv; 99 ret = ops;
100 break; 100 break;
101 } 101 }
102 } 102 }
@@ -117,7 +117,7 @@ static ssize_t temp1_input_show(struct device *dev,
117 struct dsa_switch *ds = dev_get_drvdata(dev); 117 struct dsa_switch *ds = dev_get_drvdata(dev);
118 int temp, ret; 118 int temp, ret;
119 119
120 ret = ds->drv->get_temp(ds, &temp); 120 ret = ds->ops->get_temp(ds, &temp);
121 if (ret < 0) 121 if (ret < 0)
122 return ret; 122 return ret;
123 123
@@ -131,7 +131,7 @@ static ssize_t temp1_max_show(struct device *dev,
131 struct dsa_switch *ds = dev_get_drvdata(dev); 131 struct dsa_switch *ds = dev_get_drvdata(dev);
132 int temp, ret; 132 int temp, ret;
133 133
134 ret = ds->drv->get_temp_limit(ds, &temp); 134 ret = ds->ops->get_temp_limit(ds, &temp);
135 if (ret < 0) 135 if (ret < 0)
136 return ret; 136 return ret;
137 137
@@ -149,7 +149,7 @@ static ssize_t temp1_max_store(struct device *dev,
149 if (ret < 0) 149 if (ret < 0)
150 return ret; 150 return ret;
151 151
152 ret = ds->drv->set_temp_limit(ds, DIV_ROUND_CLOSEST(temp, 1000)); 152 ret = ds->ops->set_temp_limit(ds, DIV_ROUND_CLOSEST(temp, 1000));
153 if (ret < 0) 153 if (ret < 0)
154 return ret; 154 return ret;
155 155
@@ -164,7 +164,7 @@ static ssize_t temp1_max_alarm_show(struct device *dev,
164 bool alarm; 164 bool alarm;
165 int ret; 165 int ret;
166 166
167 ret = ds->drv->get_temp_alarm(ds, &alarm); 167 ret = ds->ops->get_temp_alarm(ds, &alarm);
168 if (ret < 0) 168 if (ret < 0)
169 return ret; 169 return ret;
170 170
@@ -184,15 +184,15 @@ static umode_t dsa_hwmon_attrs_visible(struct kobject *kobj,
184{ 184{
185 struct device *dev = container_of(kobj, struct device, kobj); 185 struct device *dev = container_of(kobj, struct device, kobj);
186 struct dsa_switch *ds = dev_get_drvdata(dev); 186 struct dsa_switch *ds = dev_get_drvdata(dev);
187 struct dsa_switch_driver *drv = ds->drv; 187 struct dsa_switch_ops *ops = ds->ops;
188 umode_t mode = attr->mode; 188 umode_t mode = attr->mode;
189 189
190 if (index == 1) { 190 if (index == 1) {
191 if (!drv->get_temp_limit) 191 if (!ops->get_temp_limit)
192 mode = 0; 192 mode = 0;
193 else if (!drv->set_temp_limit) 193 else if (!ops->set_temp_limit)
194 mode &= ~S_IWUSR; 194 mode &= ~S_IWUSR;
195 } else if (index == 2 && !drv->get_temp_alarm) { 195 } else if (index == 2 && !ops->get_temp_alarm) {
196 mode = 0; 196 mode = 0;
197 } 197 }
198 return mode; 198 return mode;
@@ -228,8 +228,8 @@ int dsa_cpu_dsa_setup(struct dsa_switch *ds, struct device *dev,
228 228
229 genphy_config_init(phydev); 229 genphy_config_init(phydev);
230 genphy_read_status(phydev); 230 genphy_read_status(phydev);
231 if (ds->drv->adjust_link) 231 if (ds->ops->adjust_link)
232 ds->drv->adjust_link(ds, port, phydev); 232 ds->ops->adjust_link(ds, port, phydev);
233 } 233 }
234 234
235 return 0; 235 return 0;
@@ -303,7 +303,7 @@ void dsa_cpu_port_ethtool_restore(struct dsa_switch *ds)
303 303
304static int dsa_switch_setup_one(struct dsa_switch *ds, struct device *parent) 304static int dsa_switch_setup_one(struct dsa_switch *ds, struct device *parent)
305{ 305{
306 struct dsa_switch_driver *drv = ds->drv; 306 struct dsa_switch_ops *ops = ds->ops;
307 struct dsa_switch_tree *dst = ds->dst; 307 struct dsa_switch_tree *dst = ds->dst;
308 struct dsa_chip_data *cd = ds->cd; 308 struct dsa_chip_data *cd = ds->cd;
309 bool valid_name_found = false; 309 bool valid_name_found = false;
@@ -356,7 +356,7 @@ static int dsa_switch_setup_one(struct dsa_switch *ds, struct device *parent)
356 if (dst->cpu_switch == index) { 356 if (dst->cpu_switch == index) {
357 enum dsa_tag_protocol tag_protocol; 357 enum dsa_tag_protocol tag_protocol;
358 358
359 tag_protocol = drv->get_tag_protocol(ds); 359 tag_protocol = ops->get_tag_protocol(ds);
360 dst->tag_ops = dsa_resolve_tag_protocol(tag_protocol); 360 dst->tag_ops = dsa_resolve_tag_protocol(tag_protocol);
361 if (IS_ERR(dst->tag_ops)) { 361 if (IS_ERR(dst->tag_ops)) {
362 ret = PTR_ERR(dst->tag_ops); 362 ret = PTR_ERR(dst->tag_ops);
@@ -371,15 +371,15 @@ static int dsa_switch_setup_one(struct dsa_switch *ds, struct device *parent)
371 /* 371 /*
372 * Do basic register setup. 372 * Do basic register setup.
373 */ 373 */
374 ret = drv->setup(ds); 374 ret = ops->setup(ds);
375 if (ret < 0) 375 if (ret < 0)
376 goto out; 376 goto out;
377 377
378 ret = drv->set_addr(ds, dst->master_netdev->dev_addr); 378 ret = ops->set_addr(ds, dst->master_netdev->dev_addr);
379 if (ret < 0) 379 if (ret < 0)
380 goto out; 380 goto out;
381 381
382 if (!ds->slave_mii_bus && drv->phy_read) { 382 if (!ds->slave_mii_bus && ops->phy_read) {
383 ds->slave_mii_bus = devm_mdiobus_alloc(parent); 383 ds->slave_mii_bus = devm_mdiobus_alloc(parent);
384 if (!ds->slave_mii_bus) { 384 if (!ds->slave_mii_bus) {
385 ret = -ENOMEM; 385 ret = -ENOMEM;
@@ -426,7 +426,7 @@ static int dsa_switch_setup_one(struct dsa_switch *ds, struct device *parent)
426 * register with hardware monitoring subsystem. 426 * register with hardware monitoring subsystem.
427 * Treat registration error as non-fatal and ignore it. 427 * Treat registration error as non-fatal and ignore it.
428 */ 428 */
429 if (drv->get_temp) { 429 if (ops->get_temp) {
430 const char *netname = netdev_name(dst->master_netdev); 430 const char *netname = netdev_name(dst->master_netdev);
431 char hname[IFNAMSIZ + 1]; 431 char hname[IFNAMSIZ + 1];
432 int i, j; 432 int i, j;
@@ -457,7 +457,7 @@ dsa_switch_setup(struct dsa_switch_tree *dst, int index,
457 struct device *parent, struct device *host_dev) 457 struct device *parent, struct device *host_dev)
458{ 458{
459 struct dsa_chip_data *cd = dst->pd->chip + index; 459 struct dsa_chip_data *cd = dst->pd->chip + index;
460 struct dsa_switch_driver *drv; 460 struct dsa_switch_ops *ops;
461 struct dsa_switch *ds; 461 struct dsa_switch *ds;
462 int ret; 462 int ret;
463 const char *name; 463 const char *name;
@@ -466,8 +466,8 @@ dsa_switch_setup(struct dsa_switch_tree *dst, int index,
466 /* 466 /*
467 * Probe for switch model. 467 * Probe for switch model.
468 */ 468 */
469 drv = dsa_switch_probe(parent, host_dev, cd->sw_addr, &name, &priv); 469 ops = dsa_switch_probe(parent, host_dev, cd->sw_addr, &name, &priv);
470 if (drv == NULL) { 470 if (!ops) {
471 netdev_err(dst->master_netdev, "[%d]: could not detect attached switch\n", 471 netdev_err(dst->master_netdev, "[%d]: could not detect attached switch\n",
472 index); 472 index);
473 return ERR_PTR(-EINVAL); 473 return ERR_PTR(-EINVAL);
@@ -486,7 +486,7 @@ dsa_switch_setup(struct dsa_switch_tree *dst, int index,
486 ds->dst = dst; 486 ds->dst = dst;
487 ds->index = index; 487 ds->index = index;
488 ds->cd = cd; 488 ds->cd = cd;
489 ds->drv = drv; 489 ds->ops = ops;
490 ds->priv = priv; 490 ds->priv = priv;
491 ds->dev = parent; 491 ds->dev = parent;
492 492
@@ -541,7 +541,7 @@ static void dsa_switch_destroy(struct dsa_switch *ds)
541 ds->dsa_port_mask |= ~(1 << port); 541 ds->dsa_port_mask |= ~(1 << port);
542 } 542 }
543 543
544 if (ds->slave_mii_bus && ds->drv->phy_read) 544 if (ds->slave_mii_bus && ds->ops->phy_read)
545 mdiobus_unregister(ds->slave_mii_bus); 545 mdiobus_unregister(ds->slave_mii_bus);
546} 546}
547 547
@@ -560,8 +560,8 @@ int dsa_switch_suspend(struct dsa_switch *ds)
560 return ret; 560 return ret;
561 } 561 }
562 562
563 if (ds->drv->suspend) 563 if (ds->ops->suspend)
564 ret = ds->drv->suspend(ds); 564 ret = ds->ops->suspend(ds);
565 565
566 return ret; 566 return ret;
567} 567}
@@ -571,8 +571,8 @@ int dsa_switch_resume(struct dsa_switch *ds)
571{ 571{
572 int i, ret = 0; 572 int i, ret = 0;
573 573
574 if (ds->drv->resume) 574 if (ds->ops->resume)
575 ret = ds->drv->resume(ds); 575 ret = ds->ops->resume(ds);
576 576
577 if (ret) 577 if (ret)
578 return ret; 578 return ret;
diff --git a/net/dsa/dsa2.c b/net/dsa/dsa2.c
index 2e343221464c..8278385dcd21 100644
--- a/net/dsa/dsa2.c
+++ b/net/dsa/dsa2.c
@@ -294,25 +294,25 @@ static int dsa_ds_apply(struct dsa_switch_tree *dst, struct dsa_switch *ds)
294 int err; 294 int err;
295 295
296 /* Initialize ds->phys_mii_mask before registering the slave MDIO bus 296 /* Initialize ds->phys_mii_mask before registering the slave MDIO bus
297 * driver and before drv->setup() has run, since the switch drivers and 297 * driver and before ops->setup() has run, since the switch drivers and
298 * the slave MDIO bus driver rely on these values for probing PHY 298 * the slave MDIO bus driver rely on these values for probing PHY
299 * devices or not 299 * devices or not
300 */ 300 */
301 ds->phys_mii_mask = ds->enabled_port_mask; 301 ds->phys_mii_mask = ds->enabled_port_mask;
302 302
303 err = ds->drv->setup(ds); 303 err = ds->ops->setup(ds);
304 if (err < 0) 304 if (err < 0)
305 return err; 305 return err;
306 306
307 err = ds->drv->set_addr(ds, dst->master_netdev->dev_addr); 307 err = ds->ops->set_addr(ds, dst->master_netdev->dev_addr);
308 if (err < 0) 308 if (err < 0)
309 return err; 309 return err;
310 310
311 err = ds->drv->set_addr(ds, dst->master_netdev->dev_addr); 311 err = ds->ops->set_addr(ds, dst->master_netdev->dev_addr);
312 if (err < 0) 312 if (err < 0)
313 return err; 313 return err;
314 314
315 if (!ds->slave_mii_bus && ds->drv->phy_read) { 315 if (!ds->slave_mii_bus && ds->ops->phy_read) {
316 ds->slave_mii_bus = devm_mdiobus_alloc(ds->dev); 316 ds->slave_mii_bus = devm_mdiobus_alloc(ds->dev);
317 if (!ds->slave_mii_bus) 317 if (!ds->slave_mii_bus)
318 return -ENOMEM; 318 return -ENOMEM;
@@ -374,7 +374,7 @@ static void dsa_ds_unapply(struct dsa_switch_tree *dst, struct dsa_switch *ds)
374 dsa_user_port_unapply(port, index, ds); 374 dsa_user_port_unapply(port, index, ds);
375 } 375 }
376 376
377 if (ds->slave_mii_bus && ds->drv->phy_read) 377 if (ds->slave_mii_bus && ds->ops->phy_read)
378 mdiobus_unregister(ds->slave_mii_bus); 378 mdiobus_unregister(ds->slave_mii_bus);
379} 379}
380 380
@@ -466,7 +466,7 @@ static int dsa_cpu_parse(struct device_node *port, u32 index,
466 dst->cpu_port = index; 466 dst->cpu_port = index;
467 } 467 }
468 468
469 tag_protocol = ds->drv->get_tag_protocol(ds); 469 tag_protocol = ds->ops->get_tag_protocol(ds);
470 dst->tag_ops = dsa_resolve_tag_protocol(tag_protocol); 470 dst->tag_ops = dsa_resolve_tag_protocol(tag_protocol);
471 if (IS_ERR(dst->tag_ops)) { 471 if (IS_ERR(dst->tag_ops)) {
472 dev_warn(ds->dev, "No tagger for this switch\n"); 472 dev_warn(ds->dev, "No tagger for this switch\n");
@@ -543,7 +543,7 @@ static int dsa_parse_ports_dn(struct device_node *ports, struct dsa_switch *ds)
543 543
544 ds->ports[reg].dn = port; 544 ds->ports[reg].dn = port;
545 545
546 /* Initialize enabled_port_mask now for drv->setup() 546 /* Initialize enabled_port_mask now for ops->setup()
547 * to have access to a correct value, just like what 547 * to have access to a correct value, just like what
548 * net/dsa/dsa.c::dsa_switch_setup_one does. 548 * net/dsa/dsa.c::dsa_switch_setup_one does.
549 */ 549 */
diff --git a/net/dsa/slave.c b/net/dsa/slave.c
index fc9196745225..9f6c2a20f6ff 100644
--- a/net/dsa/slave.c
+++ b/net/dsa/slave.c
@@ -28,7 +28,7 @@ static int dsa_slave_phy_read(struct mii_bus *bus, int addr, int reg)
28 struct dsa_switch *ds = bus->priv; 28 struct dsa_switch *ds = bus->priv;
29 29
30 if (ds->phys_mii_mask & (1 << addr)) 30 if (ds->phys_mii_mask & (1 << addr))
31 return ds->drv->phy_read(ds, addr, reg); 31 return ds->ops->phy_read(ds, addr, reg);
32 32
33 return 0xffff; 33 return 0xffff;
34} 34}
@@ -38,7 +38,7 @@ static int dsa_slave_phy_write(struct mii_bus *bus, int addr, int reg, u16 val)
38 struct dsa_switch *ds = bus->priv; 38 struct dsa_switch *ds = bus->priv;
39 39
40 if (ds->phys_mii_mask & (1 << addr)) 40 if (ds->phys_mii_mask & (1 << addr))
41 return ds->drv->phy_write(ds, addr, reg, val); 41 return ds->ops->phy_write(ds, addr, reg, val);
42 42
43 return 0; 43 return 0;
44} 44}
@@ -98,14 +98,14 @@ static int dsa_slave_open(struct net_device *dev)
98 goto clear_allmulti; 98 goto clear_allmulti;
99 } 99 }
100 100
101 if (ds->drv->port_enable) { 101 if (ds->ops->port_enable) {
102 err = ds->drv->port_enable(ds, p->port, p->phy); 102 err = ds->ops->port_enable(ds, p->port, p->phy);
103 if (err) 103 if (err)
104 goto clear_promisc; 104 goto clear_promisc;
105 } 105 }
106 106
107 if (ds->drv->port_stp_state_set) 107 if (ds->ops->port_stp_state_set)
108 ds->drv->port_stp_state_set(ds, p->port, stp_state); 108 ds->ops->port_stp_state_set(ds, p->port, stp_state);
109 109
110 if (p->phy) 110 if (p->phy)
111 phy_start(p->phy); 111 phy_start(p->phy);
@@ -144,11 +144,11 @@ static int dsa_slave_close(struct net_device *dev)
144 if (!ether_addr_equal(dev->dev_addr, master->dev_addr)) 144 if (!ether_addr_equal(dev->dev_addr, master->dev_addr))
145 dev_uc_del(master, dev->dev_addr); 145 dev_uc_del(master, dev->dev_addr);
146 146
147 if (ds->drv->port_disable) 147 if (ds->ops->port_disable)
148 ds->drv->port_disable(ds, p->port, p->phy); 148 ds->ops->port_disable(ds, p->port, p->phy);
149 149
150 if (ds->drv->port_stp_state_set) 150 if (ds->ops->port_stp_state_set)
151 ds->drv->port_stp_state_set(ds, p->port, BR_STATE_DISABLED); 151 ds->ops->port_stp_state_set(ds, p->port, BR_STATE_DISABLED);
152 152
153 return 0; 153 return 0;
154} 154}
@@ -209,13 +209,13 @@ static int dsa_slave_port_vlan_add(struct net_device *dev,
209 struct dsa_switch *ds = p->parent; 209 struct dsa_switch *ds = p->parent;
210 210
211 if (switchdev_trans_ph_prepare(trans)) { 211 if (switchdev_trans_ph_prepare(trans)) {
212 if (!ds->drv->port_vlan_prepare || !ds->drv->port_vlan_add) 212 if (!ds->ops->port_vlan_prepare || !ds->ops->port_vlan_add)
213 return -EOPNOTSUPP; 213 return -EOPNOTSUPP;
214 214
215 return ds->drv->port_vlan_prepare(ds, p->port, vlan, trans); 215 return ds->ops->port_vlan_prepare(ds, p->port, vlan, trans);
216 } 216 }
217 217
218 ds->drv->port_vlan_add(ds, p->port, vlan, trans); 218 ds->ops->port_vlan_add(ds, p->port, vlan, trans);
219 219
220 return 0; 220 return 0;
221} 221}
@@ -226,10 +226,10 @@ static int dsa_slave_port_vlan_del(struct net_device *dev,
226 struct dsa_slave_priv *p = netdev_priv(dev); 226 struct dsa_slave_priv *p = netdev_priv(dev);
227 struct dsa_switch *ds = p->parent; 227 struct dsa_switch *ds = p->parent;
228 228
229 if (!ds->drv->port_vlan_del) 229 if (!ds->ops->port_vlan_del)
230 return -EOPNOTSUPP; 230 return -EOPNOTSUPP;
231 231
232 return ds->drv->port_vlan_del(ds, p->port, vlan); 232 return ds->ops->port_vlan_del(ds, p->port, vlan);
233} 233}
234 234
235static int dsa_slave_port_vlan_dump(struct net_device *dev, 235static int dsa_slave_port_vlan_dump(struct net_device *dev,
@@ -239,8 +239,8 @@ static int dsa_slave_port_vlan_dump(struct net_device *dev,
239 struct dsa_slave_priv *p = netdev_priv(dev); 239 struct dsa_slave_priv *p = netdev_priv(dev);
240 struct dsa_switch *ds = p->parent; 240 struct dsa_switch *ds = p->parent;
241 241
242 if (ds->drv->port_vlan_dump) 242 if (ds->ops->port_vlan_dump)
243 return ds->drv->port_vlan_dump(ds, p->port, vlan, cb); 243 return ds->ops->port_vlan_dump(ds, p->port, vlan, cb);
244 244
245 return -EOPNOTSUPP; 245 return -EOPNOTSUPP;
246} 246}
@@ -253,13 +253,13 @@ static int dsa_slave_port_fdb_add(struct net_device *dev,
253 struct dsa_switch *ds = p->parent; 253 struct dsa_switch *ds = p->parent;
254 254
255 if (switchdev_trans_ph_prepare(trans)) { 255 if (switchdev_trans_ph_prepare(trans)) {
256 if (!ds->drv->port_fdb_prepare || !ds->drv->port_fdb_add) 256 if (!ds->ops->port_fdb_prepare || !ds->ops->port_fdb_add)
257 return -EOPNOTSUPP; 257 return -EOPNOTSUPP;
258 258
259 return ds->drv->port_fdb_prepare(ds, p->port, fdb, trans); 259 return ds->ops->port_fdb_prepare(ds, p->port, fdb, trans);
260 } 260 }
261 261
262 ds->drv->port_fdb_add(ds, p->port, fdb, trans); 262 ds->ops->port_fdb_add(ds, p->port, fdb, trans);
263 263
264 return 0; 264 return 0;
265} 265}
@@ -271,8 +271,8 @@ static int dsa_slave_port_fdb_del(struct net_device *dev,
271 struct dsa_switch *ds = p->parent; 271 struct dsa_switch *ds = p->parent;
272 int ret = -EOPNOTSUPP; 272 int ret = -EOPNOTSUPP;
273 273
274 if (ds->drv->port_fdb_del) 274 if (ds->ops->port_fdb_del)
275 ret = ds->drv->port_fdb_del(ds, p->port, fdb); 275 ret = ds->ops->port_fdb_del(ds, p->port, fdb);
276 276
277 return ret; 277 return ret;
278} 278}
@@ -284,8 +284,8 @@ static int dsa_slave_port_fdb_dump(struct net_device *dev,
284 struct dsa_slave_priv *p = netdev_priv(dev); 284 struct dsa_slave_priv *p = netdev_priv(dev);
285 struct dsa_switch *ds = p->parent; 285 struct dsa_switch *ds = p->parent;
286 286
287 if (ds->drv->port_fdb_dump) 287 if (ds->ops->port_fdb_dump)
288 return ds->drv->port_fdb_dump(ds, p->port, fdb, cb); 288 return ds->ops->port_fdb_dump(ds, p->port, fdb, cb);
289 289
290 return -EOPNOTSUPP; 290 return -EOPNOTSUPP;
291} 291}
@@ -308,9 +308,9 @@ static int dsa_slave_stp_state_set(struct net_device *dev,
308 struct dsa_switch *ds = p->parent; 308 struct dsa_switch *ds = p->parent;
309 309
310 if (switchdev_trans_ph_prepare(trans)) 310 if (switchdev_trans_ph_prepare(trans))
311 return ds->drv->port_stp_state_set ? 0 : -EOPNOTSUPP; 311 return ds->ops->port_stp_state_set ? 0 : -EOPNOTSUPP;
312 312
313 ds->drv->port_stp_state_set(ds, p->port, attr->u.stp_state); 313 ds->ops->port_stp_state_set(ds, p->port, attr->u.stp_state);
314 314
315 return 0; 315 return 0;
316} 316}
@@ -326,8 +326,8 @@ static int dsa_slave_vlan_filtering(struct net_device *dev,
326 if (switchdev_trans_ph_prepare(trans)) 326 if (switchdev_trans_ph_prepare(trans))
327 return 0; 327 return 0;
328 328
329 if (ds->drv->port_vlan_filtering) 329 if (ds->ops->port_vlan_filtering)
330 return ds->drv->port_vlan_filtering(ds, p->port, 330 return ds->ops->port_vlan_filtering(ds, p->port,
331 attr->u.vlan_filtering); 331 attr->u.vlan_filtering);
332 332
333 return 0; 333 return 0;
@@ -365,8 +365,8 @@ static int dsa_slave_ageing_time(struct net_device *dev,
365 ds->ports[p->port].ageing_time = ageing_time; 365 ds->ports[p->port].ageing_time = ageing_time;
366 ageing_time = dsa_fastest_ageing_time(ds, ageing_time); 366 ageing_time = dsa_fastest_ageing_time(ds, ageing_time);
367 367
368 if (ds->drv->set_ageing_time) 368 if (ds->ops->set_ageing_time)
369 return ds->drv->set_ageing_time(ds, ageing_time); 369 return ds->ops->set_ageing_time(ds, ageing_time);
370 370
371 return 0; 371 return 0;
372} 372}
@@ -481,8 +481,8 @@ static int dsa_slave_bridge_port_join(struct net_device *dev,
481 481
482 p->bridge_dev = br; 482 p->bridge_dev = br;
483 483
484 if (ds->drv->port_bridge_join) 484 if (ds->ops->port_bridge_join)
485 ret = ds->drv->port_bridge_join(ds, p->port, br); 485 ret = ds->ops->port_bridge_join(ds, p->port, br);
486 486
487 return ret == -EOPNOTSUPP ? 0 : ret; 487 return ret == -EOPNOTSUPP ? 0 : ret;
488} 488}
@@ -493,16 +493,16 @@ static void dsa_slave_bridge_port_leave(struct net_device *dev)
493 struct dsa_switch *ds = p->parent; 493 struct dsa_switch *ds = p->parent;
494 494
495 495
496 if (ds->drv->port_bridge_leave) 496 if (ds->ops->port_bridge_leave)
497 ds->drv->port_bridge_leave(ds, p->port); 497 ds->ops->port_bridge_leave(ds, p->port);
498 498
499 p->bridge_dev = NULL; 499 p->bridge_dev = NULL;
500 500
501 /* Port left the bridge, put in BR_STATE_DISABLED by the bridge layer, 501 /* Port left the bridge, put in BR_STATE_DISABLED by the bridge layer,
502 * so allow it to be in BR_STATE_FORWARDING to be kept functional 502 * so allow it to be in BR_STATE_FORWARDING to be kept functional
503 */ 503 */
504 if (ds->drv->port_stp_state_set) 504 if (ds->ops->port_stp_state_set)
505 ds->drv->port_stp_state_set(ds, p->port, BR_STATE_FORWARDING); 505 ds->ops->port_stp_state_set(ds, p->port, BR_STATE_FORWARDING);
506} 506}
507 507
508static int dsa_slave_port_attr_get(struct net_device *dev, 508static int dsa_slave_port_attr_get(struct net_device *dev,
@@ -605,8 +605,8 @@ static int dsa_slave_get_regs_len(struct net_device *dev)
605 struct dsa_slave_priv *p = netdev_priv(dev); 605 struct dsa_slave_priv *p = netdev_priv(dev);
606 struct dsa_switch *ds = p->parent; 606 struct dsa_switch *ds = p->parent;
607 607
608 if (ds->drv->get_regs_len) 608 if (ds->ops->get_regs_len)
609 return ds->drv->get_regs_len(ds, p->port); 609 return ds->ops->get_regs_len(ds, p->port);
610 610
611 return -EOPNOTSUPP; 611 return -EOPNOTSUPP;
612} 612}
@@ -617,8 +617,8 @@ dsa_slave_get_regs(struct net_device *dev, struct ethtool_regs *regs, void *_p)
617 struct dsa_slave_priv *p = netdev_priv(dev); 617 struct dsa_slave_priv *p = netdev_priv(dev);
618 struct dsa_switch *ds = p->parent; 618 struct dsa_switch *ds = p->parent;
619 619
620 if (ds->drv->get_regs) 620 if (ds->ops->get_regs)
621 ds->drv->get_regs(ds, p->port, regs, _p); 621 ds->ops->get_regs(ds, p->port, regs, _p);
622} 622}
623 623
624static int dsa_slave_nway_reset(struct net_device *dev) 624static int dsa_slave_nway_reset(struct net_device *dev)
@@ -651,8 +651,8 @@ static int dsa_slave_get_eeprom_len(struct net_device *dev)
651 if (ds->cd && ds->cd->eeprom_len) 651 if (ds->cd && ds->cd->eeprom_len)
652 return ds->cd->eeprom_len; 652 return ds->cd->eeprom_len;
653 653
654 if (ds->drv->get_eeprom_len) 654 if (ds->ops->get_eeprom_len)
655 return ds->drv->get_eeprom_len(ds); 655 return ds->ops->get_eeprom_len(ds);
656 656
657 return 0; 657 return 0;
658} 658}
@@ -663,8 +663,8 @@ static int dsa_slave_get_eeprom(struct net_device *dev,
663 struct dsa_slave_priv *p = netdev_priv(dev); 663 struct dsa_slave_priv *p = netdev_priv(dev);
664 struct dsa_switch *ds = p->parent; 664 struct dsa_switch *ds = p->parent;
665 665
666 if (ds->drv->get_eeprom) 666 if (ds->ops->get_eeprom)
667 return ds->drv->get_eeprom(ds, eeprom, data); 667 return ds->ops->get_eeprom(ds, eeprom, data);
668 668
669 return -EOPNOTSUPP; 669 return -EOPNOTSUPP;
670} 670}
@@ -675,8 +675,8 @@ static int dsa_slave_set_eeprom(struct net_device *dev,
675 struct dsa_slave_priv *p = netdev_priv(dev); 675 struct dsa_slave_priv *p = netdev_priv(dev);
676 struct dsa_switch *ds = p->parent; 676 struct dsa_switch *ds = p->parent;
677 677
678 if (ds->drv->set_eeprom) 678 if (ds->ops->set_eeprom)
679 return ds->drv->set_eeprom(ds, eeprom, data); 679 return ds->ops->set_eeprom(ds, eeprom, data);
680 680
681 return -EOPNOTSUPP; 681 return -EOPNOTSUPP;
682} 682}
@@ -694,8 +694,8 @@ static void dsa_slave_get_strings(struct net_device *dev,
694 strncpy(data + len, "tx_bytes", len); 694 strncpy(data + len, "tx_bytes", len);
695 strncpy(data + 2 * len, "rx_packets", len); 695 strncpy(data + 2 * len, "rx_packets", len);
696 strncpy(data + 3 * len, "rx_bytes", len); 696 strncpy(data + 3 * len, "rx_bytes", len);
697 if (ds->drv->get_strings != NULL) 697 if (ds->ops->get_strings)
698 ds->drv->get_strings(ds, p->port, data + 4 * len); 698 ds->ops->get_strings(ds, p->port, data + 4 * len);
699 } 699 }
700} 700}
701 701
@@ -714,8 +714,8 @@ static void dsa_cpu_port_get_ethtool_stats(struct net_device *dev,
714 dst->master_ethtool_ops.get_ethtool_stats(dev, stats, data); 714 dst->master_ethtool_ops.get_ethtool_stats(dev, stats, data);
715 } 715 }
716 716
717 if (ds->drv->get_ethtool_stats) 717 if (ds->ops->get_ethtool_stats)
718 ds->drv->get_ethtool_stats(ds, cpu_port, data + count); 718 ds->ops->get_ethtool_stats(ds, cpu_port, data + count);
719} 719}
720 720
721static int dsa_cpu_port_get_sset_count(struct net_device *dev, int sset) 721static int dsa_cpu_port_get_sset_count(struct net_device *dev, int sset)
@@ -727,8 +727,8 @@ static int dsa_cpu_port_get_sset_count(struct net_device *dev, int sset)
727 if (dst->master_ethtool_ops.get_sset_count) 727 if (dst->master_ethtool_ops.get_sset_count)
728 count += dst->master_ethtool_ops.get_sset_count(dev, sset); 728 count += dst->master_ethtool_ops.get_sset_count(dev, sset);
729 729
730 if (sset == ETH_SS_STATS && ds->drv->get_sset_count) 730 if (sset == ETH_SS_STATS && ds->ops->get_sset_count)
731 count += ds->drv->get_sset_count(ds); 731 count += ds->ops->get_sset_count(ds);
732 732
733 return count; 733 return count;
734} 734}
@@ -755,14 +755,14 @@ static void dsa_cpu_port_get_strings(struct net_device *dev,
755 dst->master_ethtool_ops.get_strings(dev, stringset, data); 755 dst->master_ethtool_ops.get_strings(dev, stringset, data);
756 } 756 }
757 757
758 if (stringset == ETH_SS_STATS && ds->drv->get_strings) { 758 if (stringset == ETH_SS_STATS && ds->ops->get_strings) {
759 ndata = data + mcount * len; 759 ndata = data + mcount * len;
760 /* This function copies ETH_GSTRINGS_LEN bytes, we will mangle 760 /* This function copies ETH_GSTRINGS_LEN bytes, we will mangle
761 * the output after to prepend our CPU port prefix we 761 * the output after to prepend our CPU port prefix we
762 * constructed earlier 762 * constructed earlier
763 */ 763 */
764 ds->drv->get_strings(ds, cpu_port, ndata); 764 ds->ops->get_strings(ds, cpu_port, ndata);
765 count = ds->drv->get_sset_count(ds); 765 count = ds->ops->get_sset_count(ds);
766 for (i = 0; i < count; i++) { 766 for (i = 0; i < count; i++) {
767 memmove(ndata + (i * len + sizeof(pfx)), 767 memmove(ndata + (i * len + sizeof(pfx)),
768 ndata + i * len, len - sizeof(pfx)); 768 ndata + i * len, len - sizeof(pfx));
@@ -782,8 +782,8 @@ static void dsa_slave_get_ethtool_stats(struct net_device *dev,
782 data[1] = dev->stats.tx_bytes; 782 data[1] = dev->stats.tx_bytes;
783 data[2] = dev->stats.rx_packets; 783 data[2] = dev->stats.rx_packets;
784 data[3] = dev->stats.rx_bytes; 784 data[3] = dev->stats.rx_bytes;
785 if (ds->drv->get_ethtool_stats != NULL) 785 if (ds->ops->get_ethtool_stats)
786 ds->drv->get_ethtool_stats(ds, p->port, data + 4); 786 ds->ops->get_ethtool_stats(ds, p->port, data + 4);
787} 787}
788 788
789static int dsa_slave_get_sset_count(struct net_device *dev, int sset) 789static int dsa_slave_get_sset_count(struct net_device *dev, int sset)
@@ -795,8 +795,8 @@ static int dsa_slave_get_sset_count(struct net_device *dev, int sset)
795 int count; 795 int count;
796 796
797 count = 4; 797 count = 4;
798 if (ds->drv->get_sset_count != NULL) 798 if (ds->ops->get_sset_count)
799 count += ds->drv->get_sset_count(ds); 799 count += ds->ops->get_sset_count(ds);
800 800
801 return count; 801 return count;
802 } 802 }
@@ -809,8 +809,8 @@ static void dsa_slave_get_wol(struct net_device *dev, struct ethtool_wolinfo *w)
809 struct dsa_slave_priv *p = netdev_priv(dev); 809 struct dsa_slave_priv *p = netdev_priv(dev);
810 struct dsa_switch *ds = p->parent; 810 struct dsa_switch *ds = p->parent;
811 811
812 if (ds->drv->get_wol) 812 if (ds->ops->get_wol)
813 ds->drv->get_wol(ds, p->port, w); 813 ds->ops->get_wol(ds, p->port, w);
814} 814}
815 815
816static int dsa_slave_set_wol(struct net_device *dev, struct ethtool_wolinfo *w) 816static int dsa_slave_set_wol(struct net_device *dev, struct ethtool_wolinfo *w)
@@ -819,8 +819,8 @@ static int dsa_slave_set_wol(struct net_device *dev, struct ethtool_wolinfo *w)
819 struct dsa_switch *ds = p->parent; 819 struct dsa_switch *ds = p->parent;
820 int ret = -EOPNOTSUPP; 820 int ret = -EOPNOTSUPP;
821 821
822 if (ds->drv->set_wol) 822 if (ds->ops->set_wol)
823 ret = ds->drv->set_wol(ds, p->port, w); 823 ret = ds->ops->set_wol(ds, p->port, w);
824 824
825 return ret; 825 return ret;
826} 826}
@@ -831,10 +831,10 @@ static int dsa_slave_set_eee(struct net_device *dev, struct ethtool_eee *e)
831 struct dsa_switch *ds = p->parent; 831 struct dsa_switch *ds = p->parent;
832 int ret; 832 int ret;
833 833
834 if (!ds->drv->set_eee) 834 if (!ds->ops->set_eee)
835 return -EOPNOTSUPP; 835 return -EOPNOTSUPP;
836 836
837 ret = ds->drv->set_eee(ds, p->port, p->phy, e); 837 ret = ds->ops->set_eee(ds, p->port, p->phy, e);
838 if (ret) 838 if (ret)
839 return ret; 839 return ret;
840 840
@@ -850,10 +850,10 @@ static int dsa_slave_get_eee(struct net_device *dev, struct ethtool_eee *e)
850 struct dsa_switch *ds = p->parent; 850 struct dsa_switch *ds = p->parent;
851 int ret; 851 int ret;
852 852
853 if (!ds->drv->get_eee) 853 if (!ds->ops->get_eee)
854 return -EOPNOTSUPP; 854 return -EOPNOTSUPP;
855 855
856 ret = ds->drv->get_eee(ds, p->port, e); 856 ret = ds->ops->get_eee(ds, p->port, e);
857 if (ret) 857 if (ret)
858 return ret; 858 return ret;
859 859
@@ -988,8 +988,8 @@ static void dsa_slave_adjust_link(struct net_device *dev)
988 p->old_pause = p->phy->pause; 988 p->old_pause = p->phy->pause;
989 } 989 }
990 990
991 if (ds->drv->adjust_link && status_changed) 991 if (ds->ops->adjust_link && status_changed)
992 ds->drv->adjust_link(ds, p->port, p->phy); 992 ds->ops->adjust_link(ds, p->port, p->phy);
993 993
994 if (status_changed) 994 if (status_changed)
995 phy_print_status(p->phy); 995 phy_print_status(p->phy);
@@ -1004,8 +1004,8 @@ static int dsa_slave_fixed_link_update(struct net_device *dev,
1004 if (dev) { 1004 if (dev) {
1005 p = netdev_priv(dev); 1005 p = netdev_priv(dev);
1006 ds = p->parent; 1006 ds = p->parent;
1007 if (ds->drv->fixed_link_update) 1007 if (ds->ops->fixed_link_update)
1008 ds->drv->fixed_link_update(ds, p->port, status); 1008 ds->ops->fixed_link_update(ds, p->port, status);
1009 } 1009 }
1010 1010
1011 return 0; 1011 return 0;
@@ -1062,8 +1062,8 @@ static int dsa_slave_phy_setup(struct dsa_slave_priv *p,
1062 phy_dn = port_dn; 1062 phy_dn = port_dn;
1063 } 1063 }
1064 1064
1065 if (ds->drv->get_phy_flags) 1065 if (ds->ops->get_phy_flags)
1066 phy_flags = ds->drv->get_phy_flags(ds, p->port); 1066 phy_flags = ds->ops->get_phy_flags(ds, p->port);
1067 1067
1068 if (phy_dn) { 1068 if (phy_dn) {
1069 int phy_id = of_mdio_parse_addr(&slave_dev->dev, phy_dn); 1069 int phy_id = of_mdio_parse_addr(&slave_dev->dev, phy_dn);