Skip to content

Commit

Permalink
ethernet: sun8i-emac: add pm_runtime support
Browse files Browse the repository at this point in the history
This patch add pm_runtime support to sun8i-emac.
For the moment, only basic support is added, (the device is marked as
used when net/open)

Signed-off-by: Corentin Labbe <clabbe.montjoie@gmail.com>
  • Loading branch information
montjoie authored and Icenowy committed Dec 13, 2016
1 parent febee02 commit b497c53
Showing 1 changed file with 17 additions and 2 deletions.
19 changes: 17 additions & 2 deletions drivers/net/ethernet/allwinner/sun8i-emac.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
* - MAC filtering
* - Jumbo frame
* - features rx-all (NETIF_F_RXALL_BIT)
* - PM runtime
*/
#include <linux/bitops.h>
#include <linux/clk.h>
Expand All @@ -27,6 +26,7 @@
#include <linux/pinctrl/consumer.h>
#include <linux/pinctrl/pinctrl.h>
#include <linux/platform_device.h>
#include <linux/pm_runtime.h>
#include <linux/reset.h>
#include <linux/scatterlist.h>
#include <linux/skbuff.h>
Expand Down Expand Up @@ -1293,9 +1293,16 @@ static int sun8i_emac_open(struct net_device *ndev)
int err;
u32 v;

err = pm_runtime_get_sync(priv->dev);
if (err) {
pm_runtime_put_noidle(priv->dev);
dev_err(priv->dev, "pm_runtime error: %d\n", err);
return err;
}

err = sun8i_emac_power(ndev);
if (err)
return err;
goto err_runtime;

err = request_irq(priv->irq, sun8i_emac_dma_interrupt, 0,
dev_name(priv->dev), ndev);
Expand Down Expand Up @@ -1393,6 +1400,8 @@ static int sun8i_emac_open(struct net_device *ndev)
free_irq(priv->irq, ndev);
err_power:
sun8i_emac_unpower(ndev);
err_runtime:
pm_runtime_put(priv->dev);
return err;
}

Expand Down Expand Up @@ -1483,6 +1492,8 @@ static int sun8i_emac_stop(struct net_device *ndev)

sun8i_emac_unpower(ndev);

pm_runtime_put(priv->dev);

return 0;
}

Expand Down Expand Up @@ -2221,6 +2232,8 @@ static int sun8i_emac_probe(struct platform_device *pdev)
goto probe_err;
}

pm_runtime_enable(priv->dev);

return 0;

probe_err:
Expand All @@ -2232,6 +2245,8 @@ static int sun8i_emac_remove(struct platform_device *pdev)
{
struct net_device *ndev = platform_get_drvdata(pdev);

pm_runtime_disable(&pdev->dev);

unregister_netdev(ndev);
platform_set_drvdata(pdev, NULL);
free_netdev(ndev);
Expand Down

0 comments on commit b497c53

Please sign in to comment.