提交 50cda889 编写于 作者: K Kai-Heng Feng 提交者: Greg Kroah-Hartman

USB: Add new USB LPM helpers

commit 7529b2574a7aaf902f1f8159fbc2a7caa74be559 upstream.

Use new helpers to make LPM enabling/disabling more clear.

This is a preparation to subsequent patch.
Signed-off-by: NKai-Heng Feng <kai.heng.feng@canonical.com>
Cc: stable <stable@vger.kernel.org> # after much soaking
Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
上级 8c700e90
...@@ -1899,7 +1899,7 @@ int usb_runtime_idle(struct device *dev) ...@@ -1899,7 +1899,7 @@ int usb_runtime_idle(struct device *dev)
return -EBUSY; return -EBUSY;
} }
int usb_set_usb2_hardware_lpm(struct usb_device *udev, int enable) static int usb_set_usb2_hardware_lpm(struct usb_device *udev, int enable)
{ {
struct usb_hcd *hcd = bus_to_hcd(udev->bus); struct usb_hcd *hcd = bus_to_hcd(udev->bus);
int ret = -EPERM; int ret = -EPERM;
...@@ -1916,6 +1916,16 @@ int usb_set_usb2_hardware_lpm(struct usb_device *udev, int enable) ...@@ -1916,6 +1916,16 @@ int usb_set_usb2_hardware_lpm(struct usb_device *udev, int enable)
return ret; return ret;
} }
int usb_enable_usb2_hardware_lpm(struct usb_device *udev)
{
return usb_set_usb2_hardware_lpm(udev, 1);
}
int usb_disable_usb2_hardware_lpm(struct usb_device *udev)
{
return usb_set_usb2_hardware_lpm(udev, 0);
}
#endif /* CONFIG_PM */ #endif /* CONFIG_PM */
struct bus_type usb_bus_type = { struct bus_type usb_bus_type = {
......
...@@ -3218,7 +3218,7 @@ int usb_port_suspend(struct usb_device *udev, pm_message_t msg) ...@@ -3218,7 +3218,7 @@ int usb_port_suspend(struct usb_device *udev, pm_message_t msg)
/* disable USB2 hardware LPM */ /* disable USB2 hardware LPM */
if (udev->usb2_hw_lpm_enabled == 1) if (udev->usb2_hw_lpm_enabled == 1)
usb_set_usb2_hardware_lpm(udev, 0); usb_disable_usb2_hardware_lpm(udev);
if (usb_disable_ltm(udev)) { if (usb_disable_ltm(udev)) {
dev_err(&udev->dev, "Failed to disable LTM before suspend\n"); dev_err(&udev->dev, "Failed to disable LTM before suspend\n");
...@@ -3257,7 +3257,7 @@ int usb_port_suspend(struct usb_device *udev, pm_message_t msg) ...@@ -3257,7 +3257,7 @@ int usb_port_suspend(struct usb_device *udev, pm_message_t msg)
err_ltm: err_ltm:
/* Try to enable USB2 hardware LPM again */ /* Try to enable USB2 hardware LPM again */
if (udev->usb2_hw_lpm_capable == 1) if (udev->usb2_hw_lpm_capable == 1)
usb_set_usb2_hardware_lpm(udev, 1); usb_enable_usb2_hardware_lpm(udev);
if (udev->do_remote_wakeup) if (udev->do_remote_wakeup)
(void) usb_disable_remote_wakeup(udev); (void) usb_disable_remote_wakeup(udev);
...@@ -3541,7 +3541,7 @@ int usb_port_resume(struct usb_device *udev, pm_message_t msg) ...@@ -3541,7 +3541,7 @@ int usb_port_resume(struct usb_device *udev, pm_message_t msg)
} else { } else {
/* Try to enable USB2 hardware LPM */ /* Try to enable USB2 hardware LPM */
if (udev->usb2_hw_lpm_capable == 1) if (udev->usb2_hw_lpm_capable == 1)
usb_set_usb2_hardware_lpm(udev, 1); usb_enable_usb2_hardware_lpm(udev);
/* Try to enable USB3 LTM */ /* Try to enable USB3 LTM */
usb_enable_ltm(udev); usb_enable_ltm(udev);
...@@ -4432,7 +4432,7 @@ static void hub_set_initial_usb2_lpm_policy(struct usb_device *udev) ...@@ -4432,7 +4432,7 @@ static void hub_set_initial_usb2_lpm_policy(struct usb_device *udev)
if ((udev->bos->ext_cap->bmAttributes & cpu_to_le32(USB_BESL_SUPPORT)) || if ((udev->bos->ext_cap->bmAttributes & cpu_to_le32(USB_BESL_SUPPORT)) ||
connect_type == USB_PORT_CONNECT_TYPE_HARD_WIRED) { connect_type == USB_PORT_CONNECT_TYPE_HARD_WIRED) {
udev->usb2_hw_lpm_allowed = 1; udev->usb2_hw_lpm_allowed = 1;
usb_set_usb2_hardware_lpm(udev, 1); usb_enable_usb2_hardware_lpm(udev);
} }
} }
...@@ -5609,7 +5609,7 @@ static int usb_reset_and_verify_device(struct usb_device *udev) ...@@ -5609,7 +5609,7 @@ static int usb_reset_and_verify_device(struct usb_device *udev)
* It will be re-enabled by the enumeration process. * It will be re-enabled by the enumeration process.
*/ */
if (udev->usb2_hw_lpm_enabled == 1) if (udev->usb2_hw_lpm_enabled == 1)
usb_set_usb2_hardware_lpm(udev, 0); usb_disable_usb2_hardware_lpm(udev);
/* Disable LPM while we reset the device and reinstall the alt settings. /* Disable LPM while we reset the device and reinstall the alt settings.
* Device-initiated LPM, and system exit latency settings are cleared * Device-initiated LPM, and system exit latency settings are cleared
...@@ -5712,7 +5712,7 @@ static int usb_reset_and_verify_device(struct usb_device *udev) ...@@ -5712,7 +5712,7 @@ static int usb_reset_and_verify_device(struct usb_device *udev)
done: done:
/* Now that the alt settings are re-installed, enable LTM and LPM. */ /* Now that the alt settings are re-installed, enable LTM and LPM. */
usb_set_usb2_hardware_lpm(udev, 1); usb_enable_usb2_hardware_lpm(udev);
usb_unlocked_enable_lpm(udev); usb_unlocked_enable_lpm(udev);
usb_enable_ltm(udev); usb_enable_ltm(udev);
usb_release_bos_descriptor(udev); usb_release_bos_descriptor(udev);
......
...@@ -1244,7 +1244,7 @@ void usb_disable_device(struct usb_device *dev, int skip_ep0) ...@@ -1244,7 +1244,7 @@ void usb_disable_device(struct usb_device *dev, int skip_ep0)
} }
if (dev->usb2_hw_lpm_enabled == 1) if (dev->usb2_hw_lpm_enabled == 1)
usb_set_usb2_hardware_lpm(dev, 0); usb_disable_usb2_hardware_lpm(dev);
usb_unlocked_disable_lpm(dev); usb_unlocked_disable_lpm(dev);
usb_disable_ltm(dev); usb_disable_ltm(dev);
......
...@@ -528,7 +528,10 @@ static ssize_t usb2_hardware_lpm_store(struct device *dev, ...@@ -528,7 +528,10 @@ static ssize_t usb2_hardware_lpm_store(struct device *dev,
if (!ret) { if (!ret) {
udev->usb2_hw_lpm_allowed = value; udev->usb2_hw_lpm_allowed = value;
ret = usb_set_usb2_hardware_lpm(udev, value); if (value)
ret = usb_enable_usb2_hardware_lpm(udev);
else
ret = usb_disable_usb2_hardware_lpm(udev);
} }
usb_unlock_device(udev); usb_unlock_device(udev);
......
...@@ -92,7 +92,8 @@ extern int usb_remote_wakeup(struct usb_device *dev); ...@@ -92,7 +92,8 @@ extern int usb_remote_wakeup(struct usb_device *dev);
extern int usb_runtime_suspend(struct device *dev); extern int usb_runtime_suspend(struct device *dev);
extern int usb_runtime_resume(struct device *dev); extern int usb_runtime_resume(struct device *dev);
extern int usb_runtime_idle(struct device *dev); extern int usb_runtime_idle(struct device *dev);
extern int usb_set_usb2_hardware_lpm(struct usb_device *udev, int enable); extern int usb_enable_usb2_hardware_lpm(struct usb_device *udev);
extern int usb_disable_usb2_hardware_lpm(struct usb_device *udev);
#else #else
...@@ -112,7 +113,12 @@ static inline int usb_autoresume_device(struct usb_device *udev) ...@@ -112,7 +113,12 @@ static inline int usb_autoresume_device(struct usb_device *udev)
return 0; return 0;
} }
static inline int usb_set_usb2_hardware_lpm(struct usb_device *udev, int enable) static inline int usb_enable_usb2_hardware_lpm(struct usb_device *udev)
{
return 0;
}
static inline int usb_disable_usb2_hardware_lpm(struct usb_device *udev)
{ {
return 0; return 0;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册