linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Vincent Palatin <vpalatin@chromium.org>
To: netdev@vger.kernel.org
Cc: linux-kernel@vger.kernel.org, "Andrew Lunn" <andrew@lunn.ch>,
	"Douglas Anderson" <dianders@chromium.org>,
	"Giuseppe Cavallaro" <peppe.cavallaro@st.com>,
	"Heiko Stübner" <heiko@sntech.de>,
	"Shunqian Zheng" <zhengsq@rock-chips.com>,
	"Vincent Palatin" <vpalatin@chromium.org>
Subject: [PATCH v2 1/3] net: stmmac: allow to split suspend/resume from init/exit callbacks
Date: Wed, 15 Jun 2016 11:32:21 -0700	[thread overview]
Message-ID: <a61d39032b6d31ca936b6a3bfe92c93246a5c833.1466015458.git.vpalatin@chromium.org> (raw)
In-Reply-To: <cover.1466015458.git.vpalatin@chromium.org>
In-Reply-To: <cover.1466015458.git.vpalatin@chromium.org>

Let the stmmac platform drivers provide dedicated suspend and resume
callbacks rather than always re-using the init and exits callbacks.
If the driver does not provide the suspend or resume callback, we fall
back to the old behavior trying to use exit or init.

This allows a specific platform to perform only a partial power-down on
suspend if Wake-on-Lan is enabled but always perform the full shutdown
sequence if the module is unloaded.

Signed-off-by: Vincent Palatin <vpalatin@chromium.org>
---
 drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c | 8 ++++++--
 include/linux/stmmac.h                                | 2 ++
 2 files changed, 8 insertions(+), 2 deletions(-)

diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c
index 409db91..a96714d 100644
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c
@@ -411,7 +411,9 @@ static int stmmac_pltfr_suspend(struct device *dev)
 	struct platform_device *pdev = to_platform_device(dev);
 
 	ret = stmmac_suspend(dev);
-	if (priv->plat->exit)
+	if (priv->plat->suspend)
+		priv->plat->suspend(pdev, priv->plat->bsp_priv);
+	else if (priv->plat->exit)
 		priv->plat->exit(pdev, priv->plat->bsp_priv);
 
 	return ret;
@@ -430,7 +432,9 @@ static int stmmac_pltfr_resume(struct device *dev)
 	struct stmmac_priv *priv = netdev_priv(ndev);
 	struct platform_device *pdev = to_platform_device(dev);
 
-	if (priv->plat->init)
+	if (priv->plat->resume)
+		priv->plat->resume(pdev, priv->plat->bsp_priv);
+	else if (priv->plat->init)
 		priv->plat->init(pdev, priv->plat->bsp_priv);
 
 	return stmmac_resume(dev);
diff --git a/include/linux/stmmac.h b/include/linux/stmmac.h
index ffdaca9..0507dbf 100644
--- a/include/linux/stmmac.h
+++ b/include/linux/stmmac.h
@@ -135,6 +135,8 @@ struct plat_stmmacenet_data {
 	void (*bus_setup)(void __iomem *ioaddr);
 	int (*init)(struct platform_device *pdev, void *priv);
 	void (*exit)(struct platform_device *pdev, void *priv);
+	void (*suspend)(struct platform_device *pdev, void *priv);
+	void (*resume)(struct platform_device *pdev, void *priv);
 	void *bsp_priv;
 	struct stmmac_axi *axi;
 	int has_gmac4;
-- 
2.8.0.rc3.226.g39d4020

  reply	other threads:[~2016-06-15 18:32 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-06-03 17:29 [PATCH] net: stmmac: dwmac-rk: keep PHY up for WoL Vincent Palatin
2016-06-06 20:45 ` Heiko Stübner
2016-06-06 21:00   ` Vincent Palatin
2016-06-07  7:23 ` Giuseppe CAVALLARO
2016-06-08 22:25   ` Vincent Palatin
2016-06-09  0:17     ` Andrew Lunn
2016-06-09 23:00       ` Vincent Palatin
2016-06-10 12:29         ` Giuseppe CAVALLARO
2016-06-11  1:00           ` net: stmmac: dwmac-rk: fixes for Wake-on-Lan on RK3288 Vincent Palatin
2016-06-11  1:00             ` [PATCH 1/3] net: stmmac: allow to split suspend/resume from init/exit callbacks Vincent Palatin
2016-06-11  1:16               ` David Miller
2016-06-11  1:00             ` [PATCH 2/3] net: stmmac: dwmac-rk: keep the PHY up for WoL Vincent Palatin
2016-06-11  1:57               ` Heiko Stuebner
2016-06-15 16:03                 ` Vincent Palatin
2016-06-15 18:32                   ` [PATCH v2 0/3] net: stmmac: dwmac-rk: fixes for Wake-on-Lan on RK3288 Vincent Palatin
2016-06-15 18:32                     ` Vincent Palatin [this message]
2016-06-15 18:32                     ` [PATCH v2 2/3] net: stmmac: dwmac-rk: keep the PHY up for WoL Vincent Palatin
2016-06-15 18:32                     ` [PATCH v2 3/3] ARM: dts: rockchip: add interrupt for Wake-on-Lan on RK3288 Vincent Palatin
2016-06-16 21:15                     ` [PATCH v2 0/3] net: stmmac: dwmac-rk: fixes " David Miller
2016-06-11  1:00             ` [PATCH 3/3] ARM: dts: rockchip: add interrupt " Vincent Palatin
2016-06-11  1:16             ` net: stmmac: dwmac-rk: fixes " David Miller
2016-06-13  6:46             ` Giuseppe CAVALLARO
2016-06-15 17:04               ` Vincent Palatin
2016-06-16 13:37                 ` Giuseppe CAVALLARO
2016-06-16 14:51                   ` Vincent Palatin
2016-06-17  5:38                     ` Giuseppe CAVALLARO

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=a61d39032b6d31ca936b6a3bfe92c93246a5c833.1466015458.git.vpalatin@chromium.org \
    --to=vpalatin@chromium.org \
    --cc=andrew@lunn.ch \
    --cc=dianders@chromium.org \
    --cc=heiko@sntech.de \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=peppe.cavallaro@st.com \
    --cc=zhengsq@rock-chips.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).