diff options
author | Florian Fainelli <f.fainelli@gmail.com> | 2017-01-08 17:52:07 -0500 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2017-01-09 15:44:50 -0500 |
commit | ab3d408d3f40f939d46a32b1c24aa2833a13b846 (patch) | |
tree | d63140993898647a7db28c2b635606dc1e7d8bfd /net/dsa/dsa.c | |
parent | 73095cb1881e6da77e2ed711deaf954bdfdde71e (diff) |
net: dsa: Encapsulate legacy switch drivers into dsa_switch_driver
In preparation for making struct dsa_switch_ops const, encapsulate it
within a dsa_switch_driver which has a list pointer and a pointer to
dsa_switch_ops. This allows us to take the list_head pointer out of
dsa_switch_ops, which is written to by {un,}register_switch_driver.
Signed-off-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 | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/net/dsa/dsa.c b/net/dsa/dsa.c index cda787ebad15..4e7bc57cdae5 100644 --- a/net/dsa/dsa.c +++ b/net/dsa/dsa.c | |||
@@ -60,18 +60,18 @@ const struct dsa_device_ops *dsa_device_ops[DSA_TAG_LAST] = { | |||
60 | static DEFINE_MUTEX(dsa_switch_drivers_mutex); | 60 | static DEFINE_MUTEX(dsa_switch_drivers_mutex); |
61 | static LIST_HEAD(dsa_switch_drivers); | 61 | static LIST_HEAD(dsa_switch_drivers); |
62 | 62 | ||
63 | void register_switch_driver(struct dsa_switch_ops *ops) | 63 | void register_switch_driver(struct dsa_switch_driver *drv) |
64 | { | 64 | { |
65 | mutex_lock(&dsa_switch_drivers_mutex); | 65 | mutex_lock(&dsa_switch_drivers_mutex); |
66 | list_add_tail(&ops->list, &dsa_switch_drivers); | 66 | list_add_tail(&drv->list, &dsa_switch_drivers); |
67 | mutex_unlock(&dsa_switch_drivers_mutex); | 67 | mutex_unlock(&dsa_switch_drivers_mutex); |
68 | } | 68 | } |
69 | EXPORT_SYMBOL_GPL(register_switch_driver); | 69 | EXPORT_SYMBOL_GPL(register_switch_driver); |
70 | 70 | ||
71 | void unregister_switch_driver(struct dsa_switch_ops *ops) | 71 | void unregister_switch_driver(struct dsa_switch_driver *drv) |
72 | { | 72 | { |
73 | mutex_lock(&dsa_switch_drivers_mutex); | 73 | mutex_lock(&dsa_switch_drivers_mutex); |
74 | list_del_init(&ops->list); | 74 | list_del_init(&drv->list); |
75 | mutex_unlock(&dsa_switch_drivers_mutex); | 75 | mutex_unlock(&dsa_switch_drivers_mutex); |
76 | } | 76 | } |
77 | EXPORT_SYMBOL_GPL(unregister_switch_driver); | 77 | EXPORT_SYMBOL_GPL(unregister_switch_driver); |
@@ -90,8 +90,10 @@ dsa_switch_probe(struct device *parent, struct device *host_dev, int sw_addr, | |||
90 | mutex_lock(&dsa_switch_drivers_mutex); | 90 | mutex_lock(&dsa_switch_drivers_mutex); |
91 | list_for_each(list, &dsa_switch_drivers) { | 91 | list_for_each(list, &dsa_switch_drivers) { |
92 | struct dsa_switch_ops *ops; | 92 | struct dsa_switch_ops *ops; |
93 | struct dsa_switch_driver *drv; | ||
93 | 94 | ||
94 | ops = list_entry(list, struct dsa_switch_ops, list); | 95 | drv = list_entry(list, struct dsa_switch_driver, list); |
96 | ops = drv->ops; | ||
95 | 97 | ||
96 | name = ops->probe(parent, host_dev, sw_addr, priv); | 98 | name = ops->probe(parent, host_dev, sw_addr, priv); |
97 | if (name != NULL) { | 99 | if (name != NULL) { |