linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH V2] net: ethernet: ti: cpsw: Fix suspend/resume break
@ 2019-06-24  5:16 Keerthy
  2019-06-24 14:23 ` David Miller
  0 siblings, 1 reply; 3+ messages in thread
From: Keerthy @ 2019-06-24  5:16 UTC (permalink / raw)
  To: davem, ivan.khoronzhuk, andrew, ilias.apalodimas
  Cc: linux-kernel, netdev, linux-omap, t-kristo, j-keerthy,
	grygorii.strashko, nsekhar

Commit bfe59032bd6127ee190edb30be9381a01765b958 ("net: ethernet:
ti: cpsw: use cpsw as drv data")changes
the driver data to struct cpsw_common *cpsw. This is done
only in probe/remove but the suspend/resume functions are
still left with struct net_device *ndev. Hence fix both
suspend & resume also to fetch the updated driver data.

Fixes: bfe59032bd6127ee1 ("net: ethernet: ti: cpsw: use cpsw as drv data")
Signed-off-by: Keerthy <j-keerthy@ti.com>
---

Change in v2:

  * Added NULL Checks for cpsw->slaves[i].ndev in suspend/resume functions.

 drivers/net/ethernet/ti/cpsw.c | 30 +++++++++---------------------
 1 file changed, 9 insertions(+), 21 deletions(-)

diff --git a/drivers/net/ethernet/ti/cpsw.c b/drivers/net/ethernet/ti/cpsw.c
index 7bdd287074fc..32b7b3b74a6b 100644
--- a/drivers/net/ethernet/ti/cpsw.c
+++ b/drivers/net/ethernet/ti/cpsw.c
@@ -2590,20 +2590,13 @@ static int cpsw_remove(struct platform_device *pdev)
 #ifdef CONFIG_PM_SLEEP
 static int cpsw_suspend(struct device *dev)
 {
-	struct net_device	*ndev = dev_get_drvdata(dev);
-	struct cpsw_common	*cpsw = ndev_to_cpsw(ndev);
-
-	if (cpsw->data.dual_emac) {
-		int i;
+	struct cpsw_common *cpsw = dev_get_drvdata(dev);
+	int i;
 
-		for (i = 0; i < cpsw->data.slaves; i++) {
+	for (i = 0; i < cpsw->data.slaves; i++)
+		if (cpsw->slaves[i].ndev)
 			if (netif_running(cpsw->slaves[i].ndev))
 				cpsw_ndo_stop(cpsw->slaves[i].ndev);
-		}
-	} else {
-		if (netif_running(ndev))
-			cpsw_ndo_stop(ndev);
-	}
 
 	/* Select sleep pin state */
 	pinctrl_pm_select_sleep_state(dev);
@@ -2613,25 +2606,20 @@ static int cpsw_suspend(struct device *dev)
 
 static int cpsw_resume(struct device *dev)
 {
-	struct net_device	*ndev = dev_get_drvdata(dev);
-	struct cpsw_common	*cpsw = ndev_to_cpsw(ndev);
+	struct cpsw_common *cpsw = dev_get_drvdata(dev);
+	int i;
 
 	/* Select default pin state */
 	pinctrl_pm_select_default_state(dev);
 
 	/* shut up ASSERT_RTNL() warning in netif_set_real_num_tx/rx_queues */
 	rtnl_lock();
-	if (cpsw->data.dual_emac) {
-		int i;
 
-		for (i = 0; i < cpsw->data.slaves; i++) {
+	for (i = 0; i < cpsw->data.slaves; i++)
+		if (cpsw->slaves[i].ndev)
 			if (netif_running(cpsw->slaves[i].ndev))
 				cpsw_ndo_open(cpsw->slaves[i].ndev);
-		}
-	} else {
-		if (netif_running(ndev))
-			cpsw_ndo_open(ndev);
-	}
+
 	rtnl_unlock();
 
 	return 0;
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH V2] net: ethernet: ti: cpsw: Fix suspend/resume break
  2019-06-24  5:16 [PATCH V2] net: ethernet: ti: cpsw: Fix suspend/resume break Keerthy
@ 2019-06-24 14:23 ` David Miller
  2019-06-25 10:04   ` keerthy
  0 siblings, 1 reply; 3+ messages in thread
From: David Miller @ 2019-06-24 14:23 UTC (permalink / raw)
  To: j-keerthy
  Cc: ivan.khoronzhuk, andrew, ilias.apalodimas, linux-kernel, netdev,
	linux-omap, t-kristo, grygorii.strashko, nsekhar

From: Keerthy <j-keerthy@ti.com>
Date: Mon, 24 Jun 2019 10:46:19 +0530

> Commit bfe59032bd6127ee190edb30be9381a01765b958 ("net: ethernet:
> ti: cpsw: use cpsw as drv data")changes
> the driver data to struct cpsw_common *cpsw. This is done
> only in probe/remove but the suspend/resume functions are
> still left with struct net_device *ndev. Hence fix both
> suspend & resume also to fetch the updated driver data.
> 
> Fixes: bfe59032bd6127ee1 ("net: ethernet: ti: cpsw: use cpsw as drv data")
> Signed-off-by: Keerthy <j-keerthy@ti.com>

Applied but please make it clear that changes are targetting net-next in the
future by saying "[PATCH net-next v2] ...." in your Subject line.

Thank you.

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH V2] net: ethernet: ti: cpsw: Fix suspend/resume break
  2019-06-24 14:23 ` David Miller
@ 2019-06-25 10:04   ` keerthy
  0 siblings, 0 replies; 3+ messages in thread
From: keerthy @ 2019-06-25 10:04 UTC (permalink / raw)
  To: David Miller
  Cc: ivan.khoronzhuk, andrew, ilias.apalodimas, linux-kernel, netdev,
	linux-omap, t-kristo, grygorii.strashko, nsekhar



On 6/24/2019 7:53 PM, David Miller wrote:
> From: Keerthy <j-keerthy@ti.com>
> Date: Mon, 24 Jun 2019 10:46:19 +0530
> 
>> Commit bfe59032bd6127ee190edb30be9381a01765b958 ("net: ethernet:
>> ti: cpsw: use cpsw as drv data")changes
>> the driver data to struct cpsw_common *cpsw. This is done
>> only in probe/remove but the suspend/resume functions are
>> still left with struct net_device *ndev. Hence fix both
>> suspend & resume also to fetch the updated driver data.
>>
>> Fixes: bfe59032bd6127ee1 ("net: ethernet: ti: cpsw: use cpsw as drv data")
>> Signed-off-by: Keerthy <j-keerthy@ti.com>
> 
> Applied but please make it clear that changes are targetting net-next in the
> future by saying "[PATCH net-next v2] ...." in your Subject line.

Sure will do that. Thanks.

> 
> Thank you.
> 

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2019-06-25 10:04 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-06-24  5:16 [PATCH V2] net: ethernet: ti: cpsw: Fix suspend/resume break Keerthy
2019-06-24 14:23 ` David Miller
2019-06-25 10:04   ` keerthy

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).