aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/usb/core/hub.c
diff options
context:
space:
mode:
authorAlan Stern <stern@rowland.harvard.edu>2007-05-30 16:51:28 -0400
committerGreg Kroah-Hartman <gregkh@suse.de>2007-07-12 19:34:29 -0400
commit4956eccdd6101c5abb71966079e8183d12796d6c (patch)
treed8610e3675719818e78e967ea920c4e9c8fc7ba5 /drivers/usb/core/hub.c
parentd576bb9f2769b315a795f77f0c33322a976add7a (diff)
USB: remove __usb_port_suspend
This patch (as915b) combines the public routine usb_port_suspend() and the private routine __usb_port_suspend() into a single function. By removing the explicit mention of otg_port in the call to __usb_port_suspend(), we prevent a possible error in which the system tries to perform HNP on the wrong port when a non-targeted device is plugged into a non-OTG port. Signed-off-by: Alan Stern <stern@rowland.harvard.edu> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers/usb/core/hub.c')
-rw-r--r--drivers/usb/core/hub.c57
1 files changed, 23 insertions, 34 deletions
diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c
index 7946d7b6c71..04d6fde57d8 100644
--- a/drivers/usb/core/hub.c
+++ b/drivers/usb/core/hub.c
@@ -1333,7 +1333,6 @@ static inline void show_string(struct usb_device *udev, char *id, char *string)
1333 1333
1334#ifdef CONFIG_USB_OTG 1334#ifdef CONFIG_USB_OTG
1335#include "otg_whitelist.h" 1335#include "otg_whitelist.h"
1336static int __usb_port_suspend(struct usb_device *, int port1);
1337#endif 1336#endif
1338 1337
1339/** 1338/**
@@ -1439,7 +1438,7 @@ int usb_new_device(struct usb_device *udev)
1439 * (Includes HNP test device.) 1438 * (Includes HNP test device.)
1440 */ 1439 */
1441 if (udev->bus->b_hnp_enable || udev->bus->is_b_host) { 1440 if (udev->bus->b_hnp_enable || udev->bus->is_b_host) {
1442 err = __usb_port_suspend(udev, udev->bus->otg_port); 1441 err = usb_port_suspend(udev);
1443 if (err < 0) 1442 if (err < 0)
1444 dev_dbg(&udev->dev, "HNP fail, %d\n", err); 1443 dev_dbg(&udev->dev, "HNP fail, %d\n", err);
1445 } 1444 }
@@ -1683,6 +1682,23 @@ static int hub_port_suspend(struct usb_hub *hub, int port1,
1683} 1682}
1684 1683
1685/* 1684/*
1685 * usb_port_suspend - suspend a usb device's upstream port
1686 * @udev: device that's no longer in active use
1687 * Context: must be able to sleep; device not locked; pm locks held
1688 *
1689 * Suspends a USB device that isn't in active use, conserving power.
1690 * Devices may wake out of a suspend, if anything important happens,
1691 * using the remote wakeup mechanism. They may also be taken out of
1692 * suspend by the host, using usb_port_resume(). It's also routine
1693 * to disconnect devices while they are suspended.
1694 *
1695 * This only affects the USB hardware for a device; its interfaces
1696 * (and, for hubs, child devices) must already have been suspended.
1697 *
1698 * Suspending OTG devices may trigger HNP, if that's been enabled
1699 * between a pair of dual-role devices. That will change roles, such
1700 * as from A-Host to A-Peripheral or from B-Host back to B-Peripheral.
1701 *
1686 * Devices on USB hub ports have only one "suspend" state, corresponding 1702 * Devices on USB hub ports have only one "suspend" state, corresponding
1687 * to ACPI D2, "may cause the device to lose some context". 1703 * to ACPI D2, "may cause the device to lose some context".
1688 * State transitions include: 1704 * State transitions include:
@@ -1699,21 +1715,19 @@ static int hub_port_suspend(struct usb_hub *hub, int port1,
1699 * If CONFIG_USB_SUSPEND isn't enabled, devices only really suspend when 1715 * If CONFIG_USB_SUSPEND isn't enabled, devices only really suspend when
1700 * the root hub for their bus goes into global suspend ... so we don't 1716 * the root hub for their bus goes into global suspend ... so we don't
1701 * (falsely) update the device power state to say it suspended. 1717 * (falsely) update the device power state to say it suspended.
1718 *
1719 * Returns 0 on success, else negative errno.
1702 */ 1720 */
1703static int __usb_port_suspend (struct usb_device *udev, int port1) 1721int usb_port_suspend(struct usb_device *udev)
1704{ 1722{
1705 int status = 0; 1723 int status = 0;
1706 1724
1707 /* caller owns the udev device lock */
1708 if (port1 < 0)
1709 return port1;
1710
1711 /* we change the device's upstream USB link, 1725 /* we change the device's upstream USB link,
1712 * but root hubs have no upstream USB link. 1726 * but root hubs have no upstream USB link.
1713 */ 1727 */
1714 if (udev->parent) 1728 if (udev->parent)
1715 status = hub_port_suspend(hdev_to_hub(udev->parent), port1, 1729 status = hub_port_suspend(hdev_to_hub(udev->parent),
1716 udev); 1730 udev->portnum, udev);
1717 else { 1731 else {
1718 dev_dbg(&udev->dev, "usb %ssuspend\n", 1732 dev_dbg(&udev->dev, "usb %ssuspend\n",
1719 udev->auto_pm ? "auto-" : ""); 1733 udev->auto_pm ? "auto-" : "");
@@ -1723,31 +1737,6 @@ static int __usb_port_suspend (struct usb_device *udev, int port1)
1723} 1737}
1724 1738
1725/* 1739/*
1726 * usb_port_suspend - suspend a usb device's upstream port
1727 * @udev: device that's no longer in active use
1728 * Context: must be able to sleep; device not locked; pm locks held
1729 *
1730 * Suspends a USB device that isn't in active use, conserving power.
1731 * Devices may wake out of a suspend, if anything important happens,
1732 * using the remote wakeup mechanism. They may also be taken out of
1733 * suspend by the host, using usb_port_resume(). It's also routine
1734 * to disconnect devices while they are suspended.
1735 *
1736 * This only affects the USB hardware for a device; its interfaces
1737 * (and, for hubs, child devices) must already have been suspended.
1738 *
1739 * Suspending OTG devices may trigger HNP, if that's been enabled
1740 * between a pair of dual-role devices. That will change roles, such
1741 * as from A-Host to A-Peripheral or from B-Host back to B-Peripheral.
1742 *
1743 * Returns 0 on success, else negative errno.
1744 */
1745int usb_port_suspend(struct usb_device *udev)
1746{
1747 return __usb_port_suspend(udev, udev->portnum);
1748}
1749
1750/*
1751 * If the USB "suspend" state is in use (rather than "global suspend"), 1740 * If the USB "suspend" state is in use (rather than "global suspend"),
1752 * many devices will be individually taken out of suspend state using 1741 * many devices will be individually taken out of suspend state using
1753 * special" resume" signaling. These routines kick in shortly after 1742 * special" resume" signaling. These routines kick in shortly after