@@ -383,6 +383,12 @@ int realtek_smi_setup_mdio(struct realtek_smi *smi)
return ret;
}
+void realtek_smi_teardown_mdio(struct realtek_smi *smi)
+{
+ if (smi->slave_mii_bus)
+ mdiobus_unregister(smi->slave_mii_bus);
+}
+
static int realtek_smi_probe(struct platform_device *pdev)
{
const struct realtek_smi_variant *var;
@@ -119,6 +119,7 @@ struct realtek_smi_variant {
int realtek_smi_write_reg_noack(struct realtek_smi *smi, u32 addr,
u32 data);
int realtek_smi_setup_mdio(struct realtek_smi *smi);
+void realtek_smi_teardown_mdio(struct realtek_smi *smi);
/* RTL8366 library helpers */
int rtl8366_mc_is_used(struct realtek_smi *smi, int mc_index, int *used);
@@ -982,6 +982,13 @@ static int rtl8366rb_setup(struct dsa_switch *ds)
return 0;
}
+static void rtl8366rb_teardown(struct dsa_switch *ds)
+{
+ struct realtek_smi *smi = ds->priv;
+
+ realtek_smi_teardown_mdio(smi);
+}
+
static enum dsa_tag_protocol rtl8366_get_tag_protocol(struct dsa_switch *ds,
int port,
enum dsa_tag_protocol mp)
@@ -1505,6 +1512,7 @@ static int rtl8366rb_detect(struct realtek_smi *smi)
static const struct dsa_switch_ops rtl8366rb_switch_ops = {
.get_tag_protocol = rtl8366_get_tag_protocol,
.setup = rtl8366rb_setup,
+ .teardown = rtl8366rb_teardown,
.phylink_mac_link_up = rtl8366rb_mac_link_up,
.phylink_mac_link_down = rtl8366rb_mac_link_down,
.get_strings = rtl8366_get_strings,