Skip to content

Commit

Permalink
net: mscc: ocelot: unregister net devices on unbind
Browse files Browse the repository at this point in the history
This driver was not unregistering its network interfaces on unbind.
Now it is.

Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com>
Reviewed-by: Horatiu Vultur <horatiu.vultur@microchip.com>
Reviewed-by: Florian Fainelli <f.fainelli@gmail.com>
Tested-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
Reviewed-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Vladimir Oltean authored and David S. Miller committed Sep 18, 2020
1 parent 7c41179 commit 22cdb49
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions drivers/net/ethernet/mscc/ocelot_vsc7514.c
Original file line number Diff line number Diff line change
Expand Up @@ -896,6 +896,26 @@ static struct ptp_clock_info ocelot_ptp_clock_info = {
.enable = ocelot_ptp_enable,
};

static void mscc_ocelot_release_ports(struct ocelot *ocelot)
{
int port;

for (port = 0; port < ocelot->num_phys_ports; port++) {
struct ocelot_port_private *priv;
struct ocelot_port *ocelot_port;

ocelot_port = ocelot->ports[port];
if (!ocelot_port)
continue;

priv = container_of(ocelot_port, struct ocelot_port_private,
port);

unregister_netdev(priv->dev);
free_netdev(priv->dev);
}
}

static int mscc_ocelot_init_ports(struct platform_device *pdev,
struct device_node *ports)
{
Expand Down Expand Up @@ -1132,6 +1152,7 @@ static int mscc_ocelot_remove(struct platform_device *pdev)
struct ocelot *ocelot = platform_get_drvdata(pdev);

ocelot_deinit_timestamp(ocelot);
mscc_ocelot_release_ports(ocelot);
ocelot_deinit(ocelot);
unregister_switchdev_blocking_notifier(&ocelot_switchdev_blocking_nb);
unregister_switchdev_notifier(&ocelot_switchdev_nb);
Expand Down

0 comments on commit 22cdb49

Please sign in to comment.