]> git.baikalelectronics.ru Git - kernel.git/commitdiff
net: davicom: Fix regulator not turned off on driver removal
authorPaul Cercueil <paul@crapouillou.net>
Sun, 7 Mar 2021 13:17:48 +0000 (13:17 +0000)
committerDavid S. Miller <davem@davemloft.net>
Mon, 8 Mar 2021 20:01:58 +0000 (12:01 -0800)
We must disable the regulator that was enabled in the probe function.

Fixes: 47d1f5beb263 ("dm9000: Add regulator and reset support to dm9000")
Signed-off-by: Paul Cercueil <paul@crapouillou.net>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/ethernet/davicom/dm9000.c

index ae744826bb9e25a4b9df9cbdd434eb2a645d1ea6..a95e95ce94386582ce6f6cb79b26006a0b98f194 100644 (file)
@@ -133,6 +133,8 @@ struct board_info {
        u32             wake_state;
 
        int             ip_summed;
+
+       struct regulator *power_supply;
 };
 
 /* debug code */
@@ -1481,6 +1483,8 @@ dm9000_probe(struct platform_device *pdev)
 
        db->dev = &pdev->dev;
        db->ndev = ndev;
+       if (!IS_ERR(power))
+               db->power_supply = power;
 
        spin_lock_init(&db->lock);
        mutex_init(&db->addr_lock);
@@ -1766,10 +1770,13 @@ static int
 dm9000_drv_remove(struct platform_device *pdev)
 {
        struct net_device *ndev = platform_get_drvdata(pdev);
+       struct board_info *dm = to_dm9000_board(ndev);
 
        unregister_netdev(ndev);
-       dm9000_release_board(pdev, netdev_priv(ndev));
+       dm9000_release_board(pdev, dm);
        free_netdev(ndev);              /* free device structure */
+       if (dm->power_supply)
+               regulator_disable(dm->power_supply);
 
        dev_dbg(&pdev->dev, "released and freed device\n");
        return 0;