linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] smc91x: power down PHY on suspend
@ 2005-01-20 12:13 Ian Campbell
  2005-01-20 15:18 ` Nicolas Pitre
  0 siblings, 1 reply; 2+ messages in thread
From: Ian Campbell @ 2005-01-20 12:13 UTC (permalink / raw)
  To: Nicolas Pitre; +Cc: akpm, Jeff Garzik, linux-kernel

Hi,

Powering down the PHY saves something like 100mA at 5V on my platform.
Currently it is only done when the interface is brought down but it
makes sense to do it on suspend as well. 

Signed-off-by: Ian Campbell <icampbell@arcom.com>

Index: 2.6/drivers/net/smc91x.c
===================================================================
--- 2.6.orig/drivers/net/smc91x.c	2005-01-17 11:04:43.000000000 +0000
+++ 2.6/drivers/net/smc91x.c	2005-01-20 12:11:09.292758475 +0000
@@ -1013,13 +1008,29 @@
 /*
  * smc_phy_powerdown - powerdown phy
  * @dev: net device
- * @phy: phy address
  *
  * Power down the specified PHY
  */
-static void smc_phy_powerdown(struct net_device *dev, int phy)
+static void smc_phy_powerdown(struct net_device *dev)
 {
+	struct smc_local *lp = netdev_priv(dev);
 	unsigned int bmcr;
+	int phy = lp->mii.phy_id;
+
+	if (lp->phy_type == 0)
+		return;
+
+	/* We need to ensure that no calls to smc_phy_configure are
+	   pending.
+
+	   flush_scheduled_work() cannot be called because we are
+	   running with the netlink semaphore held (from
+	   devinet_ioctl()) and the pending work queue contains
+	   linkwatch_event() (scheduled by netif_carrier_off()
+	   above). linkwatch_event() also wants the netlink semaphore.
+	*/
+	while(lp->work_pending)
+		schedule();
 
 	bmcr = smc_phy_read(dev, phy, MII_BMCR);
 	smc_phy_write(dev, phy, MII_BMCR, bmcr | BMCR_PDOWN);
@@ -1544,21 +1555,7 @@
 	/* clear everything */
 	smc_shutdown(dev);
 
-	if (lp->phy_type != 0) {
-		/* We need to ensure that no calls to
-		   smc_phy_configure are pending.
-
-		   flush_scheduled_work() cannot be called because we
-		   are running with the netlink semaphore held (from
-		   devinet_ioctl()) and the pending work queue
-		   contains linkwatch_event() (scheduled by
-		   netif_carrier_off() above). linkwatch_event() also
-		   wants the netlink semaphore.
-		*/
-		while(lp->work_pending)
-			schedule();
-		smc_phy_powerdown(dev, lp->mii.phy_id);
-	}
+	smc_phy_powerdown(dev);
 
 	if (lp->pending_tx_skb) {
 		dev_kfree_skb(lp->pending_tx_skb);
@@ -2176,6 +2179,7 @@
 		if (netif_running(ndev)) {
 			netif_device_detach(ndev);
 			smc_shutdown(ndev);
+			smc_phy_powerdown(ndev);
 		}
 	}
 	return 0;



-- 
Ian Campbell, Senior Design Engineer
                                        Web: http://www.arcom.com
Arcom, Clifton Road,                    Direct: +44 (0)1223 403 465
Cambridge CB1 7EA, United Kingdom       Phone:  +44 (0)1223 411 200


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

* Re: [PATCH] smc91x: power down PHY on suspend
  2005-01-20 12:13 [PATCH] smc91x: power down PHY on suspend Ian Campbell
@ 2005-01-20 15:18 ` Nicolas Pitre
  0 siblings, 0 replies; 2+ messages in thread
From: Nicolas Pitre @ 2005-01-20 15:18 UTC (permalink / raw)
  To: Ian Campbell; +Cc: akpm, Jeff Garzik, linux-kernel

On Thu, 20 Jan 2005, Ian Campbell wrote:

> Hi,
> 
> Powering down the PHY saves something like 100mA at 5V on my platform.
> Currently it is only done when the interface is brought down but it
> makes sense to do it on suspend as well. 
> 
> Signed-off-by: Ian Campbell <icampbell@arcom.com>

Signed-off-by: Nicolas Pitre <nico@cam.org>

> 
> Index: 2.6/drivers/net/smc91x.c
> ===================================================================
> --- 2.6.orig/drivers/net/smc91x.c	2005-01-17 11:04:43.000000000 +0000
> +++ 2.6/drivers/net/smc91x.c	2005-01-20 12:11:09.292758475 +0000
> @@ -1013,13 +1008,29 @@
>  /*
>   * smc_phy_powerdown - powerdown phy
>   * @dev: net device
> - * @phy: phy address
>   *
>   * Power down the specified PHY
>   */
> -static void smc_phy_powerdown(struct net_device *dev, int phy)
> +static void smc_phy_powerdown(struct net_device *dev)
>  {
> +	struct smc_local *lp = netdev_priv(dev);
>  	unsigned int bmcr;
> +	int phy = lp->mii.phy_id;
> +
> +	if (lp->phy_type == 0)
> +		return;
> +
> +	/* We need to ensure that no calls to smc_phy_configure are
> +	   pending.
> +
> +	   flush_scheduled_work() cannot be called because we are
> +	   running with the netlink semaphore held (from
> +	   devinet_ioctl()) and the pending work queue contains
> +	   linkwatch_event() (scheduled by netif_carrier_off()
> +	   above). linkwatch_event() also wants the netlink semaphore.
> +	*/
> +	while(lp->work_pending)
> +		schedule();
>  
>  	bmcr = smc_phy_read(dev, phy, MII_BMCR);
>  	smc_phy_write(dev, phy, MII_BMCR, bmcr | BMCR_PDOWN);
> @@ -1544,21 +1555,7 @@
>  	/* clear everything */
>  	smc_shutdown(dev);
>  
> -	if (lp->phy_type != 0) {
> -		/* We need to ensure that no calls to
> -		   smc_phy_configure are pending.
> -
> -		   flush_scheduled_work() cannot be called because we
> -		   are running with the netlink semaphore held (from
> -		   devinet_ioctl()) and the pending work queue
> -		   contains linkwatch_event() (scheduled by
> -		   netif_carrier_off() above). linkwatch_event() also
> -		   wants the netlink semaphore.
> -		*/
> -		while(lp->work_pending)
> -			schedule();
> -		smc_phy_powerdown(dev, lp->mii.phy_id);
> -	}
> +	smc_phy_powerdown(dev);
>  
>  	if (lp->pending_tx_skb) {
>  		dev_kfree_skb(lp->pending_tx_skb);
> @@ -2176,6 +2179,7 @@
>  		if (netif_running(ndev)) {
>  			netif_device_detach(ndev);
>  			smc_shutdown(ndev);
> +			smc_phy_powerdown(ndev);
>  		}
>  	}
>  	return 0;
> 
> 
> 
> -- 
> Ian Campbell, Senior Design Engineer
>                                         Web: http://www.arcom.com
> Arcom, Clifton Road,                    Direct: +44 (0)1223 403 465
> Cambridge CB1 7EA, United Kingdom       Phone:  +44 (0)1223 411 200
> 


Nicolas

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

end of thread, other threads:[~2005-01-20 15:19 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-01-20 12:13 [PATCH] smc91x: power down PHY on suspend Ian Campbell
2005-01-20 15:18 ` Nicolas Pitre

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