]> git.proxmox.com Git - mirror_ubuntu-jammy-kernel.git/blobdiff - drivers/net/dsa/lantiq_gswip.c
net: dsa: be compatible with masters which unregister on shutdown
[mirror_ubuntu-jammy-kernel.git] / drivers / net / dsa / lantiq_gswip.c
index 267324889dd647e6fcf571b9aa3195c79d32613d..3ff4b7e177f3cb0d11ec59324df4e2222764dab0 100644 (file)
@@ -2184,6 +2184,9 @@ static int gswip_remove(struct platform_device *pdev)
        struct gswip_priv *priv = platform_get_drvdata(pdev);
        int i;
 
+       if (!priv)
+               return 0;
+
        /* disable the switch */
        gswip_mdio_mask(priv, GSWIP_MDIO_GLOB_ENABLE, 0, GSWIP_MDIO_GLOB);
 
@@ -2197,9 +2200,23 @@ static int gswip_remove(struct platform_device *pdev)
        for (i = 0; i < priv->num_gphy_fw; i++)
                gswip_gphy_fw_remove(priv, &priv->gphy_fw[i]);
 
+       platform_set_drvdata(pdev, NULL);
+
        return 0;
 }
 
+static void gswip_shutdown(struct platform_device *pdev)
+{
+       struct gswip_priv *priv = platform_get_drvdata(pdev);
+
+       if (!priv)
+               return;
+
+       dsa_switch_shutdown(priv->ds);
+
+       platform_set_drvdata(pdev, NULL);
+}
+
 static const struct gswip_hw_info gswip_xrx200 = {
        .max_ports = 7,
        .cpu_port = 6,
@@ -2223,6 +2240,7 @@ MODULE_DEVICE_TABLE(of, gswip_of_match);
 static struct platform_driver gswip_driver = {
        .probe = gswip_probe,
        .remove = gswip_remove,
+       .shutdown = gswip_shutdown,
        .driver = {
                .name = "gswip",
                .of_match_table = gswip_of_match,