mirror of
https://github.com/Fishwaldo/Star64_linux.git
synced 2025-06-20 13:41:30 +00:00
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>
This commit is contained in:
parent
73095cb188
commit
ab3d408d3f
4 changed files with 26 additions and 13 deletions
|
@ -60,18 +60,18 @@ const struct dsa_device_ops *dsa_device_ops[DSA_TAG_LAST] = {
|
|||
static DEFINE_MUTEX(dsa_switch_drivers_mutex);
|
||||
static LIST_HEAD(dsa_switch_drivers);
|
||||
|
||||
void register_switch_driver(struct dsa_switch_ops *ops)
|
||||
void register_switch_driver(struct dsa_switch_driver *drv)
|
||||
{
|
||||
mutex_lock(&dsa_switch_drivers_mutex);
|
||||
list_add_tail(&ops->list, &dsa_switch_drivers);
|
||||
list_add_tail(&drv->list, &dsa_switch_drivers);
|
||||
mutex_unlock(&dsa_switch_drivers_mutex);
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(register_switch_driver);
|
||||
|
||||
void unregister_switch_driver(struct dsa_switch_ops *ops)
|
||||
void unregister_switch_driver(struct dsa_switch_driver *drv)
|
||||
{
|
||||
mutex_lock(&dsa_switch_drivers_mutex);
|
||||
list_del_init(&ops->list);
|
||||
list_del_init(&drv->list);
|
||||
mutex_unlock(&dsa_switch_drivers_mutex);
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(unregister_switch_driver);
|
||||
|
@ -90,8 +90,10 @@ dsa_switch_probe(struct device *parent, struct device *host_dev, int sw_addr,
|
|||
mutex_lock(&dsa_switch_drivers_mutex);
|
||||
list_for_each(list, &dsa_switch_drivers) {
|
||||
struct dsa_switch_ops *ops;
|
||||
struct dsa_switch_driver *drv;
|
||||
|
||||
ops = list_entry(list, struct dsa_switch_ops, list);
|
||||
drv = list_entry(list, struct dsa_switch_driver, list);
|
||||
ops = drv->ops;
|
||||
|
||||
name = ops->probe(parent, host_dev, sw_addr, priv);
|
||||
if (name != NULL) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue