net:fec: Add fec_enet_deinit()
authorXiaolei Wang <xiaolei.wang@windriver.com>
Fri, 24 May 2024 05:05:28 +0000 (13:05 +0800)
committerJakub Kicinski <kuba@kernel.org>
Mon, 27 May 2024 23:55:32 +0000 (16:55 -0700)
When fec_probe() fails or fec_drv_remove() needs to release the
fec queue and remove a NAPI context, therefore add a function
corresponding to fec_enet_init() and call fec_enet_deinit() which
does the opposite to release memory and remove a NAPI context.

Fixes: 59d0f7465644 ("net: fec: init multi queue date structure")
Signed-off-by: Xiaolei Wang <xiaolei.wang@windriver.com>
Reviewed-by: Wei Fang <wei.fang@nxp.com>
Reviewed-by: Andrew Lunn <andrew@lunn.ch>
Link: https://lore.kernel.org/r/20240524050528.4115581-1-xiaolei.wang@windriver.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
drivers/net/ethernet/freescale/fec_main.c

index a72d8a2eb0b315a505c61f9663844fa133120ccf..881ece735dcf1470fed863fdbb765e231ca2dbbf 100644 (file)
@@ -4130,6 +4130,14 @@ free_queue_mem:
        return ret;
 }
 
+static void fec_enet_deinit(struct net_device *ndev)
+{
+       struct fec_enet_private *fep = netdev_priv(ndev);
+
+       netif_napi_del(&fep->napi);
+       fec_enet_free_queue(ndev);
+}
+
 #ifdef CONFIG_OF
 static int fec_reset_phy(struct platform_device *pdev)
 {
@@ -4524,6 +4532,7 @@ failed_register:
        fec_enet_mii_remove(fep);
 failed_mii_init:
 failed_irq:
+       fec_enet_deinit(ndev);
 failed_init:
        fec_ptp_stop(pdev);
 failed_reset:
@@ -4587,6 +4596,7 @@ fec_drv_remove(struct platform_device *pdev)
        pm_runtime_put_noidle(&pdev->dev);
        pm_runtime_disable(&pdev->dev);
 
+       fec_enet_deinit(ndev);
        free_netdev(ndev);
 }