aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/net/ethernet/ti/davinci_emac.c33
1 files changed, 29 insertions, 4 deletions
diff --git a/drivers/net/ethernet/ti/davinci_emac.c b/drivers/net/ethernet/ti/davinci_emac.c
index 383ed527dad9..5df339e9f67c 100644
--- a/drivers/net/ethernet/ti/davinci_emac.c
+++ b/drivers/net/ethernet/ti/davinci_emac.c
@@ -1538,7 +1538,13 @@ static int emac_dev_open(struct net_device *ndev)
1538 int i = 0; 1538 int i = 0;
1539 struct emac_priv *priv = netdev_priv(ndev); 1539 struct emac_priv *priv = netdev_priv(ndev);
1540 1540
1541 pm_runtime_get(&priv->pdev->dev); 1541 ret = pm_runtime_get_sync(&priv->pdev->dev);
1542 if (ret < 0) {
1543 pm_runtime_put_noidle(&priv->pdev->dev);
1544 dev_err(&priv->pdev->dev, "%s: failed to get_sync(%d)\n",
1545 __func__, ret);
1546 return ret;
1547 }
1542 1548
1543 netif_carrier_off(ndev); 1549 netif_carrier_off(ndev);
1544 for (cnt = 0; cnt < ETH_ALEN; cnt++) 1550 for (cnt = 0; cnt < ETH_ALEN; cnt++)
@@ -1725,6 +1731,15 @@ static struct net_device_stats *emac_dev_getnetstats(struct net_device *ndev)
1725 struct emac_priv *priv = netdev_priv(ndev); 1731 struct emac_priv *priv = netdev_priv(ndev);
1726 u32 mac_control; 1732 u32 mac_control;
1727 u32 stats_clear_mask; 1733 u32 stats_clear_mask;
1734 int err;
1735
1736 err = pm_runtime_get_sync(&priv->pdev->dev);
1737 if (err < 0) {
1738 pm_runtime_put_noidle(&priv->pdev->dev);
1739 dev_err(&priv->pdev->dev, "%s: failed to get_sync(%d)\n",
1740 __func__, err);
1741 return &ndev->stats;
1742 }
1728 1743
1729 /* update emac hardware stats and reset the registers*/ 1744 /* update emac hardware stats and reset the registers*/
1730 1745
@@ -1767,6 +1782,8 @@ static struct net_device_stats *emac_dev_getnetstats(struct net_device *ndev)
1767 ndev->stats.tx_fifo_errors += emac_read(EMAC_TXUNDERRUN); 1782 ndev->stats.tx_fifo_errors += emac_read(EMAC_TXUNDERRUN);
1768 emac_write(EMAC_TXUNDERRUN, stats_clear_mask); 1783 emac_write(EMAC_TXUNDERRUN, stats_clear_mask);
1769 1784
1785 pm_runtime_put(&priv->pdev->dev);
1786
1770 return &ndev->stats; 1787 return &ndev->stats;
1771} 1788}
1772 1789
@@ -1981,12 +1998,22 @@ static int davinci_emac_probe(struct platform_device *pdev)
1981 ndev->ethtool_ops = &ethtool_ops; 1998 ndev->ethtool_ops = &ethtool_ops;
1982 netif_napi_add(ndev, &priv->napi, emac_poll, EMAC_POLL_WEIGHT); 1999 netif_napi_add(ndev, &priv->napi, emac_poll, EMAC_POLL_WEIGHT);
1983 2000
2001 pm_runtime_enable(&pdev->dev);
2002 rc = pm_runtime_get_sync(&pdev->dev);
2003 if (rc < 0) {
2004 pm_runtime_put_noidle(&pdev->dev);
2005 dev_err(&pdev->dev, "%s: failed to get_sync(%d)\n",
2006 __func__, rc);
2007 goto no_cpdma_chan;
2008 }
2009
1984 /* register the network device */ 2010 /* register the network device */
1985 SET_NETDEV_DEV(ndev, &pdev->dev); 2011 SET_NETDEV_DEV(ndev, &pdev->dev);
1986 rc = register_netdev(ndev); 2012 rc = register_netdev(ndev);
1987 if (rc) { 2013 if (rc) {
1988 dev_err(&pdev->dev, "error in register_netdev\n"); 2014 dev_err(&pdev->dev, "error in register_netdev\n");
1989 rc = -ENODEV; 2015 rc = -ENODEV;
2016 pm_runtime_put(&pdev->dev);
1990 goto no_cpdma_chan; 2017 goto no_cpdma_chan;
1991 } 2018 }
1992 2019
@@ -1996,9 +2023,7 @@ static int davinci_emac_probe(struct platform_device *pdev)
1996 "(regs: %p, irq: %d)\n", 2023 "(regs: %p, irq: %d)\n",
1997 (void *)priv->emac_base_phys, ndev->irq); 2024 (void *)priv->emac_base_phys, ndev->irq);
1998 } 2025 }
1999 2026 pm_runtime_put(&pdev->dev);
2000 pm_runtime_enable(&pdev->dev);
2001 pm_runtime_resume(&pdev->dev);
2002 2027
2003 return 0; 2028 return 0;
2004 2029