diff options
author | Vivien Didelot <vivien.didelot@savoirfairelinux.com> | 2016-08-23 12:38:56 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2016-08-25 00:45:39 -0400 |
commit | 9d490b4ee4d7d495a4f4908ea998d2a7355e0807 (patch) | |
tree | cb628c4a13aa0c6140d1eef84b64af7059659398 /net/dsa/dsa.c | |
parent | c7b7b483ccc9d64ae577a04d490aa9a975afe891 (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/dsa.c')
-rw-r--r-- | net/dsa/dsa.c | 70 |
1 files changed, 35 insertions, 35 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] = { | |||
61 | static DEFINE_MUTEX(dsa_switch_drivers_mutex); | 61 | static DEFINE_MUTEX(dsa_switch_drivers_mutex); |
62 | static LIST_HEAD(dsa_switch_drivers); | 62 | static LIST_HEAD(dsa_switch_drivers); |
63 | 63 | ||
64 | void register_switch_driver(struct dsa_switch_driver *drv) | 64 | void 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 | } |
70 | EXPORT_SYMBOL_GPL(register_switch_driver); | 70 | EXPORT_SYMBOL_GPL(register_switch_driver); |
71 | 71 | ||
72 | void unregister_switch_driver(struct dsa_switch_driver *drv) | 72 | void 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 | } |
78 | EXPORT_SYMBOL_GPL(unregister_switch_driver); | 78 | EXPORT_SYMBOL_GPL(unregister_switch_driver); |
79 | 79 | ||
80 | static struct dsa_switch_driver * | 80 | static struct dsa_switch_ops * |
81 | dsa_switch_probe(struct device *parent, struct device *host_dev, int sw_addr, | 81 | dsa_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 | ||
304 | static int dsa_switch_setup_one(struct dsa_switch *ds, struct device *parent) | 304 | static 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; |