net: dsa: move fixed link registration helpers

The new bindings (dsa2.c) and the old bindings (legacy.c) share two
helpers dsa_cpu_dsa_setup and dsa_cpu_dsa_destroy, used to register or
deregister a fixed PHY if a given port has a corresponding device node.

Unclutter the code by moving them into two new port.c helpers,
dsa_port_fixed_link_register_of and dsa_port_fixed_link_(un)register_of.

Signed-off-by: Vivien Didelot <vivien.didelot@savoirfairelinux.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
Vivien Didelot 2017-10-26 10:50:07 -04:00 committed by David S. Miller
parent 952c5719aa
commit 57ab1ca215
5 changed files with 56 additions and 47 deletions

View file

@ -219,7 +219,7 @@ static int dsa_dsa_port_apply(struct dsa_port *port)
struct dsa_switch *ds = port->ds;
int err;
err = dsa_cpu_dsa_setup(port);
err = dsa_port_fixed_link_register_of(port);
if (err) {
dev_warn(ds->dev, "Failed to setup dsa port %d: %d\n",
port->index, err);
@ -235,7 +235,7 @@ static int dsa_dsa_port_apply(struct dsa_port *port)
static void dsa_dsa_port_unapply(struct dsa_port *port)
{
devlink_port_unregister(&port->devlink_port);
dsa_cpu_dsa_destroy(port);
dsa_port_fixed_link_unregister_of(port);
}
static int dsa_cpu_port_apply(struct dsa_port *port)
@ -243,7 +243,7 @@ static int dsa_cpu_port_apply(struct dsa_port *port)
struct dsa_switch *ds = port->ds;
int err;
err = dsa_cpu_dsa_setup(port);
err = dsa_port_fixed_link_register_of(port);
if (err) {
dev_warn(ds->dev, "Failed to setup cpu port %d: %d\n",
port->index, err);
@ -259,7 +259,7 @@ static int dsa_cpu_port_apply(struct dsa_port *port)
static void dsa_cpu_port_unapply(struct dsa_port *port)
{
devlink_port_unregister(&port->devlink_port);
dsa_cpu_dsa_destroy(port);
dsa_port_fixed_link_unregister_of(port);
}
static int dsa_user_port_apply(struct dsa_port *port)