Skip to content

Commit

Permalink
net: davicom: Fix regulator not turned off on driver removal
Browse files Browse the repository at this point in the history
commit cf9e60a upstream.

We must disable the regulator that was enabled in the probe function.

Fixes: 7994fe5 ("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>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
  • Loading branch information
pcercuei authored and gregkh committed Mar 17, 2021
1 parent 05517de commit d28e783
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion drivers/net/ethernet/davicom/dm9000.c
Expand Up @@ -134,6 +134,8 @@ struct board_info {
u32 wake_state;

int ip_summed;

struct regulator *power_supply;
};

/* debug code */
Expand Down Expand Up @@ -1486,6 +1488,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);
Expand Down Expand Up @@ -1771,10 +1775,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;
Expand Down

0 comments on commit d28e783

Please sign in to comment.