aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/usb
diff options
context:
space:
mode:
authorAlan Stern <stern@rowland.harvard.edu>2010-01-08 12:57:14 -0500
committerGreg Kroah-Hartman <gregkh@suse.de>2010-03-02 17:54:11 -0500
commit0c590e2361511997430130e10e372217c1128da6 (patch)
treec1d2c47b3593502b6aaed5eae494559c8737b9c2 /drivers/usb
parent5899f1e020c8d53b2b6fbd6a6cf39c891ccdfade (diff)
USB: rearrange functions in driver.c
This patch (as1328) reorders the functions in drivers/usb/core/driver.c so as to put all the routines dependent on CONFIG_PM in one place. Signed-off-by: Alan Stern <stern@rowland.harvard.edu> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers/usb')
-rw-r--r--drivers/usb/core/driver.c206
1 files changed, 103 insertions, 103 deletions
diff --git a/drivers/usb/core/driver.c b/drivers/usb/core/driver.c
index 057eeab06004..638d54693a1c 100644
--- a/drivers/usb/core/driver.c
+++ b/drivers/usb/core/driver.c
@@ -1413,6 +1413,109 @@ static int usb_resume_both(struct usb_device *udev, pm_message_t msg)
1413 return status; 1413 return status;
1414} 1414}
1415 1415
1416/**
1417 * usb_external_suspend_device - external suspend of a USB device and its interfaces
1418 * @udev: the usb_device to suspend
1419 * @msg: Power Management message describing this state transition
1420 *
1421 * This routine handles external suspend requests: ones not generated
1422 * internally by a USB driver (autosuspend) but rather coming from the user
1423 * (via sysfs) or the PM core (system sleep). The suspend will be carried
1424 * out regardless of @udev's usage counter or those of its interfaces,
1425 * and regardless of whether or not remote wakeup is enabled. Of course,
1426 * interface drivers still have the option of failing the suspend (if
1427 * there are unsuspended children, for example).
1428 *
1429 * The caller must hold @udev's device lock.
1430 */
1431int usb_external_suspend_device(struct usb_device *udev, pm_message_t msg)
1432{
1433 int status;
1434
1435 do_unbind_rebind(udev, DO_UNBIND);
1436 usb_pm_lock(udev);
1437 status = usb_suspend_both(udev, msg);
1438 usb_pm_unlock(udev);
1439 return status;
1440}
1441
1442/**
1443 * usb_external_resume_device - external resume of a USB device and its interfaces
1444 * @udev: the usb_device to resume
1445 * @msg: Power Management message describing this state transition
1446 *
1447 * This routine handles external resume requests: ones not generated
1448 * internally by a USB driver (autoresume) but rather coming from the user
1449 * (via sysfs), the PM core (system resume), or the device itself (remote
1450 * wakeup). @udev's usage counter is unaffected.
1451 *
1452 * The caller must hold @udev's device lock.
1453 */
1454int usb_external_resume_device(struct usb_device *udev, pm_message_t msg)
1455{
1456 int status;
1457
1458 usb_pm_lock(udev);
1459 status = usb_resume_both(udev, msg);
1460 udev->last_busy = jiffies;
1461 usb_pm_unlock(udev);
1462 if (status == 0)
1463 do_unbind_rebind(udev, DO_REBIND);
1464
1465 /* Now that the device is awake, we can start trying to autosuspend
1466 * it again. */
1467 if (status == 0)
1468 usb_try_autosuspend_device(udev);
1469 return status;
1470}
1471
1472int usb_suspend(struct device *dev, pm_message_t msg)
1473{
1474 struct usb_device *udev;
1475
1476 udev = to_usb_device(dev);
1477
1478 /* If udev is already suspended, we can skip this suspend and
1479 * we should also skip the upcoming system resume. High-speed
1480 * root hubs are an exception; they need to resume whenever the
1481 * system wakes up in order for USB-PERSIST port handover to work
1482 * properly.
1483 */
1484 if (udev->state == USB_STATE_SUSPENDED) {
1485 if (udev->parent || udev->speed != USB_SPEED_HIGH)
1486 udev->skip_sys_resume = 1;
1487 return 0;
1488 }
1489
1490 udev->skip_sys_resume = 0;
1491 return usb_external_suspend_device(udev, msg);
1492}
1493
1494int usb_resume(struct device *dev, pm_message_t msg)
1495{
1496 struct usb_device *udev;
1497 int status;
1498
1499 udev = to_usb_device(dev);
1500
1501 /* If udev->skip_sys_resume is set then udev was already suspended
1502 * when the system sleep started, so we don't want to resume it
1503 * during this system wakeup.
1504 */
1505 if (udev->skip_sys_resume)
1506 return 0;
1507 status = usb_external_resume_device(udev, msg);
1508
1509 /* Avoid PM error messages for devices disconnected while suspended
1510 * as we'll display regular disconnect messages just a bit later.
1511 */
1512 if (status == -ENODEV)
1513 return 0;
1514 return status;
1515}
1516
1517#endif /* CONFIG_PM */
1518
1416#ifdef CONFIG_USB_SUSPEND 1519#ifdef CONFIG_USB_SUSPEND
1417 1520
1418/** 1521/**
@@ -1784,109 +1887,6 @@ void usb_autoresume_work(struct work_struct *work)
1784 1887
1785#endif /* CONFIG_USB_SUSPEND */ 1888#endif /* CONFIG_USB_SUSPEND */
1786 1889
1787/**
1788 * usb_external_suspend_device - external suspend of a USB device and its interfaces
1789 * @udev: the usb_device to suspend
1790 * @msg: Power Management message describing this state transition
1791 *
1792 * This routine handles external suspend requests: ones not generated
1793 * internally by a USB driver (autosuspend) but rather coming from the user
1794 * (via sysfs) or the PM core (system sleep). The suspend will be carried
1795 * out regardless of @udev's usage counter or those of its interfaces,
1796 * and regardless of whether or not remote wakeup is enabled. Of course,
1797 * interface drivers still have the option of failing the suspend (if
1798 * there are unsuspended children, for example).
1799 *
1800 * The caller must hold @udev's device lock.
1801 */
1802int usb_external_suspend_device(struct usb_device *udev, pm_message_t msg)
1803{
1804 int status;
1805
1806 do_unbind_rebind(udev, DO_UNBIND);
1807 usb_pm_lock(udev);
1808 status = usb_suspend_both(udev, msg);
1809 usb_pm_unlock(udev);
1810 return status;
1811}
1812
1813/**
1814 * usb_external_resume_device - external resume of a USB device and its interfaces
1815 * @udev: the usb_device to resume
1816 * @msg: Power Management message describing this state transition
1817 *
1818 * This routine handles external resume requests: ones not generated
1819 * internally by a USB driver (autoresume) but rather coming from the user
1820 * (via sysfs), the PM core (system resume), or the device itself (remote
1821 * wakeup). @udev's usage counter is unaffected.
1822 *
1823 * The caller must hold @udev's device lock.
1824 */
1825int usb_external_resume_device(struct usb_device *udev, pm_message_t msg)
1826{
1827 int status;
1828
1829 usb_pm_lock(udev);
1830 status = usb_resume_both(udev, msg);
1831 udev->last_busy = jiffies;
1832 usb_pm_unlock(udev);
1833 if (status == 0)
1834 do_unbind_rebind(udev, DO_REBIND);
1835
1836 /* Now that the device is awake, we can start trying to autosuspend
1837 * it again. */
1838 if (status == 0)
1839 usb_try_autosuspend_device(udev);
1840 return status;
1841}
1842
1843int usb_suspend(struct device *dev, pm_message_t msg)
1844{
1845 struct usb_device *udev;
1846
1847 udev = to_usb_device(dev);
1848
1849 /* If udev is already suspended, we can skip this suspend and
1850 * we should also skip the upcoming system resume. High-speed
1851 * root hubs are an exception; they need to resume whenever the
1852 * system wakes up in order for USB-PERSIST port handover to work
1853 * properly.
1854 */
1855 if (udev->state == USB_STATE_SUSPENDED) {
1856 if (udev->parent || udev->speed != USB_SPEED_HIGH)
1857 udev->skip_sys_resume = 1;
1858 return 0;
1859 }
1860
1861 udev->skip_sys_resume = 0;
1862 return usb_external_suspend_device(udev, msg);
1863}
1864
1865int usb_resume(struct device *dev, pm_message_t msg)
1866{
1867 struct usb_device *udev;
1868 int status;
1869
1870 udev = to_usb_device(dev);
1871
1872 /* If udev->skip_sys_resume is set then udev was already suspended
1873 * when the system sleep started, so we don't want to resume it
1874 * during this system wakeup.
1875 */
1876 if (udev->skip_sys_resume)
1877 return 0;
1878 status = usb_external_resume_device(udev, msg);
1879
1880 /* Avoid PM error messages for devices disconnected while suspended
1881 * as we'll display regular disconnect messages just a bit later.
1882 */
1883 if (status == -ENODEV)
1884 return 0;
1885 return status;
1886}
1887
1888#endif /* CONFIG_PM */
1889
1890struct bus_type usb_bus_type = { 1890struct bus_type usb_bus_type = {
1891 .name = "usb", 1891 .name = "usb",
1892 .match = usb_device_match, 1892 .match = usb_device_match,