|
@@ -1538,7 +1538,13 @@ static int emac_dev_open(struct net_device *ndev)
|
|
|
int i = 0;
|
|
|
struct emac_priv *priv = netdev_priv(ndev);
|
|
|
|
|
|
- pm_runtime_get(&priv->pdev->dev);
|
|
|
+ ret = pm_runtime_get_sync(&priv->pdev->dev);
|
|
|
+ if (ret < 0) {
|
|
|
+ pm_runtime_put_noidle(&priv->pdev->dev);
|
|
|
+ dev_err(&priv->pdev->dev, "%s: failed to get_sync(%d)\n",
|
|
|
+ __func__, ret);
|
|
|
+ return ret;
|
|
|
+ }
|
|
|
|
|
|
netif_carrier_off(ndev);
|
|
|
for (cnt = 0; cnt < ETH_ALEN; cnt++)
|
|
@@ -1725,6 +1731,15 @@ static struct net_device_stats *emac_dev_getnetstats(struct net_device *ndev)
|
|
|
struct emac_priv *priv = netdev_priv(ndev);
|
|
|
u32 mac_control;
|
|
|
u32 stats_clear_mask;
|
|
|
+ int err;
|
|
|
+
|
|
|
+ err = pm_runtime_get_sync(&priv->pdev->dev);
|
|
|
+ if (err < 0) {
|
|
|
+ pm_runtime_put_noidle(&priv->pdev->dev);
|
|
|
+ dev_err(&priv->pdev->dev, "%s: failed to get_sync(%d)\n",
|
|
|
+ __func__, err);
|
|
|
+ return &ndev->stats;
|
|
|
+ }
|
|
|
|
|
|
/* update emac hardware stats and reset the registers*/
|
|
|
|
|
@@ -1767,6 +1782,8 @@ static struct net_device_stats *emac_dev_getnetstats(struct net_device *ndev)
|
|
|
ndev->stats.tx_fifo_errors += emac_read(EMAC_TXUNDERRUN);
|
|
|
emac_write(EMAC_TXUNDERRUN, stats_clear_mask);
|
|
|
|
|
|
+ pm_runtime_put(&priv->pdev->dev);
|
|
|
+
|
|
|
return &ndev->stats;
|
|
|
}
|
|
|
|
|
@@ -1981,12 +1998,22 @@ static int davinci_emac_probe(struct platform_device *pdev)
|
|
|
ndev->ethtool_ops = ðtool_ops;
|
|
|
netif_napi_add(ndev, &priv->napi, emac_poll, EMAC_POLL_WEIGHT);
|
|
|
|
|
|
+ pm_runtime_enable(&pdev->dev);
|
|
|
+ rc = pm_runtime_get_sync(&pdev->dev);
|
|
|
+ if (rc < 0) {
|
|
|
+ pm_runtime_put_noidle(&pdev->dev);
|
|
|
+ dev_err(&pdev->dev, "%s: failed to get_sync(%d)\n",
|
|
|
+ __func__, rc);
|
|
|
+ goto no_cpdma_chan;
|
|
|
+ }
|
|
|
+
|
|
|
/* register the network device */
|
|
|
SET_NETDEV_DEV(ndev, &pdev->dev);
|
|
|
rc = register_netdev(ndev);
|
|
|
if (rc) {
|
|
|
dev_err(&pdev->dev, "error in register_netdev\n");
|
|
|
rc = -ENODEV;
|
|
|
+ pm_runtime_put(&pdev->dev);
|
|
|
goto no_cpdma_chan;
|
|
|
}
|
|
|
|
|
@@ -1996,9 +2023,7 @@ static int davinci_emac_probe(struct platform_device *pdev)
|
|
|
"(regs: %p, irq: %d)\n",
|
|
|
(void *)priv->emac_base_phys, ndev->irq);
|
|
|
}
|
|
|
-
|
|
|
- pm_runtime_enable(&pdev->dev);
|
|
|
- pm_runtime_resume(&pdev->dev);
|
|
|
+ pm_runtime_put(&pdev->dev);
|
|
|
|
|
|
return 0;
|
|
|
|