diff options
author | Alan Stern <stern@rowland.harvard.edu> | 2006-07-01 22:14:24 -0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@suse.de> | 2006-09-27 14:58:50 -0400 |
commit | d388dab7b562b76525761f89702246686747ba30 (patch) | |
tree | 5bd84a39fcd05800d83b8ba5df1262568ab130ae /drivers | |
parent | 1c5df7e705671f11a71112eb3a1f9765cd1719f9 (diff) |
hub driver: improve use of #ifdef
This patch (as736) makes the hub driver more readable by improving the
usage of "#ifdef CONFIG_PM" and "#ifdef CONFIG_USB_SUSPEND".
Signed-off-by: Alan Stern <stern@rowland.harvard.edu>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/usb/core/hub.c | 64 | ||||
-rw-r--r-- | drivers/usb/core/usb.h | 11 |
2 files changed, 57 insertions, 18 deletions
diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c index a310c7cede99..64e80b964b87 100644 --- a/drivers/usb/core/hub.c +++ b/drivers/usb/core/hub.c | |||
@@ -1041,7 +1041,7 @@ void usb_set_device_state(struct usb_device *udev, | |||
1041 | } | 1041 | } |
1042 | 1042 | ||
1043 | 1043 | ||
1044 | #ifdef CONFIG_PM | 1044 | #ifdef CONFIG_PM |
1045 | 1045 | ||
1046 | /** | 1046 | /** |
1047 | * usb_root_hub_lost_power - called by HCD if the root hub lost Vbus power | 1047 | * usb_root_hub_lost_power - called by HCD if the root hub lost Vbus power |
@@ -1072,7 +1072,7 @@ void usb_root_hub_lost_power(struct usb_device *rhdev) | |||
1072 | } | 1072 | } |
1073 | EXPORT_SYMBOL_GPL(usb_root_hub_lost_power); | 1073 | EXPORT_SYMBOL_GPL(usb_root_hub_lost_power); |
1074 | 1074 | ||
1075 | #endif | 1075 | #endif /* CONFIG_PM */ |
1076 | 1076 | ||
1077 | static void choose_address(struct usb_device *udev) | 1077 | static void choose_address(struct usb_device *udev) |
1078 | { | 1078 | { |
@@ -1471,6 +1471,7 @@ static void hub_port_logical_disconnect(struct usb_hub *hub, int port1) | |||
1471 | kick_khubd(hub); | 1471 | kick_khubd(hub); |
1472 | } | 1472 | } |
1473 | 1473 | ||
1474 | #ifdef CONFIG_PM | ||
1474 | 1475 | ||
1475 | #ifdef CONFIG_USB_SUSPEND | 1476 | #ifdef CONFIG_USB_SUSPEND |
1476 | 1477 | ||
@@ -1569,8 +1570,6 @@ static int __usb_port_suspend (struct usb_device *udev, int port1) | |||
1569 | return status; | 1570 | return status; |
1570 | } | 1571 | } |
1571 | 1572 | ||
1572 | #endif | ||
1573 | |||
1574 | /* | 1573 | /* |
1575 | * usb_port_suspend - suspend a usb device's upstream port | 1574 | * usb_port_suspend - suspend a usb device's upstream port |
1576 | * @udev: device that's no longer in active use | 1575 | * @udev: device that's no longer in active use |
@@ -1593,11 +1592,7 @@ static int __usb_port_suspend (struct usb_device *udev, int port1) | |||
1593 | */ | 1592 | */ |
1594 | int usb_port_suspend(struct usb_device *udev) | 1593 | int usb_port_suspend(struct usb_device *udev) |
1595 | { | 1594 | { |
1596 | #ifdef CONFIG_USB_SUSPEND | ||
1597 | return __usb_port_suspend(udev, udev->portnum); | 1595 | return __usb_port_suspend(udev, udev->portnum); |
1598 | #else | ||
1599 | return 0; | ||
1600 | #endif | ||
1601 | } | 1596 | } |
1602 | 1597 | ||
1603 | /* | 1598 | /* |
@@ -1661,8 +1656,6 @@ static int finish_port_resume(struct usb_device *udev) | |||
1661 | return status; | 1656 | return status; |
1662 | } | 1657 | } |
1663 | 1658 | ||
1664 | #ifdef CONFIG_USB_SUSPEND | ||
1665 | |||
1666 | static int | 1659 | static int |
1667 | hub_port_resume(struct usb_hub *hub, int port1, struct usb_device *udev) | 1660 | hub_port_resume(struct usb_hub *hub, int port1, struct usb_device *udev) |
1668 | { | 1661 | { |
@@ -1722,8 +1715,6 @@ hub_port_resume(struct usb_hub *hub, int port1, struct usb_device *udev) | |||
1722 | return status; | 1715 | return status; |
1723 | } | 1716 | } |
1724 | 1717 | ||
1725 | #endif | ||
1726 | |||
1727 | /* | 1718 | /* |
1728 | * usb_port_resume - re-activate a suspended usb device's upstream port | 1719 | * usb_port_resume - re-activate a suspended usb device's upstream port |
1729 | * @udev: device to re-activate | 1720 | * @udev: device to re-activate |
@@ -1739,17 +1730,15 @@ hub_port_resume(struct usb_hub *hub, int port1, struct usb_device *udev) | |||
1739 | */ | 1730 | */ |
1740 | int usb_port_resume(struct usb_device *udev) | 1731 | int usb_port_resume(struct usb_device *udev) |
1741 | { | 1732 | { |
1742 | int status = 0; | 1733 | int status; |
1743 | 1734 | ||
1744 | /* we change the device's upstream USB link, | 1735 | /* we change the device's upstream USB link, |
1745 | * but root hubs have no upstream USB link. | 1736 | * but root hubs have no upstream USB link. |
1746 | */ | 1737 | */ |
1747 | if (udev->parent) { | 1738 | if (udev->parent) { |
1748 | #ifdef CONFIG_USB_SUSPEND | ||
1749 | // NOTE this fails if parent is also suspended... | 1739 | // NOTE this fails if parent is also suspended... |
1750 | status = hub_port_resume(hdev_to_hub(udev->parent), | 1740 | status = hub_port_resume(hdev_to_hub(udev->parent), |
1751 | udev->portnum, udev); | 1741 | udev->portnum, udev); |
1752 | #endif | ||
1753 | } else | 1742 | } else |
1754 | status = finish_port_resume(udev); | 1743 | status = finish_port_resume(udev); |
1755 | if (status < 0) | 1744 | if (status < 0) |
@@ -1761,8 +1750,6 @@ static int remote_wakeup(struct usb_device *udev) | |||
1761 | { | 1750 | { |
1762 | int status = 0; | 1751 | int status = 0; |
1763 | 1752 | ||
1764 | #ifdef CONFIG_USB_SUSPEND | ||
1765 | |||
1766 | /* don't repeat RESUME sequence if this device | 1753 | /* don't repeat RESUME sequence if this device |
1767 | * was already woken up by some other task | 1754 | * was already woken up by some other task |
1768 | */ | 1755 | */ |
@@ -1777,10 +1764,42 @@ static int remote_wakeup(struct usb_device *udev) | |||
1777 | if (status == 0) | 1764 | if (status == 0) |
1778 | usb_resume_both(udev); | 1765 | usb_resume_both(udev); |
1779 | usb_unlock_device(udev); | 1766 | usb_unlock_device(udev); |
1780 | #endif | ||
1781 | return status; | 1767 | return status; |
1782 | } | 1768 | } |
1783 | 1769 | ||
1770 | #else /* CONFIG_USB_SUSPEND */ | ||
1771 | |||
1772 | /* When CONFIG_USB_SUSPEND isn't set, we never suspend or resume any ports. */ | ||
1773 | |||
1774 | int usb_port_suspend(struct usb_device *udev) | ||
1775 | { | ||
1776 | return 0; | ||
1777 | } | ||
1778 | |||
1779 | static inline int | ||
1780 | finish_port_resume(struct usb_device *udev) | ||
1781 | { | ||
1782 | return 0; | ||
1783 | } | ||
1784 | |||
1785 | static inline int | ||
1786 | hub_port_resume(struct usb_hub *hub, int port1, struct usb_device *udev) | ||
1787 | { | ||
1788 | return 0; | ||
1789 | } | ||
1790 | |||
1791 | int usb_port_resume(struct usb_device *udev) | ||
1792 | { | ||
1793 | return 0; | ||
1794 | } | ||
1795 | |||
1796 | static inline int remote_wakeup(struct usb_device *udev) | ||
1797 | { | ||
1798 | return 0; | ||
1799 | } | ||
1800 | |||
1801 | #endif | ||
1802 | |||
1784 | static int hub_suspend(struct usb_interface *intf, pm_message_t msg) | 1803 | static int hub_suspend(struct usb_interface *intf, pm_message_t msg) |
1785 | { | 1804 | { |
1786 | struct usb_hub *hub = usb_get_intfdata (intf); | 1805 | struct usb_hub *hub = usb_get_intfdata (intf); |
@@ -1854,6 +1873,15 @@ static int hub_resume(struct usb_interface *intf) | |||
1854 | return 0; | 1873 | return 0; |
1855 | } | 1874 | } |
1856 | 1875 | ||
1876 | #else /* CONFIG_PM */ | ||
1877 | |||
1878 | static inline int remote_wakeup(struct usb_device *udev) | ||
1879 | { | ||
1880 | return 0; | ||
1881 | } | ||
1882 | |||
1883 | #endif | ||
1884 | |||
1857 | void usb_suspend_root_hub(struct usb_device *hdev) | 1885 | void usb_suspend_root_hub(struct usb_device *hdev) |
1858 | { | 1886 | { |
1859 | struct usb_hub *hub = hdev_to_hub(hdev); | 1887 | struct usb_hub *hub = hdev_to_hub(hdev); |
diff --git a/drivers/usb/core/usb.h b/drivers/usb/core/usb.h index 74df0db954c9..98675fb1bc4c 100644 --- a/drivers/usb/core/usb.h +++ b/drivers/usb/core/usb.h | |||
@@ -30,11 +30,22 @@ extern void usb_major_cleanup(void); | |||
30 | extern int usb_host_init(void); | 30 | extern int usb_host_init(void); |
31 | extern void usb_host_cleanup(void); | 31 | extern void usb_host_cleanup(void); |
32 | 32 | ||
33 | #ifdef CONFIG_PM | ||
34 | |||
33 | extern int usb_suspend_both(struct usb_device *udev, pm_message_t msg); | 35 | extern int usb_suspend_both(struct usb_device *udev, pm_message_t msg); |
34 | extern int usb_resume_both(struct usb_device *udev); | 36 | extern int usb_resume_both(struct usb_device *udev); |
35 | extern int usb_port_suspend(struct usb_device *dev); | 37 | extern int usb_port_suspend(struct usb_device *dev); |
36 | extern int usb_port_resume(struct usb_device *dev); | 38 | extern int usb_port_resume(struct usb_device *dev); |
37 | 39 | ||
40 | #else | ||
41 | |||
42 | #define usb_suspend_both(udev, msg) 0 | ||
43 | #define usb_resume_both(udev) 0 | ||
44 | #define usb_port_suspend(dev) 0 | ||
45 | #define usb_port_resume(dev) 0 | ||
46 | |||
47 | #endif | ||
48 | |||
38 | extern struct bus_type usb_bus_type; | 49 | extern struct bus_type usb_bus_type; |
39 | extern struct usb_device_driver usb_generic_driver; | 50 | extern struct usb_device_driver usb_generic_driver; |
40 | 51 | ||