usbnet: smsc95xx: fix smsc95xx_suspend
cover usbnet: smsc95xx: fix smsc95xx_suspend
Hi,
The 1st two patches fix smsc95xx_suspend, and the 1st one should be backported to 3.8.
The last one is to rename the misleading FEATURE_AUTOSUSPEND.
Thanks,
--
Ming Lei
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
PATCH 1/3 usbnet: smsc95xx: fix suspend failure
The three below functions:
smsc95xx_enter_suspend0() smsc95xx_enter_suspend1() smsc95xx_enter_suspend2()
return > 0 in case of success, so they will cause smsc95xx_suspend() to return > 0 and cause suspend failure.
The bug is introduced in commit 3b9f7d(smsc95xx: fix error handling in suspend failure case).
--- drivers/net/usb/smsc95xx.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-)
drivers/net/usb/smsc95xx.c +9 -3
@@ -1247,10 +1247,12 @@ static int smsc95xx_enter_suspend0(struct usbnet *dev)/* read back PM_CTRL */ ret =smsc95xx_read_reg_nopm (dev,PM_CTRL , &val); +if (ret <0 ) +return ret; pdata->suspend_flags |=SUSPEND_SUSPEND0 ; -return ret; +return 0 ; }static int smsc95xx_enter_suspend1 (struct usbnet *dev)
@@ -1293,10 +1295,12 @@ static int smsc95xx_enter_suspend1(struct usbnet *dev) val |= (PM_CTL_WUPS_ED_ |PM_CTL_ED_EN_ ); ret =smsc95xx_write_reg_nopm (dev,PM_CTRL , val); +if (ret <0 ) +return ret; pdata->suspend_flags |=SUSPEND_SUSPEND1 ; -return ret; +return 0 ; }static int smsc95xx_enter_suspend2 (struct usbnet *dev)
@@ -1313,10 +1317,12 @@ static int smsc95xx_enter_suspend2(struct usbnet *dev) val |=PM_CTL_SUS_MODE_2 ; ret =smsc95xx_write_reg_nopm (dev,PM_CTRL , val); +if (ret <0 ) +return ret; pdata->suspend_flags |=SUSPEND_SUSPEND2 ; -return ret; +return 0 ; }static int smsc95xx_enter_suspend3 (struct usbnet *dev)
Signature · 1 line
1.7.9.5
PATCH 2/3 usbnet: smsc95xx: fix broken runtime suspend
In reply to Ming LeiCommit b2d4b150(smsc95xx: enable dynamic autosuspend) implements autosuspend, but breaks current runtime suspend, such as:
when the interface becomes down, the usb device can't be put into runtime suspend any more.
This patch fixes the broken runtime suspend.
--- drivers/net/usb/smsc95xx.c | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-)
drivers/net/usb/smsc95xx.c +2 -10
@@ -1418,15 +1418,6 @@ static int smsc95xx_suspend(struct usb_interface *intf, pm_message_t message)u32 val, link_up;int ret; -/* TODO: don't indicate this feature to usb framework if -* our current hardware doesn't have the capability -*/ -if ((message.event ==PM_EVENT_AUTO_SUSPEND ) && - (!(pdata->features &FEATURE_AUTOSUSPEND ))) { -netdev_warn (dev->net,"autosuspend not supported\n" ); -return -EBUSY ; - } - ret =usbnet_suspend (intf, message);if (ret <0 ) {netdev_warn (dev->net,"usbnet_suspend error\n" );
@@ -1441,7 +1432,8 @@ static int smsc95xx_suspend(struct usb_interface *intf, pm_message_t message)/* determine if link is up using only _nopm functions */ link_up =smsc95xx_link_ok_nopm (dev); -if (message.event ==PM_EVENT_AUTO_SUSPEND ) { +if (message.event ==PM_EVENT_AUTO_SUSPEND && + (pdata->features &FEATURE_AUTOSUSPEND )) { ret =smsc95xx_autosuspend (dev, link_up); goto done; }
Signature · 1 line
1.7.9.5
PATCH 3/3 usbnet: smsc95xx: rename FEATURE_AUTOSUSPEND
In reply to Ming LeiThe name of FEATURE_AUTOSUSPEND is very misleading and the actual meaning is remote wakeup, but a device incapable of remote wakeup still can support USB autosuspend under some situations, so rename it to avoid misunderstanding.
--- drivers/net/usb/smsc95xx.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-)
drivers/net/usb/smsc95xx.c +7 -7
@@ -53,7 +53,7 @@#define FEATURE_8_WAKEUP_FILTERS (0x01)#define FEATURE_PHY_NLP_CROSSOVER (0x02) -#define FEATURE_AUTOSUSPEND (0x04) +#define FEATURE_REMOTE_WAKEUP (0x04)#define SUSPEND_SUSPEND0 (0x01)#define SUSPEND_SUSPEND1 (0x02)
@@ -1146,7 +1146,7 @@ static int smsc95xx_bind(struct usbnet *dev, struct usb_interface *intf) (val == ID_REV_CHIP_ID_89530_) || (val == ID_REV_CHIP_ID_9730_)) pdata->features = (FEATURE_8_WAKEUP_FILTERS |FEATURE_PHY_NLP_CROSSOVER | -FEATURE_AUTOSUSPEND ); +FEATURE_REMOTE_WAKEUP ); else if (val == ID_REV_CHIP_ID_9512_) pdata->features = FEATURE_8_WAKEUP_FILTERS;
@@ -1378,7 +1378,7 @@ static int smsc95xx_autosuspend(struct usbnet *dev, u32 link_up)if (!link_up) {/* link is down so enter EDPD mode, but only if device can * reliably resume from it. This check should be redundant -* as current FEATURE_AUTOSUSPEND parts also support +* as current FEATURE_REMOTE_WAKEUP parts also support * FEATURE_PHY_NLP_CROSSOVER but it's included for clarity */ if (!(pdata->features &FEATURE_PHY_NLP_CROSSOVER )) {netdev_warn (dev->net,"EDPD not supported\n" );
@@ -1433,7 +1433,7 @@ static int smsc95xx_suspend(struct usb_interface *intf, pm_message_t message) link_up =smsc95xx_link_ok_nopm (dev);if (message.event ==PM_EVENT_AUTO_SUSPEND && - (pdata->features &FEATURE_AUTOSUSPEND )) { + (pdata->features &FEATURE_REMOTE_WAKEUP )) { ret =smsc95xx_autosuspend (dev, link_up); goto done; }
@@ -1870,11 +1870,11 @@ static int smsc95xx_manage_power(struct usbnet *dev, int on) dev->intf->needs_remote_wakeup = on; -if (pdata->features &FEATURE_AUTOSUSPEND ) +if (pdata->features &FEATURE_REMOTE_WAKEUP )return 0 ; -/* this chip revision doesn't support autosuspend */ -netdev_info (dev->net,"hardware doesn't support USB autosuspend\n" ); +/* this chip revision isn't capable of remote wakeup */ +netdev_info (dev->net,"hardware isn't capable of remote wakeup\n" );if (on)usb_autopm_get_interface_no_resume (dev->intf);
Signature · 1 line
1.7.9.5
David Miller
maintainerFrom: Ming Lei <[email protected]>
Date: Fri, 22 Feb 2013 21:05:02 +0800
Quoted 4 lines
The 1st two patches fix
smsc95xx_suspend, and the 1st one should be backported to 3.8.The last one is to rename the misleading
FEATURE_AUTOSUSPEND.
All applied, thanks.