diff --git a/drivers/net/ethernet/lantiq_xrx200.c b/drivers/net/ethernet/lantiq_xrx200.c index 4a160761b3ff..8c5ba4b81fb7 100644 --- a/drivers/net/ethernet/lantiq_xrx200.c +++ b/drivers/net/ethernet/lantiq_xrx200.c @@ -115,12 +115,6 @@ static void xrx200_flush_dma(struct xrx200_chan *ch) static int xrx200_open(struct net_device *net_dev) { struct xrx200_priv *priv = netdev_priv(net_dev); - int err; - - /* enable clock gate */ - err = clk_prepare_enable(priv->clk); - if (err) - return err; napi_enable(&priv->chan_tx.napi); ltq_dma_open(&priv->chan_tx.dma); @@ -155,8 +149,6 @@ static int xrx200_close(struct net_device *net_dev) napi_disable(&priv->chan_tx.napi); ltq_dma_close(&priv->chan_tx.dma); - clk_disable_unprepare(priv->clk); - return 0; } @@ -497,6 +489,11 @@ static int xrx200_probe(struct platform_device *pdev) if (err) return err; + /* enable clock gate */ + err = clk_prepare_enable(priv->clk); + if (err) + goto err_uninit_dma; + /* set IPG to 12 */ xrx200_pmac_mask(priv, PMAC_RX_IPG_MASK, 0xb, PMAC_RX_IPG); @@ -514,9 +511,12 @@ static int xrx200_probe(struct platform_device *pdev) err = register_netdev(net_dev); if (err) - goto err_uninit_dma; + goto err_unprepare_clk; return err; +err_unprepare_clk: + clk_disable_unprepare(priv->clk); + err_uninit_dma: xrx200_hw_cleanup(priv); @@ -536,6 +536,9 @@ static int xrx200_remove(struct platform_device *pdev) /* remove the actual device */ unregister_netdev(net_dev); + /* release the clock */ + clk_disable_unprepare(priv->clk); + /* shut down hardware */ xrx200_hw_cleanup(priv);