Skip to content

Commit e5fb512

Browse files
vladimirolteandavem330
authored andcommitted
net: mscc: ocelot: deinitialize only initialized ports
Currently mscc_ocelot_init_ports() will skip initializing a port when it doesn't have a phy-handle, so the ocelot->ports[port] pointer will be NULL. Take this into consideration when tearing down the driver, and add a new function ocelot_deinit_port() to the switch library, mirror of ocelot_init_port(), which needs to be called by the driver for all ports it has initialized. Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.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>
1 parent 22cdb49 commit e5fb512

File tree

4 files changed

+14
-8
lines changed

4 files changed

+14
-8
lines changed

drivers/net/dsa/ocelot/felix.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -643,10 +643,13 @@ static void felix_teardown(struct dsa_switch *ds)
643643
{
644644
struct ocelot *ocelot = ds->priv;
645645
struct felix *felix = ocelot_to_felix(ocelot);
646+
int port;
646647

647648
if (felix->info->mdio_bus_free)
648649
felix->info->mdio_bus_free(ocelot);
649650

651+
for (port = 0; port < ocelot->num_phys_ports; port++)
652+
ocelot_deinit_port(ocelot, port);
650653
ocelot_deinit_timestamp(ocelot);
651654
/* stop workqueue thread */
652655
ocelot_deinit(ocelot);

drivers/net/ethernet/mscc/ocelot.c

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1550,18 +1550,18 @@ EXPORT_SYMBOL(ocelot_init);
15501550

15511551
void ocelot_deinit(struct ocelot *ocelot)
15521552
{
1553-
struct ocelot_port *port;
1554-
int i;
1555-
15561553
cancel_delayed_work(&ocelot->stats_work);
15571554
destroy_workqueue(ocelot->stats_queue);
15581555
mutex_destroy(&ocelot->stats_lock);
1559-
1560-
for (i = 0; i < ocelot->num_phys_ports; i++) {
1561-
port = ocelot->ports[i];
1562-
skb_queue_purge(&port->tx_skbs);
1563-
}
15641556
}
15651557
EXPORT_SYMBOL(ocelot_deinit);
15661558

1559+
void ocelot_deinit_port(struct ocelot *ocelot, int port)
1560+
{
1561+
struct ocelot_port *ocelot_port = ocelot->ports[port];
1562+
1563+
skb_queue_purge(&ocelot_port->tx_skbs);
1564+
}
1565+
EXPORT_SYMBOL(ocelot_deinit_port);
1566+
15671567
MODULE_LICENSE("Dual MIT/GPL");

drivers/net/ethernet/mscc/ocelot_vsc7514.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -908,6 +908,8 @@ static void mscc_ocelot_release_ports(struct ocelot *ocelot)
908908
if (!ocelot_port)
909909
continue;
910910

911+
ocelot_deinit_port(ocelot, port);
912+
911913
priv = container_of(ocelot_port, struct ocelot_port_private,
912914
port);
913915

include/soc/mscc/ocelot.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -678,6 +678,7 @@ void ocelot_configure_cpu(struct ocelot *ocelot, int npi,
678678
int ocelot_init(struct ocelot *ocelot);
679679
void ocelot_deinit(struct ocelot *ocelot);
680680
void ocelot_init_port(struct ocelot *ocelot, int port);
681+
void ocelot_deinit_port(struct ocelot *ocelot, int port);
681682

682683
/* DSA callbacks */
683684
void ocelot_port_enable(struct ocelot *ocelot, int port,

0 commit comments

Comments
 (0)