Thread (25 messages) flat view 25 messages, 2 authors, 2011-02-22
STALE5668d

[PATCH 04/14] net/fec: no need to check for validity of ndev in suspend and resume

From: Uwe Kleine-König <hidden>
Date: 2011-02-11 10:32:31
Subsystem: networking drivers, the rest · Maintainers: Andrew Lunn, "David S. Miller", Eric Dumazet, Jakub Kicinski, Paolo Abeni, Linus Torvalds

dev_set_drvdata is called unconditionally in the probe function and so
it cannot be NULL.

Noticed-by: Lothar Waßmann [off-list ref]
Signed-off-by: Uwe Kleine-König <redacted>
---
 drivers/net/fec.c |   28 ++++++++++++----------------
 1 files changed, 12 insertions(+), 16 deletions(-)
diff --git a/drivers/net/fec.c b/drivers/net/fec.c
index aa1db8e..8026a16 100644
--- a/drivers/net/fec.c
+++ b/drivers/net/fec.c
@@ -1492,16 +1492,14 @@ static int
 fec_suspend(struct device *dev)
 {
 	struct net_device *ndev = dev_get_drvdata(dev);
-	struct fec_enet_private *fep;
+	struct fec_enet_private *fep = netdev_priv(ndev);
 
-	if (ndev) {
-		fep = netdev_priv(ndev);
-		if (netif_running(ndev)) {
-			fec_stop(ndev);
-			netif_device_detach(ndev);
-		}
-		clk_disable(fep->clk);
+	if (netif_running(ndev)) {
+		fec_stop(ndev);
+		netif_device_detach(ndev);
 	}
+	clk_disable(fep->clk);
+
 	return 0;
 }
 
@@ -1509,16 +1507,14 @@ static int
 fec_resume(struct device *dev)
 {
 	struct net_device *ndev = dev_get_drvdata(dev);
-	struct fec_enet_private *fep;
+	struct fec_enet_private *fep = netdev_priv(ndev);
 
-	if (ndev) {
-		fep = netdev_priv(ndev);
-		clk_enable(fep->clk);
-		if (netif_running(ndev)) {
-			fec_restart(ndev, fep->full_duplex);
-			netif_device_attach(ndev);
-		}
+	clk_enable(fep->clk);
+	if (netif_running(ndev)) {
+		fec_restart(ndev, fep->full_duplex);
+		netif_device_attach(ndev);
 	}
+
 	return 0;
 }
 
-- 
1.7.2.3
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help