summaryrefslogtreecommitdiff
path: root/drivers/net/usb/smsc95xx.c
diff options
context:
space:
mode:
authorSteve Glendinning <steve.glendinning@shawell.net>2012-09-28 00:07:11 +0000
committerDavid S. Miller <davem@davemloft.net>2012-09-28 18:34:58 -0400
commitb5a044758672b6dc775fdab007337b47a54576f4 (patch)
tree3bab50b861a6881f1c63128d7c4d35de31ad8eae /drivers/net/usb/smsc95xx.c
parentc954679cf76095b0a1232c3dad604a9066d78ab1 (diff)
smsc95xx: enable power saving mode during system suspend
This patch enables the device to enter its lowest power SUSPEND2 state during system suspend, instead of staying up using full power. Patch updated to not add two pointers to .suspend & .resume. Patch updated to replace BUG_ON with WARN_ON_ONCE and return. Signed-off-by: Steve Glendinning <steve.glendinning@shawell.net> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/usb/smsc95xx.c')
-rw-r--r--drivers/net/usb/smsc95xx.c28
1 files changed, 27 insertions, 1 deletions
diff --git a/drivers/net/usb/smsc95xx.c b/drivers/net/usb/smsc95xx.c
index f29860d6341a..ba0360fb857f 100644
--- a/drivers/net/usb/smsc95xx.c
+++ b/drivers/net/usb/smsc95xx.c
@@ -1018,6 +1018,32 @@ static void smsc95xx_unbind(struct usbnet *dev, struct usb_interface *intf)
}
}
+static int smsc95xx_suspend(struct usb_interface *intf, pm_message_t message)
+{
+ struct usbnet *dev = usb_get_intfdata(intf);
+ int ret;
+ u32 val;
+
+ if (WARN_ON_ONCE(!dev))
+ return -EINVAL;
+
+ ret = usbnet_suspend(intf, message);
+ check_warn_return(ret, "usbnet_suspend error");
+
+ netdev_info(dev->net, "entering SUSPEND2 mode");
+
+ ret = smsc95xx_read_reg(dev, PM_CTRL, &val);
+ check_warn_return(ret, "Error reading PM_CTRL");
+
+ val &= ~(PM_CTL_SUS_MODE_ | PM_CTL_WUPS_ | PM_CTL_PHY_RST_);
+ val |= PM_CTL_SUS_MODE_2;
+
+ ret = smsc95xx_write_reg(dev, PM_CTRL, val);
+ check_warn_return(ret, "Error writing PM_CTRL");
+
+ return 0;
+}
+
static void smsc95xx_rx_csum_offload(struct sk_buff *skb)
{
skb->csum = *(u16 *)(skb_tail_pointer(skb) - 2);
@@ -1280,7 +1306,7 @@ static struct usb_driver smsc95xx_driver = {
.name = "smsc95xx",
.id_table = products,
.probe = usbnet_probe,
- .suspend = usbnet_suspend,
+ .suspend = smsc95xx_suspend,
.resume = usbnet_resume,
.reset_resume = usbnet_resume,
.disconnect = usbnet_disconnect,