Commit 88d64367 authored by Vladimir Oltean's avatar Vladimir Oltean Committed by Paolo Abeni

net: dpaa2-switch: assign port_priv->mac after dpaa2_mac_connect() call

The dpaa2-switch has the exact same locking requirements when connected
to a DPMAC, so it needs port_priv->mac to always point either to NULL,
or to a DPMAC with a fully initialized phylink instance.

Make the same preparatory change in the dpaa2-switch driver as in the
dpaa2-eth one.
Signed-off-by: default avatarVladimir Oltean <vladimir.oltean@nxp.com>
Reviewed-by: default avatarIoana Ciornei <ioana.ciornei@nxp.com>
Tested-by: default avatarIoana Ciornei <ioana.ciornei@nxp.com>
Signed-off-by: default avatarPaolo Abeni <pabeni@redhat.com>
parent 02d61948
...@@ -1449,9 +1449,8 @@ static int dpaa2_switch_port_connect_mac(struct ethsw_port_priv *port_priv) ...@@ -1449,9 +1449,8 @@ static int dpaa2_switch_port_connect_mac(struct ethsw_port_priv *port_priv)
err = dpaa2_mac_open(mac); err = dpaa2_mac_open(mac);
if (err) if (err)
goto err_free_mac; goto err_free_mac;
port_priv->mac = mac;
if (dpaa2_switch_port_is_type_phy(port_priv)) { if (dpaa2_mac_is_type_phy(mac)) {
err = dpaa2_mac_connect(mac); err = dpaa2_mac_connect(mac);
if (err) { if (err) {
netdev_err(port_priv->netdev, netdev_err(port_priv->netdev,
...@@ -1461,11 +1460,12 @@ static int dpaa2_switch_port_connect_mac(struct ethsw_port_priv *port_priv) ...@@ -1461,11 +1460,12 @@ static int dpaa2_switch_port_connect_mac(struct ethsw_port_priv *port_priv)
} }
} }
port_priv->mac = mac;
return 0; return 0;
err_close_mac: err_close_mac:
dpaa2_mac_close(mac); dpaa2_mac_close(mac);
port_priv->mac = NULL;
err_free_mac: err_free_mac:
kfree(mac); kfree(mac);
return err; return err;
...@@ -1473,15 +1473,18 @@ static int dpaa2_switch_port_connect_mac(struct ethsw_port_priv *port_priv) ...@@ -1473,15 +1473,18 @@ static int dpaa2_switch_port_connect_mac(struct ethsw_port_priv *port_priv)
static void dpaa2_switch_port_disconnect_mac(struct ethsw_port_priv *port_priv) static void dpaa2_switch_port_disconnect_mac(struct ethsw_port_priv *port_priv)
{ {
if (dpaa2_switch_port_is_type_phy(port_priv)) struct dpaa2_mac *mac = port_priv->mac;
dpaa2_mac_disconnect(port_priv->mac);
if (!dpaa2_switch_port_has_mac(port_priv)) port_priv->mac = NULL;
if (!mac)
return; return;
dpaa2_mac_close(port_priv->mac); if (dpaa2_mac_is_type_phy(mac))
kfree(port_priv->mac); dpaa2_mac_disconnect(mac);
port_priv->mac = NULL;
dpaa2_mac_close(mac);
kfree(mac);
} }
static irqreturn_t dpaa2_switch_irq0_handler_thread(int irq_num, void *arg) static irqreturn_t dpaa2_switch_irq0_handler_thread(int irq_num, void *arg)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment